Delete VCMSendStatisticsCallback and corresponding use of ProcessThread

Bug: webrtc:8422
Change-Id: I5863266a0226d475c4fdd810f2f6f1acdf922df3
Reviewed-on: https://webrtc-review.googlesource.com/14880
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20440}
This commit is contained in:
Niels Möller
2017-10-24 11:37:08 +02:00
committed by Commit Bot
parent 2729c16143
commit a0565999db
8 changed files with 9 additions and 78 deletions

View File

@ -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 {

View File

@ -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();
}

View File

@ -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_;

View File

@ -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,

View File

@ -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() {

View File

@ -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<rtc::QueuedTask>(new DestructAndGetRtpStateTask(

View File

@ -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_);

View File

@ -36,7 +36,6 @@
namespace webrtc {
class ProcessThread;
class SendStatisticsProxy;
class VideoBitrateAllocationObserver;
@ -79,12 +78,6 @@ class VideoStreamEncoder : public rtc::VideoSinkInterface<VideoFrame>,
EncodedFrameObserver* encoder_timing,
std::unique_ptr<OveruseFrameDetector> 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<VideoFrame>,
SendStatisticsProxy* const stats_proxy_;
rtc::VideoSinkInterface<VideoFrame>* 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_;