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 "modules/video_coding/decoder_database.h" 15 #include "modules/video_coding/encoded_frame.h" 16 #include "modules/video_coding/generic_decoder.h" 17 #include "modules/video_coding/timing.h" 18 #include "rtc_base/thread_checker.h" 19 #include "system_wrappers/include/clock.h" 20 21 namespace webrtc { 22 23 // This class is a copy of vcm::VideoReceiver, trimmed down to what's used by 24 // VideoReceive stream, with the aim to incrementally trim it down further and 25 // ultimately delete it. It's difficult to do this incrementally with the 26 // original VideoReceiver class, since it is used by the legacy 27 // VideoCodingModule api. 28 class VideoReceiver2 { 29 public: 30 VideoReceiver2(Clock* clock, VCMTiming* timing); 31 ~VideoReceiver2(); 32 33 int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, 34 int32_t numberOfCores, 35 bool requireKeyFrame); 36 37 void RegisterExternalDecoder(VideoDecoder* externalDecoder, 38 uint8_t payloadType); 39 int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback); 40 41 int32_t Decode(const webrtc::VCMEncodedFrame* frame); 42 43 // Notification methods that are used to check our internal state and validate 44 // threading assumptions. These are called by VideoReceiveStream. 45 // See |IsDecoderThreadRunning()| for more details. 46 void DecoderThreadStarting(); 47 void DecoderThreadStopped(); 48 49 private: 50 // Used for DCHECKing thread correctness. 51 // In build where DCHECKs are enabled, will return false before 52 // DecoderThreadStarting is called, then true until DecoderThreadStopped 53 // is called. 54 // In builds where DCHECKs aren't enabled, it will return true. 55 bool IsDecoderThreadRunning(); 56 57 rtc::ThreadChecker construction_thread_checker_; 58 rtc::ThreadChecker decoder_thread_checker_; 59 Clock* const clock_; 60 VCMTiming* timing_; 61 VCMDecodedFrameCallback decodedFrameCallback_; 62 63 // Callbacks are set before the decoder thread starts. 64 // Once the decoder thread has been started, usage of |_codecDataBase| moves 65 // over to the decoder thread. 66 VCMDecoderDataBase codecDataBase_; 67 68 #if RTC_DCHECK_IS_ON 69 bool decoder_thread_is_running_ = false; 70 #endif 71 }; 72 73 } // namespace webrtc 74 75 #endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_ 76