diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h index 5bf019df1d..08497b08cb 100644 --- a/modules/video_coding/include/video_coding_defines.h +++ b/modules/video_coding/include/video_coding_defines.h @@ -84,16 +84,6 @@ class VCMReceiveCallback { virtual ~VCMReceiveCallback() {} }; -// Callback class used for informing the user of the bit rate and frame rate, -// and the name of the encoder. -class VCMSendStatisticsCallback { - public: - virtual void SendStatistics(uint32_t bitRate, uint32_t frameRate) = 0; - - protected: - virtual ~VCMSendStatisticsCallback() {} -}; - // Callback class used for informing the user of the incoming bit rate and frame // rate. class VCMReceiveStatisticsCallback { diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc index 61350faa83..a4c6f4db00 100644 --- a/modules/video_coding/video_coding_impl.cc +++ b/modules/video_coding/video_coding_impl.cc @@ -83,7 +83,7 @@ class VideoCodingModuleImpl : public VideoCodingModule { KeyFrameRequestSender* keyframe_request_sender, EncodedImageCallback* pre_decode_image_callback) : VideoCodingModule(), - sender_(clock, &post_encode_callback_, nullptr), + sender_(clock, &post_encode_callback_), timing_(new VCMTiming(clock)), receiver_(clock, event_factory, @@ -95,15 +95,12 @@ class VideoCodingModuleImpl : public VideoCodingModule { virtual ~VideoCodingModuleImpl() {} int64_t TimeUntilNextProcess() override { - int64_t sender_time = sender_.TimeUntilNextProcess(); int64_t receiver_time = receiver_.TimeUntilNextProcess(); - RTC_DCHECK_GE(sender_time, 0); RTC_DCHECK_GE(receiver_time, 0); - return VCM_MIN(sender_time, receiver_time); + return receiver_time; } void Process() override { - sender_.Process(); receiver_.Process(); } diff --git a/modules/video_coding/video_coding_impl.h b/modules/video_coding/video_coding_impl.h index d46f9cd558..0bd5ab7ca0 100644 --- a/modules/video_coding/video_coding_impl.h +++ b/modules/video_coding/video_coding_impl.h @@ -58,13 +58,12 @@ class VCMProcessTimer { int64_t _latestMs; }; -class VideoSender : public Module { +class VideoSender { public: typedef VideoCodingModule::SenderNackMode SenderNackMode; VideoSender(Clock* clock, - EncodedImageCallback* post_encode_callback, - VCMSendStatisticsCallback* send_stats_callback); + EncodedImageCallback* post_encode_callback); ~VideoSender(); @@ -109,9 +108,6 @@ class VideoSender : public Module { int32_t IntraFrameRequest(size_t stream_index); int32_t EnableFrameDropper(bool enable); - int64_t TimeUntilNextProcess() override; - void Process() override; - private: EncoderParameters UpdateEncoderParameters( const EncoderParameters& params, @@ -120,17 +116,13 @@ class VideoSender : public Module { void SetEncoderParameters(EncoderParameters params, bool has_internal_source) RTC_EXCLUSIVE_LOCKS_REQUIRED(encoder_crit_); - Clock* const clock_; - rtc::CriticalSection encoder_crit_; VCMGenericEncoder* _encoder; media_optimization::MediaOptimization _mediaOpt; VCMEncodedFrameCallback _encodedFrameCallback RTC_GUARDED_BY(encoder_crit_); EncodedImageCallback* const post_encode_callback_; - VCMSendStatisticsCallback* const send_stats_callback_; VCMCodecDataBase _codecDataBase RTC_GUARDED_BY(encoder_crit_); bool frame_dropper_enabled_ RTC_GUARDED_BY(encoder_crit_); - VCMProcessTimer _sendStatsTimer; // Must be accessed on the construction thread of VideoSender. VideoCodec current_codec_; diff --git a/modules/video_coding/video_sender.cc b/modules/video_coding/video_sender.cc index 5b7bcdafe9..fbf6ff8dcc 100644 --- a/modules/video_coding/video_sender.cc +++ b/modules/video_coding/video_sender.cc @@ -28,17 +28,13 @@ namespace webrtc { namespace vcm { VideoSender::VideoSender(Clock* clock, - EncodedImageCallback* post_encode_callback, - VCMSendStatisticsCallback* send_stats_callback) - : clock_(clock), - _encoder(nullptr), - _mediaOpt(clock_), + EncodedImageCallback* post_encode_callback) + : _encoder(nullptr), + _mediaOpt(clock), _encodedFrameCallback(post_encode_callback, &_mediaOpt), post_encode_callback_(post_encode_callback), - send_stats_callback_(send_stats_callback), _codecDataBase(&_encodedFrameCallback), frame_dropper_enabled_(true), - _sendStatsTimer(VCMProcessTimer::kDefaultProcessIntervalMs, clock_), current_codec_(), encoder_params_({BitrateAllocation(), 0, 0, 0}), encoder_has_internal_source_(false), @@ -52,24 +48,6 @@ VideoSender::VideoSender(Clock* clock, VideoSender::~VideoSender() {} -// TODO(asapersson): Remove _sendStatsTimer and send_stats_callback_. -void VideoSender::Process() { - if (_sendStatsTimer.TimeUntilProcess() == 0) { - // |_sendStatsTimer.Processed()| must be called. Otherwise - // VideoSender::Process() will be called in an infinite loop. - _sendStatsTimer.Processed(); - if (send_stats_callback_) { - uint32_t bitRate = 0; - uint32_t frameRate = 0; - send_stats_callback_->SendStatistics(bitRate, frameRate); - } - } -} - -int64_t VideoSender::TimeUntilNextProcess() { - return _sendStatsTimer.TimeUntilProcess(); -} - // Register the send codec to be used. int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec, uint32_t numberOfCores, diff --git a/modules/video_coding/video_sender_unittest.cc b/modules/video_coding/video_sender_unittest.cc index 1a51a4063a..6cc4ae923e 100644 --- a/modules/video_coding/video_sender_unittest.cc +++ b/modules/video_coding/video_sender_unittest.cc @@ -182,7 +182,7 @@ class TestVideoSender : public ::testing::Test { TestVideoSender() : clock_(1000), encoded_frame_callback_(&clock_) {} void SetUp() override { - sender_.reset(new VideoSender(&clock_, &encoded_frame_callback_, nullptr)); + sender_.reset(new VideoSender(&clock_, &encoded_frame_callback_)); } void AddFrame() { diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 6aa8c28599..982cd53feb 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -552,7 +552,6 @@ VideoSendStream::VideoSendStream( // Only signal target bitrate for screenshare streams, for now. video_stream_encoder_->SetBitrateObserver(send_stream_.get()); } - video_stream_encoder_->RegisterProcessThread(module_process_thread); ReconfigureVideoEncoder(std::move(encoder_config)); } @@ -620,7 +619,6 @@ void VideoSendStream::StopPermanentlyAndGetRtpStates( VideoSendStream::RtpPayloadStateMap* payload_state_map) { RTC_DCHECK_RUN_ON(&thread_checker_); video_stream_encoder_->Stop(); - video_stream_encoder_->DeRegisterProcessThread(); send_stream_->DeRegisterProcessThread(); worker_queue_->PostTask( std::unique_ptr(new DestructAndGetRtpStateTask( diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 961a38e881..4b673046dd 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -391,7 +391,7 @@ VideoStreamEncoder::VideoStreamEncoder( sink_(nullptr), settings_(settings), codec_type_(PayloadStringToCodecType(settings.payload_name)), - video_sender_(Clock::GetRealTimeClock(), this, nullptr), + video_sender_(Clock::GetRealTimeClock(), this), overuse_detector_( overuse_detector.get() ? overuse_detector.release() @@ -402,7 +402,6 @@ VideoStreamEncoder::VideoStreamEncoder( stats_proxy)), stats_proxy_(stats_proxy), pre_encode_callback_(pre_encode_callback), - module_process_thread_(nullptr), max_framerate_(-1), pending_encoder_reconfiguration_(false), encoder_start_bitrate_bps_(0), @@ -468,20 +467,6 @@ void VideoStreamEncoder::Stop() { shutdown_event_.Wait(rtc::Event::kForever); } -void VideoStreamEncoder::RegisterProcessThread( - ProcessThread* module_process_thread) { - RTC_DCHECK_RUN_ON(&thread_checker_); - RTC_DCHECK(!module_process_thread_); - module_process_thread_ = module_process_thread; - module_process_thread_->RegisterModule(&video_sender_, RTC_FROM_HERE); - module_process_thread_checker_.DetachFromThread(); -} - -void VideoStreamEncoder::DeRegisterProcessThread() { - RTC_DCHECK_RUN_ON(&thread_checker_); - module_process_thread_->DeRegisterModule(&video_sender_); -} - void VideoStreamEncoder::SetBitrateObserver( VideoBitrateAllocationObserver* bitrate_observer) { RTC_DCHECK_RUN_ON(&thread_checker_); diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index feec32770b..421b733961 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -36,7 +36,6 @@ namespace webrtc { -class ProcessThread; class SendStatisticsProxy; class VideoBitrateAllocationObserver; @@ -79,12 +78,6 @@ class VideoStreamEncoder : public rtc::VideoSinkInterface, EncodedFrameObserver* encoder_timing, std::unique_ptr overuse_detector); ~VideoStreamEncoder(); - // RegisterProcessThread register |module_process_thread| with those objects - // that use it. Registration has to happen on the thread where - // |module_process_thread| was created (libjingle's worker thread). - // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. - void RegisterProcessThread(ProcessThread* module_process_thread); - void DeRegisterProcessThread(); // Sets the source that will provide I420 video frames. // |degradation_preference| control whether or not resolution or frame rate @@ -236,8 +229,6 @@ class VideoStreamEncoder : public rtc::VideoSinkInterface, SendStatisticsProxy* const stats_proxy_; rtc::VideoSinkInterface* const pre_encode_callback_; - ProcessThread* module_process_thread_; - rtc::ThreadChecker module_process_thread_checker_; // |thread_checker_| checks that public methods that are related to lifetime // of VideoStreamEncoder are called on the same thread. rtc::ThreadChecker thread_checker_;