LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/system_wrappers/include - rtp_to_ntp_estimator.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2012 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 WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_
      12             : #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_
      13             : 
      14             : #include <list>
      15             : 
      16             : #include "webrtc/system_wrappers/include/ntp_time.h"
      17             : #include "webrtc/typedefs.h"
      18             : 
      19             : namespace webrtc {
      20             : // Class for converting an RTP timestamp to the NTP domain in milliseconds.
      21             : // The class needs to be trained with (at least 2) RTP/NTP timestamp pairs from
      22             : // RTCP sender reports before the convertion can be done.
      23             : class RtpToNtpEstimator {
      24             :  public:
      25             :   RtpToNtpEstimator();
      26             :   ~RtpToNtpEstimator();
      27             : 
      28             :   // RTP and NTP timestamp pair from a RTCP SR report.
      29             :   struct RtcpMeasurement {
      30             :     RtcpMeasurement(uint32_t ntp_secs, uint32_t ntp_frac, uint32_t timestamp);
      31             :     bool IsEqual(const RtcpMeasurement& other) const;
      32             : 
      33             :     NtpTime ntp_time;
      34             :     uint32_t rtp_timestamp;
      35             :   };
      36             : 
      37             :   // Estimated parameters from RTP and NTP timestamp pairs in |measurements_|.
      38           0 :   struct Parameters {
      39             :     double frequency_khz = 0.0;
      40             :     double offset_ms = 0.0;
      41             :     bool calculated = false;
      42             :   };
      43             : 
      44             :   // Updates measurements with RTP/NTP timestamp pair from a RTCP sender report.
      45             :   // |new_rtcp_sr| is set to true if a new report is added.
      46             :   bool UpdateMeasurements(uint32_t ntp_secs,
      47             :                           uint32_t ntp_frac,
      48             :                           uint32_t rtp_timestamp,
      49             :                           bool* new_rtcp_sr);
      50             : 
      51             :   // Converts an RTP timestamp to the NTP domain in milliseconds.
      52             :   // Returns true on success, false otherwise.
      53             :   bool Estimate(int64_t rtp_timestamp, int64_t* rtp_timestamp_ms) const;
      54             : 
      55           0 :   const Parameters& params() const { return params_; }
      56             : 
      57             :  private:
      58             :   void UpdateParameters();
      59             : 
      60             :   std::list<RtcpMeasurement> measurements_;
      61             :   Parameters params_;
      62             : };
      63             : 
      64             : // Returns:
      65             : //  1: forward wrap around.
      66             : //  0: no wrap around.
      67             : // -1: backwards wrap around (i.e. reordering).
      68             : int CheckForWrapArounds(uint32_t new_timestamp, uint32_t old_timestamp);
      69             : 
      70             : }  // namespace webrtc
      71             : 
      72             : #endif  // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_RTP_TO_NTP_ESTIMATOR_H_

Generated by: LCOV version 1.13