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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Rationale for using unretained: The callback cannot be called after the | 99 // Rationale for using unretained: The callback cannot be called after the |
100 // destruction of CastTransportSenderIPC, and they both share the same thread. | 100 // destruction of CastTransportSenderIPC, and they both share the same thread. |
101 cast_transport_.reset(new CastTransportSenderIPC( | 101 cast_transport_.reset(new CastTransportSenderIPC( |
102 remote_endpoint, | 102 remote_endpoint, |
103 base::Bind(&CastSessionDelegate::StatusNotificationCB, | 103 base::Bind(&CastSessionDelegate::StatusNotificationCB, |
104 base::Unretained(this)), | 104 base::Unretained(this)), |
105 base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this)))); | 105 base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this)))); |
106 | 106 |
107 cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get()); | 107 cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get()); |
108 cast_transport_->SetPacketReceiver(cast_sender_->packet_receiver()); | |
109 } | 108 } |
110 | 109 |
111 void CastSessionDelegate::ToggleLogging(bool is_audio, bool enable) { | 110 void CastSessionDelegate::ToggleLogging(bool is_audio, bool enable) { |
112 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 111 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
113 if (!event_subscribers_.get()) | 112 if (!event_subscribers_.get()) |
114 return; | 113 return; |
115 | 114 |
116 if (enable) | 115 if (enable) |
117 event_subscribers_->AddEventSubscribers(is_audio); | 116 event_subscribers_->AddEventSubscribers(is_audio); |
118 else | 117 else |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (result == media::cast::STATUS_AUDIO_INITIALIZED) { | 210 if (result == media::cast::STATUS_AUDIO_INITIALIZED) { |
212 audio_frame_input_available_callback_.Run( | 211 audio_frame_input_available_callback_.Run( |
213 cast_sender_->audio_frame_input()); | 212 cast_sender_->audio_frame_input()); |
214 } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) { | 213 } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) { |
215 video_frame_input_available_callback_.Run( | 214 video_frame_input_available_callback_.Run( |
216 cast_sender_->video_frame_input()); | 215 cast_sender_->video_frame_input()); |
217 } | 216 } |
218 } | 217 } |
219 | 218 |
220 void CastSessionDelegate::LogRawEvents( | 219 void CastSessionDelegate::LogRawEvents( |
221 const std::vector<media::cast::PacketEvent>& packet_events) { | 220 const std::vector<media::cast::PacketEvent>& packet_events, |
| 221 const std::vector<media::cast::FrameEvent>& frame_events) { |
222 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 222 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
223 | 223 |
224 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 224 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
225 packet_events.begin(); | 225 packet_events.begin(); |
226 it != packet_events.end(); | 226 it != packet_events.end(); |
227 ++it) { | 227 ++it) { |
228 cast_environment_->Logging()->InsertPacketEvent(it->timestamp, | 228 cast_environment_->Logging()->InsertPacketEvent(it->timestamp, |
229 it->type, | 229 it->type, |
230 it->media_type, | 230 it->media_type, |
231 it->rtp_timestamp, | 231 it->rtp_timestamp, |
232 it->frame_id, | 232 it->frame_id, |
233 it->packet_id, | 233 it->packet_id, |
234 it->max_packet_id, | 234 it->max_packet_id, |
235 it->size); | 235 it->size); |
236 } | 236 } |
| 237 for (std::vector<media::cast::FrameEvent>::const_iterator it = |
| 238 frame_events.begin(); |
| 239 it != frame_events.end(); |
| 240 ++it) { |
| 241 cast_environment_->Logging()->InsertFrameEvent(it->timestamp, |
| 242 it->type, |
| 243 it->media_type, |
| 244 it->rtp_timestamp, |
| 245 it->frame_id); |
| 246 } |
237 } | 247 } |
OLD | NEW |