mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
完善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){
|
||||
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);
|
||||
|
||||
|
@ -185,25 +185,21 @@ static onceToken s_token([](){
|
||||
if(schema == RTMP_SCHEMA && app == "live"){
|
||||
static map<string,FlvRecorder::Ptr> s_mapFlvRecorder;
|
||||
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);
|
||||
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);
|
||||
lock_guard<mutex> 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(EventPollerPool::Instance().getPoller(),dynamic_pointer_cast<RtmpMediaSource>(sender.shared_from_this()),path);
|
||||
s_mapFlvRecorder[vhost + "/" + app + "/" + stream] = recorder;
|
||||
}catch(std::exception &ex){
|
||||
WarnL << ex.what();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
s_mapFlvRecorder.erase(vhost + "/" + app + "/" + stream);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user