From 8ebf127ee625c5c3276c938c5973059d568c6034 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 22 Mar 2019 13:31:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BD=95=E5=88=B6=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_server.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 710e8391..eb6f8849 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -185,21 +185,25 @@ static onceToken s_token([](){ if(schema == RTMP_SCHEMA && app == "live"){ static map s_mapFlvRecorder; static mutex s_mtxFlvRecorder; - lock_guard lck(s_mtxFlvRecorder); - if(bRegist){ - DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream; - GET_CONFIG_AND_REGISTER(string,http_root,Http::kRootPath); - auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv"; - FlvRecorder::Ptr recorder(new FlvRecorder); - try{ - recorder->startRecord(nullptr,dynamic_pointer_cast(sender.shared_from_this()),path); - s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder; - }catch(std::exception &ex){ - WarnL << ex.what(); + auto poller = EventPollerPool::Instance().getPoller(); + auto rtmpMediaSrc = dynamic_pointer_cast(sender.shared_from_this()); + poller->async([bRegist,schema,vhost,app,stream,poller,rtmpMediaSrc](){ + lock_guard lck(s_mtxFlvRecorder); + if(bRegist){ + DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream; + GET_CONFIG_AND_REGISTER(string,http_root,Http::kRootPath); + auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv"; + FlvRecorder::Ptr recorder(new FlvRecorder); + try{ + recorder->startRecord(poller,rtmpMediaSrc,path); + s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder; + }catch(std::exception &ex){ + WarnL << ex.what(); + } + }else{ + s_mapFlvRecorder.erase(vhost + "/" + app + "/" + stream); } - }else{ - s_mapFlvRecorder.erase(vhost + "/" + app + "/" + stream); - } + }); } });