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/renderer/media/cast_threads.h" | 10 #include "chrome/renderer/media/cast_threads.h" |
11 #include "chrome/renderer/media/cast_transport_sender_ipc.h" | 11 #include "chrome/renderer/media/cast_transport_sender_ipc.h" |
12 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
13 #include "media/cast/cast_config.h" | 13 #include "media/cast/cast_config.h" |
14 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
15 #include "media/cast/cast_sender.h" | 15 #include "media/cast/cast_sender.h" |
16 #include "media/cast/logging/encoding_event_subscriber.h" | 16 #include "media/cast/logging/encoding_event_subscriber.h" |
17 #include "media/cast/logging/log_serializer.h" | 17 #include "media/cast/logging/log_serializer.h" |
18 #include "media/cast/logging/logging_defines.h" | 18 #include "media/cast/logging/logging_defines.h" |
| 19 #include "media/cast/logging/stats_serializer.h" |
19 #include "media/cast/transport/cast_transport_config.h" | 20 #include "media/cast/transport/cast_transport_config.h" |
20 #include "media/cast/transport/cast_transport_sender.h" | 21 #include "media/cast/transport/cast_transport_sender.h" |
21 | 22 |
22 using media::cast::AudioSenderConfig; | 23 using media::cast::AudioSenderConfig; |
23 using media::cast::CastEnvironment; | 24 using media::cast::CastEnvironment; |
24 using media::cast::CastSender; | 25 using media::cast::CastSender; |
25 using media::cast::VideoSenderConfig; | 26 using media::cast::VideoSenderConfig; |
26 | 27 |
27 static base::LazyInstance<CastThreads> g_cast_threads = | 28 static base::LazyInstance<CastThreads> g_cast_threads = |
28 LAZY_INSTANCE_INITIALIZER; | 29 LAZY_INSTANCE_INITIALIZER; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return; | 176 return; |
176 } | 177 } |
177 | 178 |
178 scoped_ptr<std::string> serialized_log = | 179 scoped_ptr<std::string> serialized_log = |
179 log_serializer.GetSerializedLogAndReset(); | 180 log_serializer.GetSerializedLogAndReset(); |
180 DVLOG(2) << "Serialized log length: " << serialized_log->size(); | 181 DVLOG(2) << "Serialized log length: " << serialized_log->size(); |
181 | 182 |
182 callback.Run(serialized_log.Pass()); | 183 callback.Run(serialized_log.Pass()); |
183 } | 184 } |
184 | 185 |
| 186 void CastSessionDelegate::GetStatsAndReset(bool is_audio, |
| 187 const StatsCallback& callback) { |
| 188 media::cast::FrameStatsMap frame_stats = |
| 189 cast_environment_->Logging()->GetFrameStatsData( |
| 190 is_audio ? media::cast::AUDIO_EVENT : media::cast::VIDEO_EVENT); |
| 191 media::cast::PacketStatsMap packet_stats = |
| 192 cast_environment_->Logging()->GetPacketStatsData( |
| 193 is_audio ? media::cast::AUDIO_EVENT : media::cast::VIDEO_EVENT); |
| 194 scoped_ptr<std::string> result(new std::string); |
| 195 bool success = |
| 196 media::cast::SerializeStats(frame_stats, packet_stats, result.get()); |
| 197 if (!success) { |
| 198 VLOG(2) << "Failed to serialized stats."; |
| 199 callback.Run(make_scoped_ptr(new std::string).Pass()); |
| 200 return; |
| 201 } |
| 202 |
| 203 callback.Run(result.Pass()); |
| 204 } |
| 205 |
185 void CastSessionDelegate::StatusNotificationCB( | 206 void CastSessionDelegate::StatusNotificationCB( |
186 media::cast::transport::CastTransportStatus unused_status) { | 207 media::cast::transport::CastTransportStatus unused_status) { |
187 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 208 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
188 // TODO(hubbe): Call javascript UDPTransport error function. | 209 // TODO(hubbe): Call javascript UDPTransport error function. |
189 } | 210 } |
190 | 211 |
191 void CastSessionDelegate::StartSendingInternal() { | 212 void CastSessionDelegate::StartSendingInternal() { |
192 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 213 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
193 | 214 |
194 // No transport, wait. | 215 // No transport, wait. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 if (result == media::cast::STATUS_INITIALIZED) { | 264 if (result == media::cast::STATUS_INITIALIZED) { |
244 if (!audio_frame_input_available_callback_.is_null()) { | 265 if (!audio_frame_input_available_callback_.is_null()) { |
245 audio_frame_input_available_callback_.Run(cast_sender_->frame_input()); | 266 audio_frame_input_available_callback_.Run(cast_sender_->frame_input()); |
246 } | 267 } |
247 if (!video_frame_input_available_callback_.is_null()) { | 268 if (!video_frame_input_available_callback_.is_null()) { |
248 video_frame_input_available_callback_.Run(cast_sender_->frame_input()); | 269 video_frame_input_available_callback_.Run(cast_sender_->frame_input()); |
249 } | 270 } |
250 } | 271 } |
251 } | 272 } |
252 | 273 |
OLD | NEW |