blob: 5387e54293382b7950aa158d3bdfe0218dfbf3c1 [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
16#include <functional>
17
18#include "absl/types/optional.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010019#include "api/units/timestamp.h"
Evan Shrubsole9a999052021-12-12 15:27:00 +010020#include "video/frame_decode_timing.h"
21
22namespace webrtc {
23
24class 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 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 Shrubsole6cd6d8e2022-02-11 15:30:26 +010036 // 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 Shrubsole9a999052021-12-12 15:27:00 +010041
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010042 // Cancels all scheduled frames.
43 virtual void CancelOutstanding() = 0;
Evan Shrubsole9a999052021-12-12 15:27:00 +010044
Evan Shrubsole6cd6d8e2022-02-11 15:30:26 +010045 // Stop() Must be called before destruction.
46 virtual void Stop() = 0;
Evan Shrubsole9a999052021-12-12 15:27:00 +010047};
48
49} // namespace webrtc
50
51#endif // VIDEO_FRAME_DECODE_SCHEDULER_H_