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 "absl/functional/any_invocable.h" 17 #include "absl/types/optional.h" 18 #include "api/units/timestamp.h" 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 = 27 absl::AnyInvocable<void(uint32_t rtp_timestamp, 28 Timestamp render_time) &&>; 29 30 virtual ~FrameDecodeScheduler() = default; 31 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; 35 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` 39 virtual void ScheduleFrame(uint32_t rtp, 40 FrameDecodeTiming::FrameSchedule schedule, 41 FrameReleaseCallback callback) = 0; 42 43 // Cancels all scheduled frames. 44 virtual void CancelOutstanding() = 0; 45 46 // Stop() Must be called before destruction. 47 virtual void Stop() = 0; 48 }; 49 50 } // namespace webrtc 51 52 #endif // VIDEO_FRAME_DECODE_SCHEDULER_H_ 53