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_delegate.h" | 5 #include "chrome/renderer/media/cast_session_delegate.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "chrome/common/chrome_version_info.h" | 10 #include "chrome/common/chrome_version_info.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 video_frame_input_available_callback_ = callback; | 75 video_frame_input_available_callback_ = callback; |
76 | 76 |
77 cast_sender_->InitializeVideo( | 77 cast_sender_->InitializeVideo( |
78 config, | 78 config, |
79 base::Bind(&CastSessionDelegate::InitializationResultCB, | 79 base::Bind(&CastSessionDelegate::InitializationResultCB, |
80 weak_factory_.GetWeakPtr()), | 80 weak_factory_.GetWeakPtr()), |
81 create_vea_cb, | 81 create_vea_cb, |
82 create_video_encode_mem_cb); | 82 create_video_encode_mem_cb); |
83 } | 83 } |
84 | 84 |
85 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) { | 85 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint, |
| 86 const std::string& options) { |
86 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 87 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
87 | 88 |
88 // CastSender uses the renderer's IO thread as the main thread. This reduces | 89 // CastSender uses the renderer's IO thread as the main thread. This reduces |
89 // thread hopping for incoming video frames and outgoing network packets. | 90 // thread hopping for incoming video frames and outgoing network packets. |
90 cast_environment_ = new CastEnvironment( | 91 cast_environment_ = new CastEnvironment( |
91 scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(), | 92 scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(), |
92 base::MessageLoopProxy::current(), | 93 base::MessageLoopProxy::current(), |
93 g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(), | 94 g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(), |
94 g_cast_threads.Get().GetVideoEncodeMessageLoopProxy()); | 95 g_cast_threads.Get().GetVideoEncodeMessageLoopProxy()); |
95 | 96 |
96 event_subscribers_.reset( | 97 event_subscribers_.reset( |
97 new media::cast::RawEventSubscriberBundle(cast_environment_)); | 98 new media::cast::RawEventSubscriberBundle(cast_environment_)); |
98 | 99 |
99 // Rationale for using unretained: The callback cannot be called after the | 100 // Rationale for using unretained: The callback cannot be called after the |
100 // destruction of CastTransportSenderIPC, and they both share the same thread. | 101 // destruction of CastTransportSenderIPC, and they both share the same thread. |
101 cast_transport_.reset(new CastTransportSenderIPC( | 102 cast_transport_.reset(new CastTransportSenderIPC( |
102 remote_endpoint, | 103 remote_endpoint, |
| 104 options, |
103 base::Bind(&CastSessionDelegate::StatusNotificationCB, | 105 base::Bind(&CastSessionDelegate::StatusNotificationCB, |
104 base::Unretained(this)), | 106 base::Unretained(this)), |
105 base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this)))); | 107 base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this)))); |
106 | 108 |
107 cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get()); | 109 cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get()); |
108 } | 110 } |
109 | 111 |
110 void CastSessionDelegate::ToggleLogging(bool is_audio, bool enable) { | 112 void CastSessionDelegate::ToggleLogging(bool is_audio, bool enable) { |
111 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 113 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
112 if (!event_subscribers_.get()) | 114 if (!event_subscribers_.get()) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } else { | 251 } else { |
250 cast_environment_->Logging()->InsertFrameEvent( | 252 cast_environment_->Logging()->InsertFrameEvent( |
251 it->timestamp, | 253 it->timestamp, |
252 it->type, | 254 it->type, |
253 it->media_type, | 255 it->media_type, |
254 it->rtp_timestamp, | 256 it->rtp_timestamp, |
255 it->frame_id); | 257 it->frame_id); |
256 } | 258 } |
257 } | 259 } |
258 } | 260 } |
OLD | NEW |