| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/media/cast_session.h" | 5 #include "chrome/renderer/media/cast_session.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "chrome/renderer/media/cast_session_delegate.h" | 8 #include "chrome/renderer/media/cast_session_delegate.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "media/base/bind_to_current_loop.h" | 10 #include "media/base/bind_to_current_loop.h" |
| 11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
| 12 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
| 13 #include "media/cast/cast_sender.h" | 13 #include "media/cast/cast_sender.h" |
| 14 #include "media/cast/logging/logging_defines.h" | 14 #include "media/cast/logging/logging_defines.h" |
| 15 | 15 |
| 16 CastSession::CastSession() | 16 CastSession::CastSession() |
| 17 : delegate_(new CastSessionDelegate()), | 17 : delegate_(new CastSessionDelegate()), |
| 18 io_message_loop_proxy_( | 18 io_message_loop_proxy_( |
| 19 content::RenderThread::Get()->GetIOMessageLoopProxy()) {} | 19 content::RenderThread::Get()->GetIOMessageLoopProxy()) {} |
| 20 | 20 |
| 21 CastSession::~CastSession() { | 21 CastSession::~CastSession() { |
| 22 // We should always be able to delete the object on the IO thread. | 22 // We should always be able to delete the object on the IO thread. |
| 23 CHECK(io_message_loop_proxy_->DeleteSoon(FROM_HERE, delegate_.release())); | 23 CHECK(io_message_loop_proxy_->DeleteSoon(FROM_HERE, delegate_.release())); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void CastSession::StartAudio(const media::cast::AudioSenderConfig& config, | 26 void CastSession::StartAudio(const media::cast::AudioSenderConfig& config, |
| 27 const FrameInputAvailableCallback& callback) { | 27 const AudioFrameInputAvailableCallback& callback) { |
| 28 DCHECK(content::RenderThread::Get() | 28 DCHECK(content::RenderThread::Get() |
| 29 ->GetMessageLoop() | 29 ->GetMessageLoop() |
| 30 ->message_loop_proxy() | 30 ->message_loop_proxy() |
| 31 ->BelongsToCurrentThread()); | 31 ->BelongsToCurrentThread()); |
| 32 | 32 |
| 33 io_message_loop_proxy_->PostTask( | 33 io_message_loop_proxy_->PostTask( |
| 34 FROM_HERE, | 34 FROM_HERE, |
| 35 base::Bind(&CastSessionDelegate::StartAudio, | 35 base::Bind(&CastSessionDelegate::StartAudio, |
| 36 base::Unretained(delegate_.get()), | 36 base::Unretained(delegate_.get()), |
| 37 config, | 37 config, |
| 38 media::BindToCurrentLoop(callback))); | 38 media::BindToCurrentLoop(callback))); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config, | 41 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config, |
| 42 const FrameInputAvailableCallback& callback) { | 42 const VideoFrameInputAvailableCallback& callback) { |
| 43 DCHECK(content::RenderThread::Get() | 43 DCHECK(content::RenderThread::Get() |
| 44 ->GetMessageLoop() | 44 ->GetMessageLoop() |
| 45 ->message_loop_proxy() | 45 ->message_loop_proxy() |
| 46 ->BelongsToCurrentThread()); | 46 ->BelongsToCurrentThread()); |
| 47 | 47 |
| 48 io_message_loop_proxy_->PostTask( | 48 io_message_loop_proxy_->PostTask( |
| 49 FROM_HERE, | 49 FROM_HERE, |
| 50 base::Bind(&CastSessionDelegate::StartVideo, | 50 base::Bind(&CastSessionDelegate::StartVideo, |
| 51 base::Unretained(delegate_.get()), | 51 base::Unretained(delegate_.get()), |
| 52 config, | 52 config, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 void CastSession::GetStatsAndReset(bool is_audio, | 86 void CastSession::GetStatsAndReset(bool is_audio, |
| 87 const StatsCallback& callback) { | 87 const StatsCallback& callback) { |
| 88 io_message_loop_proxy_->PostTask( | 88 io_message_loop_proxy_->PostTask( |
| 89 FROM_HERE, | 89 FROM_HERE, |
| 90 base::Bind(&CastSessionDelegate::GetStatsAndReset, | 90 base::Bind(&CastSessionDelegate::GetStatsAndReset, |
| 91 base::Unretained(delegate_.get()), | 91 base::Unretained(delegate_.get()), |
| 92 is_audio, | 92 is_audio, |
| 93 media::BindToCurrentLoop(callback))); | 93 media::BindToCurrentLoop(callback))); |
| 94 } | 94 } |
| OLD | NEW |