xref: /aosp_15_r20/external/webrtc/modules/video_coding/video_receiver2.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 
14 #include <memory>
15 #include <vector>
16 
17 #include "api/field_trials_view.h"
18 #include "api/sequence_checker.h"
19 #include "api/video_codecs/video_decoder.h"
20 #include "modules/video_coding/decoder_database.h"
21 #include "modules/video_coding/encoded_frame.h"
22 #include "modules/video_coding/generic_decoder.h"
23 #include "modules/video_coding/timing/timing.h"
24 #include "rtc_base/system/no_unique_address.h"
25 #include "system_wrappers/include/clock.h"
26 
27 namespace 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.
34 class VideoReceiver2 {
35  public:
36   VideoReceiver2(Clock* clock,
37                  VCMTiming* timing,
38                  const FieldTrialsView& field_trials);
39   ~VideoReceiver2();
40 
41   void RegisterReceiveCodec(uint8_t payload_type,
42                             const VideoDecoder::Settings& decoder_settings);
43   void DeregisterReceiveCodec(uint8_t payload_type);
44   void DeregisterReceiveCodecs();
45 
46   void RegisterExternalDecoder(std::unique_ptr<VideoDecoder> decoder,
47                                uint8_t payload_type);
48 
49   bool IsExternalDecoderRegistered(uint8_t payload_type) const;
50   int32_t RegisterReceiveCallback(VCMReceiveCallback* receive_callback);
51 
52   int32_t Decode(const VCMEncodedFrame* frame);
53 
54  private:
55   RTC_NO_UNIQUE_ADDRESS SequenceChecker construction_sequence_checker_;
56   RTC_NO_UNIQUE_ADDRESS SequenceChecker decoder_sequence_checker_;
57   Clock* const clock_;
58   VCMDecodedFrameCallback decoded_frame_callback_;
59   // Callbacks are set before the decoder thread starts.
60   // Once the decoder thread has been started, usage of `_codecDataBase` moves
61   // over to the decoder thread.
62   VCMDecoderDatabase codec_database_;
63 };
64 
65 }  // namespace webrtc
66 
67 #endif  // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
68