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 4be9fe3ba02ca593dcf6d86fe87406ea2a74ee8c..506e403d11bde175e790cc67202b44d5f3b33a60 100644 |
| --- a/chrome/renderer/media/cast_session_delegate.cc |
| +++ b/chrome/renderer/media/cast_session_delegate.cc |
| @@ -31,13 +31,55 @@ using media::cast::VideoSenderConfig; |
| static base::LazyInstance<CastThreads> g_cast_threads = |
| LAZY_INSTANCE_INITIALIZER; |
| -CastSessionDelegate::CastSessionDelegate() |
| +CastSessionDelegateBase::CastSessionDelegateBase() |
| : io_message_loop_proxy_( |
| content::RenderThread::Get()->GetIOMessageLoopProxy()), |
| weak_factory_(this) { |
| DCHECK(io_message_loop_proxy_.get()); |
| } |
| +CastSessionDelegateBase::~CastSessionDelegateBase() { |
| + DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| +} |
| + |
| +void CastSessionDelegateBase::StartUDP( |
| + const net::IPEndPoint& local_endpoint, |
| + const net::IPEndPoint& remote_endpoint, |
| + scoped_ptr<base::DictionaryValue> options) { |
| + DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| + |
| + // CastSender uses the renderer's IO thread as the main thread. This reduces |
| + // thread hopping for incoming video frames and outgoing network packets. |
| + cast_environment_ = new CastEnvironment( |
|
miu
2015/02/11 02:52:50
This is a little weird. I would expect the CastEn
hubbe
2015/02/11 22:38:17
This is simply replicating existing (but perhaps s
|
| + scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(), |
| + base::MessageLoopProxy::current(), |
| + g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(), |
| + g_cast_threads.Get().GetVideoEncodeMessageLoopProxy()); |
| + |
| + // Rationale for using unretained: The callback cannot be called after the |
| + // destruction of CastTransportSenderIPC, and they both share the same thread. |
| + cast_transport_.reset(new CastTransportSenderIPC( |
| + local_endpoint, |
| + remote_endpoint, |
| + options.Pass(), |
| + media::cast::PacketReceiverCallback(), |
| + base::Bind(&CastSessionDelegateBase::StatusNotificationCB, |
| + base::Unretained(this)), |
| + base::Bind(&CastSessionDelegateBase::LogRawEvents, |
| + base::Unretained(this)))); |
| +} |
| + |
| +void CastSessionDelegateBase::StatusNotificationCB( |
| + media::cast::CastTransportStatus unused_status) { |
| + DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| + // TODO(hubbe): Call javascript UDPTransport error function. |
| +} |
| + |
| +CastSessionDelegate::CastSessionDelegate() |
| + : weak_factory_(this) { |
| + DCHECK(io_message_loop_proxy_.get()); |
| +} |
| + |
| CastSessionDelegate::~CastSessionDelegate() { |
| DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| } |
| @@ -84,32 +126,18 @@ void CastSessionDelegate::StartVideo( |
| create_video_encode_mem_cb); |
| } |
| -void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint, |
| - scoped_ptr<base::DictionaryValue> options) { |
| - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| - |
| - // CastSender uses the renderer's IO thread as the main thread. This reduces |
| - // thread hopping for incoming video frames and outgoing network packets. |
| - cast_environment_ = new CastEnvironment( |
| - scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(), |
| - base::MessageLoopProxy::current(), |
| - g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(), |
| - g_cast_threads.Get().GetVideoEncodeMessageLoopProxy()); |
| +void CastSessionDelegate::StartUDP( |
| + const net::IPEndPoint& local_endpoint, |
| + const net::IPEndPoint& remote_endpoint, |
| + scoped_ptr<base::DictionaryValue> options) { |
| + DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| + CastSessionDelegateBase::StartUDP(local_endpoint, |
| + remote_endpoint, |
| + options.Pass()); |
| event_subscribers_.reset( |
| new media::cast::RawEventSubscriberBundle(cast_environment_)); |
| - // Rationale for using unretained: The callback cannot be called after the |
| - // destruction of CastTransportSenderIPC, and they both share the same thread. |
| - cast_transport_.reset(new CastTransportSenderIPC( |
| - net::IPEndPoint(), |
| - remote_endpoint, |
| - options.Pass(), |
| - media::cast::PacketReceiverCallback(), |
| - base::Bind(&CastSessionDelegate::StatusNotificationCB, |
| - base::Unretained(this)), |
| - base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this)))); |
| - |
| cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get()); |
| } |
| @@ -202,12 +230,6 @@ void CastSessionDelegate::GetStatsAndReset(bool is_audio, |
| callback.Run(stats.Pass()); |
| } |
| -void CastSessionDelegate::StatusNotificationCB( |
| - media::cast::CastTransportStatus unused_status) { |
| - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| - // TODO(hubbe): Call javascript UDPTransport error function. |
| -} |
| - |
| void CastSessionDelegate::OnOperationalStatusChange( |
| bool is_for_audio, |
| const ErrorCallback& error_callback, |