| 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 d44a62b34c30fdb7995fd28776fc8e9afcaecc2c..164f3016ccdc293cdfe841931df3ee5d0316c420 100644
|
| --- a/chrome/renderer/media/cast_session_delegate.cc
|
| +++ b/chrome/renderer/media/cast_session_delegate.cc
|
| @@ -29,13 +29,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(
|
| + 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());
|
| }
|
| @@ -82,32 +124,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());
|
| }
|
|
|
| @@ -200,12 +228,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::InitializationResultCB(
|
| const ErrorCallback& error_callback,
|
| media::cast::CastInitializationStatus result) const {
|
|
|