Niels Möller | ee3d995 | 2019-09-09 12:51:55 +0200 | [diff] [blame] | 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, |
Niels Möller | 18c83d3 | 2020-08-07 14:14:49 +0200 | [diff] [blame] | 34 | int32_t numberOfCores); |
Niels Möller | ee3d995 | 2019-09-09 12:51:55 +0200 | [diff] [blame] | 35 | |
| 36 | void RegisterExternalDecoder(VideoDecoder* externalDecoder, |
| 37 | uint8_t payloadType); |
| 38 | int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback); |
| 39 | |
| 40 | int32_t Decode(const webrtc::VCMEncodedFrame* frame); |
| 41 | |
Niels Möller | ee3d995 | 2019-09-09 12:51:55 +0200 | [diff] [blame] | 42 | // Notification methods that are used to check our internal state and validate |
| 43 | // threading assumptions. These are called by VideoReceiveStream. |
| 44 | // See |IsDecoderThreadRunning()| for more details. |
| 45 | void DecoderThreadStarting(); |
| 46 | void DecoderThreadStopped(); |
| 47 | |
| 48 | private: |
| 49 | // Used for DCHECKing thread correctness. |
| 50 | // In build where DCHECKs are enabled, will return false before |
| 51 | // DecoderThreadStarting is called, then true until DecoderThreadStopped |
| 52 | // is called. |
| 53 | // In builds where DCHECKs aren't enabled, it will return true. |
| 54 | bool IsDecoderThreadRunning(); |
| 55 | |
| 56 | rtc::ThreadChecker construction_thread_checker_; |
| 57 | rtc::ThreadChecker decoder_thread_checker_; |
| 58 | Clock* const clock_; |
| 59 | VCMTiming* timing_; |
| 60 | VCMDecodedFrameCallback decodedFrameCallback_; |
| 61 | |
| 62 | // Callbacks are set before the decoder thread starts. |
| 63 | // Once the decoder thread has been started, usage of |_codecDataBase| moves |
| 64 | // over to the decoder thread. |
| 65 | VCMDecoderDataBase codecDataBase_; |
| 66 | |
| 67 | #if RTC_DCHECK_IS_ON |
| 68 | bool decoder_thread_is_running_ = false; |
| 69 | #endif |
| 70 | }; |
| 71 | |
| 72 | } // namespace webrtc |
| 73 | |
| 74 | #endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_ |