Chromium Code Reviews| Index: chrome/renderer/media/cast_session_delegate.cc |
| diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc |
| index 5da3443f493cb3339e0c6ce789e1a66776af4f78..f014638a9775029f5273664a0fad55d32ca8930f 100644 |
| --- a/chrome/renderer/media/cast_session_delegate.cc |
| +++ b/chrome/renderer/media/cast_session_delegate.cc |
| @@ -70,15 +70,6 @@ CastSessionDelegate::CastSessionDelegate() |
| video_encode_thread_("CastVideoEncodeThread"), |
| io_message_loop_proxy_( |
| content::RenderThread::Get()->GetIOMessageLoopProxy()) { |
| -} |
| - |
| -CastSessionDelegate::~CastSessionDelegate() { |
| - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| -} |
| - |
| -void CastSessionDelegate::Initialize() { |
| - if (cast_environment_) |
| - return; // Already initialized. |
| cast_transport_.reset(new DummyTransport()); |
| audio_encode_thread_.Start(); |
| @@ -97,6 +88,15 @@ void CastSessionDelegate::Initialize() { |
| NULL, |
| base::MessageLoopProxy::current(), |
| media::cast::GetDefaultCastSenderLoggingConfig()); |
| + cast_sender_.reset(CastSender::CreateCastSender( |
| + cast_environment_, |
| + base::Bind(&CastSessionDelegate::InitializationResult, |
| + base::Unretained(this)), |
|
Ami GONE FROM CHROMIUM
2014/02/13 18:02:14
What makes this Unretained safe?
Is it that this b
Alpha Left Google
2014/02/13 19:53:59
I too this this needs an explanation.
Please make
mikhal1
2014/02/14 18:03:16
Switching to a weak ptr.
On 2014/02/13 19:53:59, A
|
| + cast_transport_.get())); |
| +} |
| + |
| +CastSessionDelegate::~CastSessionDelegate() { |
| + DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| } |
| void CastSessionDelegate::StartAudio( |
| @@ -104,8 +104,9 @@ void CastSessionDelegate::StartAudio( |
| const FrameInputAvailableCallback& callback) { |
| DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| - audio_config_.reset(new AudioSenderConfig(config)); |
| - StartSendingInternal(callback, true); |
| + cast_sender_->InitializeAudio(config); |
| + audio_frame_input_available_callback_.reset( |
| + new FrameInputAvailableCallback(callback)); |
| } |
| void CastSessionDelegate::StartVideo( |
| @@ -113,33 +114,10 @@ void CastSessionDelegate::StartVideo( |
| const FrameInputAvailableCallback& callback) { |
| DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| - video_config_.reset(new VideoSenderConfig(config)); |
| - StartSendingInternal(callback, false); |
| -} |
| - |
| -void CastSessionDelegate::StartSendingInternal( |
| - const FrameInputAvailableCallback& callback, |
| - bool is_audio) { |
| - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| - |
| - Initialize(); |
| - |
| - if (is_audio) { |
| - audio_frame_input_available_callback_.reset( |
| - new FrameInputAvailableCallback(callback)); |
| - } else { |
| - video_frame_input_available_callback_.reset( |
| + // Initialize video - set gpu to NULL. |
| + cast_sender_->InitializeVideo(config, NULL); |
| + video_frame_input_available_callback_.reset( |
| new FrameInputAvailableCallback(callback)); |
| - } |
| - |
| - cast_sender_.reset(CastSender::CreateCastSender( |
| - cast_environment_, |
| - audio_config_.get(), |
| - video_config_.get(), |
| - NULL, // GPU. |
| - base::Bind(&CastSessionDelegate::InitializationResult, |
| - base::Unretained(this)), |
| - cast_transport_.get())); |
| } |
| void CastSessionDelegate::InitializationResult( |
| @@ -147,12 +125,11 @@ void CastSessionDelegate::InitializationResult( |
| DCHECK(cast_sender_); |
| // TODO(pwestin): handle the error codes. |
| - if (result == media::cast::STATUS_INITIALIZED) { |
| - if (audio_frame_input_available_callback_) { |
| + if (result == media::cast::STATUS_AUDIO_INITIALIZED) { |
| + if (audio_frame_input_available_callback_) |
| audio_frame_input_available_callback_->Run(cast_sender_->frame_input()); |
| - } |
| - if (video_frame_input_available_callback_) { |
| + } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) { |
| + if (video_frame_input_available_callback_) |
| video_frame_input_available_callback_->Run(cast_sender_->frame_input()); |
| - } |
| } |
| } |