diff options
37 files changed, 59 insertions, 335 deletions
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 6ec266b68d..d4e9c0ea77 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -70,7 +70,6 @@ namespace { std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive( Clock* clock, webrtc::AudioState* audio_state, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, const webrtc::AudioReceiveStream::Config& config, RtcEventLog* event_log) { @@ -78,11 +77,10 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive( internal::AudioState* internal_audio_state = static_cast<internal::AudioState*>(audio_state); return voe::CreateChannelReceive( - clock, module_process_thread, neteq_factory, - internal_audio_state->audio_device_module(), config.rtcp_send_transport, - event_log, config.rtp.local_ssrc, config.rtp.remote_ssrc, - config.jitter_buffer_max_packets, config.jitter_buffer_fast_accelerate, - config.jitter_buffer_min_delay_ms, + clock, neteq_factory, internal_audio_state->audio_device_module(), + config.rtcp_send_transport, event_log, config.rtp.local_ssrc, + config.rtp.remote_ssrc, config.jitter_buffer_max_packets, + config.jitter_buffer_fast_accelerate, config.jitter_buffer_min_delay_ms, config.jitter_buffer_enable_rtx_handling, config.decoder_factory, config.codec_pair_id, std::move(config.frame_decryptor), config.crypto_options, std::move(config.frame_transformer)); @@ -92,7 +90,6 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive( AudioReceiveStream::AudioReceiveStream( Clock* clock, PacketRouter* packet_router, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, const webrtc::AudioReceiveStream::Config& config, const rtc::scoped_refptr<webrtc::AudioState>& audio_state, @@ -104,7 +101,6 @@ AudioReceiveStream::AudioReceiveStream( event_log, CreateChannelReceive(clock, audio_state.get(), - module_process_thread, neteq_factory, config, event_log)) {} diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index dc64e94510..61ebc2719f 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -48,7 +48,6 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, public: AudioReceiveStream(Clock* clock, PacketRouter* packet_router, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, const webrtc::AudioReceiveStream::Config& config, const rtc::scoped_refptr<webrtc::AudioState>& audio_state, diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index aca7cd38b8..5d7bc71659 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -102,7 +102,6 @@ AudioSendStream::AudioSendStream( const webrtc::AudioSendStream::Config& config, const rtc::scoped_refptr<webrtc::AudioState>& audio_state, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, @@ -119,7 +118,6 @@ AudioSendStream::AudioSendStream( voe::CreateChannelSend( clock, task_queue_factory, - module_process_thread, config.send_transport, rtcp_rtt_stats, event_log, diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index 223328b26b..e0b15dc0c9 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -58,7 +58,6 @@ class AudioSendStream final : public webrtc::AudioSendStream, const webrtc::AudioSendStream::Config& config, const rtc::scoped_refptr<webrtc::AudioState>& audio_state, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 150e2074e4..acab1467f4 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -86,7 +86,6 @@ class ChannelReceive : public ChannelReceiveInterface { // Used for receive streams. ChannelReceive( Clock* clock, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, AudioDeviceModule* audio_device_module, Transport* rtcp_send_transport, @@ -269,7 +268,6 @@ class ChannelReceive : public ChannelReceiveInterface { // frame. int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_); - ProcessThread* const module_process_thread_; AudioDeviceModule* _audioDeviceModulePtr; float _outputGain RTC_GUARDED_BY(volume_settings_mutex_); @@ -507,7 +505,6 @@ void ChannelReceive::SetSourceTracker(SourceTracker* source_tracker) { ChannelReceive::ChannelReceive( Clock* clock, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, AudioDeviceModule* audio_device_module, Transport* rtcp_send_transport, @@ -540,15 +537,12 @@ ChannelReceive::ChannelReceive( rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), capture_start_rtp_time_stamp_(-1), capture_start_ntp_time_ms_(-1), - module_process_thread_(module_process_thread), _audioDeviceModulePtr(audio_device_module), _outputGain(1.0f), associated_send_channel_(nullptr), frame_decryptor_(frame_decryptor), crypto_options_(crypto_options), absolute_capture_time_interpolator_(clock) { - RTC_DCHECK(worker_thread_); - RTC_DCHECK(module_process_thread_); RTC_DCHECK(audio_device_module); network_thread_checker_.Detach(); @@ -579,20 +573,11 @@ ChannelReceive::ChannelReceive( // Ensure that RTCP is enabled for the created channel. rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); - - // TODO(tommi): This should be an implementation detail of ModuleRtpRtcpImpl2 - // and the pointer to the process thread should be there (which also localizes - // the problem of getting rid of that dependency). - module_process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); } ChannelReceive::~ChannelReceive() { RTC_DCHECK_RUN_ON(&construction_thread_); - // Unregister the module before stopping playout etc, to match the order - // things were set up in the ctor. - module_process_thread_->DeRegisterModule(rtp_rtcp_.get()); - // Resets the delegate's callback to ChannelReceive::OnReceivedPayloadData. if (frame_transformer_delegate_) frame_transformer_delegate_->Reset(); @@ -1090,7 +1075,6 @@ int64_t ChannelReceive::GetRTT() const { std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive( Clock* clock, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, AudioDeviceModule* audio_device_module, Transport* rtcp_send_transport, @@ -1107,12 +1091,11 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive( const webrtc::CryptoOptions& crypto_options, rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) { return std::make_unique<ChannelReceive>( - clock, module_process_thread, neteq_factory, audio_device_module, - rtcp_send_transport, rtc_event_log, local_ssrc, remote_ssrc, - jitter_buffer_max_packets, jitter_buffer_fast_playout, - jitter_buffer_min_delay_ms, jitter_buffer_enable_rtx_handling, - decoder_factory, codec_pair_id, std::move(frame_decryptor), - crypto_options, std::move(frame_transformer)); + clock, neteq_factory, audio_device_module, rtcp_send_transport, + rtc_event_log, local_ssrc, remote_ssrc, jitter_buffer_max_packets, + jitter_buffer_fast_playout, jitter_buffer_min_delay_ms, + jitter_buffer_enable_rtx_handling, decoder_factory, codec_pair_id, + std::move(frame_decryptor), crypto_options, std::move(frame_transformer)); } } // namespace voe diff --git a/audio/channel_receive.h b/audio/channel_receive.h index 196e441fac..f5afe50f3b 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -44,7 +44,6 @@ namespace webrtc { class AudioDeviceModule; class FrameDecryptorInterface; class PacketRouter; -class ProcessThread; class RateLimiter; class ReceiveStatistics; class RtcEventLog; @@ -169,7 +168,6 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface { std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive( Clock* clock, - ProcessThread* module_process_thread, NetEqFactory* neteq_factory, AudioDeviceModule* audio_device_module, Transport* rtcp_send_transport, diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 47afc7982b..52dd528504 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -69,7 +69,6 @@ class ChannelSend : public ChannelSendInterface, ChannelSend(Clock* clock, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, @@ -180,7 +179,6 @@ class ChannelSend : public ChannelSendInterface, // voe::Channel into parts with single-threaded semantics, and thereby reduce // the need for locks. SequenceChecker worker_thread_checker_; - SequenceChecker module_process_thread_checker_; // Methods accessed from audio and video threads are checked for sequential- // only access. We don't necessarily own and control these threads, so thread // checkers cannot be used. E.g. Chromium may transfer "ownership" from one @@ -200,7 +198,6 @@ class ChannelSend : public ChannelSendInterface, uint32_t _timeStamp RTC_GUARDED_BY(encoder_queue_); // uses - ProcessThread* const _moduleProcessThreadPtr; RmsLevel rms_level_ RTC_GUARDED_BY(encoder_queue_); bool input_mute_ RTC_GUARDED_BY(volume_settings_mutex_); bool previous_frame_muted_ RTC_GUARDED_BY(encoder_queue_); @@ -445,7 +442,6 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, ChannelSend::ChannelSend( Clock* clock, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, @@ -459,7 +455,6 @@ ChannelSend::ChannelSend( : event_log_(rtc_event_log), _timeStamp(0), // This is just an offset, RTP module will add it's own // random offset - _moduleProcessThreadPtr(module_process_thread), input_mute_(false), previous_frame_muted_(false), _includeAudioLevelIndication(false), @@ -475,9 +470,6 @@ ChannelSend::ChannelSend( TaskQueueFactory::Priority::NORMAL)), fixing_timestamp_stall_( !field_trial::IsDisabled("WebRTC-Audio-FixTimestampStall")) { - RTC_DCHECK(module_process_thread); - module_process_thread_checker_.Detach(); - audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config())); RtpRtcpInterface::Configuration configuration; @@ -504,8 +496,6 @@ ChannelSend::ChannelSend( rtp_sender_audio_ = std::make_unique<RTPSenderAudio>(configuration.clock, rtp_rtcp_->RtpSender()); - _moduleProcessThreadPtr->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); - // Ensure that RTCP is enabled by default for the created channel. rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); @@ -525,9 +515,6 @@ ChannelSend::~ChannelSend() { StopSend(); int error = audio_coding_->RegisterTransportCallback(NULL); RTC_DCHECK_EQ(0, error); - - if (_moduleProcessThreadPtr) - _moduleProcessThreadPtr->DeRegisterModule(rtp_rtcp_.get()); } void ChannelSend::StartSend() { @@ -858,7 +845,6 @@ ANAStats ChannelSend::GetANAStatistics() const { } RtpRtcpInterface* ChannelSend::GetRtpRtcp() const { - RTC_DCHECK(module_process_thread_checker_.IsCurrent()); return rtp_rtcp_.get(); } @@ -930,7 +916,6 @@ void ChannelSend::InitFrameTransformerDelegate( std::unique_ptr<ChannelSendInterface> CreateChannelSend( Clock* clock, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, @@ -942,10 +927,10 @@ std::unique_ptr<ChannelSendInterface> CreateChannelSend( rtc::scoped_refptr<FrameTransformerInterface> frame_transformer, TransportFeedbackObserver* feedback_observer) { return std::make_unique<ChannelSend>( - clock, task_queue_factory, module_process_thread, rtp_transport, - rtcp_rtt_stats, rtc_event_log, frame_encryptor, crypto_options, - extmap_allow_mixed, rtcp_report_interval_ms, ssrc, - std::move(frame_transformer), feedback_observer); + clock, task_queue_factory, rtp_transport, rtcp_rtt_stats, rtc_event_log, + frame_encryptor, crypto_options, extmap_allow_mixed, + rtcp_report_interval_ms, ssrc, std::move(frame_transformer), + feedback_observer); } } // namespace voe diff --git a/audio/channel_send.h b/audio/channel_send.h index 2e23ef5d2d..cbdb3ee70a 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -28,7 +28,6 @@ namespace webrtc { class FrameEncryptorInterface; -class ProcessThread; class RtcEventLog; class RtpTransportControllerSendInterface; @@ -126,7 +125,6 @@ class ChannelSendInterface { std::unique_ptr<ChannelSendInterface> CreateChannelSend( Clock* clock, TaskQueueFactory* task_queue_factory, - ProcessThread* module_process_thread, Transport* rtp_transport, RtcpRttStats* rtcp_rtt_stats, RtcEventLog* rtc_event_log, diff --git a/audio/voip/audio_channel.cc b/audio/voip/audio_channel.cc index d11e6d79f9..b4a50eec12 100644 --- a/audio/voip/audio_channel.cc +++ b/audio/voip/audio_channel.cc @@ -32,12 +32,10 @@ AudioChannel::AudioChannel( Transport* transport, uint32_t local_ssrc, TaskQueueFactory* task_queue_factory, - ProcessThread* process_thread, AudioMixer* audio_mixer, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) - : audio_mixer_(audio_mixer), process_thread_(process_thread) { + : audio_mixer_(audio_mixer) { RTC_DCHECK(task_queue_factory); - RTC_DCHECK(process_thread); RTC_DCHECK(audio_mixer); Clock* clock = Clock::GetRealTimeClock(); @@ -56,9 +54,6 @@ AudioChannel::AudioChannel( rtp_rtcp_->SetSendingMediaStatus(false); rtp_rtcp_->SetRTCPStatus(RtcpMode::kCompound); - // ProcessThread periodically services RTP stack for RTCP. - process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); - ingress_ = std::make_unique<AudioIngress>(rtp_rtcp_.get(), clock, receive_statistics_.get(), std::move(decoder_factory)); @@ -80,12 +75,10 @@ AudioChannel::~AudioChannel() { audio_mixer_->RemoveSource(ingress_.get()); - // AudioEgress could hold current global TaskQueueBase that we need to clear - // before ProcessThread::DeRegisterModule. + // TODO(bugs.webrtc.org/11581): unclear if we still need to clear |egress_| + // here. egress_.reset(); ingress_.reset(); - - process_thread_->DeRegisterModule(rtp_rtcp_.get()); } bool AudioChannel::StartSend() { diff --git a/audio/voip/audio_channel.h b/audio/voip/audio_channel.h index 7b9fa6f74e..7338d9faab 100644 --- a/audio/voip/audio_channel.h +++ b/audio/voip/audio_channel.h @@ -22,7 +22,6 @@ #include "audio/voip/audio_egress.h" #include "audio/voip/audio_ingress.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" -#include "modules/utility/include/process_thread.h" #include "rtc_base/ref_count.h" namespace webrtc { @@ -35,7 +34,6 @@ class AudioChannel : public rtc::RefCountInterface { AudioChannel(Transport* transport, uint32_t local_ssrc, TaskQueueFactory* task_queue_factory, - ProcessThread* process_thread, AudioMixer* audio_mixer, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory); ~AudioChannel() override; @@ -120,9 +118,6 @@ class AudioChannel : public rtc::RefCountInterface { // Synchronization is handled internally by AudioMixer. AudioMixer* audio_mixer_; - // Synchronization is handled internally by ProcessThread. - ProcessThread* process_thread_; - // Listed in order for safe destruction of AudioChannel object. // Synchronization for these are handled internally. std::unique_ptr<ReceiveStatistics> receive_statistics_; diff --git a/audio/voip/test/audio_channel_unittest.cc b/audio/voip/test/audio_channel_unittest.cc index f99d163022..a4f518c5bd 100644 --- a/audio/voip/test/audio_channel_unittest.cc +++ b/audio/voip/test/audio_channel_unittest.cc @@ -17,7 +17,6 @@ #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_mixer/sine_wave_generator.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "modules/utility/include/process_thread.h" #include "rtc_base/logging.h" #include "test/gmock.h" #include "test/gtest.h" @@ -43,7 +42,6 @@ class AudioChannelTest : public ::testing::Test { AudioChannelTest() : fake_clock_(kStartTime), wave_generator_(1000.0, kAudioLevel) { task_queue_factory_ = std::make_unique<MockTaskQueueFactory>(&task_queue_); - process_thread_ = ProcessThread::Create("ModuleProcessThread"); audio_mixer_ = AudioMixerImpl::Create(); encoder_factory_ = CreateBuiltinAudioEncoderFactory(); decoder_factory_ = CreateBuiltinAudioDecoderFactory(); @@ -66,8 +64,8 @@ class AudioChannelTest : public ::testing::Test { // simplify network routing logic. rtc::scoped_refptr<AudioChannel> audio_channel = rtc::make_ref_counted<AudioChannel>( - &transport_, ssrc, task_queue_factory_.get(), process_thread_.get(), - audio_mixer_.get(), decoder_factory_); + &transport_, ssrc, task_queue_factory_.get(), audio_mixer_.get(), + decoder_factory_); audio_channel->SetEncoder(kPcmuPayload, kPcmuFormat, encoder_factory_->MakeAudioEncoder( kPcmuPayload, kPcmuFormat, absl::nullopt)); @@ -95,7 +93,6 @@ class AudioChannelTest : public ::testing::Test { rtc::scoped_refptr<AudioMixer> audio_mixer_; rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_; - std::unique_ptr<ProcessThread> process_thread_; rtc::scoped_refptr<AudioChannel> audio_channel_; }; diff --git a/audio/voip/test/voip_core_unittest.cc b/audio/voip/test/voip_core_unittest.cc index 0d407601a3..896d0d98bb 100644 --- a/audio/voip/test/voip_core_unittest.cc +++ b/audio/voip/test/voip_core_unittest.cc @@ -14,7 +14,6 @@ #include "api/task_queue/default_task_queue_factory.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_processing/include/mock_audio_processing.h" -#include "modules/utility/include/mock/mock_process_thread.h" #include "test/gtest.h" #include "test/mock_transport.h" @@ -41,20 +40,15 @@ class VoipCoreTest : public ::testing::Test { rtc::scoped_refptr<AudioProcessing> audio_processing = rtc::make_ref_counted<NiceMock<test::MockAudioProcessing>>(); - auto process_thread = std::make_unique<NiceMock<MockProcessThread>>(); - // Hold the pointer to use for testing. - process_thread_ = process_thread.get(); - voip_core_ = std::make_unique<VoipCore>( std::move(encoder_factory), std::move(decoder_factory), CreateDefaultTaskQueueFactory(), audio_device_, - std::move(audio_processing), std::move(process_thread)); + std::move(audio_processing)); } std::unique_ptr<VoipCore> voip_core_; NiceMock<MockTransport> transport_; rtc::scoped_refptr<test::MockAudioDeviceModule> audio_device_; - NiceMock<MockProcessThread>* process_thread_; }; // Validate expected API calls that involves with VoipCore. Some verification is @@ -192,31 +186,5 @@ TEST_F(VoipCoreTest, StopSendAndPlayoutWithoutStarting) { EXPECT_EQ(voip_core_->ReleaseChannel(channel), VoipResult::kOk); } -// This tests correctness on ProcessThread usage where we expect the first/last -// channel creation/release triggers its Start/Stop method once only. -TEST_F(VoipCoreTest, TestProcessThreadOperation) { - EXPECT_CALL(*process_thread_, Start); - EXPECT_CALL(*process_thread_, RegisterModule).Times(2); - - auto channel_one = voip_core_->CreateChannel(&transport_, 0xdeadc0de); - auto channel_two = voip_core_->CreateChannel(&transport_, 0xdeadbeef); - - EXPECT_CALL(*process_thread_, Stop); - EXPECT_CALL(*process_thread_, DeRegisterModule).Times(2); - - EXPECT_EQ(voip_core_->ReleaseChannel(channel_one), VoipResult::kOk); - EXPECT_EQ(voip_core_->ReleaseChannel(channel_two), VoipResult::kOk); - - EXPECT_CALL(*process_thread_, Start); - EXPECT_CALL(*process_thread_, RegisterModule); - - auto channel_three = voip_core_->CreateChannel(&transport_, absl::nullopt); - - EXPECT_CALL(*process_thread_, Stop); - EXPECT_CALL(*process_thread_, DeRegisterModule); - - EXPECT_EQ(voip_core_->ReleaseChannel(channel_three), VoipResult::kOk); -} - } // namespace } // namespace webrtc diff --git a/audio/voip/voip_core.cc b/audio/voip/voip_core.cc index 67ae4c6521..fd66379f4a 100644 --- a/audio/voip/voip_core.cc +++ b/audio/voip/voip_core.cc @@ -41,18 +41,12 @@ VoipCore::VoipCore(rtc::scoped_refptr<AudioEncoderFactory> encoder_factory, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, std::unique_ptr<TaskQueueFactory> task_queue_factory, rtc::scoped_refptr<AudioDeviceModule> audio_device_module, - rtc::scoped_refptr<AudioProcessing> audio_processing, - std::unique_ptr<ProcessThread> process_thread) { + rtc::scoped_refptr<AudioProcessing> audio_processing) { encoder_factory_ = std::move(encoder_factory); decoder_factory_ = std::move(decoder_factory); task_queue_factory_ = std::move(task_queue_factory); audio_device_module_ = std::move(audio_device_module); audio_processing_ = std::move(audio_processing); - process_thread_ = std::move(process_thread); - - if (!process_thread_) { - process_thread_ = ProcessThread::Create("ModuleProcessThread"); - } audio_mixer_ = AudioMixerImpl::Create(); // AudioTransportImpl depends on audio mixer and audio processing instances. @@ -138,19 +132,13 @@ ChannelId VoipCore::CreateChannel(Transport* transport, } rtc::scoped_refptr<AudioChannel> channel = - rtc::make_ref_counted<AudioChannel>( - transport, local_ssrc.value(), task_queue_factory_.get(), - process_thread_.get(), audio_mixer_.get(), decoder_factory_); - - // Check if we need to start the process thread. - bool start_process_thread = false; + rtc::make_ref_counted<AudioChannel>(transport, local_ssrc.value(), + task_queue_factory_.get(), + audio_mixer_.get(), decoder_factory_); { MutexLock lock(&lock_); - // Start process thread if the channel is the first one. - start_process_thread = channels_.empty(); - channel_id = static_cast<ChannelId>(next_channel_id_); channels_[channel_id] = channel; next_channel_id_++; @@ -162,10 +150,6 @@ ChannelId VoipCore::CreateChannel(Transport* transport, // Set ChannelId in audio channel for logging/debugging purpose. channel->SetId(channel_id); - if (start_process_thread) { - process_thread_->Start(); - } - return channel_id; } @@ -194,9 +178,9 @@ VoipResult VoipCore::ReleaseChannel(ChannelId channel_id) { } if (no_channels_after_release) { - // Release audio channel first to have it DeRegisterModule first. + // TODO(bugs.webrtc.org/11581): unclear if we still need to clear |channel| + // here. channel = nullptr; - process_thread_->Stop(); // Make sure to stop playout on ADM if it is playing. if (audio_device_module_->Playing()) { diff --git a/audio/voip/voip_core.h b/audio/voip/voip_core.h index b7c1f2947f..359e07272d 100644 --- a/audio/voip/voip_core.h +++ b/audio/voip/voip_core.h @@ -33,7 +33,6 @@ #include "modules/audio_device/include/audio_device.h" #include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_processing/include/audio_processing.h" -#include "modules/utility/include/process_thread.h" #include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -61,8 +60,7 @@ class VoipCore : public VoipEngine, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, std::unique_ptr<TaskQueueFactory> task_queue_factory, rtc::scoped_refptr<AudioDeviceModule> audio_device_module, - rtc::scoped_refptr<AudioProcessing> audio_processing, - std::unique_ptr<ProcessThread> process_thread = nullptr); + rtc::scoped_refptr<AudioProcessing> audio_processing); ~VoipCore() override = default; // Implements VoipEngine interfaces. @@ -160,10 +158,6 @@ class VoipCore : public VoipEngine, // Synchronization is handled internally by AudioDeviceModule. rtc::scoped_refptr<AudioDeviceModule> audio_device_module_; - // Synchronization is handled internally by ProcessThread. - // Must be placed before |channels_| for proper destruction. - std::unique_ptr<ProcessThread> process_thread_; - Mutex lock_; // Member to track a next ChannelId for new AudioChannel. diff --git a/call/call.cc b/call/call.cc index f4a7d7cc9e..4651b0be70 100644 --- a/call/call.cc +++ b/call/call.cc @@ -893,9 +893,8 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( AudioSendStream* send_stream = new AudioSendStream( clock_, config, config_.audio_state, task_queue_factory_, - module_process_thread_->process_thread(), transport_send_.get(), - bitrate_allocator_.get(), event_log_, call_stats_->AsRtcpRttStats(), - suspended_rtp_state); + transport_send_.get(), bitrate_allocator_.get(), event_log_, + call_stats_->AsRtcpRttStats(), suspended_rtp_state); RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == audio_send_ssrcs_.end()); audio_send_ssrcs_[config.rtp.ssrc] = send_stream; @@ -950,8 +949,7 @@ webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( CreateRtcLogStreamConfig(config))); AudioReceiveStream* receive_stream = new AudioReceiveStream( - clock_, transport_send_->packet_router(), - module_process_thread_->process_thread(), config_.neteq_factory, config, + clock_, transport_send_->packet_router(), config_.neteq_factory, config, config_.audio_state, event_log_); audio_receive_streams_.insert(receive_stream); @@ -1033,8 +1031,8 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream( std::vector<uint32_t> ssrcs = config.rtp.ssrcs; VideoSendStream* send_stream = new VideoSendStream( - clock_, num_cpu_cores_, module_process_thread_->process_thread(), - task_queue_factory_, call_stats_->AsRtcpRttStats(), transport_send_.get(), + clock_, num_cpu_cores_, task_queue_factory_, + call_stats_->AsRtcpRttStats(), transport_send_.get(), bitrate_allocator_.get(), video_send_delay_stats_.get(), event_log_, std::move(config), std::move(encoder_config), suspended_video_send_ssrcs_, suspended_video_payload_states_, std::move(fec_controller)); @@ -1131,8 +1129,7 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( VideoReceiveStream2* receive_stream = new VideoReceiveStream2( task_queue_factory_, this, num_cpu_cores_, transport_send_->packet_router(), std::move(configuration), - module_process_thread_->process_thread(), call_stats_.get(), clock_, - new VCMTiming(clock_)); + call_stats_.get(), clock_, new VCMTiming(clock_)); // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network // thread. receive_stream->RegisterWithTransport(&video_receiver_controller_); @@ -1200,8 +1197,7 @@ FlexfecReceiveStream* Call::CreateFlexfecReceiveStream( // OnRtpPacket until the constructor is finished and the object is // in a valid state, since OnRtpPacket runs on the same thread. receive_stream = new FlexfecReceiveStreamImpl( - clock_, config, recovered_packet_receiver, call_stats_->AsRtcpRttStats(), - module_process_thread_->process_thread()); + clock_, config, recovered_packet_receiver, call_stats_->AsRtcpRttStats()); // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network // thread. diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index ab82a6d71a..688efb7b5e 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -140,8 +140,7 @@ FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( Clock* clock, const Config& config, RecoveredPacketReceiver* recovered_packet_receiver, - RtcpRttStats* rtt_stats, - ProcessThread* process_thread) + RtcpRttStats* rtt_stats) : config_(config), receiver_(MaybeCreateFlexfecReceiver(clock, config_, @@ -150,20 +149,17 @@ FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( rtp_rtcp_(CreateRtpRtcpModule(clock, rtp_receive_statistics_.get(), config_, - rtt_stats)), - process_thread_(process_thread) { + rtt_stats)) { RTC_LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config_.ToString(); packet_sequence_checker_.Detach(); // RTCP reporting. rtp_rtcp_->SetRTCPStatus(config_.rtcp_mode); - process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); } FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { RTC_LOG(LS_INFO) << "~FlexfecReceiveStreamImpl: " << config_.ToString(); - process_thread_->DeRegisterModule(rtp_rtcp_.get()); } void FlexfecReceiveStreamImpl::RegisterWithTransport( diff --git a/call/flexfec_receive_stream_impl.h b/call/flexfec_receive_stream_impl.h index 12c4b04332..285a33f7bb 100644 --- a/call/flexfec_receive_stream_impl.h +++ b/call/flexfec_receive_stream_impl.h @@ -22,7 +22,6 @@ namespace webrtc { class FlexfecReceiver; -class ProcessThread; class ReceiveStatistics; class RecoveredPacketReceiver; class RtcpRttStats; @@ -33,12 +32,10 @@ class RtpStreamReceiverInterface; class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { public: - FlexfecReceiveStreamImpl( - Clock* clock, - const Config& config, - RecoveredPacketReceiver* recovered_packet_receiver, - RtcpRttStats* rtt_stats, - ProcessThread* process_thread); + FlexfecReceiveStreamImpl(Clock* clock, + const Config& config, + RecoveredPacketReceiver* recovered_packet_receiver, + RtcpRttStats* rtt_stats); // Destruction happens on the worker thread. Prior to destruction the caller // must ensure that a registration with the transport has been cleared. See // `RegisterWithTransport` for details. @@ -75,7 +72,6 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { // RTCP reporting. const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; const std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; - ProcessThread* const process_thread_; std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_ RTC_GUARDED_BY(packet_sequence_checker_); diff --git a/call/flexfec_receive_stream_unittest.cc b/call/flexfec_receive_stream_unittest.cc index f4944d054f..312fe0c907 100644 --- a/call/flexfec_receive_stream_unittest.cc +++ b/call/flexfec_receive_stream_unittest.cc @@ -26,7 +26,6 @@ #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "modules/utility/include/mock/mock_process_thread.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" @@ -87,15 +86,13 @@ class FlexfecReceiveStreamTest : public ::testing::Test { protected: FlexfecReceiveStreamTest() : config_(CreateDefaultConfig(&rtcp_send_transport_)) { - EXPECT_CALL(process_thread_, RegisterModule(_, _)).Times(1); receive_stream_ = std::make_unique<FlexfecReceiveStreamImpl>( Clock::GetRealTimeClock(), config_, &recovered_packet_receiver_, - &rtt_stats_, &process_thread_); + &rtt_stats_); receive_stream_->RegisterWithTransport(&rtp_stream_receiver_controller_); } ~FlexfecReceiveStreamTest() { - EXPECT_CALL(process_thread_, DeRegisterModule(_)).Times(1); receive_stream_->UnregisterFromTransport(); } @@ -103,7 +100,6 @@ class FlexfecReceiveStreamTest : public ::testing::Test { FlexfecReceiveStream::Config config_; MockRecoveredPacketReceiver recovered_packet_receiver_; MockRtcpRttStats rtt_stats_; - MockProcessThread process_thread_; RtpStreamReceiverController rtp_stream_receiver_controller_; std::unique_ptr<FlexfecReceiveStreamImpl> receive_stream_; }; @@ -146,10 +142,9 @@ TEST_F(FlexfecReceiveStreamTest, RecoversPacket) { // clang-format on ::testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver; - EXPECT_CALL(process_thread_, RegisterModule(_, _)).Times(1); FlexfecReceiveStreamImpl receive_stream(Clock::GetRealTimeClock(), config_, &recovered_packet_receiver, - &rtt_stats_, &process_thread_); + &rtt_stats_); receive_stream.RegisterWithTransport(&rtp_stream_receiver_controller_); EXPECT_CALL(recovered_packet_receiver, @@ -158,8 +153,6 @@ TEST_F(FlexfecReceiveStreamTest, RecoversPacket) { receive_stream.OnRtpPacket(ParsePacket(kFlexfecPacket)); // Tear-down - EXPECT_CALL(process_thread_, DeRegisterModule(_)).Times(1); - receive_stream.UnregisterFromTransport(); } diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index e20ba321c9..7fad89b20b 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -371,7 +371,6 @@ RtpVideoSender::RtpVideoSender( field_trials_.Lookup("WebRTC-Vp9DependencyDescriptor"), "Enabled")), active_(false), - module_process_thread_(nullptr), suspended_ssrcs_(std::move(suspended_ssrcs)), fec_controller_(std::move(fec_controller)), fec_allowed_(true), @@ -399,7 +398,6 @@ RtpVideoSender::RtpVideoSender( RTC_DCHECK_EQ(rtp_config_.ssrcs.size(), rtp_streams_.size()); if (send_side_bwe_with_overhead_ && has_packet_feedback_) transport_->IncludeOverheadInPacedSender(); - module_process_thread_checker_.Detach(); // SSRCs are assumed to be sorted in the same order as |rtp_modules|. for (uint32_t ssrc : rtp_config_.ssrcs) { // Restore state if it previously existed. @@ -460,25 +458,6 @@ RtpVideoSender::~RtpVideoSender() { this); } -void RtpVideoSender::RegisterProcessThread( - ProcessThread* module_process_thread) { - TRACE_EVENT0("webrtc", "RtpVideoSender::RegisterProcessThread"); - RTC_DCHECK_RUN_ON(&module_process_thread_checker_); - RTC_DCHECK(!module_process_thread_); - module_process_thread_ = module_process_thread; - - for (const RtpStreamSender& stream : rtp_streams_) { - module_process_thread_->RegisterModule(stream.rtp_rtcp.get(), - RTC_FROM_HERE); - } -} - -void RtpVideoSender::DeRegisterProcessThread() { - RTC_DCHECK_RUN_ON(&module_process_thread_checker_); - for (const RtpStreamSender& stream : rtp_streams_) - module_process_thread_->DeRegisterModule(stream.rtp_rtcp.get()); -} - void RtpVideoSender::SetActive(bool active) { MutexLock lock(&mutex_); if (active_ == active) diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index 611edc6b27..991276fe79 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -35,7 +35,6 @@ #include "modules/rtp_rtcp/source/rtp_sender_video.h" #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" -#include "modules/utility/include/process_thread.h" #include "rtc_base/constructor_magic.h" #include "rtc_base/rate_limiter.h" #include "rtc_base/synchronization/mutex.h" @@ -90,15 +89,6 @@ class RtpVideoSender : public RtpVideoSenderInterface, rtc::scoped_refptr<FrameTransformerInterface> frame_transformer); ~RtpVideoSender() override; - // RegisterProcessThread register |module_process_thread| with those objects - // that use it. Registration has to happen on the thread were - // |module_process_thread| was created (libjingle's worker thread). - // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue, - // maybe |worker_queue|. - void RegisterProcessThread(ProcessThread* module_process_thread) - RTC_LOCKS_EXCLUDED(mutex_) override; - void DeRegisterProcessThread() RTC_LOCKS_EXCLUDED(mutex_) override; - // RtpVideoSender will only route packets if being active, all packets will be // dropped otherwise. void SetActive(bool active) RTC_LOCKS_EXCLUDED(mutex_) override; @@ -185,8 +175,6 @@ class RtpVideoSender : public RtpVideoSenderInterface, mutable Mutex mutex_; bool active_ RTC_GUARDED_BY(mutex_); - ProcessThread* module_process_thread_; - SequenceChecker module_process_thread_checker_; std::map<uint32_t, RtpState> suspended_ssrcs_; const std::unique_ptr<FecController> fec_controller_; diff --git a/call/rtp_video_sender_interface.h b/call/rtp_video_sender_interface.h index 632c9e835a..a0b4baccb4 100644 --- a/call/rtp_video_sender_interface.h +++ b/call/rtp_video_sender_interface.h @@ -22,7 +22,6 @@ #include "call/rtp_config.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_sequence_number_map.h" -#include "modules/utility/include/process_thread.h" #include "modules/video_coding/include/video_codec_interface.h" namespace webrtc { @@ -32,9 +31,6 @@ struct FecProtectionParams; class RtpVideoSenderInterface : public EncodedImageCallback, public FecControllerOverride { public: - virtual void RegisterProcessThread(ProcessThread* module_process_thread) = 0; - virtual void DeRegisterProcessThread() = 0; - // RtpVideoSender will only route packets if being active, all // packets will be dropped otherwise. virtual void SetActive(bool active) = 0; diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc index 8afaf3ee61..fc035047b0 100644 --- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc +++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc @@ -218,7 +218,6 @@ class RtpRtcpRtxNackTest : public ::testing::Test { if (length > 0) rtp_rtcp_module_->SendNACK(nack_list, length); fake_clock.AdvanceTimeMilliseconds(28); // 33ms - 5ms delay. - rtp_rtcp_module_->Process(); // Prepare next frame. timestamp += 3000; } @@ -265,7 +264,6 @@ TEST_F(RtpRtcpRtxNackTest, LongNackList) { // Prepare next frame. timestamp += 3000; fake_clock.AdvanceTimeMilliseconds(33); - rtp_rtcp_module_->Process(); } EXPECT_FALSE(transport_.expected_sequence_numbers_.empty()); EXPECT_FALSE(media_stream_.sequence_numbers_.empty()); diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index 30a9d01ebb..8f5e3b104c 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -955,6 +955,8 @@ void RTCPSender::SendCombinedRtcpPacket( void RTCPSender::SetNextRtcpSendEvaluationDuration(TimeDelta duration) { next_time_to_send_rtcp_ = clock_->CurrentTime() + duration; + // TODO(bugs.webrtc.org/11581): make unconditional once downstream consumers + // are using the callback method. if (schedule_next_rtcp_send_evaluation_function_) schedule_next_rtcp_send_evaluation_function_(duration); } diff --git a/modules/rtp_rtcp/source/rtcp_sender.h b/modules/rtp_rtcp/source/rtcp_sender.h index 027d3d0c13..2d1c7da0fc 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.h +++ b/modules/rtp_rtcp/source/rtcp_sender.h @@ -69,6 +69,11 @@ class RTCPSender final { // TimeToSendRTCPReport/SendRTCP. // The RTCPSender client still needs to call TimeToSendRTCPReport/SendRTCP // to actually get RTCP sent. + // + // Note: It's recommended to use the callback to ensure program design that + // doesn't use polling. + // TODO(bugs.webrtc.org/11581): Make mandatory once downstream consumers + // have migrated to the callback solution. std::function<void(TimeDelta)> schedule_next_rtcp_send_evaluation_function; RtcEventLog* event_log = nullptr; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index 77054576a8..7fae1e3bd0 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -39,7 +39,6 @@ namespace webrtc { namespace { -const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; const int64_t kDefaultExpectedRetransmissionTimeMs = 125; constexpr TimeDelta kRttUpdateInterval = TimeDelta::Millis(1000); @@ -84,9 +83,6 @@ ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Configuration& configuration) })), rtcp_receiver_(configuration, this), clock_(configuration.clock), - last_rtt_process_time_(clock_->TimeInMilliseconds()), - next_process_time_(clock_->TimeInMilliseconds() + - kRtpRtcpMaxIdleTimeProcessMs), packet_overhead_(28), // IPV4 UDP. nack_last_time_sent_full_ms_(0), nack_last_seq_number_sent_(0), @@ -94,7 +90,6 @@ ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Configuration& configuration) rtt_stats_(configuration.rtt_stats), rtt_ms_(0) { RTC_DCHECK(worker_queue_); - process_thread_checker_.Detach(); packet_sequence_checker_.Detach(); if (!configuration.receiver_only) { rtp_sender_ = std::make_unique<RtpSenderContext>(configuration); @@ -131,39 +126,6 @@ std::unique_ptr<ModuleRtpRtcpImpl2> ModuleRtpRtcpImpl2::Create( return std::make_unique<ModuleRtpRtcpImpl2>(configuration); } -// Returns the number of milliseconds until the module want a worker thread -// to call Process. -int64_t ModuleRtpRtcpImpl2::TimeUntilNextProcess() { - RTC_DCHECK_RUN_ON(&process_thread_checker_); - return std::max<int64_t>(0, - next_process_time_ - clock_->TimeInMilliseconds()); -} - -// Process any pending tasks such as timeouts (non time critical events). -void ModuleRtpRtcpImpl2::Process() { - RTC_DCHECK_RUN_ON(&process_thread_checker_); - - const Timestamp now = clock_->CurrentTime(); - - // TODO(bugs.webrtc.org/11581): Figure out why we need to call Process() 200 - // times a second. - next_process_time_ = now.ms() + kRtpRtcpMaxIdleTimeProcessMs; - - // TODO(bugs.webrtc.org/11581): once we don't use Process() to trigger - // calls to SendRTCP(), the only remaining timer will require remote_bitrate_ - // to be not null. In that case, we can disable the timer when it is null. - if (remote_bitrate_ && rtcp_sender_.Sending() && rtcp_sender_.TMMBR()) { - unsigned int target_bitrate = 0; - std::vector<unsigned int> ssrcs; - if (remote_bitrate_->LatestEstimate(&ssrcs, &target_bitrate)) { - if (!ssrcs.empty()) { - target_bitrate = target_bitrate / ssrcs.size(); - } - rtcp_sender_.SetTargetBitrate(target_bitrate); - } - } -} - void ModuleRtpRtcpImpl2::SetRtxSendStatus(int mode) { rtp_sender_->packet_generator.SetRtxStatus(mode); } @@ -780,13 +742,6 @@ void ModuleRtpRtcpImpl2::PeriodicUpdate() { rtt_stats_->OnRttUpdate(rtt->ms()); set_rtt_ms(rtt->ms()); } - - // kTmmbrTimeoutIntervalMs is 25 seconds, so an order of seconds. - // Instead of this polling approach, consider having an optional timer in the - // RTCPReceiver class that is started/stopped based on the state of - // rtcp_sender_.TMMBR(). - if (rtcp_sender_.TMMBR() && rtcp_receiver_.UpdateTmmbrTimers()) - rtcp_receiver_.NotifyTmmbrUpdated(); } // RTC_RUN_ON(worker_queue_); diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h index 849cc42c5e..0ad495593d 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h @@ -50,7 +50,6 @@ struct PacedPacketInfo; struct RTPVideoHeader; class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, - public Module, public RTCPReceiver::ModuleRtpRtcp { public: explicit ModuleRtpRtcpImpl2( @@ -64,13 +63,6 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, static std::unique_ptr<ModuleRtpRtcpImpl2> Create( const Configuration& configuration); - // Returns the number of milliseconds until the module want a worker thread to - // call Process. - int64_t TimeUntilNextProcess() override; - - // Process any pending tasks such as timeouts. - void Process() override; - // Receiver part. // Called when we receive an RTCP packet. @@ -310,7 +302,6 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, TimeDelta duration); TaskQueueBase* const worker_queue_; - RTC_NO_UNIQUE_ADDRESS SequenceChecker process_thread_checker_; RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_; std::unique_ptr<RtpSenderContext> rtp_sender_; @@ -319,8 +310,6 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, Clock* const clock_; - int64_t last_rtt_process_time_; - int64_t next_process_time_; uint16_t packet_overhead_; // Send side diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc index 5deb12d465..c8ab15de78 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc @@ -199,25 +199,20 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, }; RtpRtcpModule(GlobalSimulatedTimeController* time_controller, - ProcessThread* process_thread, bool is_sender, const FieldTrialConfig& trials) : time_controller_(time_controller), is_sender_(is_sender), trials_(trials), - process_thread_(process_thread), receive_statistics_( ReceiveStatistics::Create(time_controller->GetClock())), transport_(kOneWayNetworkDelay, time_controller) { CreateModuleImpl(); } - ~RtpRtcpModule() { process_thread_->DeRegisterModule(impl_.get()); } - TimeController* const time_controller_; const bool is_sender_; const FieldTrialConfig& trials_; - ProcessThread* const process_thread_; RtcpPacketTypeCounter packets_sent_; RtcpPacketTypeCounter packets_received_; std::unique_ptr<ReceiveStatistics> receive_statistics_; @@ -286,10 +281,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, config.field_trials = &trials_; config.send_packet_observer = this; config.fec_generator = fec_generator_; - if (impl_) - process_thread_->DeRegisterModule(impl_.get()); impl_.reset(new ModuleRtpRtcpImpl2(config)); - process_thread_->RegisterModule(impl_.get(), RTC_FROM_HERE); impl_->SetRemoteSSRC(is_sender_ ? kReceiverSsrc : kSenderSsrc); impl_->SetRTCPStatus(RtcpMode::kCompound); } @@ -306,20 +298,12 @@ class RtpRtcpImpl2Test : public ::testing::TestWithParam<TestConfig> { RtpRtcpImpl2Test() : time_controller_(Timestamp::Micros(133590000000000)), field_trials_(FieldTrialConfig::GetFromTestConfig(GetParam())), - process_thread_( - time_controller_.CreateProcessThread("RtpRtcpImpl2Test")), sender_(&time_controller_, - process_thread_.get(), /*is_sender=*/true, field_trials_), receiver_(&time_controller_, - process_thread_.get(), /*is_sender=*/false, - field_trials_) { - process_thread_->Start(); - } - - ~RtpRtcpImpl2Test() { process_thread_->Stop(); } + field_trials_) {} void SetUp() override { // Send module. @@ -367,7 +351,6 @@ class RtpRtcpImpl2Test : public ::testing::TestWithParam<TestConfig> { GlobalSimulatedTimeController time_controller_; FieldTrialConfig field_trials_; - std::unique_ptr<ProcessThread> process_thread_; RtpRtcpModule sender_; std::unique_ptr<RTPSenderVideo> sender_video_; RtpRtcpModule receiver_; diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 1dcdf72e60..4b43247b18 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -36,7 +36,6 @@ #include "modules/rtp_rtcp/source/rtp_rtcp_config.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h" -#include "modules/utility/include/process_thread.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/h264_sprop_parameter_sets.h" #include "modules/video_coding/h264_sps_pps_tracker.h" @@ -211,7 +210,6 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( ReceiveStatistics* rtp_receive_statistics, RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, RtcpCnameCallback* rtcp_cname_callback, - ProcessThread* process_thread, NackSender* nack_sender, KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, @@ -220,7 +218,6 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( : clock_(clock), config_(*config), packet_router_(packet_router), - process_thread_(process_thread), ntp_estimator_(clock), rtp_header_extensions_(config_.rtp.extensions), forced_playout_delay_max_ms_("max_ms", absl::nullopt), @@ -289,8 +286,6 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( {&forced_playout_delay_max_ms_, &forced_playout_delay_min_ms_}, field_trial::FindFullName("WebRTC-ForcePlayoutDelay")); - process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); - if (config_.rtp.lntf.enabled) { loss_notification_controller_ = std::make_unique<LossNotificationController>(&rtcp_feedback_buffer_, @@ -316,8 +311,6 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( } RtpVideoStreamReceiver2::~RtpVideoStreamReceiver2() { - process_thread_->DeRegisterModule(rtp_rtcp_.get()); - if (packet_router_) packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); UpdateHistograms(); diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index 0c7e826189..ddff26b3bd 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -54,7 +54,6 @@ namespace webrtc { class NackModule2; class PacketRouter; -class ProcessThread; class ReceiveStatistics; class RtcpRttStats; class RtpPacketReceived; @@ -90,7 +89,6 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, ReceiveStatistics* rtp_receive_statistics, RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, RtcpCnameCallback* rtcp_cname_callback, - ProcessThread* process_thread, NackSender* nack_sender, // The KeyFrameRequestSender is optional; if not provided, key frame // requests are sent via the internal RtpRtcp module. @@ -287,7 +285,6 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, // Ownership of this object lies with VideoReceiveStream, which owns |this|. const VideoReceiveStream::Config& config_; PacketRouter* const packet_router_; - ProcessThread* const process_thread_; RemoteNtpTimeEstimator ntp_estimator_; diff --git a/video/rtp_video_stream_receiver2_unittest.cc b/video/rtp_video_stream_receiver2_unittest.cc index d23b6047aa..7ccf0a5faa 100644 --- a/video/rtp_video_stream_receiver2_unittest.cc +++ b/video/rtp_video_stream_receiver2_unittest.cc @@ -166,16 +166,14 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, TaskQueueFactory::Priority::NORMAL)), task_queue_setter_(task_queue_.get()), override_field_trials_(field_trials), - config_(CreateConfig()), - process_thread_(ProcessThread::Create("TestThread")) { + config_(CreateConfig()) { rtp_receive_statistics_ = ReceiveStatistics::Create(Clock::GetRealTimeClock()); rtp_video_stream_receiver_ = std::make_unique<RtpVideoStreamReceiver2>( TaskQueueBase::Current(), Clock::GetRealTimeClock(), &mock_transport_, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, - nullptr, process_thread_.get(), &mock_nack_sender_, - &mock_key_frame_request_sender_, &mock_on_complete_frame_callback_, - nullptr, nullptr); + nullptr, &mock_nack_sender_, &mock_key_frame_request_sender_, + &mock_on_complete_frame_callback_, nullptr, nullptr); VideoCodec codec; codec.codecType = kVideoCodecGeneric; rtp_video_stream_receiver_->AddReceiveCodec(kPayloadType, codec, {}, @@ -250,7 +248,6 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, MockKeyFrameRequestSender mock_key_frame_request_sender_; MockTransport mock_transport_; MockOnCompleteFrameCallback mock_on_complete_frame_callback_; - std::unique_ptr<ProcessThread> process_thread_; std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; std::unique_ptr<RtpVideoStreamReceiver2> rtp_video_stream_receiver_; RtpPacketSinkInterface* test_packet_sink_ = nullptr; @@ -1135,8 +1132,8 @@ TEST_F(RtpVideoStreamReceiver2Test, TransformFrame) { auto receiver = std::make_unique<RtpVideoStreamReceiver2>( TaskQueueBase::Current(), Clock::GetRealTimeClock(), &mock_transport_, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, - nullptr, process_thread_.get(), &mock_nack_sender_, nullptr, - &mock_on_complete_frame_callback_, nullptr, mock_frame_transformer); + nullptr, &mock_nack_sender_, nullptr, &mock_on_complete_frame_callback_, + nullptr, mock_frame_transformer); VideoCodec video_codec; video_codec.codecType = kVideoCodecGeneric; receiver->AddReceiveCodec(kPayloadType, video_codec, {}, diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index c929f07616..72257f01cc 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -216,7 +216,6 @@ VideoReceiveStream2::VideoReceiveStream2(TaskQueueFactory* task_queue_factory, int num_cpu_cores, PacketRouter* packet_router, VideoReceiveStream::Config config, - ProcessThread* process_thread, CallStats* call_stats, Clock* clock, VCMTiming* timing) @@ -241,7 +240,6 @@ VideoReceiveStream2::VideoReceiveStream2(TaskQueueFactory* task_queue_factory, rtp_receive_statistics_.get(), &stats_proxy_, &stats_proxy_, - process_thread, this, // NackSender nullptr, // Use default KeyFrameRequestSender this, // OnCompleteFrameCallback @@ -262,7 +260,6 @@ VideoReceiveStream2::VideoReceiveStream2(TaskQueueFactory* task_queue_factory, RTC_DCHECK(call_->worker_thread()); RTC_DCHECK(config_.renderer); RTC_DCHECK(call_stats_); - module_process_sequence_checker_.Detach(); packet_sequence_checker_.Detach(); RTC_DCHECK(!config_.decoders.empty()); diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 8fd995084e..9557044277 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -39,7 +39,6 @@ namespace webrtc { -class ProcessThread; class RtpStreamReceiverInterface; class RtpStreamReceiverControllerInterface; class RtxReceiveStream; @@ -96,7 +95,6 @@ class VideoReceiveStream2 int num_cpu_cores, PacketRouter* packet_router, VideoReceiveStream::Config config, - ProcessThread* process_thread, CallStats* call_stats, Clock* clock, VCMTiming* timing); @@ -199,7 +197,6 @@ class VideoReceiveStream2 void UpdateHistograms(); RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_sequence_checker_; - RTC_NO_UNIQUE_ADDRESS SequenceChecker module_process_sequence_checker_; // TODO(bugs.webrtc.org/11993): This checker conceptually represents // operations that belong to the network thread. The Call class is currently // moving towards handling network packets on the network thread and while diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index a37a5defb2..850fd0dbb5 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -109,8 +109,7 @@ class FrameObjectFake : public EncodedFrame { class VideoReceiveStream2Test : public ::testing::Test { public: VideoReceiveStream2Test() - : process_thread_(ProcessThread::Create("TestThread")), - task_queue_factory_(CreateDefaultTaskQueueFactory()), + : task_queue_factory_(CreateDefaultTaskQueueFactory()), h264_decoder_factory_(&mock_h264_video_decoder_), config_(&mock_transport_, &h264_decoder_factory_), call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()) {} @@ -138,15 +137,13 @@ class VideoReceiveStream2Test : public ::testing::Test { video_receive_stream_ = std::make_unique<webrtc::internal::VideoReceiveStream2>( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), process_thread_.get(), - &call_stats_, clock_, timing_); + &packet_router_, config_.Copy(), &call_stats_, clock_, timing_); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); } protected: test::RunLoop loop_; - std::unique_ptr<ProcessThread> process_thread_; const std::unique_ptr<TaskQueueFactory> task_queue_factory_; test::VideoDecoderProxyFactory h264_decoder_factory_; VideoReceiveStream::Config config_; @@ -290,7 +287,6 @@ class VideoReceiveStream2TestWithFakeDecoder : public ::testing::Test { VideoReceiveStream2TestWithFakeDecoder() : fake_decoder_factory_( []() { return std::make_unique<test::FakeDecoder>(); }), - process_thread_(ProcessThread::Create("TestThread")), task_queue_factory_(CreateDefaultTaskQueueFactory()), config_(&mock_transport_, &fake_decoder_factory_), call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()) {} @@ -320,8 +316,7 @@ class VideoReceiveStream2TestWithFakeDecoder : public ::testing::Test { timing_ = new VCMTiming(clock_); video_receive_stream_.reset(new webrtc::internal::VideoReceiveStream2( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), process_thread_.get(), &call_stats_, - clock_, timing_)); + &packet_router_, config_.Copy(), &call_stats_, clock_, timing_)); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); video_receive_stream_->SetAndGetRecordingState(std::move(state), false); @@ -330,7 +325,6 @@ class VideoReceiveStream2TestWithFakeDecoder : public ::testing::Test { protected: test::RunLoop loop_; test::FunctionVideoDecoderFactory fake_decoder_factory_; - std::unique_ptr<ProcessThread> process_thread_; const std::unique_ptr<TaskQueueFactory> task_queue_factory_; VideoReceiveStream::Config config_; internal::CallStats call_stats_; @@ -576,7 +570,6 @@ class VideoReceiveStream2TestWithSimulatedClock fake_decoder_factory_([this] { return std::make_unique<FakeDecoder2>([this] { OnFrameDecoded(); }); }), - process_thread_(time_controller_.CreateProcessThread("ProcessThread")), config_(GetConfig(&mock_transport_, &fake_decoder_factory_, &fake_renderer_)), @@ -586,7 +579,6 @@ class VideoReceiveStream2TestWithSimulatedClock /*num_cores=*/2, &packet_router_, config_.Copy(), - process_thread_.get(), &call_stats_, time_controller_.GetClock(), new VCMTiming(time_controller_.GetClock())) { @@ -613,7 +605,6 @@ class VideoReceiveStream2TestWithSimulatedClock GlobalSimulatedTimeController time_controller_; test::RunLoop loop_; test::FunctionVideoDecoderFactory fake_decoder_factory_; - std::unique_ptr<ProcessThread> process_thread_; MockTransport mock_transport_; FakeRenderer fake_renderer_; cricket::FakeCall fake_call_; @@ -729,8 +720,7 @@ INSTANTIATE_TEST_SUITE_P( class VideoReceiveStream2TestWithLazyDecoderCreation : public ::testing::Test { public: VideoReceiveStream2TestWithLazyDecoderCreation() - : process_thread_(ProcessThread::Create("TestThread")), - task_queue_factory_(CreateDefaultTaskQueueFactory()), + : task_queue_factory_(CreateDefaultTaskQueueFactory()), config_(&mock_transport_, &mock_h264_decoder_factory_), call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()) {} @@ -759,15 +749,13 @@ class VideoReceiveStream2TestWithLazyDecoderCreation : public ::testing::Test { video_receive_stream_ = std::make_unique<webrtc::internal::VideoReceiveStream2>( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), process_thread_.get(), - &call_stats_, clock_, timing_); + &packet_router_, config_.Copy(), &call_stats_, clock_, timing_); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); } protected: test::RunLoop loop_; - std::unique_ptr<ProcessThread> process_thread_; const std::unique_ptr<TaskQueueFactory> task_queue_factory_; MockVideoDecoderFactory mock_h264_decoder_factory_; VideoReceiveStream::Config config_; diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 591a8d58d8..46bf0dbc67 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -112,7 +112,6 @@ namespace internal { VideoSendStream::VideoSendStream( Clock* clock, int num_cpu_cores, - ProcessThread* module_process_thread, TaskQueueFactory* task_queue_factory, RtcpRttStats* call_stats, RtpTransportControllerSendInterface* transport, @@ -174,14 +173,12 @@ VideoSendStream::VideoSendStream( video_stream_encoder_->SetFecControllerOverride(rtp_video_sender_); - rtp_video_sender_->RegisterProcessThread(module_process_thread); ReconfigureVideoEncoder(std::move(encoder_config)); } VideoSendStream::~VideoSendStream() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(!running_); - rtp_video_sender_->DeRegisterProcessThread(); transport_->DestroyRtpVideoSender(rtp_video_sender_); } diff --git a/video/video_send_stream.h b/video/video_send_stream.h index 7e89c46abd..b52871c6e1 100644 --- a/video/video_send_stream.h +++ b/video/video_send_stream.h @@ -37,7 +37,6 @@ class VideoSendStreamPeer; class CallStats; class IvfFileWriter; -class ProcessThread; class RateLimiter; class RtpRtcp; class RtpTransportControllerSendInterface; @@ -58,7 +57,6 @@ class VideoSendStream : public webrtc::VideoSendStream { VideoSendStream( Clock* clock, int num_cpu_cores, - ProcessThread* module_process_thread, TaskQueueFactory* task_queue_factory, RtcpRttStats* call_stats, RtpTransportControllerSendInterface* transport, diff --git a/video/video_send_stream_impl_unittest.cc b/video/video_send_stream_impl_unittest.cc index 71cec7c981..30a4aacd92 100644 --- a/video/video_send_stream_impl_unittest.cc +++ b/video/video_send_stream_impl_unittest.cc @@ -62,8 +62,6 @@ std::string GetAlrProbingExperimentString() { } class MockRtpVideoSender : public RtpVideoSenderInterface { public: - MOCK_METHOD(void, RegisterProcessThread, (ProcessThread*), (override)); - MOCK_METHOD(void, DeRegisterProcessThread, (), (override)); MOCK_METHOD(void, SetActive, (bool), (override)); MOCK_METHOD(void, SetActiveModules, (const std::vector<bool>), (override)); MOCK_METHOD(bool, IsActive, (), (override)); diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 4e94d8fc77..9f9b8c16da 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -1486,7 +1486,6 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) { "bps", false); if (total_bitrate_bps > kHighBitrateBps) { rtp_rtcp_->SetRemb(kRembBitrateBps, {rtp_packet.Ssrc()}); - rtp_rtcp_->Process(); bitrate_capped_ = true; } else if (bitrate_capped_ && total_bitrate_bps < kRembRespectedBitrateBps) { |