New method RtpReceiver::GetLatestTimestamps.

The two timestamps, rtp time and corresponding system time, are always
used together, for audio/video sync. The new method reads both
timestamps, without releasing a lock in between. Ensures that the
caller gets values corresponding to the same packet.

Bug: webrtc:7135
Change-Id: I25bdcbe9ad620016bfad39841b339c266efade14
Reviewed-on: https://webrtc-review.googlesource.com/4062
Commit-Queue: Niels Moller <nisse@webrtc.org>
Commit-Queue: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20120}
This commit is contained in:
Niels Möller
2017-10-03 15:28:26 +02:00
committed by Commit Bot
parent 1cfa95b8b8
commit c3fa8e1ce7
6 changed files with 31 additions and 35 deletions

View File

@ -225,24 +225,16 @@ std::vector<RtpSource> RtpReceiverImpl::GetSources() const {
return sources;
}
bool RtpReceiverImpl::Timestamp(uint32_t* timestamp) const {
bool RtpReceiverImpl::GetLatestTimestamps(uint32_t* timestamp,
int64_t* receive_time_ms) const {
rtc::CritScope lock(&critical_section_rtp_receiver_);
if (!HaveReceivedFrame())
if (last_received_frame_time_ms_ < 0)
return false;
*timestamp = last_received_timestamp_;
return true;
}
bool RtpReceiverImpl::LastReceivedTimeMs(int64_t* receive_time_ms) const {
rtc::CritScope lock(&critical_section_rtp_receiver_);
if (!HaveReceivedFrame())
return false;
*receive_time_ms = last_received_frame_time_ms_;
return true;
}
bool RtpReceiverImpl::HaveReceivedFrame() const {
return last_received_frame_time_ms_ >= 0;
return true;
}
// Implementation note: must not hold critsect when called.