webrtc_m130/modules/video_coding/video_receiver2.h
Niels Möller ee3d995091 New class VideoReceiver2, a trimmed-down vcm::VideoReceiver
The vcm::VideoReceiver class is used by both VideoReceiveStream and
the legacy api VideoCodingModule. They have different requirements,
since the latter uses the old jitterbuffer and runs the code on a
ProcessThread.

By making a copy and trimming it down to what's actually used by
VideoReceiveStream, we can drop the dependency on the old
jitterbuffer, without breaking the legacy api. This should also make
it easier to do follow-up refactorings to trim down the class further,
and ultimately remove it.

Bug: webrtc:7408
Change-Id: Iec8a167fe5d0425114b0b67a5b4c2fd5fc4fa150
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151910
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29108}
2019-09-09 11:23:54 +00:00

78 lines
2.7 KiB
C++

/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
#define MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
#include "modules/video_coding/decoder_database.h"
#include "modules/video_coding/encoded_frame.h"
#include "modules/video_coding/generic_decoder.h"
#include "modules/video_coding/timing.h"
#include "rtc_base/thread_checker.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
// This class is a copy of vcm::VideoReceiver, trimmed down to what's used by
// VideoReceive stream, with the aim to incrementally trim it down further and
// ultimately delete it. It's difficult to do this incrementally with the
// original VideoReceiver class, since it is used by the legacy
// VideoCodingModule api.
class VideoReceiver2 {
public:
VideoReceiver2(Clock* clock, VCMTiming* timing);
~VideoReceiver2();
int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec,
int32_t numberOfCores,
bool requireKeyFrame);
void RegisterExternalDecoder(VideoDecoder* externalDecoder,
uint8_t payloadType);
int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
int32_t Decode(const webrtc::VCMEncodedFrame* frame);
void TriggerDecoderShutdown();
// Notification methods that are used to check our internal state and validate
// threading assumptions. These are called by VideoReceiveStream.
// See |IsDecoderThreadRunning()| for more details.
void DecoderThreadStarting();
void DecoderThreadStopped();
private:
// Used for DCHECKing thread correctness.
// In build where DCHECKs are enabled, will return false before
// DecoderThreadStarting is called, then true until DecoderThreadStopped
// is called.
// In builds where DCHECKs aren't enabled, it will return true.
bool IsDecoderThreadRunning();
rtc::ThreadChecker construction_thread_checker_;
rtc::ThreadChecker decoder_thread_checker_;
Clock* const clock_;
VCMTiming* timing_;
VCMDecodedFrameCallback decodedFrameCallback_;
// Callbacks are set before the decoder thread starts.
// Once the decoder thread has been started, usage of |_codecDataBase| moves
// over to the decoder thread.
VCMDecoderDataBase codecDataBase_;
#if RTC_DCHECK_IS_ON
bool decoder_thread_is_running_ = false;
#endif
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_