| 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_converter.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 |
| 195 scoped_ptr<base::DictionaryValue> stats = media::cast::ConvertStats( |
| 196 frame_stats, packet_stats); |
| 197 |
| 198 callback.Run(stats.Pass()); |
| 199 } |
| 200 |
| 185 void CastSessionDelegate::StatusNotificationCB( | 201 void CastSessionDelegate::StatusNotificationCB( |
| 186 media::cast::transport::CastTransportStatus unused_status) { | 202 media::cast::transport::CastTransportStatus unused_status) { |
| 187 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 203 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 188 // TODO(hubbe): Call javascript UDPTransport error function. | 204 // TODO(hubbe): Call javascript UDPTransport error function. |
| 189 } | 205 } |
| 190 | 206 |
| 191 void CastSessionDelegate::StartSendingInternal() { | 207 void CastSessionDelegate::StartSendingInternal() { |
| 192 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 208 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 193 | 209 |
| 194 // No transport, wait. | 210 // No transport, wait. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (result == media::cast::STATUS_INITIALIZED) { | 259 if (result == media::cast::STATUS_INITIALIZED) { |
| 244 if (!audio_frame_input_available_callback_.is_null()) { | 260 if (!audio_frame_input_available_callback_.is_null()) { |
| 245 audio_frame_input_available_callback_.Run(cast_sender_->frame_input()); | 261 audio_frame_input_available_callback_.Run(cast_sender_->frame_input()); |
| 246 } | 262 } |
| 247 if (!video_frame_input_available_callback_.is_null()) { | 263 if (!video_frame_input_available_callback_.is_null()) { |
| 248 video_frame_input_available_callback_.Run(cast_sender_->frame_input()); | 264 video_frame_input_available_callback_.Run(cast_sender_->frame_input()); |
| 249 } | 265 } |
| 250 } | 266 } |
| 251 } | 267 } |
| 252 | 268 |
| OLD | NEW |