Make SendStatisticsProxy paramter mandatory in ViEEncoder ctor.

The only implementation which used a nullptr was a mock used in tests,
so add a dummy instance there instead.
Remove tests for stats_proxy_ in vie_encoder and just dcheck in the
constructor instead.

BUG=None

Review-Url: https://codereview.webrtc.org/2695643002
Cr-Commit-Position: refs/heads/master@{#16577}
This commit is contained in:
sprang 2017-02-13 04:41:45 -08:00 committed by Commit bot
parent 1458462303
commit 552c7c70b0
2 changed files with 19 additions and 15 deletions

View File

@ -13,6 +13,7 @@
#include "webrtc/modules/utility/include/mock/mock_process_thread.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
#include "webrtc/video/send_statistics_proxy.h"
#include "webrtc/video/vie_encoder.h"
using ::testing::NiceMock;
@ -21,9 +22,9 @@ namespace webrtc {
class MockVieEncoder : public ViEEncoder {
public:
MockVieEncoder()
explicit MockVieEncoder(SendStatisticsProxy* send_stats_proxy)
: ViEEncoder(1,
nullptr,
send_stats_proxy,
VideoSendStream::Config::EncoderSettings("fake", 0, nullptr),
nullptr,
nullptr) {}
@ -38,6 +39,10 @@ class VieKeyRequestTest : public ::testing::Test {
public:
VieKeyRequestTest()
: simulated_clock_(123456789),
send_stats_proxy_(&simulated_clock_,
VideoSendStream::Config(nullptr),
VideoEncoderConfig::ContentType::kRealtimeVideo),
encoder_(&send_stats_proxy_),
encoder_rtcp_feedback_(
&simulated_clock_,
std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
@ -45,8 +50,10 @@ class VieKeyRequestTest : public ::testing::Test {
protected:
const uint32_t kSsrc = 1234;
MockVieEncoder encoder_;
SimulatedClock simulated_clock_;
SendStatisticsProxy send_stats_proxy_;
MockVieEncoder encoder_;
EncoderRtcpFeedback encoder_rtcp_feedback_;
};

View File

@ -295,6 +295,7 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
dropped_frame_count_(0),
bitrate_observer_(nullptr),
encoder_queue_("EncoderQueue") {
RTC_DCHECK(stats_proxy);
encoder_queue_.PostTask([this] {
RTC_DCHECK_RUN_ON(&encoder_queue_);
overuse_detector_.StartCheckForOveruse();
@ -444,13 +445,11 @@ void ViEEncoder::ReconfigureEncoder() {
video_sender_.UpdateChannelParemeters(rate_allocator_.get(),
bitrate_observer_);
if (stats_proxy_) {
int framerate = stats_proxy_->GetSendFrameRate();
if (framerate == 0)
framerate = codec.maxFramerate;
stats_proxy_->OnEncoderReconfigured(
encoder_config_, rate_allocator_->GetPreferredBitrateBps(framerate));
}
int framerate = stats_proxy_->GetSendFrameRate();
if (framerate == 0)
framerate = codec.maxFramerate;
stats_proxy_->OnEncoderReconfigured(
encoder_config_, rate_allocator_->GetPreferredBitrateBps(framerate));
pending_encoder_reconfiguration_ = false;
@ -642,8 +641,7 @@ EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
// Encoded is called on whatever thread the real encoder implementation run
// on. In the case of hardware encoders, there might be several encoders
// running in parallel on different threads.
if (stats_proxy_)
stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info);
stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info);
EncodedImageCallback::Result result =
sink_->OnEncodedImage(encoded_image, codec_specific_info, fragmentation);
@ -671,8 +669,7 @@ void ViEEncoder::OnDroppedFrame() {
void ViEEncoder::SendStatistics(uint32_t bit_rate, uint32_t frame_rate) {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
if (stats_proxy_)
stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate);
stats_proxy_->OnEncoderStatsUpdate(frame_rate, bit_rate);
}
void ViEEncoder::OnReceivedSLI(uint8_t picture_id) {
@ -734,7 +731,7 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
bool video_suspension_changed = video_is_suspended != EncoderPaused();
last_observed_bitrate_bps_ = bitrate_bps;
if (stats_proxy_ && video_suspension_changed) {
if (video_suspension_changed) {
LOG(LS_INFO) << "Video suspend state changed to: "
<< (video_is_suspended ? "suspended" : "not suspended");
stats_proxy_->OnSuspendChange(video_is_suspended);