From bf70a01f6adc67b5fac477ec1572282d2b00b450 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 25 Nov 2019 17:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8D=87rtsp=E7=9A=84=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspPlayer.cpp | 15 ++++++--------- src/Rtsp/RtspPlayer.h | 1 - src/Rtsp/RtspPusher.cpp | 3 +++ src/Rtsp/RtspSession.cpp | 6 ++++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 7c9c74ad..10a1f7e3 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -823,21 +823,15 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeComplete } } -int RtspPlayer::getTrackIndexByControlSuffix(const string &controlSuffix) const{ - for (unsigned int i = 0; i < _aTrackInfo.size(); i++) { - auto pos = _aTrackInfo[i]->_control_surffix.find(controlSuffix); - if (pos == 0) { - return i; - } - } - return -1; -} int RtspPlayer::getTrackIndexByInterleaved(int interleaved) const{ for (unsigned int i = 0; i < _aTrackInfo.size(); i++) { if (_aTrackInfo[i]->_interleaved == interleaved) { return i; } } + if(_aTrackInfo.size() == 1){ + return 0; + } return -1; } @@ -847,6 +841,9 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType trackType) const { return i; } } + if(_aTrackInfo.size() == 1){ + return 0; + } return -1; } diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index a633ab91..ee7afba0 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -103,7 +103,6 @@ private: void onRecvRTP_l(const RtpPacket::Ptr &pRtppt, const SdpTrack::Ptr &track); void onPlayResult_l(const SockException &ex , bool handshakeCompleted); - int getTrackIndexByControlSuffix(const string &controlSuffix) const; int getTrackIndexByInterleaved(int interleaved) const; int getTrackIndexByTrackType(TrackType trackType) const; diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index 7e2ca8c2..e40a185b 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -351,6 +351,9 @@ inline int RtspPusher::getTrackIndexByTrackType(TrackType type) { return i; } } + if(_aTrackInfo.size() == 1){ + return 0; + } return -1; } diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 14e2b89a..c06e204a 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -1105,6 +1105,9 @@ inline int RtspSession::getTrackIndexByTrackType(TrackType type) { return i; } } + if(_aTrackInfo.size() == 1){ + return 0; + } return -1; } inline int RtspSession::getTrackIndexByControlSuffix(const string &controlSuffix) { @@ -1125,6 +1128,9 @@ inline int RtspSession::getTrackIndexByInterleaved(int interleaved){ return i; } } + if(_aTrackInfo.size() == 1){ + return 0; + } return -1; }