niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |
| 12 | #define MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Niels Möller | a12c42a | 2018-07-25 16:05:48 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 16 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 18 | class VCMInterFrameDelay { |
| 19 | public: |
| 20 | explicit VCMInterFrameDelay(int64_t currentWallClock); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 22 | // Resets the estimate. Zeros are given as parameters. |
| 23 | void Reset(int64_t currentWallClock); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 25 | // Calculates the delay of a frame with the given timestamp. |
| 26 | // This method is called when the frame is complete. |
| 27 | // |
| 28 | // Input: |
Åsa Persson | 288cbe8 | 2019-04-01 14:31:46 +0200 | [diff] [blame] | 29 | // - timestamp : RTP timestamp of a received frame. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 30 | // - *delay : Pointer to memory where the result should be |
Åsa Persson | 288cbe8 | 2019-04-01 14:31:46 +0200 | [diff] [blame] | 31 | // stored. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 32 | // - currentWallClock : The current time in milliseconds. |
| 33 | // Should be -1 for normal operation, only used |
| 34 | // for testing. |
Åsa Persson | 288cbe8 | 2019-04-01 14:31:46 +0200 | [diff] [blame] | 35 | // Return value : true if OK, false when reordered timestamps. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 36 | bool CalculateDelay(uint32_t timestamp, |
| 37 | int64_t* delay, |
| 38 | int64_t currentWallClock); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 40 | private: |
Åsa Persson | 288cbe8 | 2019-04-01 14:31:46 +0200 | [diff] [blame] | 41 | // Controls if the RTP timestamp counter has had a wrap around between the |
| 42 | // current and the previously received frame. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 43 | // |
| 44 | // Input: |
Åsa Persson | 288cbe8 | 2019-04-01 14:31:46 +0200 | [diff] [blame] | 45 | // - timestamp : RTP timestamp of the current frame. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 46 | void CheckForWrapArounds(uint32_t timestamp); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 48 | int64_t _zeroWallClock; // Local timestamp of the first video packet received |
| 49 | int32_t _wrapArounds; // Number of wrapArounds detected |
| 50 | // The previous timestamp passed to the delay estimate |
| 51 | uint32_t _prevTimestamp; |
| 52 | // The previous wall clock timestamp used by the delay estimate |
| 53 | int64_t _prevWallClock; |
| 54 | // Wrap-around compensated difference between incoming timestamps |
| 55 | int64_t _dTS; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 58 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 60 | #endif // MODULES_VIDEO_CODING_INTER_FRAME_DELAY_H_ |