Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: webrtc/system_wrappers/include/rtp_to_ntp_estimator.h

Issue 2574133003: Make class of static functions in rtp_to_ntp.h: (Closed)
Patch Set: address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 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 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_
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/include/rtp_to_ntp.h ('k') | webrtc/system_wrappers/source/rtp_to_ntp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698