录制接口支持指定切片时间大小:#747

This commit is contained in:
xiongziliang
2021-03-07 10:41:57 +08:00
parent daedbed737
commit c0f4899950
13 changed files with 54 additions and 40 deletions

View File

@@ -55,7 +55,7 @@ string Recorder::getRecordPath(Recorder::type type, const string &vhost, const s
}
}
std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const string &vhost, const string &app, const string &stream_id, const string &customized_path){
std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const string &vhost, const string &app, const string &stream_id, const string &customized_path, size_t max_second){
auto path = Recorder::getRecordPath(type, vhost, app, stream_id, customized_path);
switch (type) {
case Recorder::type_hls: {
@@ -72,7 +72,7 @@ std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const st
case Recorder::type_mp4: {
#if defined(ENABLE_MP4)
return std::make_shared<MP4Recorder>(path, vhost, app, stream_id);
return std::make_shared<MP4Recorder>(path, vhost, app, stream_id, max_second);
#else
throw std::invalid_argument("mp4相关功能未打开请开启ENABLE_MP4宏后编译再测试");
#endif
@@ -90,13 +90,13 @@ bool Recorder::isRecording(type type, const string &vhost, const string &app, co
return src->isRecording(type);
}
bool Recorder::startRecord(type type, const string &vhost, const string &app, const string &stream_id,const string &customized_path){
bool Recorder::startRecord(type type, const string &vhost, const string &app, const string &stream_id,const string &customized_path, size_t max_second){
auto src = MediaSource::find(vhost, app, stream_id);
if (!src) {
WarnL << "未找到相关的MediaSource,startRecord失败:" << vhost << "/" << app << "/" << stream_id;
return false;
}
return src->setupRecord(type, true, customized_path);
return src->setupRecord(type, true, customized_path, max_second);
}
bool Recorder::stopRecord(type type, const string &vhost, const string &app, const string &stream_id){
@@ -104,7 +104,7 @@ bool Recorder::stopRecord(type type, const string &vhost, const string &app, con
if(!src){
return false;
}
return src->setupRecord(type, false, "");
return src->setupRecord(type, false, "", 0);
}
} /* namespace mediakit */