完善FLV复用器
This commit is contained in:
parent
8ebf127ee6
commit
2b4d8a123d
|
|
@ -1 +1 @@
|
||||||
Subproject commit eefe3ce118c0720a3a9c1e5770411b0b80275593
|
Subproject commit e589ef61db16b3d7c43661f1e421b451227af07e
|
||||||
|
|
@ -42,6 +42,16 @@ void FlvMuxer::start(const EventPoller::Ptr &poller,const RtmpMediaSource::Ptr &
|
||||||
if(!media){
|
if(!media){
|
||||||
throw std::runtime_error("RtmpMediaSource 无效");
|
throw std::runtime_error("RtmpMediaSource 无效");
|
||||||
}
|
}
|
||||||
|
if(!poller->isCurrentThread()){
|
||||||
|
weak_ptr<FlvMuxer> weakSelf = getSharedPtr();
|
||||||
|
poller->async([weakSelf,poller,media](){
|
||||||
|
auto strongSelf = weakSelf.lock();
|
||||||
|
if(strongSelf){
|
||||||
|
strongSelf->start(poller,media);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
onWriteFlvHeader(media);
|
onWriteFlvHeader(media);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,25 +185,21 @@ 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();
|
lock_guard<mutex> lck(s_mtxFlvRecorder);
|
||||||
auto rtmpMediaSrc = dynamic_pointer_cast<RtmpMediaSource>(sender.shared_from_this());
|
if(bRegist){
|
||||||
poller->async([bRegist,schema,vhost,app,stream,poller,rtmpMediaSrc](){
|
DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream;
|
||||||
lock_guard<mutex> lck(s_mtxFlvRecorder);
|
GET_CONFIG_AND_REGISTER(string,http_root,Http::kRootPath);
|
||||||
if(bRegist){
|
auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv";
|
||||||
DebugL << "开始录制RTMP:" << schema << " " << vhost << " " << app << " " << stream;
|
FlvRecorder::Ptr recorder(new FlvRecorder);
|
||||||
GET_CONFIG_AND_REGISTER(string,http_root,Http::kRootPath);
|
try{
|
||||||
auto path = http_root + "/" + vhost + "/" + app + "/" + stream + "_" + to_string(time(NULL)) + ".flv";
|
recorder->startRecord(EventPollerPool::Instance().getPoller(),dynamic_pointer_cast<RtmpMediaSource>(sender.shared_from_this()),path);
|
||||||
FlvRecorder::Ptr recorder(new FlvRecorder);
|
s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder;
|
||||||
try{
|
}catch(std::exception &ex){
|
||||||
recorder->startRecord(poller,rtmpMediaSrc,path);
|
WarnL << ex.what();
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue