Use a lock to protect members accessed by RtpVideoStreamReceiver::GetSyncInfo()

Proper synchronization was overlooked in
https://webrtc-review.googlesource.com/93261

Bug: chromium:878319, webrtc:7135
Change-Id: Ifc850c4d67a4e9dd2660dab9b6da67258338553e
Reviewed-on: https://webrtc-review.googlesource.com/96461
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24495}
This commit is contained in:
Niels Möller
2018-08-28 13:58:15 +02:00
committed by Commit Bot
parent 5304a32a94
commit b0d4b415cc
2 changed files with 18 additions and 10 deletions

View File

@ -176,17 +176,20 @@ void RtpVideoStreamReceiver::AddReceiveCodec(
}
absl::optional<Syncable::Info> RtpVideoStreamReceiver::GetSyncInfo() const {
if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) {
return absl::nullopt;
}
Syncable::Info info;
if (rtp_rtcp_->RemoteNTP(&info.capture_time_ntp_secs,
&info.capture_time_ntp_frac, nullptr, nullptr,
&info.capture_time_source_clock) != 0) {
return absl::nullopt;
}
info.latest_received_capture_timestamp = *last_received_rtp_timestamp_;
info.latest_receive_time_ms = *last_received_rtp_system_time_ms_;
{
rtc::CritScope lock(&last_seq_num_cs_);
if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) {
return absl::nullopt;
}
info.latest_received_capture_timestamp = *last_received_rtp_timestamp_;
info.latest_receive_time_ms = *last_received_rtp_system_time_ms_;
}
// Leaves info.current_delay_ms uninitialized.
return info;
@ -279,10 +282,13 @@ void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
if (!packet.recovered()) {
int64_t now_ms = clock_->TimeInMilliseconds();
// TODO(nisse): Exclude out-of-order packets?
last_received_rtp_timestamp_ = packet.Timestamp();
last_received_rtp_system_time_ms_ = now_ms;
{
rtc::CritScope lock(&last_seq_num_cs_);
// TODO(nisse): Exclude out-of-order packets?
last_received_rtp_timestamp_ = packet.Timestamp();
last_received_rtp_system_time_ms_ = now_ms;
}
// Periodically log the RTP header of incoming packets.
if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) {
std::stringstream ss;

View File

@ -177,8 +177,10 @@ class RtpVideoStreamReceiver : public RtpData,
RTC_GUARDED_BY(last_seq_num_cs_);
video_coding::H264SpsPpsTracker tracker_;
absl::optional<uint32_t> last_received_rtp_timestamp_;
absl::optional<int64_t> last_received_rtp_system_time_ms_;
absl::optional<uint32_t> last_received_rtp_timestamp_
RTC_GUARDED_BY(last_seq_num_cs_);
absl::optional<int64_t> last_received_rtp_system_time_ms_
RTC_GUARDED_BY(last_seq_num_cs_);
std::map<uint8_t, VideoCodecType> pt_codec_type_;
// TODO(johan): Remove pt_codec_params_ once
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6883 is resolved.