优化拉流代理成功率

This commit is contained in:
xiongziliang 2018-11-17 14:41:12 +08:00
parent 0efe7a26b5
commit e0920536cc

View File

@ -99,7 +99,7 @@ void PlayerProxy::play(const char* strUrl) {
return; return;
} }
if(strongSelf->_mediaMuxer) { if(strongSelf->_mediaMuxer) {
auto tracks = strongSelf->getTracks(); auto tracks = strongSelf->getTracks(false);
for (auto & track : tracks){ for (auto & track : tracks){
track->delDelegate(strongSelf->_mediaMuxer.get()); track->delDelegate(strongSelf->_mediaMuxer.get());
} }
@ -176,7 +176,7 @@ void PlayerProxy::onPlaySuccess() {
_mediaMuxer.reset(new MultiMediaSourceMuxer(_strVhost.data(),_strApp.data(),_strSrc.data(),getDuration(),_bEnableHls,_bEnableMp4)); _mediaMuxer.reset(new MultiMediaSourceMuxer(_strVhost.data(),_strApp.data(),_strSrc.data(),getDuration(),_bEnableHls,_bEnableMp4));
_mediaMuxer->setListener(shared_from_this()); _mediaMuxer->setListener(shared_from_this());
auto videoTrack = getTrack(TrackVideo); auto videoTrack = getTrack(TrackVideo,false);
if(videoTrack){ if(videoTrack){
//添加视频 //添加视频
_mediaMuxer->addTrack(videoTrack); _mediaMuxer->addTrack(videoTrack);
@ -184,7 +184,7 @@ void PlayerProxy::onPlaySuccess() {
videoTrack->addDelegate(_mediaMuxer); videoTrack->addDelegate(_mediaMuxer);
} }
auto audioTrack = getTrack(TrackAudio); auto audioTrack = getTrack(TrackAudio, false);
if(audioTrack){ if(audioTrack){
//添加音频 //添加音频
_mediaMuxer->addTrack(audioTrack); _mediaMuxer->addTrack(audioTrack);