blob: 67cb9afd481b6fe54405c7b67dceb99a703c2882 [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
Tommibd02e702022-08-22 12:56:38 +020014#include <memory>
15#include <vector>
16
Jonas Orelande62c2f22022-03-29 11:04:48 +020017#include "api/field_trials_view.h"
Artem Titovd15a5752021-02-10 14:31:24 +010018#include "api/sequence_checker.h"
Danil Chapovalov355b8d22021-08-13 16:50:37 +020019#include "api/video_codecs/video_decoder.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020020#include "modules/video_coding/decoder_database.h"
21#include "modules/video_coding/encoded_frame.h"
22#include "modules/video_coding/generic_decoder.h"
Rasmus Brandtc4d253c2022-05-25 12:03:35 +020023#include "modules/video_coding/timing/timing.h"
Tommi96c1a9b2022-09-29 12:24:02 +020024#include "rtc_base/system/no_unique_address.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020025#include "system_wrappers/include/clock.h"
26
27namespace webrtc {
28
29// This class is a copy of vcm::VideoReceiver, trimmed down to what's used by
30// VideoReceive stream, with the aim to incrementally trim it down further and
31// ultimately delete it. It's difficult to do this incrementally with the
32// original VideoReceiver class, since it is used by the legacy
33// VideoCodingModule api.
34class VideoReceiver2 {
35 public:
Jonas Orelande02f9ee2022-03-25 12:43:14 +010036 VideoReceiver2(Clock* clock,
37 VCMTiming* timing,
Jonas Orelande62c2f22022-03-29 11:04:48 +020038 const FieldTrialsView& field_trials);
Niels Mölleree3d9952019-09-09 12:51:55 +020039 ~VideoReceiver2();
40
Danil Chapovalovba0a3062021-08-13 18:15:55 +020041 void RegisterReceiveCodec(uint8_t payload_type,
Danil Chapovalov355b8d22021-08-13 16:50:37 +020042 const VideoDecoder::Settings& decoder_settings);
Tommi96c1a9b2022-09-29 12:24:02 +020043 void DeregisterReceiveCodec(uint8_t payload_type);
44 void DeregisterReceiveCodecs();
Niels Mölleree3d9952019-09-09 12:51:55 +020045
Tommibd02e702022-08-22 12:56:38 +020046 void RegisterExternalDecoder(std::unique_ptr<VideoDecoder> decoder,
47 uint8_t payload_type);
Niels Mölleree3d9952019-09-09 12:51:55 +020048
Tommibd02e702022-08-22 12:56:38 +020049 bool IsExternalDecoderRegistered(uint8_t payload_type) const;
50 int32_t RegisterReceiveCallback(VCMReceiveCallback* receive_callback);
51
52 int32_t Decode(const VCMEncodedFrame* frame);
Niels Mölleree3d9952019-09-09 12:51:55 +020053
Niels Mölleree3d9952019-09-09 12:51:55 +020054 private:
Tommi96c1a9b2022-09-29 12:24:02 +020055 RTC_NO_UNIQUE_ADDRESS SequenceChecker construction_sequence_checker_;
56 RTC_NO_UNIQUE_ADDRESS SequenceChecker decoder_sequence_checker_;
Niels Mölleree3d9952019-09-09 12:51:55 +020057 Clock* const clock_;
Tommibd02e702022-08-22 12:56:38 +020058 VCMDecodedFrameCallback decoded_frame_callback_;
59 // Holds/owns the decoder instances that are registered via
60 // `RegisterExternalDecoder` and referenced by `codec_database_`.
61 std::vector<std::unique_ptr<VideoDecoder>> video_decoders_;
Niels Mölleree3d9952019-09-09 12:51:55 +020062
63 // Callbacks are set before the decoder thread starts.
Artem Titovdcd7fc72021-08-09 13:02:57 +020064 // Once the decoder thread has been started, usage of `_codecDataBase` moves
Niels Mölleree3d9952019-09-09 12:51:55 +020065 // over to the decoder thread.
Tommi20b32712022-09-29 14:13:15 +020066 VCMDecoderDatabase codec_database_;
Niels Mölleree3d9952019-09-09 12:51:55 +020067};
68
69} // namespace webrtc
70
71#endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_