blob: 579a488cb1c9cf7d80b779f0c9f0309d5ed67125 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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 Brandt23772262022-05-23 09:53:15 +020011#ifndef MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_
12#define MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Niels Möllera12c42a2018-07-25 16:05:48 +020014#include <stdint.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000015
Evan Shrubsolee9126c12022-03-07 14:50:51 +010016#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
philipel9d3ab612015-12-21 04:12:39 -080021namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
Rasmus Brandt23772262022-05-23 09:53:15 +020023class InterFrameDelay {
philipel9d3ab612015-12-21 04:12:39 -080024 public:
Rasmus Brandt23772262022-05-23 09:53:15 +020025 InterFrameDelay();
niklase@google.com470e71d2011-07-07 08:21:25 +000026
philipel9d3ab612015-12-21 04:12:39 -080027 // Resets the estimate. Zeros are given as parameters.
Evan Shrubsolee9126c12022-03-07 14:50:51 +010028 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
philipel9d3ab612015-12-21 04:12:39 -080030 // Calculates the delay of a frame with the given timestamp.
31 // This method is called when the frame is complete.
Evan Shrubsolee9126c12022-03-07 14:50:51 +010032 absl::optional<TimeDelta> CalculateDelay(uint32_t rtp_timestamp,
33 Timestamp now);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
philipel9d3ab612015-12-21 04:12:39 -080035 private:
Evan Shrubsolee9126c12022-03-07 14:50:51 +010036 // The previous rtp timestamp passed to the delay estimate
37 int64_t prev_rtp_timestamp_unwrapped_;
38 TimestampUnwrapper unwrapper_;
niklase@google.com470e71d2011-07-07 08:21:25 +000039
philipel9d3ab612015-12-21 04:12:39 -080040 // The previous wall clock timestamp used by the delay estimate
Evan Shrubsolee9126c12022-03-07 14:50:51 +010041 absl::optional<Timestamp> prev_wall_clock_;
niklase@google.com470e71d2011-07-07 08:21:25 +000042};
43
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000044} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000045
Rasmus Brandt23772262022-05-23 09:53:15 +020046#endif // MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_