1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/rtp_rtcp/source/capture_clock_offset_updater.h" 12 13 namespace webrtc { 14 15 absl::optional<int64_t> AdjustEstimatedCaptureClockOffset(absl::optional<int64_t> remote_capture_clock_offset) const16CaptureClockOffsetUpdater::AdjustEstimatedCaptureClockOffset( 17 absl::optional<int64_t> remote_capture_clock_offset) const { 18 if (remote_capture_clock_offset == absl::nullopt || 19 remote_to_local_clock_offset_ == absl::nullopt) { 20 return absl::nullopt; 21 } 22 23 // Do calculations as "unsigned" to make overflows deterministic. 24 return static_cast<uint64_t>(*remote_capture_clock_offset) + 25 static_cast<uint64_t>(*remote_to_local_clock_offset_); 26 } 27 SetRemoteToLocalClockOffset(absl::optional<int64_t> offset_q32x32)28void CaptureClockOffsetUpdater::SetRemoteToLocalClockOffset( 29 absl::optional<int64_t> offset_q32x32) { 30 remote_to_local_clock_offset_ = offset_q32x32; 31 } 32 33 } // namespace webrtc 34