blob: 6bde4702add58db7a69028e1404b42369161d4fe [file] [log] [blame]
Evan Shrubsole9a999052021-12-12 15:27:00 +01001/*
2 * Copyright (c) 2022 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 VIDEO_FRAME_DECODE_TIMING_H_
12#define VIDEO_FRAME_DECODE_TIMING_H_
13
14#include <stdint.h>
15
16#include <functional>
17
Artem Titovc374d112022-06-16 21:27:45 +020018#include "api/task_queue/pending_task_safety_flag.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010019#include "api/task_queue/task_queue_base.h"
Rasmus Brandtc4d253c2022-05-25 12:03:35 +020020#include "modules/video_coding/timing/timing.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010021#include "system_wrappers/include/clock.h"
22
23namespace webrtc {
24
25class FrameDecodeTiming {
26 public:
27 FrameDecodeTiming(Clock* clock, webrtc::VCMTiming const* timing);
28 ~FrameDecodeTiming() = default;
29 FrameDecodeTiming(const FrameDecodeTiming&) = delete;
30 FrameDecodeTiming& operator=(const FrameDecodeTiming&) = delete;
31
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010032 // Any frame that has decode delay more than this in the past can be
33 // fast-forwarded.
34 static constexpr TimeDelta kMaxAllowedFrameDelay = TimeDelta::Millis(5);
35
Evan Shrubsole9a999052021-12-12 15:27:00 +010036 struct FrameSchedule {
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010037 Timestamp latest_decode_time;
Evan Shrubsole9a999052021-12-12 15:27:00 +010038 Timestamp render_time;
39 };
40
41 absl::optional<FrameSchedule> OnFrameBufferUpdated(
42 uint32_t next_temporal_unit_rtp,
43 uint32_t last_temporal_unit_rtp,
Evan Shrubsole3fa9a662022-06-13 14:19:10 +000044 TimeDelta max_wait_for_frame,
Evan Shrubsole9a999052021-12-12 15:27:00 +010045 bool too_many_frames_queued);
46
47 private:
48 Clock* const clock_;
49 webrtc::VCMTiming const* const timing_;
50};
51
52} // namespace webrtc
53
54#endif // VIDEO_FRAME_DECODE_TIMING_H_