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_SCHEDULER_H_ |
| 12 | #define VIDEO_FRAME_DECODE_SCHEDULER_H_ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
Evan Shrubsole | c5a9144 | 2022-09-05 14:09:29 +0000 | [diff] [blame] | 16 | #include "absl/functional/any_invocable.h" |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 17 | #include "absl/types/optional.h" |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 18 | #include "api/units/timestamp.h" |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 19 | #include "video/frame_decode_timing.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class FrameDecodeScheduler { |
| 24 | public: |
| 25 | // Invoked when a frame with `rtp_timestamp` is ready for decoding. |
| 26 | using FrameReleaseCallback = |
Evan Shrubsole | c5a9144 | 2022-09-05 14:09:29 +0000 | [diff] [blame] | 27 | absl::AnyInvocable<void(uint32_t rtp_timestamp, |
| 28 | Timestamp render_time) &&>; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 29 | |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 30 | virtual ~FrameDecodeScheduler() = default; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 31 | |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 32 | // Returns the rtp timestamp of the next frame scheduled for release, or |
| 33 | // `nullopt` if no frame is currently scheduled. |
| 34 | virtual absl::optional<uint32_t> ScheduledRtpTimestamp() = 0; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 35 | |
Evan Shrubsole | c5a9144 | 2022-09-05 14:09:29 +0000 | [diff] [blame] | 36 | // Schedules a frame for release based on `schedule`. When released, |
| 37 | // `callback` will be invoked with the `rtp` timestamp of the frame and the |
| 38 | // `render_time` |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 39 | virtual void ScheduleFrame(uint32_t rtp, |
| 40 | FrameDecodeTiming::FrameSchedule schedule, |
| 41 | FrameReleaseCallback callback) = 0; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 42 | |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 43 | // Cancels all scheduled frames. |
| 44 | virtual void CancelOutstanding() = 0; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 45 | |
Evan Shrubsole | 6cd6d8e | 2022-02-11 15:30:26 +0100 | [diff] [blame] | 46 | // Stop() Must be called before destruction. |
| 47 | virtual void Stop() = 0; |
Evan Shrubsole | 9a99905 | 2021-12-12 15:27:00 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace webrtc |
| 51 | |
| 52 | #endif // VIDEO_FRAME_DECODE_SCHEDULER_H_ |