Commit 33047ddc by xiongziliang

程序退出前停止一切录制

parent 728fd55e
...@@ -336,6 +336,7 @@ int start_main(int argc,char *argv[]) { ...@@ -336,6 +336,7 @@ int start_main(int argc,char *argv[]) {
} }
unInstallWebApi(); unInstallWebApi();
unInstallWebHook(); unInstallWebHook();
Recorder::stopAll();
//休眠1秒再退出,防止资源释放顺序错误 //休眠1秒再退出,防止资源释放顺序错误
InfoL << "程序退出中,请等待..."; InfoL << "程序退出中,请等待...";
sleep(1); sleep(1);
......
...@@ -206,6 +206,11 @@ public: ...@@ -206,6 +206,11 @@ public:
_recorder_map.erase(getRecorderKey(vhost, app, stream_id)); _recorder_map.erase(getRecorderKey(vhost, app, stream_id));
} }
void stopAll(){
lock_guard<decltype(_recorder_mtx)> lck(_recorder_mtx);
_recorder_map.clear();
}
private: private:
MediaSourceWatcher(){ MediaSourceWatcher(){
NoticeCenter::Instance().addListener(this,Broadcast::kBroadcastMediaChanged,[this](BroadcastMediaChangedArgs){ NoticeCenter::Instance().addListener(this,Broadcast::kBroadcastMediaChanged,[this](BroadcastMediaChangedArgs){
...@@ -352,4 +357,9 @@ void Recorder::stopRecord(Recorder::type type, const string &vhost, const string ...@@ -352,4 +357,9 @@ void Recorder::stopRecord(Recorder::type type, const string &vhost, const string
} }
} }
void Recorder::stopAll() {
MediaSourceWatcher<type_hls>::Instance().stopAll();
MediaSourceWatcher<type_mp4>::Instance().stopAll();
}
} /* namespace mediakit */ } /* namespace mediakit */
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
static status getRecordStatus(type type, const string &vhost, const string &app, const string &stream_id); static status getRecordStatus(type type, const string &vhost, const string &app, const string &stream_id);
static int startRecord(type type, const string &vhost, const string &app, const string &stream_id,bool waitForRecord, bool continueRecord); static int startRecord(type type, const string &vhost, const string &app, const string &stream_id,bool waitForRecord, bool continueRecord);
static void stopRecord(type type, const string &vhost, const string &app, const string &stream_id); static void stopRecord(type type, const string &vhost, const string &app, const string &stream_id);
static void stopAll();
private: private:
Recorder() = delete; Recorder() = delete;
~Recorder() = delete; ~Recorder() = delete;
......
...@@ -354,6 +354,7 @@ int main(int argc,char *argv[]) { ...@@ -354,6 +354,7 @@ int main(int argc,char *argv[]) {
signal(SIGHUP, [](int) { loadIniConfig(); }); signal(SIGHUP, [](int) { loadIniConfig(); });
sem.wait(); sem.wait();
Recorder::stopAll();
lock_guard<mutex> lck(s_mtxFlvRecorder); lock_guard<mutex> lck(s_mtxFlvRecorder);
s_mapFlvRecorder.clear(); s_mapFlvRecorder.clear();
return 0; return 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论