写mp4文件缓存可配置
This commit is contained in:
parent
13a6d3ac16
commit
1f89019818
|
|
@ -260,11 +260,15 @@ const string kFileSecond = RECORD_FIELD"fileSecond";
|
|||
#define RECORD_FILE_PATH HTTP_ROOT_PATH
|
||||
const string kFilePath = RECORD_FIELD"filePath";
|
||||
|
||||
//mp4文件写缓存大小
|
||||
const string kFileBufSize = RECORD_FIELD"fileBufSize";
|
||||
|
||||
onceToken token([](){
|
||||
mINI::Instance()[kAppName] = RECORD_APP_NAME;
|
||||
mINI::Instance()[kSampleMS] = RECORD_SAMPLE_MS;
|
||||
mINI::Instance()[kFileSecond] = RECORD_FILE_SECOND;
|
||||
mINI::Instance()[kFilePath] = RECORD_FILE_PATH;
|
||||
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
||||
},nullptr);
|
||||
|
||||
} //namespace Record
|
||||
|
|
|
|||
|
|
@ -255,6 +255,8 @@ extern const string kSampleMS;
|
|||
extern const string kFileSecond;
|
||||
//录制文件路径
|
||||
extern const string kFilePath;
|
||||
//mp4文件写缓存大小
|
||||
extern const string kFileBufSize;
|
||||
} //namespace Record
|
||||
|
||||
////////////HLS相关配置///////////
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "MP4Muxer.h"
|
||||
#include "Util/File.h"
|
||||
#include "Common/config.h"
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
|
|
@ -213,8 +214,6 @@ void MP4Muxer::onTrackReady(const Track::Ptr &track) {
|
|||
}
|
||||
}
|
||||
|
||||
#define FILE_BUF_SIZE (64 * 1024)
|
||||
|
||||
MP4MuxerFile::MP4MuxerFile(const char *file) {
|
||||
//创建文件
|
||||
auto fp = File::createfile_file(file,"wb+");
|
||||
|
|
@ -222,8 +221,10 @@ MP4MuxerFile::MP4MuxerFile(const char *file) {
|
|||
throw std::runtime_error(string("打开文件失败:") + file);
|
||||
}
|
||||
|
||||
GET_CONFIG(uint32_t,mp4BufSize,Record::kFileBufSize);
|
||||
|
||||
//新建文件io缓存
|
||||
std::shared_ptr<char> file_buf(new char[FILE_BUF_SIZE],[](char *ptr){
|
||||
std::shared_ptr<char> file_buf(new char[mp4BufSize],[](char *ptr){
|
||||
if(ptr){
|
||||
delete [] ptr;
|
||||
}
|
||||
|
|
@ -231,7 +232,7 @@ MP4MuxerFile::MP4MuxerFile(const char *file) {
|
|||
|
||||
if(file_buf){
|
||||
//设置文件io缓存
|
||||
setvbuf(fp, file_buf.get(), _IOFBF, FILE_BUF_SIZE);
|
||||
setvbuf(fp, file_buf.get(), _IOFBF, mp4BufSize);
|
||||
}
|
||||
|
||||
//创建智能指针
|
||||
|
|
|
|||
Loading…
Reference in New Issue