Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 1 | /* |
| 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 Titov | c374d11 | 2022-06-16 21:27:45 +0200 | [diff] [blame] | 18 | #include "api/task_queue/pending_task_safety_flag.h" |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 19 | #include "api/task_queue/task_queue_base.h" |
Rasmus Brandt | c4d253c | 2022-05-25 12:03:35 +0200 | [diff] [blame] | 20 | #include "modules/video_coding/timing/timing.h" |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 21 | #include "system_wrappers/include/clock.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class 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 Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 32 | // 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 Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 36 | struct FrameSchedule { |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 37 | Timestamp latest_decode_time; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 38 | 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 Shrubsole | 3fa9a66 | 2022-06-13 14:19:10 +0000 | [diff] [blame] | 44 | TimeDelta max_wait_for_frame, |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 45 | 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_ |