diff --git a/src/Rtsp/RtpCodec.h b/src/Rtsp/RtpCodec.h index b1acde58..423b70c9 100644 --- a/src/Rtsp/RtpCodec.h +++ b/src/Rtsp/RtpCodec.h @@ -84,7 +84,9 @@ public: uint32_t getSsrc() const { return _ssrc; } - + int16_t getSeq() const {return _seq;} + void setSeq(int16_t seq) {_seq = seq;} + RtpPacket::Ptr makeRtp(TrackType type,const void *data, size_t len, bool mark, uint64_t stamp); private: diff --git a/src/Rtsp/RtspMuxer.cpp b/src/Rtsp/RtspMuxer.cpp index 6f5e4f8f..6d4c425d 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -38,6 +38,7 @@ void RtspMuxer::onRtp(RtpPacket::Ptr in, bool is_key) { in->ntp_stamp = _ntp_stamp_start + (in->getStamp() * uint64_t(1000) / in->sample_rate); } #endif + _rtp_seq[in->type] = in->getSeq() + 1; _rtpRing->write(std::move(in), is_key); } @@ -71,7 +72,8 @@ bool RtspMuxer::addTrack(const Track::Ptr &track) { if (!encoder) { return false; } - + auto rtp = std::dynamic_pointer_cast(encoder); + rtp->setSeq(_rtp_seq[track->getTrackType()]); //设置rtp输出环形缓存 encoder->setRtpRing(_rtpInterceptor); diff --git a/src/Rtsp/RtspMuxer.h b/src/Rtsp/RtspMuxer.h index 6b5cfa56..84729c2f 100644 --- a/src/Rtsp/RtspMuxer.h +++ b/src/Rtsp/RtspMuxer.h @@ -53,7 +53,7 @@ public: * 获取完整的SDP字符串 * @return SDP字符串 */ - std::string getSdp() ; + std::string getSdp(); /** * 获取rtp环形缓存 @@ -80,7 +80,7 @@ public: /** * 重置所有track */ - void resetTracks() override ; + void resetTracks() override; private: void onRtp(RtpPacket::Ptr in, bool is_key); @@ -88,6 +88,7 @@ private: private: bool _live = true; + uint16_t _rtp_seq[TrackMax]{0}; uint32_t _rtp_stamp[TrackMax]{0}; uint64_t _ntp_stamp[TrackMax]{0}; uint64_t _ntp_stamp_start;