Merge pull request #1805 from ZLMediaKit/feature/fix_rtsp_player_pt_error

Feature/fix rtsp player pt error
This commit is contained in:
夏楚 2022-07-18 11:25:16 +08:00 committed by GitHub
commit d703ec29c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 3 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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<RtcpContextForRecv>());
}
sendSetup(0);