Remove video_coding dependency on ProcessThread and Module

Bug: webrtc:7219
Change-Id: I360f7df5554389274fcaef64070b9441ce0ef984
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266486
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37351}
This commit is contained in:
Danil Chapovalov
2022-06-22 15:48:36 +02:00
committed by WebRTC LUCI CQ
parent e58f1991dc
commit ce80886bf2
5 changed files with 10 additions and 49 deletions

View File

@ -94,7 +94,6 @@ rtc_library("nack_requester") {
"../../rtc_base/experiments:field_trial_parser",
"../../rtc_base/task_utils:repeating_task",
"../../system_wrappers",
"../utility",
]
}
@ -364,7 +363,6 @@ rtc_library("video_coding_legacy") {
"../../system_wrappers",
"../rtp_rtcp:rtp_rtcp_format",
"../rtp_rtcp:rtp_video_header",
"../utility",
"timing:inter_frame_delay",
"timing:jitter_estimator",
"timing:timing_module",

View File

@ -14,7 +14,6 @@
#include "api/field_trials_view.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_decoder.h"
#include "modules/include/module.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "modules/video_coding/include/video_coding_defines.h"
@ -26,13 +25,15 @@ class VideoDecoder;
class VideoEncoder;
struct CodecSpecificInfo;
class VideoCodingModule : public Module {
class VideoCodingModule {
public:
// DEPRECATED.
static VideoCodingModule* Create(
Clock* clock,
const FieldTrialsView* field_trials = nullptr);
virtual ~VideoCodingModule() = default;
/*
* Receiver
*/
@ -139,6 +140,9 @@ class VideoCodingModule : public Module {
virtual void SetNackSettings(size_t max_nack_list_size,
int max_packet_age_to_nack,
int max_incomplete_time_ms) = 0;
// Runs delayed tasks. Expected to be called periodically.
virtual void Process() = 0;
};
} // namespace webrtc

View File

@ -51,13 +51,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
timing_(new VCMTiming(clock, *field_trials_)),
receiver_(clock, timing_.get(), *field_trials_) {}
~VideoCodingModuleImpl() override {}
int64_t TimeUntilNextProcess() override {
int64_t receiver_time = receiver_.TimeUntilNextProcess();
RTC_DCHECK_GE(receiver_time, 0);
return receiver_time;
}
~VideoCodingModuleImpl() override = default;
void Process() override { receiver_.Process(); }

View File

@ -55,12 +55,12 @@ class VCMProcessTimer {
int64_t _latestMs;
};
class VideoReceiver : public Module {
class VideoReceiver {
public:
VideoReceiver(Clock* clock,
VCMTiming* timing,
const FieldTrialsView& field_trials);
~VideoReceiver() override;
~VideoReceiver();
void RegisterReceiveCodec(uint8_t payload_type,
const VideoDecoder::Settings& settings);
@ -82,9 +82,7 @@ class VideoReceiver : public Module {
int max_packet_age_to_nack,
int max_incomplete_time_ms);
int64_t TimeUntilNextProcess() override;
void Process() override;
void ProcessThreadAttached(ProcessThread* process_thread) override;
void Process();
protected:
int32_t Decode(const webrtc::VCMEncodedFrame& frame);
@ -130,11 +128,6 @@ class VideoReceiver : public Module {
VCMProcessTimer _keyRequestTimer RTC_GUARDED_BY(module_thread_checker_);
ThreadUnsafeOneTimeEvent first_frame_received_
RTC_GUARDED_BY(decoder_thread_checker_);
// Modified on the construction thread. Can be read without a lock and assumed
// to be non-null on the module and decoder threads.
ProcessThread* process_thread_ = nullptr;
bool is_attached_to_process_thread_
RTC_GUARDED_BY(construction_thread_checker_) = false;
};
} // namespace vcm

View File

@ -17,7 +17,6 @@
#include "api/sequence_checker.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_decoder.h"
#include "modules/utility/include/process_thread.h"
#include "modules/video_coding/decoder_database.h"
#include "modules/video_coding/encoded_frame.h"
#include "modules/video_coding/generic_decoder.h"
@ -103,27 +102,6 @@ void VideoReceiver::Process() {
}
}
void VideoReceiver::ProcessThreadAttached(ProcessThread* process_thread) {
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
if (process_thread) {
is_attached_to_process_thread_ = true;
RTC_DCHECK(!process_thread_ || process_thread_ == process_thread);
process_thread_ = process_thread;
} else {
is_attached_to_process_thread_ = false;
}
}
int64_t VideoReceiver::TimeUntilNextProcess() {
RTC_DCHECK_RUN_ON(&module_thread_checker_);
int64_t timeUntilNextProcess = _retransmissionTimer.TimeUntilProcess();
timeUntilNextProcess =
VCM_MIN(timeUntilNextProcess, _keyRequestTimer.TimeUntilProcess());
return timeUntilNextProcess;
}
// Register a receive callback. Will be called whenever there is a new frame
// ready for rendering.
int32_t VideoReceiver::RegisterReceiveCallback(
@ -150,7 +128,6 @@ void VideoReceiver::RegisterExternalDecoder(VideoDecoder* externalDecoder,
int32_t VideoReceiver::RegisterFrameTypeCallback(
VCMFrameTypeCallback* frameTypeCallback) {
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
RTC_DCHECK(!is_attached_to_process_thread_);
// This callback is used on the module thread, but since we don't get
// callbacks on the module thread while the decoder thread isn't running
// (and this function must not be called when the decoder is running),
@ -162,7 +139,6 @@ int32_t VideoReceiver::RegisterFrameTypeCallback(
int32_t VideoReceiver::RegisterPacketRequestCallback(
VCMPacketRequestCallback* callback) {
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
RTC_DCHECK(!is_attached_to_process_thread_);
// This callback is used on the module thread, but since we don't get
// callbacks on the module thread while the decoder thread isn't running
// (and this function must not be called when the decoder is running),
@ -189,10 +165,6 @@ int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) {
if (frame->FrameType() != VideoFrameType::kVideoFrameKey) {
drop_frame = true;
_scheduleKeyRequest = true;
// TODO(tommi): Consider if we could instead post a task to the module
// thread and call RequestKeyFrame directly. Here we call WakeUp so that
// TimeUntilNextProcess() gets called straight away.
process_thread_->WakeUp(this);
} else {
drop_frames_until_keyframe_ = false;
}