blob: cbc78852278ce2e62a6019cbff66057da7d878ed [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"
Niels Mölleree3d9952019-09-09 12:51:55 +020024#include "system_wrappers/include/clock.h"
25
26namespace webrtc {
27
28// This class is a copy of vcm::VideoReceiver, trimmed down to what's used by
29// VideoReceive stream, with the aim to incrementally trim it down further and
30// ultimately delete it. It's difficult to do this incrementally with the
31// original VideoReceiver class, since it is used by the legacy
32// VideoCodingModule api.
33class VideoReceiver2 {
34 public:
Jonas Orelande02f9ee2022-03-25 12:43:14 +010035 VideoReceiver2(Clock* clock,
36 VCMTiming* timing,
Jonas Orelande62c2f22022-03-29 11:04:48 +020037 const FieldTrialsView& field_trials);
Niels Mölleree3d9952019-09-09 12:51:55 +020038 ~VideoReceiver2();
39
Danil Chapovalovba0a3062021-08-13 18:15:55 +020040 void RegisterReceiveCodec(uint8_t payload_type,
Danil Chapovalov355b8d22021-08-13 16:50:37 +020041 const VideoDecoder::Settings& decoder_settings);
Niels Mölleree3d9952019-09-09 12:51:55 +020042
Tommibd02e702022-08-22 12:56:38 +020043 void RegisterExternalDecoder(std::unique_ptr<VideoDecoder> decoder,
44 uint8_t payload_type);
Niels Mölleree3d9952019-09-09 12:51:55 +020045
Tommibd02e702022-08-22 12:56:38 +020046 bool IsExternalDecoderRegistered(uint8_t payload_type) const;
47 int32_t RegisterReceiveCallback(VCMReceiveCallback* receive_callback);
48
49 int32_t Decode(const VCMEncodedFrame* frame);
Niels Mölleree3d9952019-09-09 12:51:55 +020050
Niels Mölleree3d9952019-09-09 12:51:55 +020051 private:
Johannes Kron16359f62021-02-18 23:37:22 +010052 SequenceChecker construction_sequence_checker_;
53 SequenceChecker decoder_sequence_checker_;
Niels Mölleree3d9952019-09-09 12:51:55 +020054 Clock* const clock_;
Tommibd02e702022-08-22 12:56:38 +020055 VCMDecodedFrameCallback decoded_frame_callback_;
56 // Holds/owns the decoder instances that are registered via
57 // `RegisterExternalDecoder` and referenced by `codec_database_`.
58 std::vector<std::unique_ptr<VideoDecoder>> video_decoders_;
Niels Mölleree3d9952019-09-09 12:51:55 +020059
60 // Callbacks are set before the decoder thread starts.
Artem Titovdcd7fc72021-08-09 13:02:57 +020061 // Once the decoder thread has been started, usage of `_codecDataBase` moves
Niels Mölleree3d9952019-09-09 12:51:55 +020062 // over to the decoder thread.
Tommibd02e702022-08-22 12:56:38 +020063 VCMDecoderDataBase codec_database_;
Niels Mölleree3d9952019-09-09 12:51:55 +020064};
65
66} // namespace webrtc
67
68#endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_