From d955b639d7bf801c3bfb37f65932712d48dfad88 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 5 Jul 2018 18:56:11 +0800 Subject: [PATCH] bug fixed --- src/Rtsp/RtpBroadCaster.cpp | 7 +++---- src/Rtsp/RtpBroadCaster.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Rtsp/RtpBroadCaster.cpp b/src/Rtsp/RtpBroadCaster.cpp index 431924d0..d0a9a7c1 100644 --- a/src/Rtsp/RtpBroadCaster.cpp +++ b/src/Rtsp/RtpBroadCaster.cpp @@ -126,7 +126,7 @@ RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strVhost,c } m_pReader = src->getRing()->attach(); m_pReader->setReadCB([this](const RtpPacket::Ptr &pkt){ - int i = (pkt->interleaved/2)%2; + int i = (int)(pkt->type); auto &pSock = m_apUdpSock[i]; auto &peerAddr = m_aPeerUdpAddr[i]; BufferRtp::Ptr buffer(new BufferRtp(pkt,4)); @@ -148,9 +148,8 @@ RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strVhost,c << strVhost << " " << strApp << " " << strStream; } -uint16_t RtpBroadCaster::getPort(int iTrackId){ - int i = iTrackId%2; - return m_apUdpSock[i]->get_local_port(); +uint16_t RtpBroadCaster::getPort(int trackType){ + return m_apUdpSock[trackType]->get_local_port(); } string RtpBroadCaster::getIP(){ return inet_ntoa(m_aPeerUdpAddr[0].sin_addr); diff --git a/src/Rtsp/RtpBroadCaster.h b/src/Rtsp/RtpBroadCaster.h index 9c5df0d4..29199d7e 100644 --- a/src/Rtsp/RtpBroadCaster.h +++ b/src/Rtsp/RtpBroadCaster.h @@ -74,7 +74,7 @@ public: virtual ~RtpBroadCaster(); static Ptr get(const string &strLocalIp,const string &strVhost,const string &strApp,const string &strStream); void setDetachCB(void *listener,const onDetach &cb); - uint16_t getPort(int iTrackId); + uint16_t getPort(int trackType); string getIP(); private: static recursive_mutex g_mtx;