blob: 29e27c22c81e941363f20ea3a4fe1ac75618dbbf [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_SCHEDULER_H_
12#define VIDEO_FRAME_DECODE_SCHEDULER_H_
13
14#include <stdint.h>
15
Evan Shrubsolec5a91442022-09-05 14:09:29 +000016#include "absl/functional/any_invocable.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010017#include "absl/types/optional.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010018#include "api/units/timestamp.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010019#include "video/frame_decode_timing.h"
20
21namespace webrtc {
22
23class FrameDecodeScheduler {
24 public:
25 // Invoked when a frame with `rtp_timestamp` is ready for decoding.
26 using FrameReleaseCallback =
Evan Shrubsolec5a91442022-09-05 14:09:29 +000027 absl::AnyInvocable<void(uint32_t rtp_timestamp,
28 Timestamp render_time) &&>;
Evan Shrubsole9a999052021-12-12 15:27:00 +010029
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010030 virtual ~FrameDecodeScheduler() = default;
Evan Shrubsole9a999052021-12-12 15:27:00 +010031
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010032 // 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 Shrubsole9a999052021-12-12 15:27:00 +010035
Evan Shrubsolec5a91442022-09-05 14:09:29 +000036 // 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 Shrubsole6cd6d8e2022-02-11 15:30:26 +010039 virtual void ScheduleFrame(uint32_t rtp,
40 FrameDecodeTiming::FrameSchedule schedule,
41 FrameReleaseCallback callback) = 0;
Evan Shrubsole9a999052021-12-12 15:27:00 +010042
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010043 // Cancels all scheduled frames.
44 virtual void CancelOutstanding() = 0;
Evan Shrubsole9a999052021-12-12 15:27:00 +010045
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010046 // Stop() Must be called before destruction.
47 virtual void Stop() = 0;
Evan Shrubsole9a999052021-12-12 15:27:00 +010048};
49
50} // namespace webrtc
51
52#endif // VIDEO_FRAME_DECODE_SCHEDULER_H_