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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/renderer/media/cast_threads.h" | 19 #include "chrome/renderer/media/cast_threads.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 event_subscribers_->RemoveEventSubscribers(is_audio); | 201 event_subscribers_->RemoveEventSubscribers(is_audio); |
201 } | 202 } |
202 | 203 |
203 void CastSessionDelegate::GetEventLogsAndReset( | 204 void CastSessionDelegate::GetEventLogsAndReset( |
204 bool is_audio, | 205 bool is_audio, |
205 const std::string& extra_data, | 206 const std::string& extra_data, |
206 const EventLogsCallback& callback) { | 207 const EventLogsCallback& callback) { |
207 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 208 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
208 | 209 |
209 if (!event_subscribers_.get()) { | 210 if (!event_subscribers_.get()) { |
210 callback.Run(base::MakeUnique<base::BinaryValue>()); | 211 callback.Run(base::MakeUnique<base::Value>(base::Value::Type::BINARY)); |
211 return; | 212 return; |
212 } | 213 } |
213 | 214 |
214 media::cast::EncodingEventSubscriber* subscriber = | 215 media::cast::EncodingEventSubscriber* subscriber = |
215 event_subscribers_->GetEncodingEventSubscriber(is_audio); | 216 event_subscribers_->GetEncodingEventSubscriber(is_audio); |
216 if (!subscriber) { | 217 if (!subscriber) { |
217 callback.Run(base::MakeUnique<base::BinaryValue>()); | 218 callback.Run(base::MakeUnique<base::Value>(base::Value::Type::BINARY)); |
218 return; | 219 return; |
219 } | 220 } |
220 | 221 |
221 media::cast::proto::LogMetadata metadata; | 222 media::cast::proto::LogMetadata metadata; |
222 media::cast::FrameEventList frame_events; | 223 media::cast::FrameEventList frame_events; |
223 media::cast::PacketEventList packet_events; | 224 media::cast::PacketEventList packet_events; |
224 | 225 |
225 subscriber->GetEventsAndReset(&metadata, &frame_events, &packet_events); | 226 subscriber->GetEventsAndReset(&metadata, &frame_events, &packet_events); |
226 | 227 |
227 if (!extra_data.empty()) | 228 if (!extra_data.empty()) |
(...skipping 10 matching lines...) Expand all Loading... |
238 bool success = media::cast::SerializeEvents(metadata, | 239 bool success = media::cast::SerializeEvents(metadata, |
239 frame_events, | 240 frame_events, |
240 packet_events, | 241 packet_events, |
241 true, | 242 true, |
242 media::cast::kMaxSerializedBytes, | 243 media::cast::kMaxSerializedBytes, |
243 serialized_log.get(), | 244 serialized_log.get(), |
244 &output_bytes); | 245 &output_bytes); |
245 | 246 |
246 if (!success) { | 247 if (!success) { |
247 DVLOG(2) << "Failed to serialize event log."; | 248 DVLOG(2) << "Failed to serialize event log."; |
248 callback.Run(base::MakeUnique<base::BinaryValue>()); | 249 callback.Run(base::MakeUnique<base::Value>(base::Value::Type::BINARY)); |
249 return; | 250 return; |
250 } | 251 } |
251 | 252 |
252 DVLOG(2) << "Serialized log length: " << output_bytes; | 253 DVLOG(2) << "Serialized log length: " << output_bytes; |
253 | 254 |
254 std::unique_ptr<base::BinaryValue> blob( | 255 auto blob = base::MakeUnique<base::BinaryValue>(std::vector<char>( |
255 new base::BinaryValue(std::move(serialized_log), output_bytes)); | 256 serialized_log.get(), serialized_log.get() + output_bytes)); |
256 callback.Run(std::move(blob)); | 257 callback.Run(std::move(blob)); |
257 } | 258 } |
258 | 259 |
259 void CastSessionDelegate::GetStatsAndReset(bool is_audio, | 260 void CastSessionDelegate::GetStatsAndReset(bool is_audio, |
260 const StatsCallback& callback) { | 261 const StatsCallback& callback) { |
261 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 262 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
262 | 263 |
263 if (!event_subscribers_.get()) { | 264 if (!event_subscribers_.get()) { |
264 callback.Run(base::MakeUnique<base::DictionaryValue>()); | 265 callback.Run(base::MakeUnique<base::DictionaryValue>()); |
265 return; | 266 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 error_callback.Run(base::StringPrintf("%s codec runtime error.", | 325 error_callback.Run(base::StringPrintf("%s codec runtime error.", |
325 is_for_audio ? "Audio" : "Video")); | 326 is_for_audio ? "Audio" : "Video")); |
326 break; | 327 break; |
327 } | 328 } |
328 } | 329 } |
329 | 330 |
330 void CastSessionDelegate::ReceivePacket( | 331 void CastSessionDelegate::ReceivePacket( |
331 std::unique_ptr<media::cast::Packet> packet) { | 332 std::unique_ptr<media::cast::Packet> packet) { |
332 // Do nothing (frees packet) | 333 // Do nothing (frees packet) |
333 } | 334 } |
OLD | NEW |