Commit 8ebf127e by xiongziliang

完善录制相关功能

parent cc2d2273
...@@ -185,6 +185,9 @@ static onceToken s_token([](){ ...@@ -185,6 +185,9 @@ static onceToken s_token([](){
if(schema == RTMP_SCHEMA && app == "live"){ if(schema == RTMP_SCHEMA && app == "live"){
static map<string,FlvRecorder::Ptr> s_mapFlvRecorder; static map<string,FlvRecorder::Ptr> s_mapFlvRecorder;
static mutex s_mtxFlvRecorder; static mutex s_mtxFlvRecorder;
auto poller = EventPollerPool::Instance().getPoller();
auto rtmpMediaSrc = dynamic_pointer_cast<RtmpMediaSource>(sender.shared_from_this());
poller->async([bRegist,schema,vhost,app,stream,poller,rtmpMediaSrc](){
lock_guard<mutex> lck(s_mtxFlvRecorder); lock_guard<mutex> lck(s_mtxFlvRecorder);
if(bRegist){ if(bRegist){
DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream; DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream;
...@@ -192,7 +195,7 @@ static onceToken s_token([](){ ...@@ -192,7 +195,7 @@ static onceToken s_token([](){
auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv"; auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv";
FlvRecorder::Ptr recorder(new FlvRecorder); FlvRecorder::Ptr recorder(new FlvRecorder);
try{ try{
recorder->startRecord(nullptr,dynamic_pointer_cast<RtmpMediaSource>(sender.shared_from_this()),path); recorder->startRecord(poller,rtmpMediaSrc,path);
s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder; s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder;
}catch(std::exception &ex){ }catch(std::exception &ex){
WarnL << ex.what(); WarnL << ex.what();
...@@ -200,6 +203,7 @@ static onceToken s_token([](){ ...@@ -200,6 +203,7 @@ static onceToken s_token([](){
}else{ }else{
s_mapFlvRecorder.erase(vhost + "/" + app + "/" + stream); s_mapFlvRecorder.erase(vhost + "/" + app + "/" + stream);
} }
});
} }
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论