Skip to content

Commit

Permalink
RTC2RTMP: Write important trace log for sync timestamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 14, 2023
1 parent 1b34fc4 commit 84d1a33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ SrsRtcFrameBuilder::SrsRtcFrameBuilder(ISrsStreamBridge* bridge)
header_sn_ = 0;
memset(cache_video_pkts_, 0, sizeof(cache_video_pkts_));
rtp_key_frame_ts_ = -1;
sync_state_ = -1;
}

SrsRtcFrameBuilder::~SrsRtcFrameBuilder()
Expand Down Expand Up @@ -1366,8 +1367,18 @@ srs_error_t SrsRtcFrameBuilder::on_rtp(SrsRtpPacket *pkt)

// Have no received any sender report, can't calculate avsync_time,
// discard it to avoid timestamp problem in live source
const SrsRtpHeader& h = pkt->header;
if (pkt->get_avsync_time() <= 0) {
if (sync_state_ < 0) {
srs_trace("RTC: Discard no-sync %s, ssrc=%u, seq=%u, ts=%u, state=%d", pkt->is_audio() ? "Audio" : "Video",
h.get_ssrc(), h.get_sequence(), h.get_timestamp(), sync_state_);
sync_state_ = 0;
}
return err;
} else if (sync_state_ < 1) {
srs_trace("RTC: Accept sync %s, ssrc=%u, seq=%u, ts=%u, state=%d", pkt->is_audio() ? "Audio" : "Video",
h.get_ssrc(), h.get_sequence(), h.get_timestamp(), sync_state_);
sync_state_ = 2;
}

if (pkt->is_audio()) {
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_rtc_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class SrsRtcFrameBuilder
uint16_t header_sn_;
uint16_t lost_sn_;
int64_t rtp_key_frame_ts_;
// The state for timestamp sync state. -1 for init. 0 not sync. 1 sync.
int sync_state_;
public:
SrsRtcFrameBuilder(ISrsStreamBridge* bridge);
virtual ~SrsRtcFrameBuilder();
Expand Down

0 comments on commit 84d1a33

Please sign in to comment.