| Index: webrtc/modules/rtp_rtcp/source/rtp_sender.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
|
| index d7c2830eb8683bee599da12ceef5b19b80b6160b..b918a908a7d03d0420b1a4e0e08201f1834e4c91 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
|
| @@ -109,6 +109,8 @@
|
| send_packet_observer_(send_packet_observer),
|
| bitrate_callback_(bitrate_callback),
|
| // RTP variables
|
| + start_timestamp_forced_(false),
|
| + start_timestamp_(0),
|
| ssrc_db_(SSRCDatabase::GetSSRCDatabase()),
|
| remote_ssrc_(0),
|
| sequence_number_forced_(false),
|
| @@ -126,8 +128,6 @@
|
| ssrc_rtx_ = ssrc_db_->CreateSSRC();
|
| RTC_DCHECK(ssrc_rtx_ != 0);
|
|
|
| - // This random initialization is not intended to be cryptographic strong.
|
| - timestamp_offset_ = random_.Rand<uint32_t>();
|
| // Random start, 16 bits. Can't be 0.
|
| sequence_number_rtx_ = random_.Rand(1, kMaxInitRtpSeqNumber);
|
| sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
|
| @@ -1099,7 +1099,7 @@
|
| if (!sending_media_)
|
| return -1;
|
|
|
| - timestamp_ = timestamp_offset_ + capture_timestamp;
|
| + timestamp_ = start_timestamp_ + capture_timestamp;
|
| last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
|
| uint32_t sequence_number = sequence_number_++;
|
| capture_time_ms_ = capture_time_ms;
|
| @@ -1499,7 +1499,13 @@
|
| }
|
|
|
| void RTPSender::SetSendingStatus(bool enabled) {
|
| - if (!enabled) {
|
| + if (enabled) {
|
| + uint32_t frequency_hz = SendPayloadFrequency();
|
| + uint32_t RTPtime = CurrentRtp(*clock_, frequency_hz);
|
| +
|
| + // Will be ignored if it's already configured via API.
|
| + SetStartTimestamp(RTPtime, false);
|
| + } else {
|
| rtc::CritScope lock(&send_critsect_);
|
| if (!ssrc_forced_) {
|
| // Generate a new SSRC.
|
| @@ -1530,14 +1536,21 @@
|
| return timestamp_;
|
| }
|
|
|
| -void RTPSender::SetTimestampOffset(uint32_t timestamp) {
|
| - rtc::CritScope lock(&send_critsect_);
|
| - timestamp_offset_ = timestamp;
|
| -}
|
| -
|
| -uint32_t RTPSender::TimestampOffset() const {
|
| - rtc::CritScope lock(&send_critsect_);
|
| - return timestamp_offset_;
|
| +void RTPSender::SetStartTimestamp(uint32_t timestamp, bool force) {
|
| + rtc::CritScope lock(&send_critsect_);
|
| + if (force) {
|
| + start_timestamp_forced_ = true;
|
| + start_timestamp_ = timestamp;
|
| + } else {
|
| + if (!start_timestamp_forced_) {
|
| + start_timestamp_ = timestamp;
|
| + }
|
| + }
|
| +}
|
| +
|
| +uint32_t RTPSender::StartTimestamp() const {
|
| + rtc::CritScope lock(&send_critsect_);
|
| + return start_timestamp_;
|
| }
|
|
|
| uint32_t RTPSender::GenerateNewSSRC() {
|
| @@ -1716,7 +1729,6 @@
|
| rtc::CritScope lock(&send_critsect_);
|
| sequence_number_ = rtp_state.sequence_number;
|
| sequence_number_forced_ = true;
|
| - timestamp_offset_ = rtp_state.start_timestamp;
|
| timestamp_ = rtp_state.timestamp;
|
| capture_time_ms_ = rtp_state.capture_time_ms;
|
| last_timestamp_time_ms_ = rtp_state.last_timestamp_time_ms;
|
| @@ -1728,7 +1740,7 @@
|
|
|
| RtpState state;
|
| state.sequence_number = sequence_number_;
|
| - state.start_timestamp = timestamp_offset_;
|
| + state.start_timestamp = start_timestamp_;
|
| state.timestamp = timestamp_;
|
| state.capture_time_ms = capture_time_ms_;
|
| state.last_timestamp_time_ms = last_timestamp_time_ms_;
|
| @@ -1747,7 +1759,7 @@
|
|
|
| RtpState state;
|
| state.sequence_number = sequence_number_rtx_;
|
| - state.start_timestamp = timestamp_offset_;
|
| + state.start_timestamp = start_timestamp_;
|
|
|
| return state;
|
| }
|
|
|