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