diff --git a/server/WebApi.cpp b/server/WebApi.cpp index b9e6664f..31810f7e 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -709,10 +709,11 @@ void installWebApi() { API_REGIST(api,stopRecord,{ CHECK_SECRET(); CHECK_ARGS("type","vhost","app","stream"); - Recorder::stopRecord((Recorder::type)allArgs["type"].as(), - allArgs["vhost"], - allArgs["app"], - allArgs["stream"]); + int result = Recorder::stopRecord((Recorder::type)allArgs["type"].as(), + allArgs["vhost"], + allArgs["app"], + allArgs["stream"]); + val["result"] = result; }); // 获取hls或MP4录制状态 diff --git a/src/Record/Recorder.cpp b/src/Record/Recorder.cpp index 2a1646f1..42d145e3 100644 --- a/src/Record/Recorder.cpp +++ b/src/Record/Recorder.cpp @@ -205,9 +205,9 @@ public: 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 lck(_recorder_mtx); - _recorder_map.erase(getRecorderKey(vhost, app, stream_id)); + return _recorder_map.erase(getRecorderKey(vhost, app, stream_id)); } void stopAll(){ @@ -345,13 +345,14 @@ int Recorder::startRecord(Recorder::type type, const string &vhost, const string 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){ case type_mp4: return MediaSourceWatcher::Instance().stopRecord(vhost,app,stream_id); case type_hls: return MediaSourceWatcher::Instance().stopRecord(vhost,app,stream_id); } + return false; } void Recorder::stopAll() { diff --git a/src/Record/Recorder.h b/src/Record/Recorder.h index ffb8017c..6172cabd 100644 --- a/src/Record/Recorder.h +++ b/src/Record/Recorder.h @@ -82,7 +82,7 @@ public: * @param app 应用名 * @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); /** * 停止所有录制,一般程序退出时调用