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 | |
Rasmus Brandt | 2377226 | 2022-05-23 09:53:15 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_ |
| 12 | #define MODULES_VIDEO_CODING_TIMING_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 | |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame] | 16 | #include "absl/types/optional.h" |
| 17 | #include "api/units/time_delta.h" |
| 18 | #include "api/units/timestamp.h" |
| 19 | #include "modules/include/module_common_types_public.h" |
| 20 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 21 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
Rasmus Brandt | 2377226 | 2022-05-23 09:53:15 +0200 | [diff] [blame] | 23 | class InterFrameDelay { |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 24 | public: |
Rasmus Brandt | 2377226 | 2022-05-23 09:53:15 +0200 | [diff] [blame] | 25 | InterFrameDelay(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 27 | // Resets the estimate. Zeros are given as parameters. |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame] | 28 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 30 | // Calculates the delay of a frame with the given timestamp. |
| 31 | // This method is called when the frame is complete. |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame] | 32 | absl::optional<TimeDelta> CalculateDelay(uint32_t rtp_timestamp, |
| 33 | Timestamp now); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 35 | private: |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame] | 36 | // The previous rtp timestamp passed to the delay estimate |
| 37 | int64_t prev_rtp_timestamp_unwrapped_; |
| 38 | TimestampUnwrapper unwrapper_; |
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 | // The previous wall clock timestamp used by the delay estimate |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame] | 41 | absl::optional<Timestamp> prev_wall_clock_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 44 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
Rasmus Brandt | 2377226 | 2022-05-23 09:53:15 +0200 | [diff] [blame] | 46 | #endif // MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_ |