blob: cab0bd20a32f6c1be2601437d645c721b015ecc2 [file] [log] [blame]
Evan Shrubsole9d290262021-12-15 13:33:401/*
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_BUFFER_PROXY_H_
12#define VIDEO_FRAME_BUFFER_PROXY_H_
13
14#include <memory>
15
16#include "api/task_queue/task_queue_base.h"
17#include "api/video/encoded_frame.h"
18#include "modules/video_coding/include/video_coding_defines.h"
19#include "modules/video_coding/timing.h"
20#include "rtc_base/task_queue.h"
21#include "system_wrappers/include/clock.h"
22namespace webrtc {
23
24class FrameSchedulingReceiver {
25 public:
26 virtual ~FrameSchedulingReceiver() = default;
27
28 virtual void OnEncodedFrame(std::unique_ptr<EncodedFrame> frame) = 0;
29 virtual void OnDecodableFrameTimeout(TimeDelta wait_time) = 0;
30};
31
32// Temporary class to enable replacement of frame_buffer2 with frame_buffer3.
33// Once frame_buffer3 has shown to work with a field trial, frame_buffer2 will
34// be removed and this class should be directly integrated into
35// video_receive_stream2. bugs.webrtc.org/13343 tracks this integration.
36class FrameBufferProxy {
37 public:
38 static std::unique_ptr<FrameBufferProxy> CreateFromFieldTrial(
39 Clock* clock,
40 TaskQueueBase* worker_queue,
41 VCMTiming* timing,
42 VCMReceiveStatisticsCallback* stats_proxy,
43 rtc::TaskQueue* decode_queue,
44 FrameSchedulingReceiver* receiver,
45 TimeDelta max_wait_for_keyframe,
46 TimeDelta max_wait_for_frame);
47 virtual ~FrameBufferProxy() = default;
48
49 // Run on the worker thread.
50 virtual void StopOnWorker() = 0;
51 virtual void SetProtectionMode(VCMVideoProtection protection_mode) = 0;
52 virtual void Clear() = 0;
53 virtual absl::optional<int64_t> InsertFrame(
54 std::unique_ptr<EncodedFrame> frame) = 0;
55 virtual void UpdateRtt(int64_t max_rtt_ms) = 0;
56 virtual int Size() = 0;
57
58 // Run on either the worker thread or the decode thread.
59 virtual void StartNextDecode(bool keyframe_required) = 0;
60};
61
62} // namespace webrtc
63
64#endif // VIDEO_FRAME_BUFFER_PROXY_H_