diff options
author | mikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 18:20:42 +0000 |
---|---|---|
committer | mikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 18:20:42 +0000 |
commit | 20cbba1908082eb3fa03c989e04738dfeeb73a4b (patch) | |
tree | d3962a8929970b6f1787f814c3b708a3ab4090d8 | |
parent | ed30847f42c7e838d3aabb7d6a63515c34c2cb72 (diff) | |
download | chromium_src-20cbba1908082eb3fa03c989e04738dfeeb73a4b.zip chromium_src-20cbba1908082eb3fa03c989e04738dfeeb73a4b.tar.gz chromium_src-20cbba1908082eb3fa03c989e04738dfeeb73a4b.tar.bz2 |
Cast: Refactoring VideoSender to Clang format
This cl is pure style-targeted refactoring.
No functional changes were made.
BUG=339176
Review URL: https://codereview.chromium.org/138153005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249445 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/cast/video_sender/codecs/vp8/vp8_encoder.cc | 62 | ||||
-rw-r--r-- | media/cast/video_sender/codecs/vp8/vp8_encoder.gypi | 4 | ||||
-rw-r--r-- | media/cast/video_sender/codecs/vp8/vp8_encoder.h | 5 | ||||
-rw-r--r-- | media/cast/video_sender/external_video_encoder.cc | 123 | ||||
-rw-r--r-- | media/cast/video_sender/external_video_encoder_unittest.cc | 44 | ||||
-rw-r--r-- | media/cast/video_sender/video_encoder.h | 1 | ||||
-rw-r--r-- | media/cast/video_sender/video_encoder_impl.cc | 63 | ||||
-rw-r--r-- | media/cast/video_sender/video_encoder_impl.h | 1 | ||||
-rw-r--r-- | media/cast/video_sender/video_encoder_impl_unittest.cc | 87 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender.cc | 9 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender.h | 5 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender_unittest.cc | 59 |
12 files changed, 260 insertions, 203 deletions
diff --git a/media/cast/video_sender/codecs/vp8/vp8_encoder.cc b/media/cast/video_sender/codecs/vp8/vp8_encoder.cc index c977dd2..a073b9f0 100644 --- a/media/cast/video_sender/codecs/vp8/vp8_encoder.cc +++ b/media/cast/video_sender/codecs/vp8/vp8_encoder.cc @@ -19,6 +19,13 @@ namespace cast { static const uint32 kMinIntra = 300; +static int ComputeMaxNumOfRepeatedBuffes(uint8 max_unacked_frames) { + if (max_unacked_frames > kNumberOfVp8VideoBuffers) + return (max_unacked_frames - 1) / kNumberOfVp8VideoBuffers; + + return 0; +} + Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, uint8 max_unacked_frames) : cast_config_(video_config), @@ -26,8 +33,7 @@ Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, cast_config_.max_number_of_video_buffers_used == kNumberOfVp8VideoBuffers), max_number_of_repeated_buffers_in_a_row_( - (max_unacked_frames > kNumberOfVp8VideoBuffers) ? - ((max_unacked_frames - 1) / kNumberOfVp8VideoBuffers) : 0), + ComputeMaxNumOfRepeatedBuffes(max_unacked_frames)), key_frame_requested_(true), timestamp_(0), last_encoded_frame_id_(kStartFrameId), @@ -36,7 +42,8 @@ Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, // internal state of the encoder, ideally the encoder will tell if we can // send another frame. DCHECK(!use_multiple_video_buffers_ || - max_number_of_repeated_buffers_in_a_row_ == 0) << "Invalid config"; + max_number_of_repeated_buffers_in_a_row_ == 0) + << "Invalid config"; // VP8 have 3 buffers available for prediction, with // max_number_of_video_buffers_used set to 1 we maximize the coding efficiency @@ -46,7 +53,8 @@ Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, // propagation. DCHECK(cast_config_.max_number_of_video_buffers_used == 1 || cast_config_.max_number_of_video_buffers_used == - kNumberOfVp8VideoBuffers) << "Invalid argument"; + kNumberOfVp8VideoBuffers) + << "Invalid argument"; thread_checker_.DetachFromThread(); } @@ -64,8 +72,8 @@ void Vp8Encoder::Initialize() { // Creating a wrapper to the image - setting image data to NULL. Actual // pointer will be set during encode. Setting align to 1, as it is // meaningless (actual memory is not allocated). - raw_image_ = vpx_img_wrap(NULL, IMG_FMT_I420, cast_config_.width, - cast_config_.height, 1, NULL); + raw_image_ = vpx_img_wrap( + NULL, IMG_FMT_I420, cast_config_.width, cast_config_.height, 1, NULL); for (int i = 0; i < kNumberOfVp8VideoBuffers; ++i) { acked_frame_buffers_[i] = true; @@ -95,8 +103,8 @@ void Vp8Encoder::InitEncode(int number_of_cores) { config_->g_error_resilient = 1; } - if (cast_config_.width * cast_config_.height > 640 * 480 - && number_of_cores >= 2) { + if (cast_config_.width * cast_config_.height > 640 * 480 && + number_of_cores >= 2) { config_->g_threads = 2; // 2 threads for qHD/HD. } else { config_->g_threads = 1; // 1 thread for VGA or less. @@ -120,10 +128,8 @@ void Vp8Encoder::InitEncode(int number_of_cores) { uint32 rc_max_intra_target = MaxIntraTarget(config_->rc_buf_optimal_sz); vpx_codec_flags_t flags = 0; // TODO(mikhal): Tune settings. - if (vpx_codec_enc_init(encoder_.get(), - vpx_codec_vp8_cx(), - config_.get(), - flags)) { + if (vpx_codec_enc_init( + encoder_.get(), vpx_codec_vp8_cx(), config_.get(), flags)) { DCHECK(false) << "vpx_codec_enc_init() failed."; encoder_.reset(); return; @@ -131,8 +137,8 @@ void Vp8Encoder::InitEncode(int number_of_cores) { vpx_codec_control(encoder_.get(), VP8E_SET_STATIC_THRESHOLD, 1); vpx_codec_control(encoder_.get(), VP8E_SET_NOISE_SENSITIVITY, 0); vpx_codec_control(encoder_.get(), VP8E_SET_CPUUSED, -6); - vpx_codec_control(encoder_.get(), VP8E_SET_MAX_INTRA_BITRATE_PCT, - rc_max_intra_target); + vpx_codec_control( + encoder_.get(), VP8E_SET_MAX_INTRA_BITRATE_PCT, rc_max_intra_target); } bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, @@ -183,7 +189,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, timestamp_ += duration; // Get encoded frame. - const vpx_codec_cx_pkt_t *pkt = NULL; + const vpx_codec_cx_pkt_t* pkt = NULL; vpx_codec_iter_t iter = NULL; size_t total_size = 0; while ((pkt = vpx_codec_get_cx_data(encoder_.get(), &iter)) != NULL) { @@ -193,8 +199,7 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, encoded_image->data.insert( encoded_image->data.end(), static_cast<const uint8*>(pkt->data.frame.buf), - static_cast<const uint8*>(pkt->data.frame.buf) + - pkt->data.frame.sz); + static_cast<const uint8*>(pkt->data.frame.buf) + pkt->data.frame.sz); if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { encoded_image->key_frame = true; } else { @@ -203,7 +208,8 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, } } // Don't update frame_id for zero size frames. - if (total_size == 0) return true; + if (total_size == 0) + return true; // Populate the encoded frame. encoded_image->codec = transport::kVp8; @@ -233,12 +239,14 @@ bool Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, } void Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) { - if (!use_multiple_video_buffers_) return; + if (!use_multiple_video_buffers_) + return; // We need to reference something. DCHECK(acked_frame_buffers_[kAltRefBuffer] || acked_frame_buffers_[kGoldenBuffer] || - acked_frame_buffers_[kLastBuffer]) << "Invalid state"; + acked_frame_buffers_[kLastBuffer]) + << "Invalid state"; if (!acked_frame_buffers_[kAltRefBuffer]) { *flags |= VP8_EFLAG_NO_REF_ARF; @@ -252,7 +260,8 @@ void Vp8Encoder::GetCodecReferenceFlags(vpx_codec_flags_t* flags) { } uint32 Vp8Encoder::GetLatestFrameIdToReference() { - if (!use_multiple_video_buffers_) return last_encoded_frame_id_; + if (!use_multiple_video_buffers_) + return last_encoded_frame_id_; int latest_frame_id_to_reference = -1; if (acked_frame_buffers_[kAltRefBuffer]) { @@ -317,7 +326,8 @@ Vp8Encoder::Vp8Buffers Vp8Encoder::GetNextBufferToUpdate() { void Vp8Encoder::GetCodecUpdateFlags(Vp8Buffers buffer_to_update, vpx_codec_flags_t* flags) { - if (!use_multiple_video_buffers_) return; + if (!use_multiple_video_buffers_) + return; // Update at most one buffer, except for key-frames. switch (buffer_to_update) { @@ -345,7 +355,8 @@ void Vp8Encoder::GetCodecUpdateFlags(Vp8Buffers buffer_to_update, void Vp8Encoder::UpdateRates(uint32 new_bitrate) { DCHECK(thread_checker_.CalledOnValidThread()); uint32 new_bitrate_kbit = new_bitrate / 1000; - if (config_->rc_target_bitrate == new_bitrate_kbit) return; + if (config_->rc_target_bitrate == new_bitrate_kbit) + return; config_->rc_target_bitrate = new_bitrate_kbit; @@ -357,7 +368,8 @@ void Vp8Encoder::UpdateRates(uint32 new_bitrate) { void Vp8Encoder::LatestFrameIdToReference(uint32 frame_id) { DCHECK(thread_checker_.CalledOnValidThread()); - if (!use_multiple_video_buffers_) return; + if (!use_multiple_video_buffers_) + return; VLOG(1) << "VP8 ok to reference frame:" << static_cast<int>(frame_id); for (int i = 0; i < kNumberOfVp8VideoBuffers; ++i) { @@ -383,7 +395,7 @@ uint32 Vp8Encoder::MaxIntraTarget(uint32 optimal_buffer_size_ms) const { float scale_parameter = 0.5; uint32 target_pct = optimal_buffer_size_ms * scale_parameter * - cast_config_.max_frame_rate / 10; + cast_config_.max_frame_rate / 10; // Don't go below 3 times the per frame bandwidth. return std::max(target_pct, kMinIntra); diff --git a/media/cast/video_sender/codecs/vp8/vp8_encoder.gypi b/media/cast/video_sender/codecs/vp8/vp8_encoder.gypi index 7c8e286..4a1a536 100644 --- a/media/cast/video_sender/codecs/vp8/vp8_encoder.gypi +++ b/media/cast/video_sender/codecs/vp8/vp8_encoder.gypi @@ -1,3 +1,7 @@ +# Copyright 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + { 'targets': [ { diff --git a/media/cast/video_sender/codecs/vp8/vp8_encoder.h b/media/cast/video_sender/codecs/vp8/vp8_encoder.h index a6dd396..7cc3754 100644 --- a/media/cast/video_sender/codecs/vp8/vp8_encoder.h +++ b/media/cast/video_sender/codecs/vp8/vp8_encoder.h @@ -25,8 +25,7 @@ const int kNumberOfVp8VideoBuffers = 3; class Vp8Encoder { public: - Vp8Encoder(const VideoSenderConfig& video_config, - uint8 max_unacked_frames); + Vp8Encoder(const VideoSenderConfig& video_config, uint8 max_unacked_frames); ~Vp8Encoder(); @@ -91,6 +90,8 @@ class Vp8Encoder { // This is bound to the thread where Initialize() is called. base::ThreadChecker thread_checker_; + + DISALLOW_COPY_AND_ASSIGN(Vp8Encoder); }; } // namespace cast diff --git a/media/cast/video_sender/external_video_encoder.cc b/media/cast/video_sender/external_video_encoder.cc index 6bba936..f810e63 100644 --- a/media/cast/video_sender/external_video_encoder.cc +++ b/media/cast/video_sender/external_video_encoder.cc @@ -16,21 +16,20 @@ #include "media/video/video_encode_accelerator.h" namespace { - // We allocate more input buffers than what is asked for by - // RequireBitstreamBuffers() due to potential threading timing. - static const int kInputBufferExtraCount = 1; - static const int kOutputBufferCount = 3; - - void LogFrameEncodedEvent( - const base::TimeTicks& now, - media::cast::CastEnvironment* const cast_environment, - const base::TimeTicks& capture_time) { - cast_environment->Logging()->InsertFrameEvent( - now, - media::cast::kVideoFrameEncoded, - media::cast::GetVideoRtpTimestamp(capture_time), - media::cast::kFrameIdUnknown); - } +// We allocate more input buffers than what is asked for by +// RequireBitstreamBuffers() due to potential threading timing. +static const int kInputBufferExtraCount = 1; +static const int kOutputBufferCount = 3; + +void LogFrameEncodedEvent(const base::TimeTicks& now, + media::cast::CastEnvironment* const cast_environment, + const base::TimeTicks& capture_time) { + cast_environment->Logging()->InsertFrameEvent( + now, + media::cast::kVideoFrameEncoded, + media::cast::GetVideoRtpTimestamp(capture_time), + media::cast::kFrameIdUnknown); +} } // namespace namespace media { @@ -75,7 +74,8 @@ class LocalVideoEncodeAcceleratorClient video_encode_accelerator_ = gpu_factories_->CreateVideoEncodeAccelerator(this).Pass(); - if (!video_encode_accelerator_) return; + if (!video_encode_accelerator_) + return; VideoCodecProfile output_profile = media::VIDEO_CODEC_PROFILE_UNKNOWN; switch (video_config.codec) { @@ -112,8 +112,8 @@ class LocalVideoEncodeAcceleratorClient DCHECK(encoder_task_runner_); DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); - video_encode_accelerator_->RequestEncodingParametersChange( - bit_rate, max_frame_rate_); + video_encode_accelerator_->RequestEncodingParametersChange(bit_rate, + max_frame_rate_); } void EncodeVideoFrame( @@ -146,8 +146,8 @@ class LocalVideoEncodeAcceleratorClient input_buffer->handle(), video_frame->GetTimestamp(), base::Bind(&LocalVideoEncodeAcceleratorClient::FinishedWithInBuffer, - this, - index)); + this, + index)); if (!frame) { VLOG(1) << "EncodeVideoFrame(): failed to create frame"; @@ -180,9 +180,10 @@ class LocalVideoEncodeAcceleratorClient DCHECK(encoder_task_runner_); DCHECK(encoder_task_runner_->RunsTasksOnCurrentThread()); - cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, - base::Bind(&ExternalVideoEncoder::EncoderInitialized, - weak_owner_)); + cast_environment_->PostTask( + CastEnvironment::MAIN, + FROM_HERE, + base::Bind(&ExternalVideoEncoder::EncoderInitialized, weak_owner_)); } virtual void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE { @@ -193,9 +194,10 @@ class LocalVideoEncodeAcceleratorClient if (video_encode_accelerator_) { video_encode_accelerator_.release()->Destroy(); } - cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, - base::Bind(&ExternalVideoEncoder::EncoderError, - weak_owner_)); + cast_environment_->PostTask( + CastEnvironment::MAIN, + FROM_HERE, + base::Bind(&ExternalVideoEncoder::EncoderError, weak_owner_)); } // Called to allocate the input and output buffers. @@ -207,9 +209,9 @@ class LocalVideoEncodeAcceleratorClient DCHECK(video_encode_accelerator_); for (unsigned int i = 0; i < input_count + kInputBufferExtraCount; ++i) { - base::SharedMemory* shm = gpu_factories_->CreateSharedMemory( - media::VideoFrame::AllocationSize(media::VideoFrame::I420, - input_coded_size)); + base::SharedMemory* shm = + gpu_factories_->CreateSharedMemory(media::VideoFrame::AllocationSize( + media::VideoFrame::I420, input_coded_size)); if (!shm) { VLOG(1) << "RequireBitstreamBuffers(): failed to create input buffer "; return; @@ -231,8 +233,8 @@ class LocalVideoEncodeAcceleratorClient for (size_t i = 0; i < output_buffers_.size(); ++i) { video_encode_accelerator_->UseOutputBitstreamBuffer( media::BitstreamBuffer(static_cast<int32>(i), - output_buffers_[i]->handle(), - output_buffers_[i]->mapped_size())); + output_buffers_[i]->handle(), + output_buffers_[i]->mapped_size())); } } @@ -247,7 +249,7 @@ class LocalVideoEncodeAcceleratorClient bitstream_buffer_id >= static_cast<int32>(output_buffers_.size())) { NOTREACHED(); VLOG(1) << "BitstreamBufferReady(): invalid bitstream_buffer_id=" - << bitstream_buffer_id; + << bitstream_buffer_id; NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); return; } @@ -264,8 +266,8 @@ class LocalVideoEncodeAcceleratorClient NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); return; } - scoped_ptr<transport::EncodedVideoFrame> - encoded_frame(new transport::EncodedVideoFrame()); + scoped_ptr<transport::EncodedVideoFrame> encoded_frame( + new transport::EncodedVideoFrame()); encoded_frame->codec = codec_; encoded_frame->key_frame = key_frame; @@ -280,24 +282,30 @@ class LocalVideoEncodeAcceleratorClient encoded_frame->data.insert( 0, static_cast<const char*>(output_buffer->memory()), payload_size); - cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, + cast_environment_->PostTask( + CastEnvironment::MAIN, + FROM_HERE, base::Bind(encoded_frame_data_storage_.front().frame_encoded_callback, - base::Passed(&encoded_frame), - encoded_frame_data_storage_.front().capture_time)); + base::Passed(&encoded_frame), + encoded_frame_data_storage_.front().capture_time)); base::TimeTicks now = cast_environment_->Clock()->NowTicks(); - cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, - base::Bind(LogFrameEncodedEvent, now, cast_environment_, - encoded_frame_data_storage_.front().capture_time)); + cast_environment_->PostTask( + CastEnvironment::MAIN, + FROM_HERE, + base::Bind(LogFrameEncodedEvent, + now, + cast_environment_, + encoded_frame_data_storage_.front().capture_time)); encoded_frame_data_storage_.pop_front(); // We need to re-add the output buffer to the encoder after we are done // with it. - video_encode_accelerator_->UseOutputBitstreamBuffer( - media::BitstreamBuffer(bitstream_buffer_id, - output_buffers_[bitstream_buffer_id]->handle(), - output_buffers_[bitstream_buffer_id]->mapped_size())); + video_encode_accelerator_->UseOutputBitstreamBuffer(media::BitstreamBuffer( + bitstream_buffer_id, + output_buffers_[bitstream_buffer_id]->handle(), + output_buffers_[bitstream_buffer_id]->mapped_size())); } private: @@ -350,7 +358,7 @@ ExternalVideoEncoder::ExternalVideoEncoder( skip_next_frame_(false), skip_count_(0), encoder_task_runner_(gpu_factories->GetTaskRunner()), - weak_factory_(this) { + weak_factory_(this) { DCHECK(gpu_factories); DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); video_accelerator_client_ = new LocalVideoEncodeAcceleratorClient( @@ -359,14 +367,15 @@ ExternalVideoEncoder::ExternalVideoEncoder( encoder_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalVideoEncodeAcceleratorClient::Initialize, - video_accelerator_client_, video_config)); + video_accelerator_client_, + video_config)); } ExternalVideoEncoder::~ExternalVideoEncoder() { encoder_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalVideoEncodeAcceleratorClient::Destroy, - video_accelerator_client_)); + video_accelerator_client_)); } void ExternalVideoEncoder::EncoderInitialized() { @@ -385,7 +394,8 @@ bool ExternalVideoEncoder::EncodeVideoFrame( const FrameEncodedCallback& frame_encoded_callback) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); - if (!encoder_active_) return false; + if (!encoder_active_) + return false; if (skip_next_frame_) { VLOG(1) << "Skip encoding frame"; @@ -394,14 +404,20 @@ bool ExternalVideoEncoder::EncodeVideoFrame( return false; } base::TimeTicks now = cast_environment_->Clock()->NowTicks(); - cast_environment_->Logging()->InsertFrameEvent(now, kVideoFrameSentToEncoder, - GetVideoRtpTimestamp(capture_time), kFrameIdUnknown); + cast_environment_->Logging()->InsertFrameEvent( + now, + kVideoFrameSentToEncoder, + GetVideoRtpTimestamp(capture_time), + kFrameIdUnknown); encoder_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalVideoEncodeAcceleratorClient::EncodeVideoFrame, - video_accelerator_client_, video_frame, capture_time, - key_frame_requested_, frame_encoded_callback)); + video_accelerator_client_, + video_frame, + capture_time, + key_frame_requested_, + frame_encoded_callback)); key_frame_requested_ = false; return true; @@ -412,7 +428,8 @@ void ExternalVideoEncoder::SetBitRate(int new_bit_rate) { encoder_task_runner_->PostTask( FROM_HERE, base::Bind(&LocalVideoEncodeAcceleratorClient::SetBitRate, - video_accelerator_client_, new_bit_rate)); + video_accelerator_client_, + new_bit_rate)); } // Inform the encoder to not encode the next frame. diff --git a/media/cast/video_sender/external_video_encoder_unittest.cc b/media/cast/video_sender/external_video_encoder_unittest.cc index 4e97416..8f9b2f7 100644 --- a/media/cast/video_sender/external_video_encoder_unittest.cc +++ b/media/cast/video_sender/external_video_encoder_unittest.cc @@ -23,8 +23,8 @@ namespace cast { using testing::_; namespace { -class TestVideoEncoderCallback : - public base::RefCountedThreadSafe<TestVideoEncoderCallback> { +class TestVideoEncoderCallback + : public base::RefCountedThreadSafe<TestVideoEncoderCallback> { public: TestVideoEncoderCallback() {} @@ -58,10 +58,11 @@ class TestVideoEncoderCallback : uint8 expected_frame_id_; uint8 expected_last_referenced_frame_id_; base::TimeTicks expected_capture_time_; + + DISALLOW_COPY_AND_ASSIGN(TestVideoEncoderCallback); }; } // namespace - class ExternalVideoEncoderTest : public ::testing::Test { protected: ExternalVideoEncoderTest() @@ -81,26 +82,29 @@ class ExternalVideoEncoderTest : public ::testing::Test { video_config_.max_number_of_video_buffers_used = 3; video_config_.codec = transport::kVp8; gfx::Size size(video_config_.width, video_config_.height); - video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420, - size, gfx::Rect(size), size, base::TimeDelta()); + video_frame_ = media::VideoFrame::CreateFrame( + VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); PopulateVideoFrame(video_frame_, 123); - } - - virtual ~ExternalVideoEncoderTest() {} - virtual void SetUp() { testing_clock_ = new base::SimpleTestTickClock(); task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); - cast_environment_ = new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, task_runner_, - GetDefaultCastSenderLoggingConfig()); + cast_environment_ = + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetDefaultCastSenderLoggingConfig()); video_encoder_.reset(new ExternalVideoEncoder( cast_environment_, video_config_, new test::FakeGpuVideoAcceleratorFactories(task_runner_))); } + virtual ~ExternalVideoEncoderTest() {} + base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_; VideoSenderConfig video_config_; @@ -108,6 +112,8 @@ class ExternalVideoEncoderTest : public ::testing::Test { scoped_ptr<VideoEncoder> video_encoder_; scoped_refptr<media::VideoFrame> video_frame_; scoped_refptr<CastEnvironment> cast_environment_; + + DISALLOW_COPY_AND_ASSIGN(ExternalVideoEncoderTest); }; TEST_F(ExternalVideoEncoderTest, EncodePattern30fpsRunningOutOfAck) { @@ -120,16 +126,16 @@ TEST_F(ExternalVideoEncoderTest, EncodePattern30fpsRunningOutOfAck) { base::TimeTicks capture_time; capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(true, 0, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); for (int i = 0; i < 6; ++i) { capture_time += base::TimeDelta::FromMilliseconds(33); - test_video_encoder_callback_->SetExpectedResult(false, i + 1, i, - capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + test_video_encoder_callback_->SetExpectedResult( + false, i + 1, i, capture_time); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); } // We need to run the task to cleanup the GPU instance. diff --git a/media/cast/video_sender/video_encoder.h b/media/cast/video_sender/video_encoder.h index 43d6e8c..09a5b29 100644 --- a/media/cast/video_sender/video_encoder.h +++ b/media/cast/video_sender/video_encoder.h @@ -56,4 +56,3 @@ class VideoEncoder { } // namespace media #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_ENCODER_H_ - diff --git a/media/cast/video_sender/video_encoder_impl.cc b/media/cast/video_sender/video_encoder_impl.cc index b852b97..94b9840 100644 --- a/media/cast/video_sender/video_encoder_impl.cc +++ b/media/cast/video_sender/video_encoder_impl.cc @@ -24,8 +24,11 @@ void LogFrameEncodedEvent(const base::TimeTicks& now, scoped_refptr<CastEnvironment> cast_environment, const base::TimeTicks& capture_time) { DCHECK(cast_environment->CurrentlyOn(CastEnvironment::MAIN)); - cast_environment->Logging()->InsertFrameEvent(now, kVideoFrameEncoded, - GetVideoRtpTimestamp(capture_time), kFrameIdUnknown); + cast_environment->Logging()->InsertFrameEvent( + now, + kVideoFrameEncoded, + GetVideoRtpTimestamp(capture_time), + kFrameIdUnknown); } void InitializeVp8EncoderOnEncoderThread( @@ -56,7 +59,8 @@ void EncodeVideoFrameOnEncoderThread( base::TimeTicks now = environment->Clock()->NowTicks(); environment->PostTask( - CastEnvironment::MAIN, FROM_HERE, + CastEnvironment::MAIN, + FROM_HERE, base::Bind(LogFrameEncodedEvent, now, environment, capture_time)); if (!retval) { @@ -68,13 +72,11 @@ void EncodeVideoFrameOnEncoderThread( return; } environment->PostTask( - CastEnvironment::MAIN, FROM_HERE, + CastEnvironment::MAIN, + FROM_HERE, base::Bind( - frame_encoded_callback, - base::Passed(&encoded_frame), - capture_time)); + frame_encoded_callback, base::Passed(&encoded_frame), capture_time)); } - } // namespace VideoEncoderImpl::VideoEncoderImpl( @@ -87,12 +89,11 @@ VideoEncoderImpl::VideoEncoderImpl( skip_count_(0) { if (video_config.codec == transport::kVp8) { vp8_encoder_.reset(new Vp8Encoder(video_config, max_unacked_frames)); - cast_environment_->PostTask( - CastEnvironment::VIDEO_ENCODER, FROM_HERE, - base::Bind( - &InitializeVp8EncoderOnEncoderThread, - cast_environment, - vp8_encoder_.get())); + cast_environment_->PostTask(CastEnvironment::VIDEO_ENCODER, + FROM_HERE, + base::Bind(&InitializeVp8EncoderOnEncoderThread, + cast_environment, + vp8_encoder_.get())); } else { DCHECK(false) << "Invalid config"; // Codec not supported. } @@ -106,7 +107,8 @@ VideoEncoderImpl::~VideoEncoderImpl() { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); if (vp8_encoder_) { cast_environment_->PostTask( - CastEnvironment::VIDEO_ENCODER, FROM_HERE, + CastEnvironment::VIDEO_ENCODER, + FROM_HERE, base::Bind(&base::DeletePointer<Vp8Encoder>, vp8_encoder_.release())); } } @@ -116,7 +118,8 @@ bool VideoEncoderImpl::EncodeVideoFrame( const base::TimeTicks& capture_time, const FrameEncodedCallback& frame_encoded_callback) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); - if (video_config_.codec != transport::kVp8) return false; + if (video_config_.codec != transport::kVp8) + return false; if (skip_next_frame_) { ++skip_count_; @@ -126,16 +129,20 @@ bool VideoEncoderImpl::EncodeVideoFrame( } base::TimeTicks now = cast_environment_->Clock()->NowTicks(); - cast_environment_->Logging()->InsertFrameEvent(now, kVideoFrameSentToEncoder, - GetVideoRtpTimestamp(capture_time), kFrameIdUnknown); - cast_environment_->PostTask(CastEnvironment::VIDEO_ENCODER, FROM_HERE, - base::Bind(&EncodeVideoFrameOnEncoderThread, - cast_environment_, - vp8_encoder_.get(), - video_frame, - capture_time, - dynamic_config_, - frame_encoded_callback)); + cast_environment_->Logging()->InsertFrameEvent( + now, + kVideoFrameSentToEncoder, + GetVideoRtpTimestamp(capture_time), + kFrameIdUnknown); + cast_environment_->PostTask(CastEnvironment::VIDEO_ENCODER, + FROM_HERE, + base::Bind(&EncodeVideoFrameOnEncoderThread, + cast_environment_, + vp8_encoder_.get(), + video_frame, + capture_time, + dynamic_config_, + frame_encoded_callback)); dynamic_config_.key_frame_requested = false; return true; @@ -161,9 +168,7 @@ void VideoEncoderImpl::LatestFrameIdToReference(uint32 frame_id) { dynamic_config_.latest_frame_id_to_reference = frame_id; } -int VideoEncoderImpl::NumberOfSkippedFrames() const { - return skip_count_; -} +int VideoEncoderImpl::NumberOfSkippedFrames() const { return skip_count_; } } // namespace cast } // namespace media diff --git a/media/cast/video_sender/video_encoder_impl.h b/media/cast/video_sender/video_encoder_impl.h index 1a13a79..887a779 100644 --- a/media/cast/video_sender/video_encoder_impl.h +++ b/media/cast/video_sender/video_encoder_impl.h @@ -55,7 +55,6 @@ class VideoEncoderImpl : public VideoEncoder { virtual int NumberOfSkippedFrames() const OVERRIDE; private: - const VideoSenderConfig video_config_; scoped_refptr<CastEnvironment> cast_environment_; CodecDynamicConfig dynamic_config_; diff --git a/media/cast/video_sender/video_encoder_impl_unittest.cc b/media/cast/video_sender/video_encoder_impl_unittest.cc index 22855cf8..6efcd6f 100644 --- a/media/cast/video_sender/video_encoder_impl_unittest.cc +++ b/media/cast/video_sender/video_encoder_impl_unittest.cc @@ -21,8 +21,8 @@ namespace cast { using testing::_; namespace { -class TestVideoEncoderCallback : - public base::RefCountedThreadSafe<TestVideoEncoderCallback> { +class TestVideoEncoderCallback + : public base::RefCountedThreadSafe<TestVideoEncoderCallback> { public: TestVideoEncoderCallback() {} @@ -56,6 +56,8 @@ class TestVideoEncoderCallback : uint8 expected_frame_id_; uint8 expected_last_referenced_frame_id_; base::TimeTicks expected_capture_time_; + + DISALLOW_COPY_AND_ASSIGN(TestVideoEncoderCallback); }; } // namespace @@ -78,8 +80,8 @@ class VideoEncoderImplTest : public ::testing::Test { video_config_.max_number_of_video_buffers_used = 3; video_config_.codec = transport::kVp8; gfx::Size size(video_config_.width, video_config_.height); - video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420, - size, gfx::Rect(size), size, base::TimeDelta()); + video_frame_ = media::VideoFrame::CreateFrame( + VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); PopulateVideoFrame(video_frame_, 123); } @@ -88,10 +90,15 @@ class VideoEncoderImplTest : public ::testing::Test { virtual void SetUp() OVERRIDE { testing_clock_ = new base::SimpleTestTickClock(); task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); - cast_environment_ = new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, - task_runner_, GetDefaultCastSenderLoggingConfig()); + cast_environment_ = + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetDefaultCastSenderLoggingConfig()); } virtual void TearDown() OVERRIDE { @@ -100,8 +107,8 @@ class VideoEncoderImplTest : public ::testing::Test { } void Configure(uint8 max_unacked_frames) { - video_encoder_.reset(new VideoEncoderImpl(cast_environment_, video_config_, - max_unacked_frames)); + video_encoder_.reset(new VideoEncoderImpl( + cast_environment_, video_config_, max_unacked_frames)); } base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. @@ -112,6 +119,8 @@ class VideoEncoderImplTest : public ::testing::Test { scoped_refptr<media::VideoFrame> video_frame_; scoped_refptr<CastEnvironment> cast_environment_; + + DISALLOW_COPY_AND_ASSIGN(VideoEncoderImplTest); }; TEST_F(VideoEncoderImplTest, EncodePattern30fpsRunningOutOfAck) { @@ -124,22 +133,22 @@ TEST_F(VideoEncoderImplTest, EncodePattern30fpsRunningOutOfAck) { base::TimeTicks capture_time; capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(true, 0, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); capture_time += base::TimeDelta::FromMilliseconds(33); video_encoder_->LatestFrameIdToReference(0); test_video_encoder_callback_->SetExpectedResult(false, 1, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); capture_time += base::TimeDelta::FromMilliseconds(33); video_encoder_->LatestFrameIdToReference(1); test_video_encoder_callback_->SetExpectedResult(false, 2, 1, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(2); @@ -147,15 +156,15 @@ TEST_F(VideoEncoderImplTest, EncodePattern30fpsRunningOutOfAck) { for (int i = 3; i < 6; ++i) { capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, i, 2, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); } } // TODO(pwestin): Re-enabled after redesign the encoder to control number of // frames in flight. -TEST_F(VideoEncoderImplTest,DISABLED_EncodePattern60fpsRunningOutOfAck) { +TEST_F(VideoEncoderImplTest, DISABLED_EncodePattern60fpsRunningOutOfAck) { video_config_.max_number_of_video_buffers_used = 1; Configure(6); @@ -166,22 +175,22 @@ TEST_F(VideoEncoderImplTest,DISABLED_EncodePattern60fpsRunningOutOfAck) { capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(true, 0, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(0); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 1, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(1); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 2, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(2); @@ -189,8 +198,8 @@ TEST_F(VideoEncoderImplTest,DISABLED_EncodePattern60fpsRunningOutOfAck) { for (int i = 3; i < 9; ++i) { capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, i, 2, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); } } @@ -208,44 +217,44 @@ TEST_F(VideoEncoderImplTest, capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(true, 0, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(0); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 1, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(1); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 2, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(2); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 3, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(3); capture_time += base::TimeDelta::FromMilliseconds(33); test_video_encoder_callback_->SetExpectedResult(false, 4, 0, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); video_encoder_->LatestFrameIdToReference(4); for (int i = 5; i < 17; ++i) { test_video_encoder_callback_->SetExpectedResult(false, i, 4, capture_time); - EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, - frame_encoded_callback)); + EXPECT_TRUE(video_encoder_->EncodeVideoFrame( + video_frame_, capture_time, frame_encoded_callback)); task_runner_->RunTasks(); } } diff --git a/media/cast/video_sender/video_sender.cc b/media/cast/video_sender/video_sender.cc index 7eba267..eeb2930 100644 --- a/media/cast/video_sender/video_sender.cc +++ b/media/cast/video_sender/video_sender.cc @@ -31,6 +31,8 @@ class LocalRtcpVideoSenderFeedback : public RtcpSenderFeedback { private: VideoSender* video_sender_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtcpVideoSenderFeedback); }; class LocalRtpVideoSenderStatistics : public RtpSenderStatistics { @@ -70,6 +72,8 @@ class LocalRtpVideoSenderStatistics : public RtpSenderStatistics { transport::RtcpSenderInfo sender_info_; base::TimeTicks time_sent_; uint32 rtp_timestamp_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtpVideoSenderStatistics); }; VideoSender::VideoSender( @@ -369,10 +373,9 @@ void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { video_encoder_->SetBitRate(new_bitrate); } } + // We only count duplicate ACKs when we have sent newer frames. if (static_cast<uint32>(last_acked_frame_id_) == - cast_feedback.ack_frame_id_ - // We only count duplicate ACKs when we have sent newer frames. - && + cast_feedback.ack_frame_id_ && IsNewerFrameId(last_sent_frame_id_, last_acked_frame_id_)) { duplicate_ack_++; } else { diff --git a/media/cast/video_sender/video_sender.h b/media/cast/video_sender/video_sender.h index cbd2644..15688fe 100644 --- a/media/cast/video_sender/video_sender.h +++ b/media/cast/video_sender/video_sender.h @@ -54,9 +54,8 @@ class VideoSender : public base::NonThreadSafe, // The closure callback is called from the video encoder thread as soon as // the encoder is done with the frame; it does not mean that the encoded frame // has been sent out. - void InsertRawVideoFrame( - const scoped_refptr<media::VideoFrame>& video_frame, - const base::TimeTicks& capture_time); + void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, + const base::TimeTicks& capture_time); // Only called from the main cast thread. void IncomingRtcpPacket(scoped_ptr<Packet> packet); diff --git a/media/cast/video_sender/video_sender_unittest.cc b/media/cast/video_sender/video_sender_unittest.cc index a5871ce..aeffe233 100644 --- a/media/cast/video_sender/video_sender_unittest.cc +++ b/media/cast/video_sender/video_sender_unittest.cc @@ -34,9 +34,7 @@ using testing::AtLeast; class TestPacketSender : public transport::PacketSender { public: - TestPacketSender() - : number_of_rtp_packets_(0), - number_of_rtcp_packets_(0) {} + TestPacketSender() : number_of_rtp_packets_(0), number_of_rtcp_packets_(0) {} // A singular packet implies a RTCP packet. virtual bool SendPacket(const Packet& packet) OVERRIDE { @@ -48,13 +46,9 @@ class TestPacketSender : public transport::PacketSender { return true; } - int number_of_rtp_packets() const { - return number_of_rtp_packets_; - } + int number_of_rtp_packets() const { return number_of_rtp_packets_; } - int number_of_rtcp_packets() const { - return number_of_rtcp_packets_; - } + int number_of_rtcp_packets() const { return number_of_rtcp_packets_; } private: int number_of_rtp_packets_; @@ -72,9 +66,11 @@ class PeerVideoSender : public VideoSender { const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, const CastInitializationCallback& initialization_status, transport::CastTransportSender* const transport_sender) - : VideoSender(cast_environment, video_config, gpu_factories, - initialization_status, transport_sender) { - } + : VideoSender(cast_environment, + video_config, + gpu_factories, + initialization_status, + transport_sender) {} using VideoSender::OnReceivedCastFeedback; }; } // namespace @@ -86,10 +82,15 @@ class VideoSenderTest : public ::testing::Test { testing_clock_->Advance( base::TimeDelta::FromMilliseconds(kStartMillisecond)); task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); - cast_environment_ = new CastEnvironment( - scoped_ptr<base::TickClock>(testing_clock_).Pass(), - task_runner_, task_runner_, task_runner_, task_runner_, - task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig()); + cast_environment_ = + new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetDefaultCastSenderLoggingConfig()); transport::CastTransportConfig transport_config; transport_sender_.reset(new transport::CastTransportSenderImpl( testing_clock_, @@ -129,28 +130,29 @@ class VideoSenderTest : public ::testing::Test { video_config.codec = transport::kVp8; if (external) { - video_sender_.reset(new PeerVideoSender(cast_environment_, + video_sender_.reset(new PeerVideoSender( + cast_environment_, video_config, new test::FakeGpuVideoAcceleratorFactories(task_runner_), base::Bind(&VideoSenderTest::InitializationResult, base::Unretained(this)), transport_sender_.get())); } else { - video_sender_.reset(new PeerVideoSender( - cast_environment_, - video_config, - NULL, - base::Bind(&VideoSenderTest::InitializationResult, - base::Unretained(this)), - transport_sender_.get())); + video_sender_.reset( + new PeerVideoSender(cast_environment_, + video_config, + NULL, + base::Bind(&VideoSenderTest::InitializationResult, + base::Unretained(this)), + transport_sender_.get())); } } scoped_refptr<media::VideoFrame> GetNewVideoFrame() { gfx::Size size(kWidth, kHeight); scoped_refptr<media::VideoFrame> video_frame = - media::VideoFrame::CreateFrame(VideoFrame::I420, size, gfx::Rect(size), - size, base::TimeDelta()); + media::VideoFrame::CreateFrame( + VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); PopulateVideoFrame(video_frame, kPixelValue); return video_frame; } @@ -185,8 +187,9 @@ TEST_F(VideoSenderTest, BuiltInEncoder) { video_sender_->InsertRawVideoFrame(video_frame, capture_time); task_runner_->RunTasks(); - EXPECT_GE(transport_.number_of_rtp_packets() + - transport_.number_of_rtcp_packets(), 1); + EXPECT_GE( + transport_.number_of_rtp_packets() + transport_.number_of_rtcp_packets(), + 1); } TEST_F(VideoSenderTest, ExternalEncoder) { |