OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |
13 | 13 |
14 #include "webrtc/typedefs.h" | 14 #include "webrtc/typedefs.h" |
15 | 15 |
16 namespace webrtc | 16 namespace webrtc { |
17 { | |
18 | 17 |
19 class VCMInterFrameDelay | 18 class VCMInterFrameDelay { |
20 { | 19 public: |
21 public: | 20 explicit VCMInterFrameDelay(int64_t currentWallClock); |
22 VCMInterFrameDelay(int64_t currentWallClock); | |
23 | 21 |
24 // Resets the estimate. Zeros are given as parameters. | 22 // Resets the estimate. Zeros are given as parameters. |
25 void Reset(int64_t currentWallClock); | 23 void Reset(int64_t currentWallClock); |
26 | 24 |
27 // Calculates the delay of a frame with the given timestamp. | 25 // Calculates the delay of a frame with the given timestamp. |
28 // This method is called when the frame is complete. | 26 // This method is called when the frame is complete. |
29 // | 27 // |
30 // Input: | 28 // Input: |
31 // - timestamp : RTP timestamp of a received frame | 29 // - timestamp : RTP timestamp of a received frame |
32 // - *delay : Pointer to memory where the result should
be stored | 30 // - *delay : Pointer to memory where the result should be |
33 // - currentWallClock : The current time in milliseconds. | 31 // stored |
34 // Should be -1 for normal operation, only us
ed for testing. | 32 // - currentWallClock : The current time in milliseconds. |
35 // Return value : true if OK, false when reordered timestamp
s | 33 // Should be -1 for normal operation, only used |
36 bool CalculateDelay(uint32_t timestamp, | 34 // for testing. |
37 int64_t *delay, | 35 // Return value : true if OK, false when reordered timestamps |
38 int64_t currentWallClock); | 36 bool CalculateDelay(uint32_t timestamp, |
| 37 int64_t* delay, |
| 38 int64_t currentWallClock); |
39 | 39 |
40 // Returns the current difference between incoming timestamps | 40 // Returns the current difference between incoming timestamps |
41 // | 41 // |
42 // Return value : Wrap-around compensated difference between
incoming | 42 // Return value : Wrap-around compensated difference between |
43 // timestamps. | 43 // incoming |
44 uint32_t CurrentTimeStampDiffMs() const; | 44 // timestamps. |
| 45 uint32_t CurrentTimeStampDiffMs() const; |
45 | 46 |
46 private: | 47 private: |
47 // Controls if the RTP timestamp counter has had a wrap around | 48 // Controls if the RTP timestamp counter has had a wrap around |
48 // between the current and the previously received frame. | 49 // between the current and the previously received frame. |
49 // | 50 // |
50 // Input: | 51 // Input: |
51 // - timestmap : RTP timestamp of the current frame. | 52 // - timestmap : RTP timestamp of the current frame. |
52 void CheckForWrapArounds(uint32_t timestamp); | 53 void CheckForWrapArounds(uint32_t timestamp); |
53 | 54 |
54 int64_t _zeroWallClock; // Local timestamp of the first video packet
received | 55 int64_t _zeroWallClock; // Local timestamp of the first video packet received |
55 int32_t _wrapArounds; // Number of wrapArounds detected | 56 int32_t _wrapArounds; // Number of wrapArounds detected |
56 // The previous timestamp passed to the delay estimate | 57 // The previous timestamp passed to the delay estimate |
57 uint32_t _prevTimestamp; | 58 uint32_t _prevTimestamp; |
58 // The previous wall clock timestamp used by the delay estimate | 59 // The previous wall clock timestamp used by the delay estimate |
59 int64_t _prevWallClock; | 60 int64_t _prevWallClock; |
60 // Wrap-around compensated difference between incoming timestamps | 61 // Wrap-around compensated difference between incoming timestamps |
61 int64_t _dTS; | 62 int64_t _dTS; |
62 }; | 63 }; |
63 | 64 |
64 } // namespace webrtc | 65 } // namespace webrtc |
65 | 66 |
66 #endif // WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ | 67 #endif // WEBRTC_MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |
OLD | NEW |