diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index ee81e952..c6e73a40 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -117,19 +117,22 @@ void PlayerProxy::play(const string &strUrlTmp) { }); MediaPlayer::play(strUrlTmp); _pull_url = strUrlTmp; + setDirectProxy(); +} +void PlayerProxy::setDirectProxy(){ MediaSource::Ptr mediaSource; - if(dynamic_pointer_cast(_delegate)){ + if (dynamic_pointer_cast(_delegate)) { //rtsp拉流 - GET_CONFIG(bool,directProxy,Rtsp::kDirectProxy); - if(directProxy){ + GET_CONFIG(bool, directProxy, Rtsp::kDirectProxy); + if (directProxy) { mediaSource = std::make_shared(_vhost, _app, _stream_id); } - } else if(dynamic_pointer_cast(_delegate)){ + } else if (dynamic_pointer_cast(_delegate)) { //rtmp拉流,rtmp强制直接代理 mediaSource = std::make_shared(_vhost, _app, _stream_id); } - if(mediaSource){ + if (mediaSource) { setMediaSource(mediaSource); mediaSource->setListener(shared_from_this()); } @@ -150,6 +153,7 @@ void PlayerProxy::rePlay(const string &strUrl,int iFailedCnt){ } WarnL << "重试播放[" << iFailedCnt << "]:" << strUrl; strongPlayer->MediaPlayer::play(strUrl); + strongPlayer->setDirectProxy(); return false; }, getPoller()); } diff --git a/src/Player/PlayerProxy.h b/src/Player/PlayerProxy.h index dbb87001..bdd57f23 100644 --- a/src/Player/PlayerProxy.h +++ b/src/Player/PlayerProxy.h @@ -65,6 +65,7 @@ private: void rePlay(const string &strUrl,int iFailedCnt); void onPlaySuccess(); + void setDirectProxy(); private: bool _enable_hls;