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 #ifndef MODULES_RTP_RTCP_SOURCE_CAPTURE_CLOCK_OFFSET_UPDATER_H_ 12 #define MODULES_RTP_RTCP_SOURCE_CAPTURE_CLOCK_OFFSET_UPDATER_H_ 13 14 #include <stdint.h> 15 16 #include "absl/types/optional.h" 17 18 namespace webrtc { 19 20 // 21 // Helper class for calculating the clock offset against the capturer's clock. 22 // 23 // This is achieved by adjusting the estimated capture clock offset in received 24 // Absolute Capture Time RTP header extension (see 25 // https://webrtc.org/experiments/rtp-hdrext/abs-capture-time/), which 26 // represents the clock offset between a remote sender and the capturer, by 27 // adding local-to-remote clock offset. 28 29 class CaptureClockOffsetUpdater { 30 public: 31 // Adjusts remote_capture_clock_offset, which originates from Absolute Capture 32 // Time RTP header extension, to get the local clock offset against the 33 // capturer's clock. 34 absl::optional<int64_t> AdjustEstimatedCaptureClockOffset( 35 absl::optional<int64_t> remote_capture_clock_offset) const; 36 37 // Sets the NTP clock offset between the sender system (which may be different 38 // from the capture system) and the local system. This information is normally 39 // provided by passing half the value of the Round-Trip Time estimation given 40 // by RTCP sender reports (see DLSR/DLRR). 41 // 42 // Note that the value must be in Q32.32-formatted fixed-point seconds. 43 void SetRemoteToLocalClockOffset(absl::optional<int64_t> offset_q32x32); 44 45 private: 46 absl::optional<int64_t> remote_to_local_clock_offset_; 47 }; 48 49 } // namespace webrtc 50 51 #endif // MODULES_RTP_RTCP_SOURCE_CAPTURE_CLOCK_OFFSET_UPDATER_H_ 52