| 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/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
| 11 | 11 |
| 12 CastSession::CastSession() | 12 CastSession::CastSession() |
| 13 : delegate_(new CastSessionDelegate()), | 13 : delegate_(new CastSessionDelegate()), |
| 14 io_message_loop_proxy_( | 14 io_message_loop_proxy_( |
| 15 content::RenderThread::Get()->GetIOMessageLoopProxy()) { | 15 content::RenderThread::Get()->GetIOMessageLoopProxy()) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 CastSession::~CastSession() { | 18 CastSession::~CastSession() { |
| 19 // We should always be able to delete the object on the IO thread. | 19 // We should always be able to delete the object on the IO thread. |
| 20 CHECK(io_message_loop_proxy_->DeleteSoon(FROM_HERE, delegate_.release())); | 20 CHECK(io_message_loop_proxy_->DeleteSoon(FROM_HERE, delegate_.release())); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void CastSession::SetSocketFactory(scoped_ptr<SocketFactory> socket_factory, |
| 24 const net::IPEndPoint& remote_address) { |
| 25 io_message_loop_proxy_->PostTask( |
| 26 FROM_HERE, |
| 27 base::Bind(&CastSessionDelegate::SetSocketFactory, |
| 28 base::Unretained(delegate_.get()), |
| 29 base::Passed(socket_factory.Pass()), |
| 30 remote_address)); |
| 31 } |
| 32 |
| 33 CastSession::SocketFactory::~SocketFactory() {} |
| 34 |
| 23 void CastSession::StartAudio(const media::cast::AudioSenderConfig& config) { | 35 void CastSession::StartAudio(const media::cast::AudioSenderConfig& config) { |
| 24 io_message_loop_proxy_->PostTask(FROM_HERE, | 36 io_message_loop_proxy_->PostTask(FROM_HERE, |
| 25 base::Bind(&CastSessionDelegate::StartAudio, | 37 base::Bind(&CastSessionDelegate::StartAudio, |
| 26 base::Unretained(delegate_.get()), | 38 base::Unretained(delegate_.get()), |
| 27 config)); | 39 config)); |
| 28 } | 40 } |
| 29 | 41 |
| 30 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config) { | 42 void CastSession::StartVideo(const media::cast::VideoSenderConfig& config) { |
| 31 io_message_loop_proxy_->PostTask(FROM_HERE, | 43 io_message_loop_proxy_->PostTask(FROM_HERE, |
| 32 base::Bind(&CastSessionDelegate::StartVideo, | 44 base::Bind(&CastSessionDelegate::StartVideo, |
| 33 base::Unretained(delegate_.get()), | 45 base::Unretained(delegate_.get()), |
| 34 config)); | 46 config)); |
| 35 } | 47 } |
| OLD | NEW |