blob: 0c3fe1a257698090c1567b0890bfc5c8f945e071 [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
Artem Titovd15a5752021-02-10 14:31:24 +010014#include "api/sequence_checker.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020015#include "modules/video_coding/decoder_database.h"
16#include "modules/video_coding/encoded_frame.h"
17#include "modules/video_coding/generic_decoder.h"
18#include "modules/video_coding/timing.h"
Niels Mölleree3d9952019-09-09 12:51:55 +020019#include "system_wrappers/include/clock.h"
20
21namespace 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.
28class VideoReceiver2 {
29 public:
30 VideoReceiver2(Clock* clock, VCMTiming* timing);
31 ~VideoReceiver2();
32
Niels Möller582102c2020-08-07 16:19:56 +020033 int32_t RegisterReceiveCodec(uint8_t payload_type,
34 const VideoCodec* receiveCodec,
Niels Möller18c83d32020-08-07 14:14:49 +020035 int32_t numberOfCores);
Niels Mölleree3d9952019-09-09 12:51:55 +020036
37 void RegisterExternalDecoder(VideoDecoder* externalDecoder,
38 uint8_t payloadType);
Johannes Kron16359f62021-02-18 23:37:22 +010039 bool IsExternalDecoderRegistered(uint8_t payloadType) const;
Niels Mölleree3d9952019-09-09 12:51:55 +020040 int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
41
42 int32_t Decode(const webrtc::VCMEncodedFrame* frame);
43
Niels Mölleree3d9952019-09-09 12:51:55 +020044 // Notification methods that are used to check our internal state and validate
45 // threading assumptions. These are called by VideoReceiveStream.
46 // See |IsDecoderThreadRunning()| for more details.
47 void DecoderThreadStarting();
48 void DecoderThreadStopped();
49
50 private:
51 // Used for DCHECKing thread correctness.
52 // In build where DCHECKs are enabled, will return false before
53 // DecoderThreadStarting is called, then true until DecoderThreadStopped
54 // is called.
55 // In builds where DCHECKs aren't enabled, it will return true.
56 bool IsDecoderThreadRunning();
57
Johannes Kron16359f62021-02-18 23:37:22 +010058 SequenceChecker construction_sequence_checker_;
59 SequenceChecker decoder_sequence_checker_;
Niels Mölleree3d9952019-09-09 12:51:55 +020060 Clock* const clock_;
61 VCMTiming* timing_;
62 VCMDecodedFrameCallback decodedFrameCallback_;
63
64 // Callbacks are set before the decoder thread starts.
65 // Once the decoder thread has been started, usage of |_codecDataBase| moves
66 // over to the decoder thread.
67 VCMDecoderDataBase codecDataBase_;
68
69#if RTC_DCHECK_IS_ON
70 bool decoder_thread_is_running_ = false;
71#endif
72};
73
74} // namespace webrtc
75
76#endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_