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}
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index cdb5560..16b8842 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -94,7 +94,6 @@
"../../rtc_base/experiments:field_trial_parser",
"../../rtc_base/task_utils:repeating_task",
"../../system_wrappers",
- "../utility",
]
}
@@ -364,7 +363,6 @@
"../../system_wrappers",
"../rtp_rtcp:rtp_rtcp_format",
"../rtp_rtcp:rtp_video_header",
- "../utility",
"timing:inter_frame_delay",
"timing:jitter_estimator",
"timing:timing_module",
diff --git a/modules/video_coding/include/video_coding.h b/modules/video_coding/include/video_coding.h
index 80398fc..ee9326d 100644
--- a/modules/video_coding/include/video_coding.h
+++ b/modules/video_coding/include/video_coding.h
@@ -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 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 @@
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
diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc
index eec968a..e0ad033 100644
--- a/modules/video_coding/video_coding_impl.cc
+++ b/modules/video_coding/video_coding_impl.cc
@@ -51,13 +51,7 @@
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(); }
diff --git a/modules/video_coding/video_coding_impl.h b/modules/video_coding/video_coding_impl.h
index c50cb17..22237ca 100644
--- a/modules/video_coding/video_coding_impl.h
+++ b/modules/video_coding/video_coding_impl.h
@@ -55,12 +55,12 @@
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 @@
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 @@
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
diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc
index 5d14337..51d74c9 100644
--- a/modules/video_coding/video_receiver.cc
+++ b/modules/video_coding/video_receiver.cc
@@ -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::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 @@
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::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 @@
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;
}