2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_RTP_RTCP_INTERFACE_REMOTE_NTP_TIME_ESTIMATOR_H_
12 #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_REMOTE_NTP_TIME_ESTIMATOR_H_
14 #include "webrtc/system_wrappers/interface/rtp_to_ntp.h"
15 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
21 class TimestampExtrapolator;
23 // RemoteNtpTimeEstimator can be used to estimate a given RTP timestamp's NTP
24 // time in local timebase.
25 // Note that it needs to be trained with at least 2 RTCP SR (by calling
26 // |UpdateRtcpTimestamp|) before it can be used.
27 class RemoteNtpTimeEstimator {
29 explicit RemoteNtpTimeEstimator(Clock* clock);
31 ~RemoteNtpTimeEstimator();
33 // Updates the estimator with the timestamp from newly received RTCP SR for
34 // |ssrc|. The RTCP SR is read from |rtp_rtcp|.
35 bool UpdateRtcpTimestamp(uint32_t ssrc, RtpRtcp* rtp_rtcp);
37 // Estimates the NTP timestamp in local timebase from |rtp_timestamp|.
38 // Returns the NTP timestamp in ms when success. -1 if failed.
39 int64_t Estimate(uint32_t rtp_timestamp);
43 scoped_ptr<TimestampExtrapolator> ts_extrapolator_;
45 DISALLOW_COPY_AND_ASSIGN(RemoteNtpTimeEstimator);
50 #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_REMOTE_NTP_TIME_ESTIMATOR_H_