From 0e2c717e6168b2a3c59263ca03bdb6e5fdbfd262 Mon Sep 17 00:00:00 2001 From: "hubbe@chromium.org" Date: Fri, 21 Mar 2014 19:43:29 +0000 Subject: [PATCH] Cast: Reduce number of threads in cast environment. Since encoding and decoding rarely or never use the same cast environment, there is no need to have specific threads for encode and decode. Review URL: https://codereview.chromium.org/206493004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258650 0039d316-1c4b-4281-b951-d872f2087c98 --- .../renderer/media/cast_session_delegate.cc | 3 -- media/cast/audio_receiver/audio_decoder.cc | 2 +- .../audio_receiver/audio_decoder_unittest.cc | 2 - media/cast/audio_receiver/audio_receiver.cc | 6 +-- .../audio_receiver/audio_receiver_unittest.cc | 7 +++- media/cast/audio_sender/audio_encoder.cc | 2 +- .../audio_sender/audio_encoder_unittest.cc | 2 - .../audio_sender/audio_sender_unittest.cc | 2 - media/cast/cast_environment.cc | 42 +++++++------------ media/cast/cast_environment.h | 36 +++++++--------- media/cast/cast_sender_impl.cc | 4 +- .../encoding_event_subscriber_unittest.cc | 2 - .../simple_event_subscriber_unittest.cc | 9 ++-- ...receiver_rtcp_event_subscriber_unittest.cc | 9 ++-- media/cast/rtcp/rtcp_receiver_unittest.cc | 2 - media/cast/rtcp/rtcp_sender_unittest.cc | 2 - media/cast/rtcp/rtcp_unittest.cc | 2 - .../sender_rtcp_event_subscriber_unittest.cc | 9 ++-- media/cast/test/encode_decode_test.cc | 4 +- media/cast/test/end2end_unittest.cc | 4 -- media/cast/test/sender.cc | 4 +- .../utility/standalone_cast_environment.cc | 20 +++------ .../utility/standalone_cast_environment.h | 6 +-- .../video_receiver/codecs/vp8/vp8_decoder.cc | 4 +- .../video_receiver/video_decoder_unittest.cc | 2 - media/cast/video_receiver/video_receiver.cc | 4 +- .../video_receiver/video_receiver_unittest.cc | 2 - .../external_video_encoder_unittest.cc | 2 - media/cast/video_sender/video_encoder_impl.cc | 10 ++--- .../video_encoder_impl_unittest.cc | 2 - .../video_sender/video_sender_unittest.cc | 2 - 31 files changed, 77 insertions(+), 132 deletions(-) diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc index 66ec865703eb88..093615d0ea1029 100644 --- a/chrome/renderer/media/cast_session_delegate.cc +++ b/chrome/renderer/media/cast_session_delegate.cc @@ -121,14 +121,11 @@ void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) { // CastSender uses the renderer's IO thread as the main thread. This reduces // thread hopping for incoming video frames and outgoing network packets. - // There's no need to decode so no thread assigned for decoding. cast_environment_ = new CastEnvironment( scoped_ptr(new base::DefaultTickClock()).Pass(), base::MessageLoopProxy::current(), g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(), - NULL, g_cast_threads.Get().GetVideoEncodeMessageLoopProxy(), - NULL, base::MessageLoopProxy::current(), logging_config); diff --git a/media/cast/audio_receiver/audio_decoder.cc b/media/cast/audio_receiver/audio_decoder.cc index 20331999d5b9b1..b1a8256f2e9d7d 100644 --- a/media/cast/audio_receiver/audio_decoder.cc +++ b/media/cast/audio_receiver/audio_decoder.cc @@ -62,7 +62,7 @@ bool AudioDecoder::GetRawAudioFrame(int number_of_10ms_blocks, int desired_frequency, PcmAudioFrame* audio_frame, uint32* rtp_timestamp) { - DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::AUDIO_DECODER)); + DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::AUDIO)); // We don't care about the race case where a packet arrives at the same time // as this function in called. The data will be there the next time this // function is called. diff --git a/media/cast/audio_receiver/audio_decoder_unittest.cc b/media/cast/audio_receiver/audio_decoder_unittest.cc index 703d7333c1dba9..78daadbbbe5e3c 100644 --- a/media/cast/audio_receiver/audio_decoder_unittest.cc +++ b/media/cast/audio_receiver/audio_decoder_unittest.cc @@ -36,8 +36,6 @@ class AudioDecoderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastReceiverLoggingConfig()); } virtual ~AudioDecoderTest() {} diff --git a/media/cast/audio_receiver/audio_receiver.cc b/media/cast/audio_receiver/audio_receiver.cc index f7988f55a2bc13..3cf1244aeaa050 100644 --- a/media/cast/audio_receiver/audio_receiver.cc +++ b/media/cast/audio_receiver/audio_receiver.cc @@ -177,7 +177,7 @@ void AudioReceiver::IncomingParsedRtpPacket(const uint8* payload_data, DecodedAudioCallbackData decoded_data = queued_decoded_callbacks_.front(); queued_decoded_callbacks_.pop_front(); cast_environment_->PostTask( - CastEnvironment::AUDIO_DECODER, FROM_HERE, + CastEnvironment::AUDIO, FROM_HERE, base::Bind(&AudioReceiver::DecodeAudioFrameThread, base::Unretained(this), decoded_data.number_of_10ms_blocks, decoded_data.desired_frequency, decoded_data.callback)); @@ -215,7 +215,7 @@ void AudioReceiver::GetRawAudioFrame( DCHECK(audio_decoder_) << "Invalid function call in this configuration"; // TODO(pwestin): we can skip this function by posting direct to the decoder. cast_environment_->PostTask( - CastEnvironment::AUDIO_DECODER, FROM_HERE, + CastEnvironment::AUDIO, FROM_HERE, base::Bind(&AudioReceiver::DecodeAudioFrameThread, base::Unretained(this), number_of_10ms_blocks, desired_frequency, callback)); } @@ -223,7 +223,7 @@ void AudioReceiver::GetRawAudioFrame( void AudioReceiver::DecodeAudioFrameThread( int number_of_10ms_blocks, int desired_frequency, const AudioFrameDecodedCallback callback) { - DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::AUDIO_DECODER)); + DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::AUDIO)); // TODO(mikhal): Allow the application to allocate this memory. scoped_ptr audio_frame(new PcmAudioFrame()); diff --git a/media/cast/audio_receiver/audio_receiver_unittest.cc b/media/cast/audio_receiver/audio_receiver_unittest.cc index 9d4917acd2a2c4..03797a3e8d6ca7 100644 --- a/media/cast/audio_receiver/audio_receiver_unittest.cc +++ b/media/cast/audio_receiver/audio_receiver_unittest.cc @@ -86,8 +86,11 @@ class AudioReceiverTest : public ::testing::Test { logging_config.enable_raw_data_collection = true; cast_environment_ = new CastEnvironment( - scoped_ptr(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, task_runner_, + scoped_ptr(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, logging_config); test_audio_encoder_callback_ = new TestAudioEncoderCallback(); diff --git a/media/cast/audio_sender/audio_encoder.cc b/media/cast/audio_sender/audio_encoder.cc index ece368f65415fc..3d36b715b7fb33 100644 --- a/media/cast/audio_sender/audio_encoder.cc +++ b/media/cast/audio_sender/audio_encoder.cc @@ -350,7 +350,7 @@ void AudioEncoder::InsertAudio(scoped_ptr audio_bus, NOTREACHED(); return; } - cast_environment_->PostTask(CastEnvironment::AUDIO_ENCODER, + cast_environment_->PostTask(CastEnvironment::AUDIO, FROM_HERE, base::Bind(&AudioEncoder::ImplBase::EncodeAudio, impl_, diff --git a/media/cast/audio_sender/audio_encoder_unittest.cc b/media/cast/audio_sender/audio_encoder_unittest.cc index 37f5b49bd617ac..7b435fcd32ea1e 100644 --- a/media/cast/audio_sender/audio_encoder_unittest.cc +++ b/media/cast/audio_sender/audio_encoder_unittest.cc @@ -97,8 +97,6 @@ class AudioEncoderTest : public ::testing::TestWithParam { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastSenderLoggingConfig()); } diff --git a/media/cast/audio_sender/audio_sender_unittest.cc b/media/cast/audio_sender/audio_sender_unittest.cc index 49607bacd5db2a..a759687901dbcf 100644 --- a/media/cast/audio_sender/audio_sender_unittest.cc +++ b/media/cast/audio_sender/audio_sender_unittest.cc @@ -61,8 +61,6 @@ class AudioSenderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, logging_config); audio_config_.codec = transport::kOpus; audio_config_.use_external_encoder = false; diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc index 9077b52b723294..effc999d0d256f 100644 --- a/media/cast/cast_environment.cc +++ b/media/cast/cast_environment.cc @@ -24,17 +24,13 @@ namespace cast { CastEnvironment::CastEnvironment( scoped_ptr clock, scoped_refptr main_thread_proxy, - scoped_refptr audio_encode_thread_proxy, - scoped_refptr audio_decode_thread_proxy, - scoped_refptr video_encode_thread_proxy, - scoped_refptr video_decode_thread_proxy, + scoped_refptr audio_thread_proxy, + scoped_refptr video_thread_proxy, scoped_refptr transport_thread_proxy, const CastLoggingConfig& logging_config) : main_thread_proxy_(main_thread_proxy), - audio_encode_thread_proxy_(audio_encode_thread_proxy), - audio_decode_thread_proxy_(audio_decode_thread_proxy), - video_encode_thread_proxy_(video_encode_thread_proxy), - video_decode_thread_proxy_(video_decode_thread_proxy), + audio_thread_proxy_(audio_thread_proxy), + video_thread_proxy_(video_thread_proxy), transport_thread_proxy_(transport_thread_proxy), clock_(clock.Pass()), logging_(new LoggingImpl(logging_config)) {} @@ -67,14 +63,10 @@ scoped_refptr CastEnvironment::GetTaskRunner( switch (identifier) { case CastEnvironment::MAIN: return main_thread_proxy_; - case CastEnvironment::AUDIO_ENCODER: - return audio_encode_thread_proxy_; - case CastEnvironment::AUDIO_DECODER: - return audio_decode_thread_proxy_; - case CastEnvironment::VIDEO_ENCODER: - return video_encode_thread_proxy_; - case CastEnvironment::VIDEO_DECODER: - return video_decode_thread_proxy_; + case CastEnvironment::AUDIO: + return audio_thread_proxy_; + case CastEnvironment::VIDEO: + return video_thread_proxy_; case CastEnvironment::TRANSPORT: return transport_thread_proxy_; default: @@ -88,18 +80,12 @@ bool CastEnvironment::CurrentlyOn(ThreadId identifier) { case CastEnvironment::MAIN: return main_thread_proxy_ && main_thread_proxy_->RunsTasksOnCurrentThread(); - case CastEnvironment::AUDIO_ENCODER: - return audio_encode_thread_proxy_ && - audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); - case CastEnvironment::AUDIO_DECODER: - return audio_decode_thread_proxy_ && - audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); - case CastEnvironment::VIDEO_ENCODER: - return video_encode_thread_proxy_ && - video_encode_thread_proxy_->RunsTasksOnCurrentThread(); - case CastEnvironment::VIDEO_DECODER: - return video_decode_thread_proxy_ && - video_decode_thread_proxy_->RunsTasksOnCurrentThread(); + case CastEnvironment::AUDIO: + return audio_thread_proxy_ && + audio_thread_proxy_->RunsTasksOnCurrentThread(); + case CastEnvironment::VIDEO: + return video_thread_proxy_ && + video_thread_proxy_->RunsTasksOnCurrentThread(); case CastEnvironment::TRANSPORT: return transport_thread_proxy_ && transport_thread_proxy_->RunsTasksOnCurrentThread(); diff --git a/media/cast/cast_environment.h b/media/cast/cast_environment.h index 95d4ccb9033e9a..399ebb773fc8fb 100644 --- a/media/cast/cast_environment.h +++ b/media/cast/cast_environment.h @@ -24,16 +24,11 @@ class CastEnvironment : public base::RefCountedThreadSafe { // The main thread is where the cast system is configured and where timers // and network IO is performed. MAIN, - // The audio encoder thread is where all send side audio processing is done, - // primarily encoding but also re-sampling. - AUDIO_ENCODER, - // The audio decoder thread is where all receive side audio processing is - // done, primarily decoding but also error concealment and re-sampling. - AUDIO_DECODER, - // The video encoder thread is where the video encode processing is done. - VIDEO_ENCODER, - // The video decoder thread is where the video decode processing is done. - VIDEO_DECODER, + // The audio thread is where all send side audio processing is done, + // primarily encoding / decoding but also re-sampling. + AUDIO, + // The video encoder thread is where the video processing is done. + VIDEO, // The transport thread is where the transport processing is done. TRANSPORT, }; @@ -41,10 +36,8 @@ class CastEnvironment : public base::RefCountedThreadSafe { CastEnvironment( scoped_ptr clock, scoped_refptr main_thread_proxy, - scoped_refptr audio_encode_thread_proxy, - scoped_refptr audio_decode_thread_proxy, - scoped_refptr video_encode_thread_proxy, - scoped_refptr video_decode_thread_proxy, + scoped_refptr audio_thread_proxy, + scoped_refptr video_thread_proxy, scoped_refptr transport_thread_proxy, const CastLoggingConfig& logging_config); @@ -69,17 +62,18 @@ class CastEnvironment : public base::RefCountedThreadSafe { // Logging is not thread safe. Its methods should always be called from the // main thread. + // TODO(hubbe): Logging should be a thread-safe interface. LoggingImpl* Logging() const { return logging_.get(); } scoped_refptr GetTaskRunner( ThreadId identifier) const; - bool HasAudioEncoderThread() { - return audio_encode_thread_proxy_ ? true : false; + bool HasAudioThread() { + return audio_thread_proxy_ ? true : false; } - bool HasVideoEncoderThread() { - return video_encode_thread_proxy_ ? true : false; + bool HasVideoThread() { + return video_thread_proxy_ ? true : false; } protected: @@ -87,10 +81,8 @@ class CastEnvironment : public base::RefCountedThreadSafe { // Subclasses may override these. scoped_refptr main_thread_proxy_; - scoped_refptr audio_encode_thread_proxy_; - scoped_refptr audio_decode_thread_proxy_; - scoped_refptr video_encode_thread_proxy_; - scoped_refptr video_decode_thread_proxy_; + scoped_refptr audio_thread_proxy_; + scoped_refptr video_thread_proxy_; scoped_refptr transport_thread_proxy_; private: diff --git a/media/cast/cast_sender_impl.cc b/media/cast/cast_sender_impl.cc index 3c9046116f6577..7a60ffc84ad1a5 100644 --- a/media/cast/cast_sender_impl.cc +++ b/media/cast/cast_sender_impl.cc @@ -95,7 +95,7 @@ void CastSenderImpl::InitializeAudio( const CastInitializationCallback& cast_initialization_cb) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); CHECK(audio_config.use_external_encoder || - cast_environment_->HasAudioEncoderThread()); + cast_environment_->HasAudioThread()); audio_sender_.reset( new AudioSender(cast_environment_, audio_config, transport_sender_)); @@ -116,7 +116,7 @@ void CastSenderImpl::InitializeVideo( const scoped_refptr& gpu_factories) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); CHECK(video_config.use_external_encoder || - cast_environment_->HasVideoEncoderThread()); + cast_environment_->HasVideoThread()); video_sender_.reset(new VideoSender(cast_environment_, video_config, diff --git a/media/cast/logging/encoding_event_subscriber_unittest.cc b/media/cast/logging/encoding_event_subscriber_unittest.cc index f0f552d328b15e..c14af48e4f7525 100644 --- a/media/cast/logging/encoding_event_subscriber_unittest.cc +++ b/media/cast/logging/encoding_event_subscriber_unittest.cc @@ -31,8 +31,6 @@ class EncodingEventSubscriberTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetLoggingConfigWithRawEventsAndStatsEnabled())), first_rtp_timestamp_(0) {} diff --git a/media/cast/logging/simple_event_subscriber_unittest.cc b/media/cast/logging/simple_event_subscriber_unittest.cc index 310db9ca4092f6..ea3bcdc55edb1d 100644 --- a/media/cast/logging/simple_event_subscriber_unittest.cc +++ b/media/cast/logging/simple_event_subscriber_unittest.cc @@ -21,9 +21,12 @@ class SimpleEventSubscriberTest : public ::testing::Test { : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), cast_environment_(new CastEnvironment( - scoped_ptr(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, - task_runner_, GetLoggingConfigWithRawEventsAndStatsEnabled())) { + scoped_ptr(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetLoggingConfigWithRawEventsAndStatsEnabled())) { cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); } diff --git a/media/cast/rtcp/receiver_rtcp_event_subscriber_unittest.cc b/media/cast/rtcp/receiver_rtcp_event_subscriber_unittest.cc index 6feea7c509fbec..dd227f97c8eee4 100644 --- a/media/cast/rtcp/receiver_rtcp_event_subscriber_unittest.cc +++ b/media/cast/rtcp/receiver_rtcp_event_subscriber_unittest.cc @@ -28,9 +28,12 @@ class ReceiverRtcpEventSubscriberTest : public ::testing::Test { : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), cast_environment_(new CastEnvironment( - scoped_ptr(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, - task_runner_, GetLoggingConfigWithRawEventsAndStatsEnabled())) {} + scoped_ptr(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetLoggingConfigWithRawEventsAndStatsEnabled())) {} virtual ~ReceiverRtcpEventSubscriberTest() {} diff --git a/media/cast/rtcp/rtcp_receiver_unittest.cc b/media/cast/rtcp/rtcp_receiver_unittest.cc index 06b25e9e279dd1..27c98e394b0039 100644 --- a/media/cast/rtcp/rtcp_receiver_unittest.cc +++ b/media/cast/rtcp/rtcp_receiver_unittest.cc @@ -164,8 +164,6 @@ class RtcpReceiverTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastReceiverLoggingConfig())), rtcp_receiver_(new RtcpReceiver(cast_environment_, &mock_sender_feedback_, diff --git a/media/cast/rtcp/rtcp_sender_unittest.cc b/media/cast/rtcp/rtcp_sender_unittest.cc index 18d67d167c4c91..0bac775f8d116e 100644 --- a/media/cast/rtcp/rtcp_sender_unittest.cc +++ b/media/cast/rtcp/rtcp_sender_unittest.cc @@ -81,8 +81,6 @@ class RtcpSenderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastSenderLoggingConfig())), rtcp_sender_(new RtcpSender(cast_environment_, &test_transport_, diff --git a/media/cast/rtcp/rtcp_unittest.cc b/media/cast/rtcp/rtcp_unittest.cc index bcf7be11ac0cfc..856f25b52c3915 100644 --- a/media/cast/rtcp/rtcp_unittest.cc +++ b/media/cast/rtcp/rtcp_unittest.cc @@ -150,8 +150,6 @@ class RtcpTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, logging_config_)), sender_to_receiver_(testing_clock_), receiver_to_sender_(cast_environment_, testing_clock_), diff --git a/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc b/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc index 56897c2d63538c..ab75171802d668 100644 --- a/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc +++ b/media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc @@ -27,9 +27,12 @@ class SenderRtcpEventSubscriberTest : public ::testing::Test { : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), cast_environment_(new CastEnvironment( - scoped_ptr(testing_clock_).Pass(), task_runner_, - task_runner_, task_runner_, task_runner_, task_runner_, - task_runner_, GetLoggingConfigWithRawEventsAndStatsEnabled())), + scoped_ptr(testing_clock_).Pass(), + task_runner_, + task_runner_, + task_runner_, + task_runner_, + GetLoggingConfigWithRawEventsAndStatsEnabled())), event_subscriber_(kMaxEventEntries) { cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); } diff --git a/media/cast/test/encode_decode_test.cc b/media/cast/test/encode_decode_test.cc index a405242adb8b4b..df9708993a6aff 100644 --- a/media/cast/test/encode_decode_test.cc +++ b/media/cast/test/encode_decode_test.cc @@ -73,13 +73,11 @@ class EncodeDecodeTest : public ::testing::Test { : testing_clock_(new base::SimpleTestTickClock()), task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_)), // CastEnvironment will only be used by the vp8 decoder; Enable only the - // video decoder and main threads. + // video and main threads. cast_environment_(new CastEnvironment( scoped_ptr(testing_clock_).Pass(), task_runner_, NULL, - NULL, - NULL, task_runner_, NULL, GetDefaultCastReceiverLoggingConfig())), diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc index e85f9aa716a2d9..27181a292f2eeb 100644 --- a/media/cast/test/end2end_unittest.cc +++ b/media/cast/test/end2end_unittest.cc @@ -409,8 +409,6 @@ class End2EndTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, logging_config_)), cast_environment_receiver_(new CastEnvironment( scoped_ptr(testing_clock_receiver_).Pass(), @@ -418,8 +416,6 @@ class End2EndTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, logging_config_)), receiver_to_sender_(cast_environment_receiver_), sender_to_receiver_(cast_environment_sender_), diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc index 62c6bf3f3dafce..b400ff4d931ca4 100644 --- a/media/cast/test/sender.cc +++ b/media/cast/test/sender.cc @@ -467,16 +467,14 @@ int main(int argc, char** argv) { transport_video_config.base.ssrc = video_config.sender_ssrc; transport_video_config.base.rtp_config = video_config.rtp_config; - // Enable main and send side threads only. Enable raw event and stats logging. + // Enable raw event and stats logging. // Running transport on the main thread. scoped_refptr cast_environment( new media::cast::CastEnvironment( make_scoped_ptr(new base::DefaultTickClock()), io_message_loop.message_loop_proxy(), audio_thread.message_loop_proxy(), - NULL, video_thread.message_loop_proxy(), - NULL, io_message_loop.message_loop_proxy(), media::cast::GetLoggingConfigWithRawEventsAndStatsEnabled())); diff --git a/media/cast/test/utility/standalone_cast_environment.cc b/media/cast/test/utility/standalone_cast_environment.cc index 7e826209870e9d..386239ea202059 100644 --- a/media/cast/test/utility/standalone_cast_environment.cc +++ b/media/cast/test/utility/standalone_cast_environment.cc @@ -17,14 +17,10 @@ StandaloneCastEnvironment::StandaloneCastEnvironment( NULL, NULL, NULL, - NULL, - NULL, logging_config), main_thread_("StandaloneCastEnvironment Main"), - audio_encode_thread_("StandaloneCastEnvironment Audio Encode"), - audio_decode_thread_("StandaloneCastEnvironment Audio Decode"), - video_encode_thread_("StandaloneCastEnvironment Video Encode"), - video_decode_thread_("StandaloneCastEnvironment Video Decode"), + audio_thread_("StandaloneCastEnvironment Audio"), + video_thread_("StandaloneCastEnvironment Video"), transport_thread_("StandaloneCastEnvironment Transport") { #define CREATE_TASK_RUNNER(name, options) \ name##_thread_.StartWithOptions(options); \ @@ -32,10 +28,8 @@ StandaloneCastEnvironment::StandaloneCastEnvironment( CREATE_TASK_RUNNER(main, base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); - CREATE_TASK_RUNNER(audio_encode, base::Thread::Options()); - CREATE_TASK_RUNNER(audio_decode, base::Thread::Options()); - CREATE_TASK_RUNNER(video_encode, base::Thread::Options()); - CREATE_TASK_RUNNER(video_decode, base::Thread::Options()); + CREATE_TASK_RUNNER(audio, base::Thread::Options()); + CREATE_TASK_RUNNER(video, base::Thread::Options()); CREATE_TASK_RUNNER(transport, base::Thread::Options()); #undef CREATE_TASK_RUNNER @@ -48,10 +42,8 @@ StandaloneCastEnvironment::~StandaloneCastEnvironment() { void StandaloneCastEnvironment::Shutdown() { DCHECK(CalledOnValidThread()); main_thread_.Stop(); - audio_encode_thread_.Stop(); - audio_decode_thread_.Stop(); - video_encode_thread_.Stop(); - video_decode_thread_.Stop(); + audio_thread_.Stop(); + video_thread_.Stop(); transport_thread_.Stop(); } diff --git a/media/cast/test/utility/standalone_cast_environment.h b/media/cast/test/utility/standalone_cast_environment.h index 39c6e7ca2c5f27..a16e04eb225097 100644 --- a/media/cast/test/utility/standalone_cast_environment.h +++ b/media/cast/test/utility/standalone_cast_environment.h @@ -27,10 +27,8 @@ class StandaloneCastEnvironment : public CastEnvironment, virtual ~StandaloneCastEnvironment(); base::Thread main_thread_; - base::Thread audio_encode_thread_; - base::Thread audio_decode_thread_; - base::Thread video_encode_thread_; - base::Thread video_decode_thread_; + base::Thread audio_thread_; + base::Thread video_thread_; base::Thread transport_thread_; DISALLOW_COPY_AND_ASSIGN(StandaloneCastEnvironment); diff --git a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc index 02b94b37fad7a7..e0f45de0421456 100644 --- a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc +++ b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc @@ -30,7 +30,7 @@ Vp8Decoder::Vp8Decoder(scoped_refptr cast_environment) : cast_environment_(cast_environment) { // Make sure that we initialize the decoder from the correct thread. cast_environment_->PostTask( - CastEnvironment::VIDEO_DECODER, + CastEnvironment::VIDEO, FROM_HERE, base::Bind(&Vp8Decoder::InitDecoder, base::Unretained(this))); } @@ -61,7 +61,7 @@ void Vp8Decoder::InitDecoder() { bool Vp8Decoder::Decode(const transport::EncodedVideoFrame* encoded_frame, const base::TimeTicks render_time, const VideoFrameDecodedCallback& frame_decoded_cb) { - DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO_DECODER)); + DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO)); const int frame_id_int = static_cast(encoded_frame->frame_id); VLOG(2) << "VP8 decode frame:" << frame_id_int << " sized:" << encoded_frame->data.size(); diff --git a/media/cast/video_receiver/video_decoder_unittest.cc b/media/cast/video_receiver/video_decoder_unittest.cc index 105d1fedaa6e74..4b93f34ac3f270 100644 --- a/media/cast/video_receiver/video_decoder_unittest.cc +++ b/media/cast/video_receiver/video_decoder_unittest.cc @@ -52,8 +52,6 @@ class VideoDecoderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastReceiverLoggingConfig())), test_callback_(new DecodeTestFrameCallback()) { // Configure to vp8. diff --git a/media/cast/video_receiver/video_receiver.cc b/media/cast/video_receiver/video_receiver.cc index 5855218178502e..f2331e14a40fac 100644 --- a/media/cast/video_receiver/video_receiver.cc +++ b/media/cast/video_receiver/video_receiver.cc @@ -172,7 +172,7 @@ void VideoReceiver::DecodeVideoFrame( DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); // Hand the ownership of the encoded frame to the decode thread. - cast_environment_->PostTask(CastEnvironment::VIDEO_DECODER, + cast_environment_->PostTask(CastEnvironment::VIDEO, FROM_HERE, base::Bind(&VideoReceiver::DecodeVideoFrameThread, base::Unretained(this), @@ -186,7 +186,7 @@ void VideoReceiver::DecodeVideoFrameThread( scoped_ptr encoded_frame, const base::TimeTicks render_time, const VideoFrameDecodedCallback& frame_decoded_callback) { - DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO_DECODER)); + DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO)); DCHECK(video_decoder_); if (!(video_decoder_->DecodeVideoFrame( diff --git a/media/cast/video_receiver/video_receiver_unittest.cc b/media/cast/video_receiver/video_receiver_unittest.cc index 04a7f9d667f9b8..8e0aeba5230426 100644 --- a/media/cast/video_receiver/video_receiver_unittest.cc +++ b/media/cast/video_receiver/video_receiver_unittest.cc @@ -83,8 +83,6 @@ class VideoReceiverTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetLoggingConfigWithRawEventsAndStatsEnabled()); receiver_.reset(new PeerVideoReceiver( cast_environment_, config_, &mock_transport_, target_delay_cb_)); diff --git a/media/cast/video_sender/external_video_encoder_unittest.cc b/media/cast/video_sender/external_video_encoder_unittest.cc index 8f9b2f7f66dea7..773306b4cbab79 100644 --- a/media/cast/video_sender/external_video_encoder_unittest.cc +++ b/media/cast/video_sender/external_video_encoder_unittest.cc @@ -94,8 +94,6 @@ class ExternalVideoEncoderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastSenderLoggingConfig()); video_encoder_.reset(new ExternalVideoEncoder( cast_environment_, diff --git a/media/cast/video_sender/video_encoder_impl.cc b/media/cast/video_sender/video_encoder_impl.cc index bd5281df60e70a..854f8c436b2721 100644 --- a/media/cast/video_sender/video_encoder_impl.cc +++ b/media/cast/video_sender/video_encoder_impl.cc @@ -23,7 +23,7 @@ typedef base::Callback PassEncoderCallback; void InitializeVp8EncoderOnEncoderThread( const scoped_refptr& environment, Vp8Encoder* vp8_encoder) { - DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO_ENCODER)); + DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO)); vp8_encoder->Initialize(); } @@ -34,7 +34,7 @@ void EncodeVideoFrameOnEncoderThread( const base::TimeTicks& capture_time, const VideoEncoderImpl::CodecDynamicConfig& dynamic_config, const VideoEncoderImpl::FrameEncodedCallback& frame_encoded_callback) { - DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO_ENCODER)); + DCHECK(environment->CurrentlyOn(CastEnvironment::VIDEO)); if (dynamic_config.key_frame_requested) { vp8_encoder->GenerateKeyFrame(); } @@ -74,7 +74,7 @@ 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, + cast_environment_->PostTask(CastEnvironment::VIDEO, FROM_HERE, base::Bind(&InitializeVp8EncoderOnEncoderThread, cast_environment, @@ -92,7 +92,7 @@ VideoEncoderImpl::~VideoEncoderImpl() { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); if (vp8_encoder_) { cast_environment_->PostTask( - CastEnvironment::VIDEO_ENCODER, + CastEnvironment::VIDEO, FROM_HERE, base::Bind(&base::DeletePointer, vp8_encoder_.release())); } @@ -117,7 +117,7 @@ bool VideoEncoderImpl::EncodeVideoFrame( kVideoFrameSentToEncoder, GetVideoRtpTimestamp(capture_time), kFrameIdUnknown); - cast_environment_->PostTask(CastEnvironment::VIDEO_ENCODER, + cast_environment_->PostTask(CastEnvironment::VIDEO, FROM_HERE, base::Bind(&EncodeVideoFrameOnEncoderThread, cast_environment_, diff --git a/media/cast/video_sender/video_encoder_impl_unittest.cc b/media/cast/video_sender/video_encoder_impl_unittest.cc index 6efcd6f22b63e0..9cfa2f4f432cf7 100644 --- a/media/cast/video_sender/video_encoder_impl_unittest.cc +++ b/media/cast/video_sender/video_encoder_impl_unittest.cc @@ -96,8 +96,6 @@ class VideoEncoderImplTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, GetDefaultCastSenderLoggingConfig()); } diff --git a/media/cast/video_sender/video_sender_unittest.cc b/media/cast/video_sender/video_sender_unittest.cc index 8847013fabe7a5..fde04e3f1227b7 100644 --- a/media/cast/video_sender/video_sender_unittest.cc +++ b/media/cast/video_sender/video_sender_unittest.cc @@ -89,8 +89,6 @@ class VideoSenderTest : public ::testing::Test { task_runner_, task_runner_, task_runner_, - task_runner_, - task_runner_, logging_config); transport::CastTransportVideoConfig transport_config; net::IPEndPoint dummy_endpoint;