diff --git a/src/Rtsp/RtpReceiver.cpp b/src/Rtsp/RtpReceiver.cpp index 697ede18..96b077d7 100644 --- a/src/Rtsp/RtpReceiver.cpp +++ b/src/Rtsp/RtpReceiver.cpp @@ -114,6 +114,10 @@ void RtpTrack::setNtpStamp(uint32_t rtp_stamp, uint64_t ntp_stamp_ms) { } } +void RtpTrack::setPT(uint8_t pt){ + _pt = pt; +} + //////////////////////////////////////////////////////////////////////////////////// void RtpTrackImp::setOnSorted(OnSorted cb) { diff --git a/src/Rtsp/RtpReceiver.h b/src/Rtsp/RtpReceiver.h index 86dbb8d7..d7ec3efe 100644 --- a/src/Rtsp/RtpReceiver.h +++ b/src/Rtsp/RtpReceiver.h @@ -175,6 +175,7 @@ public: uint32_t getSSRC() const; RtpPacket::Ptr inputRtp(TrackType type, int sample_rate, uint8_t *ptr, size_t len); void setNtpStamp(uint32_t rtp_stamp, uint64_t ntp_stamp_ms); + void setPT(uint8_t pt); protected: virtual void onRtpSorted(RtpPacket::Ptr rtp) {} @@ -252,6 +253,11 @@ public: _track[index].setNtpStamp(rtp_stamp, ntp_stamp_ms); } + void setPT(int index, uint8_t pt){ + assert(index < kCount && index >= 0); + _track[index].setPT(pt); + } + void clear() { for (auto &track : _track) { track.clear(); diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index f7cbed17..52d86468 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -212,7 +212,7 @@ void SdpParser::load(const string &sdp) { char codec[16] = {0}; sscanf(rtpmap.data(), "%d", &pt); - if (track._pt != pt) { + if (track._pt != pt && track._pt != 0xff) { //pt不匹配 it = track._attr.erase(it); continue; @@ -237,7 +237,7 @@ void SdpParser::load(const string &sdp) { auto &fmtp = it->second; int pt; sscanf(fmtp.data(), "%d", &pt); - if (track._pt != pt) { + if (track._pt != pt && track._pt != 0xff) { //pt不匹配 it = track._attr.erase(it); continue; diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index 6da75da9..d18bc374 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -217,7 +217,7 @@ public: std::string getControlUrl(const std::string &base_url) const; public: - int _pt; + int _pt = 0xff; int _channel; int _samplerate; TrackType _type; diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 498196de..38b53669 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -208,6 +208,9 @@ void RtspPlayer::handleResDESCRIBE(const Parser& parser) { } _rtcp_context.clear(); for (auto &track : _sdp_track) { + if(track->_pt != 0xff){ + setPT(_rtcp_context.size(),track->_pt); + } _rtcp_context.emplace_back(std::make_shared()); } sendSetup(0);