Commit 10dc2545 by xiongziliang

完善stopRecord接口

parent 055c3125
...@@ -709,10 +709,11 @@ void installWebApi() { ...@@ -709,10 +709,11 @@ void installWebApi() {
API_REGIST(api,stopRecord,{ API_REGIST(api,stopRecord,{
CHECK_SECRET(); CHECK_SECRET();
CHECK_ARGS("type","vhost","app","stream"); CHECK_ARGS("type","vhost","app","stream");
Recorder::stopRecord((Recorder::type)allArgs["type"].as<int>(), int result = Recorder::stopRecord((Recorder::type)allArgs["type"].as<int>(),
allArgs["vhost"], allArgs["vhost"],
allArgs["app"], allArgs["app"],
allArgs["stream"]); allArgs["stream"]);
val["result"] = result;
}); });
// 获取hls或MP4录制状态 // 获取hls或MP4录制状态
......
...@@ -205,9 +205,9 @@ public: ...@@ -205,9 +205,9 @@ public:
return 0; return 0;
} }
void stopRecord(const string &vhost, const string &app, const string &stream_id) { bool stopRecord(const string &vhost, const string &app, const string &stream_id) {
lock_guard<decltype(_recorder_mtx)> lck(_recorder_mtx); lock_guard<decltype(_recorder_mtx)> lck(_recorder_mtx);
_recorder_map.erase(getRecorderKey(vhost, app, stream_id)); return _recorder_map.erase(getRecorderKey(vhost, app, stream_id));
} }
void stopAll(){ void stopAll(){
...@@ -345,13 +345,14 @@ int Recorder::startRecord(Recorder::type type, const string &vhost, const string ...@@ -345,13 +345,14 @@ int Recorder::startRecord(Recorder::type type, const string &vhost, const string
return -3; return -3;
} }
void Recorder::stopRecord(Recorder::type type, const string &vhost, const string &app, const string &stream_id) { bool Recorder::stopRecord(Recorder::type type, const string &vhost, const string &app, const string &stream_id) {
switch (type){ switch (type){
case type_mp4: case type_mp4:
return MediaSourceWatcher<type_mp4>::Instance().stopRecord(vhost,app,stream_id); return MediaSourceWatcher<type_mp4>::Instance().stopRecord(vhost,app,stream_id);
case type_hls: case type_hls:
return MediaSourceWatcher<type_hls>::Instance().stopRecord(vhost,app,stream_id); return MediaSourceWatcher<type_hls>::Instance().stopRecord(vhost,app,stream_id);
} }
return false;
} }
void Recorder::stopAll() { void Recorder::stopAll() {
......
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
* @param app 应用名 * @param app 应用名
* @param stream_id 流id * @param stream_id 流id
*/ */
static void stopRecord(type type, const string &vhost, const string &app, const string &stream_id); static bool stopRecord(type type, const string &vhost, const string &app, const string &stream_id);
/** /**
* 停止所有录制,一般程序退出时调用 * 停止所有录制,一般程序退出时调用
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论