blob: 86f7f550966e7323cd98a29321d1299de04edeaa [file] [log] [blame]
Niels Mölleree3d9952019-09-09 12:51:55 +02001/*
2 * Copyright (c) 2019 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 MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
12#define MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
13
Jonas Orelande62c2f22022-03-29 11:04:48 +020014#include "api/field_trials_view.h"
Artem Titovd15a5752021-02-10 14:31:24 +010015#include "api/sequence_checker.h"
Danil Chapovalov355b8d22021-08-13 16:50:37 +020016#include "api/video_codecs/video_decoder.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020017#include "modules/video_coding/decoder_database.h"
18#include "modules/video_coding/encoded_frame.h"
19#include "modules/video_coding/generic_decoder.h"
Rasmus Brandtc4d253c2022-05-25 12:03:35 +020020#include "modules/video_coding/timing/timing.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020021#include "system_wrappers/include/clock.h"
22
23namespace webrtc {
24
25// This class is a copy of vcm::VideoReceiver, trimmed down to what's used by
26// VideoReceive stream, with the aim to incrementally trim it down further and
27// ultimately delete it. It's difficult to do this incrementally with the
28// original VideoReceiver class, since it is used by the legacy
29// VideoCodingModule api.
30class VideoReceiver2 {
31 public:
Jonas Orelande02f9ee2022-03-25 12:43:14 +010032 VideoReceiver2(Clock* clock,
33 VCMTiming* timing,
Jonas Orelande62c2f22022-03-29 11:04:48 +020034 const FieldTrialsView& field_trials);
Niels Mölleree3d9952019-09-09 12:51:55 +020035 ~VideoReceiver2();
36
Danil Chapovalovba0a3062021-08-13 18:15:55 +020037 void RegisterReceiveCodec(uint8_t payload_type,
Danil Chapovalov355b8d22021-08-13 16:50:37 +020038 const VideoDecoder::Settings& decoder_settings);
Niels Mölleree3d9952019-09-09 12:51:55 +020039
40 void RegisterExternalDecoder(VideoDecoder* externalDecoder,
41 uint8_t payloadType);
Johannes Kron16359f62021-02-18 23:37:22 +010042 bool IsExternalDecoderRegistered(uint8_t payloadType) const;
Niels Mölleree3d9952019-09-09 12:51:55 +020043 int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
44
45 int32_t Decode(const webrtc::VCMEncodedFrame* frame);
46
Niels Mölleree3d9952019-09-09 12:51:55 +020047 private:
Johannes Kron16359f62021-02-18 23:37:22 +010048 SequenceChecker construction_sequence_checker_;
49 SequenceChecker decoder_sequence_checker_;
Niels Mölleree3d9952019-09-09 12:51:55 +020050 Clock* const clock_;
51 VCMTiming* timing_;
52 VCMDecodedFrameCallback decodedFrameCallback_;
53
54 // Callbacks are set before the decoder thread starts.
Artem Titovdcd7fc72021-08-09 13:02:57 +020055 // Once the decoder thread has been started, usage of `_codecDataBase` moves
Niels Mölleree3d9952019-09-09 12:51:55 +020056 // over to the decoder thread.
57 VCMDecoderDataBase codecDataBase_;
Niels Mölleree3d9952019-09-09 12:51:55 +020058};
59
60} // namespace webrtc
61
62#endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_