RtpCodec保存和还原Rtp seq

This commit is contained in:
cqm 2022-11-30 16:32:50 +08:00
parent 5c92b4e48f
commit 5041cf5ba4
3 changed files with 9 additions and 4 deletions

View File

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

View File

@ -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<RtpInfo>(encoder);
rtp->setSeq(_rtp_seq[track->getTrackType()]);
//设置rtp输出环形缓存
encoder->setRtpRing(_rtpInterceptor);

View File

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