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

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: rebase 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 // Updates measurements with RTP/NTP timestamp pair from a RTCP sender report.
29 // |new_rtcp_sr| is set to true if a new report is added.
30 bool UpdateMeasurements(uint32_t ntp_secs,
31 uint32_t ntp_frac,
32 uint32_t rtp_timestamp,
33 bool* new_rtcp_sr);
34
35 // Converts an RTP timestamp to the NTP domain in milliseconds.
36 // Returns true on success, false otherwise.
37 bool Estimate(int64_t rtp_timestamp, int64_t* rtp_timestamp_ms) const;
38
39 // Estimated parameters from RTP and NTP timestamp pairs in |measurements_|.
40 struct Parameters {
41 double frequency_khz = 0.0;
42 double offset_ms = 0.0;
43 bool calculated = false;
44 };
45
46 // RTP and NTP timestamp pair from a RTCP SR report.
47 struct RtcpMeasurement {
48 RtcpMeasurement(uint32_t ntp_secs, uint32_t ntp_frac, uint32_t timestamp);
49 bool IsEqual(const RtcpMeasurement& other) const;
50
51 NtpTime ntp_time;
52 uint32_t rtp_timestamp;
53 };
54
stefan-webrtc 2016/12/19 12:36:07 Move these structs to the top of the class.
åsapersson 2016/12/19 15:06:47 Done.
55 const Parameters& params() const { return params_; }
56
57 // Only for testing.
58 const std::list<RtcpMeasurement>& measurements() const {
stefan-webrtc 2016/12/19 12:36:07 I'd prefer not to expose this. Can we write the te
åsapersson 2016/12/19 15:06:47 Done.
59 return measurements_;
60 }
61
62 private:
63 void UpdateParameters();
64
65 std::list<RtcpMeasurement> measurements_;
66 Parameters params_;
67 };
68
69 // Returns:
70 // 1: forward wrap around.
71 // 0: no wrap around.
72 // -1: backwards wrap around (i.e. reordering).
73 int CheckForWrapArounds(uint32_t new_timestamp, uint32_t old_timestamp);
74
75 } // namespace webrtc
76
77 #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