tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

capture_clock_offset_updater.h (2154B)


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