Improve:files datebase code.

This commit is contained in:
Fancy code 2024-06-26 16:18:46 +08:00
parent 4706bfa7dd
commit 8e07140ca3
32 changed files with 241 additions and 74 deletions

View File

@ -15,7 +15,14 @@
#include "MediaTask.h"
#include "DataProcessing.h"
#include "IMediaManager.h"
#include <cctype>
#include <chrono>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEvent,
const std::weak_ptr<VMediaTaskIniator> &iniator, const unsigned long &serialNumber,
@ -27,4 +34,19 @@ MediaTask::MediaTask(const MediaTaskType &type, const InternalStateEvent &bindEv
unsigned int MediaTask::GetTaskTimeOutMs(void)
{
return MEDIA_TASK_TIMEOUT_MS;
}
std::string MediaTask::GetTargetNameForSaving(void)
{
auto now = std::chrono::system_clock::now();
time_t t_now = std::chrono::system_clock::to_time_t(now);
struct tm tm_now = *std::localtime(&t_now);
int hour = tm_now.tm_hour;
int minute = tm_now.tm_min;
int second = tm_now.tm_sec;
std::ostringstream pathStream;
pathStream << mSavePath << std::setw(2) << std::setfill('0') << hour << std::setw(2) << std::setfill('0') << minute
<< std::setw(2) << std::setfill('0') << second << ".mp4";
return pathStream.str();
}

View File

@ -16,6 +16,7 @@
#define MEDIA_TASK_H
#include "DataProcessing.h"
#include "IMediaManager.h"
#include <string>
constexpr unsigned int MEDIA_TASK_TIMEOUT_MS = 1000 * 60;
class VMediaTaskIniator
{
@ -32,6 +33,7 @@ public:
const std::string &savePath);
virtual ~MediaTask() = default;
virtual unsigned int GetTaskTimeOutMs(void);
std::string GetTargetNameForSaving(void) override;
private:
const MediaTaskType mType;

View File

@ -21,6 +21,7 @@
#include "McuAskBase.h"
#include "MissionManagerMakePtr.h"
#include "StatusCode.h"
#include "VStateBase.h"
#include <memory>
// #include "TopState.h"
std::shared_ptr<MissionStateMachine> &MissionStateMachine::GetInstance(std::shared_ptr<MissionStateMachine> *impl)
@ -57,6 +58,7 @@ void MissionStateMachine::Init(void)
void MissionStateMachine::UnInit(void)
{
mStateMachine->StopHandlerThread();
UnInitAllState();
mStateTree.clear();
}
StatusCode MissionStateMachine::SendStateMessage(const std::shared_ptr<VMissionData> &message)
@ -119,11 +121,30 @@ void MissionStateMachine::RunStateMachine(const IpcMission &mission)
mStateMachine->StatePlus(mStateTree[SystemState::IDLE_STATE].get(), mStateTree[SystemState::MISSION_STATE].get());
mStateMachine->SetCurrentState(mStateTree[SystemState::TOP_STATE].get());
mStateMachine->StartStateMachine();
/**
* @brief The business can only be processed after the state machine is started.
*
*/
std::shared_ptr<VMissionData> message =
std::make_shared<VMissionData>(static_cast<MissionEvent>(InternalStateEvent::STORAGE_HANDLE_STATE_INIT));
SendStateMessage(message);
// /**
// * @brief The business can only be processed after the state machine is started.
// *
// */
// std::shared_ptr<VMissionData> message =
// std::make_shared<VMissionData>(static_cast<MissionEvent>(InternalStateEvent::STORAGE_HANDLE_STATE_INIT));
// SendStateMessage(message);
InitAllState();
}
void MissionStateMachine::InitAllState(void)
{
for (auto &state : mStateTree) {
std::shared_ptr<VStateBase> stateBase = std::dynamic_pointer_cast<VStateBase>(state.second);
if (stateBase) {
stateBase->StateInit();
}
}
}
void MissionStateMachine::UnInitAllState(void)
{
for (auto &state : mStateTree) {
std::shared_ptr<VStateBase> stateBase = std::dynamic_pointer_cast<VStateBase>(state.second);
if (stateBase) {
stateBase->StateUnInit();
}
}
}

View File

@ -51,6 +51,8 @@ public:
private:
IpcMission GetStartMission(void);
void RunStateMachine(const IpcMission &mission);
void InitAllState(void);
void UnInitAllState(void);
private:
std::shared_ptr<VStateMachineHandle> mStateMachine;

View File

@ -45,6 +45,13 @@ bool SdCardHandleState::ExecuteStateMsg(VStateMachineData *msg)
{
return DataProcessing::EventHandle(msg);
}
void SdCardHandleState::StateInit(void)
{
}
void SdCardHandleState::StateUnInit(void)
{
IFilesManager::GetInstance()->UnInit();
}
bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
{
LogInfo(" MediaReportHandle.\n");

View File

@ -19,7 +19,11 @@
#include "IMediaManager.h"
#include "IStateMachine.h"
#include "IStorageManager.h"
class SdCardHandleState : public State, public DataProcessing, public std::enable_shared_from_this<SdCardHandleState>
#include "VStateBase.h"
class SdCardHandleState : public State,
public DataProcessing,
public VStateBase,
public std::enable_shared_from_this<SdCardHandleState>
{
public:
SdCardHandleState();
@ -29,6 +33,8 @@ public:
bool ExecuteStateMsg(VStateMachineData *msg) override;
protected:
void StateInit(void) override;
void StateUnInit(void) override;
bool MediaReportHandle(VStateMachineData *msg);
bool SdCardEventHandle(VStateMachineData *msg);
bool ResetKeyMediaTaskHandle(VStateMachineData *msg);

View File

@ -19,12 +19,11 @@
#include "IStateMachine.h"
#include "IStorageManager.h"
#include "MissionStateMachine.h"
#include <functional>
#include <memory>
StorageHandleState::StorageHandleState() : State("StorageHandleState")
{
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
std::bind(&StorageHandleState::StorageStartInitHandle, this, _1);
// mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
// std::bind(&StorageHandleState::StorageStartInitHandle, this, _1);
}
void StorageHandleState::GoInState()
{
@ -57,8 +56,10 @@ void StorageHandleState::ReportEvent(const StorageEvent &event)
static_cast<MissionEvent>(InternalStateEvent::ANY_STATE_SD_STATUS_PERORIED), event);
MissionStateMachine::GetInstance()->SendStateMessage(message2);
}
bool StorageHandleState::StorageStartInitHandle(VStateMachineData *msg)
void StorageHandleState::StateInit(void)
{
Init();
return EXECUTED;
}
void StorageHandleState::StateUnInit(void)
{
}

View File

@ -18,9 +18,11 @@
#include "IMediaManager.h"
#include "IStateMachine.h"
#include "IStorageManager.h"
#include "VStateBase.h"
class StorageHandleState : public State,
public DataProcessing,
public VStorageMoniter,
public VStateBase,
public std::enable_shared_from_this<StorageHandleState>
{
public:
@ -34,6 +36,7 @@ public:
private: // About VStorageMoniter
void ReportEvent(const StorageEvent &event) override;
bool StorageStartInitHandle(VStateMachineData *msg);
void StateInit(void) override;
void StateUnInit(void) override;
};
#endif

View File

@ -24,12 +24,11 @@
#include "McuMonitor.h"
#include "MissionStateMachine.h"
#include "StatusCode.h"
#include <functional>
#include <memory>
TopState::TopState() : State("TopState")
{
mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
std::bind(&TopState::StorageStartInitHandle, this, _1);
// mEventHandle[InternalStateEvent::STORAGE_HANDLE_STATE_INIT] =
// std::bind(&TopState::StorageStartInitHandle, this, _1);
}
void TopState::GoInState()
{
@ -68,10 +67,4 @@ void TopState::KeyEventReport(const std::string &keyName, const VirtualKeyEvent
std::shared_ptr<VMissionData> message = std::make_shared<VMissionDataV2<KeyEventData>>(
static_cast<MissionEvent>(InternalStateEvent::KEY_EVENT_HANDLE), data);
MissionStateMachine::GetInstance()->SendStateMessage(message);
}
bool TopState::StorageStartInitHandle(VStateMachineData *msg)
{
MissionStateMachine::GetInstance()->DelayMessage(msg);
MissionStateMachine::GetInstance()->SwitchState(SystemState::STORAGE_HANDLE_STATE);
return EXECUTED;
}

View File

@ -38,8 +38,5 @@ private: // About VMediaMonitor
private: // About KeyMonitor
void KeyEventReport(const std::string &keyName, const VirtualKeyEvent &event, const unsigned int &timeMs) override;
private:
bool StorageStartInitHandle(VStateMachineData *msg);
};
#endif

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 Fancy Code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "VStateBase.h"
void VStateBase::StateInit(void)
{
}
void VStateBase::StateUnInit(void)
{
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2023 Fancy Code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef V_STATE_BASE_H
#define V_STATE_BASE_H
class VStateBase
{
public:
VStateBase() = default;
virtual ~VStateBase() = default;
virtual void StateInit(void);
virtual void StateUnInit(void);
};
#endif

View File

@ -24,6 +24,7 @@ StatusCode FilesManagerImpl::Init(void)
}
StatusCode FilesManagerImpl::UnInit(void)
{
FilesDatabase::UnInit();
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode FilesManagerImpl::SaveFile(const SaveFileInfo &fileInfo)

View File

@ -49,6 +49,7 @@ StatusCode FilesDatabase::DatabaseSaveFile(const SaveFileInfo &fileInfo)
InfoToBeSaved FilesDatabase::CreateInfoForSavingFiles(const unsigned int &count)
{
const unsigned long key = SqliteHandle::GetInstance()->CreateFiles(count);
InfoToBeSaved info(key, ".");
std::string savingPath = IStorageManager::GetInstance()->GetFilesSavingPath();
InfoToBeSaved info(key, savingPath);
return info;
}

View File

@ -69,26 +69,6 @@ void SqliteHandle::UnInit(void)
mDb = nullptr;
}
}
void SqliteHandle::DbInit(sqlite3 *db)
{
if (nullptr == db) {
LogError("db is null.\n");
return;
}
char *errMsg = nullptr;
int rc = SQLITE_UNDEFINE;
const char *sql =
"CREATE TABLE IF NOT EXISTS " FILES_TABLE " (" TABLE_KEY " INTEGER PRIMARY KEY AUTOINCREMENT, " FILE_PATH
" TEXT, " CREATE_TIME " INTEGER," FILE_TYPE " TEXT, " FILE_SIZE " INTEGER);";
rc = sqlite3_exec(db, sql, nullptr, nullptr, &errMsg);
if (SQLITE_OK != rc) {
LogError("Sql: %s, errMsg: %s\n", sql, errMsg);
sqlite3_free(errMsg);
}
else {
LogInfo("Sqlite init success. table = %s\n", FILES_TABLE);
}
}
unsigned long int SqliteHandle::CreateFiles(const unsigned int &count)
{
char *err_msg = nullptr;
@ -119,4 +99,24 @@ unsigned long int SqliteHandle::CreateFiles(const unsigned int &count)
return 0;
}
return last_rowid - count + 1;
}
void SqliteHandle::DbInit(sqlite3 *db)
{
if (nullptr == db) {
LogError("db is null.\n");
return;
}
char *errMsg = nullptr;
int rc = SQLITE_UNDEFINE;
const char *sql =
"CREATE TABLE IF NOT EXISTS " FILES_TABLE " (" TABLE_KEY " INTEGER PRIMARY KEY AUTOINCREMENT, " FILE_PATH
" TEXT, " CREATE_TIME " INTEGER," FILE_TYPE " TEXT, " FILE_SIZE " INTEGER);";
rc = sqlite3_exec(db, sql, nullptr, nullptr, &errMsg);
if (SQLITE_OK != rc) {
LogError("Sql: %s, errMsg: %s\n", sql, errMsg);
sqlite3_free(errMsg);
}
else {
LogInfo("Sqlite init success. table = %s\n", FILES_TABLE);
}
}

View File

@ -25,13 +25,15 @@ public:
static std::shared_ptr<SqliteHandle> &GetInstance(std::shared_ptr<SqliteHandle> *impl = nullptr);
void Init(const std::string &dbFileName);
void UnInit(void);
void DbInit(sqlite3 *db);
unsigned long int CreateFiles(const unsigned int &count);
bool Add();
bool Remove();
bool Modified();
bool Serach();
private:
static void DbInit(sqlite3 *db);
private:
sqlite3 *mDb;
};

View File

@ -56,7 +56,7 @@ public:
VMediaTask() = default;
virtual ~VMediaTask() = default;
virtual const MediaTaskType GetTaskType(void);
virtual const std::string GetTargetNameForSaving(void);
virtual std::string GetTargetNameForSaving(void);
virtual void Response(const std::vector<MediaTaskResponse> &response);
virtual bool IsTaskFinished(void);
virtual const signed int GetIsNight(void);

View File

@ -29,7 +29,7 @@ const MediaTaskType VMediaTask::GetTaskType(void)
{
return MediaTaskType::END;
}
const std::string VMediaTask::GetTargetNameForSaving(void)
std::string VMediaTask::GetTargetNameForSaving(void)
{
const std::string fileName = "Undefined";
return fileName;

View File

@ -66,12 +66,17 @@ StatusCode MediaHandle::ExecuteTask(std::shared_ptr<VMediaTask> &task)
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
}
mStreamHandle = std::make_shared<RecordMp4>();
mStreamHandle = std::make_shared<RecordMp4>(task);
if (nullptr == mStreamHandle) {
LogError("Create stream handle failed.\n");
mStreamHandle.reset();
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
mStreamHandle->Init();
auto code2 = mStreamHandle->Init();
if (!IsCodeOK(code2)) {
LogError("StreamHandle init failed.\n");
return code2;
}
CameraTaskType taskType = TaskTypeConvert(task->GetTaskType());
CameraTaskParam data(taskType);
auto code = mCameraHal->StartSingleTask(data);

View File

@ -14,29 +14,42 @@
*/
#include "RecordMp4.h"
#include "ILog.h"
#include "IMediaManager.h"
#include "MediaBase.h"
#include "StatusCode.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
RecordMp4::RecordMp4() : mRecordMp4Object(nullptr)
#include <memory>
#include <string>
RecordMp4::RecordMp4(std::shared_ptr<VMediaTask> &recordTask) : mRecordMp4Object(nullptr), mRecordTask(recordTask)
{
}
void RecordMp4::Init(void)
StatusCode RecordMp4::Init(void)
{
mRecordMp4Object = ICreateMediaBase(MEDIA_HANDLE_TYPE_COMBINE_MP4);
if (nullptr == mRecordMp4Object) {
LogError("mRecordMp4Object is null.\n");
return;
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
IOpenOutputFile(mRecordMp4Object, "./record.mp4");
std::string videoPath = mRecordTask->GetTargetNameForSaving();
StatusCode code = IOpenOutputFile(mRecordMp4Object, videoPath.c_str());
if (!IsCodeOK(code)) {
LogError("OpenOutputFile failed.\n");
ICloseOutputFile(mRecordMp4Object);
IMediaBaseFree(mRecordMp4Object);
mRecordMp4Object = nullptr;
}
return code;
}
void RecordMp4::UnInit(void)
StatusCode RecordMp4::UnInit(void)
{
if (mRecordMp4Object) {
ICloseOutputFile(mRecordMp4Object);
IMediaBaseFree(mRecordMp4Object);
mRecordMp4Object = nullptr;
}
return CreateStatusCode(STATUS_CODE_OK);
}
void RecordMp4::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{

View File

@ -14,19 +14,21 @@
*/
#ifndef RECORD_MP4_H
#define RECORD_MP4_H
#include "IMediaManager.h"
#include "VStreamHandle.h"
#include <cstdio>
class RecordMp4 : public VStreamHandle
{
public:
RecordMp4();
RecordMp4(std::shared_ptr<VMediaTask> &recordTask);
virtual ~RecordMp4() = default;
void Init(void) override;
void UnInit(void) override;
StatusCode Init(void) override;
StatusCode UnInit(void) override;
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
private:
void *mRecordMp4Object;
std::shared_ptr<VMediaTask> mRecordTask;
};
#endif

View File

@ -14,18 +14,20 @@
*/
#include "SaveStream.h"
#include "ILog.h"
#include "StatusCode.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
SaveStream::SaveStream() : mFileAudio(nullptr), mFileVideo(nullptr)
{
}
void SaveStream::Init(void)
StatusCode SaveStream::Init(void)
{
mFileAudio = fopen("./audio.g711", "a+"); // TODO:
mFileVideo = fopen("./video.h264", "a+"); // TODO:
return CreateStatusCode(STATUS_CODE_OK);
}
void SaveStream::UnInit(void)
StatusCode SaveStream::UnInit(void)
{
if (mFileAudio) {
fclose(mFileAudio);
@ -35,6 +37,7 @@ void SaveStream::UnInit(void)
fclose(mFileVideo);
mFileVideo = nullptr;
}
return CreateStatusCode(STATUS_CODE_OK);
}
void SaveStream::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)
{

View File

@ -21,8 +21,8 @@ class SaveStream : public VStreamHandle
public:
SaveStream();
virtual ~SaveStream() = default;
void Init(void) override;
void UnInit(void) override;
StatusCode Init(void) override;
StatusCode UnInit(void) override;
void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;
void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) override;

View File

@ -13,10 +13,11 @@
* limitations under the License.
*/
#include "VStreamHandle.h"
void VStreamHandle::Init(void)
#include "StatusCode.h"
StatusCode VStreamHandle::Init(void)
{
}
void VStreamHandle::UnInit(void)
StatusCode VStreamHandle::UnInit(void)
{
}
void VStreamHandle::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp)

View File

@ -14,13 +14,14 @@
*/
#ifndef V_STREAM_HANDLE_H
#define V_STREAM_HANDLE_H
#include "StatusCode.h"
class VStreamHandle
{
public:
VStreamHandle() = default;
virtual ~VStreamHandle() = default;
virtual void Init(void);
virtual void UnInit(void);
virtual StatusCode Init(void);
virtual StatusCode UnInit(void);
virtual void GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
virtual void GetAudioStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp);
};

View File

@ -55,5 +55,6 @@ public:
virtual const char *PrintStringStorageEvent(const StorageEvent &event);
virtual StatusCode GetSdCardInfo(SdCardInfo &info);
virtual std::string GetFilesDatabasePath(void);
virtual std::string GetFilesSavingPath(void);
};
#endif

View File

@ -67,6 +67,12 @@ StatusCode IStorageManager::GetSdCardInfo(SdCardInfo &info)
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
}
std::string IStorageManager::GetFilesDatabasePath(void)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n");
std::string path = "undefined";
return path;
}
std::string IStorageManager::GetFilesSavingPath(void)
{
LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n");
std::string path = "undefined";

View File

@ -15,10 +15,18 @@
#include "StorageBase.h"
#include "ILog.h"
#include "IStorageManager.h"
#include <cctype>
#include <chrono>
#include <cstring>
#include <ctime>
#include <errno.h>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sys/stat.h>
bool StorageBase::CheckDirectory(const char *filepath)
{
@ -90,4 +98,19 @@ const char *StorageBase::PrintStringStorageEvent(const StorageEvent &event)
break;
}
}
}
std::string StorageBase::CreateFilesSavingPath(void)
{
auto now = std::chrono::system_clock::now();
time_t t_now = std::chrono::system_clock::to_time_t(now);
struct tm tm_now = *std::localtime(&t_now);
int year = tm_now.tm_year + 1900;
int month = tm_now.tm_mon + 1;
int day = tm_now.tm_mday;
std::ostringstream pathStream;
pathStream << SD_CARD_MOUNT_PATH << "/DCIM/" << std::setw(4) << std::setfill('0') << year << "/" << std::setw(2)
<< std::setfill('0') << month << "/" << std::setw(2) << std::setfill('0') << day << "/";
return pathStream.str();
}

View File

@ -25,6 +25,7 @@ public:
protected:
const char *PrintStringStorageEvent(const StorageEvent &event);
std::string CreateFilesSavingPath(void);
protected:
std::weak_ptr<VStorageMoniter> mStorageMonitor;

View File

@ -55,4 +55,8 @@ std::string StorageManagerImpl::GetFilesDatabasePath(void)
}
path = SD_CARD_MOUNT_PATH SYSTEM_FILE_PATH;
return path;
}
std::string StorageManagerImpl::GetFilesSavingPath(void)
{
return StorageBase::CreateFilesSavingPath();
}

View File

@ -31,5 +31,6 @@ protected:
StatusCode SaveFile(const std::string &sourceFile, const std::string &savePaht) override;
const char *PrintStringStorageEvent(const StorageEvent &event) override;
std::string GetFilesDatabasePath(void) override;
std::string GetFilesSavingPath(void) override;
};
#endif

View File

@ -106,9 +106,9 @@ StatusCode FfmpegMuxStream::OpenOutputFile(const std::string &fileName)
ret = avio_open(&oc->pb, fileName.c_str(), AVIO_FLAG_WRITE);
if (ret < 0) {
char error_str[AV_ERROR_MAX_STRING_SIZE] = {0};
LogInfo("Could not open '%s': %s\n",
fileName.c_str(),
av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret));
LogError("Could not open '%s': %s\n",
fileName.c_str(),
av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret));
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
}
@ -116,15 +116,17 @@ StatusCode FfmpegMuxStream::OpenOutputFile(const std::string &fileName)
ret = avformat_write_header(oc, &opt);
if (ret < 0) {
char error_str[AV_ERROR_MAX_STRING_SIZE] = {0};
LogInfo("Error occurred when opening output file: %s\n",
av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret));
LogError("Error occurred when opening output file: %s\n",
av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret));
return CreateStatusCode(STATUS_CODE_NOT_OK);
}
return CreateStatusCode(STATUS_CODE_OK);
}
StatusCode FfmpegMuxStream::CloseOutputFile(void)
{
av_write_trailer(mOc);
if (mOc->pb) {
av_write_trailer(mOc);
}
if (mFrameVideo) {
av_frame_free(&mFrameVideo);
mFrameVideo = nullptr;