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 // Test application that simulates a cast sender - Data can be either generated | 5 // Test application that simulates a cast sender - Data can be either generated |
6 // or read from a file. | 6 // or read from a file. |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "base/time/default_tick_clock.h" | 13 #include "base/time/default_tick_clock.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 #include "media/cast/cast_config.h" | 15 #include "media/cast/cast_config.h" |
16 #include "media/cast/cast_environment.h" | 16 #include "media/cast/cast_environment.h" |
17 #include "media/cast/cast_sender.h" | 17 #include "media/cast/cast_sender.h" |
18 #include "media/cast/logging/encoding_event_subscriber.h" | 18 #include "media/cast/logging/encoding_event_subscriber.h" |
19 #include "media/cast/logging/log_serializer.h" | 19 #include "media/cast/logging/log_serializer.h" |
20 #include "media/cast/logging/logging_defines.h" | 20 #include "media/cast/logging/logging_defines.h" |
21 #include "media/cast/logging/proto/raw_events.pb.h" | 21 #include "media/cast/logging/proto/raw_events.pb.h" |
22 #include "media/cast/logging/stats_serializer.h" | |
22 #include "media/cast/test/utility/audio_utility.h" | 23 #include "media/cast/test/utility/audio_utility.h" |
23 #include "media/cast/test/utility/input_builder.h" | 24 #include "media/cast/test/utility/input_builder.h" |
24 #include "media/cast/test/utility/video_utility.h" | 25 #include "media/cast/test/utility/video_utility.h" |
25 #include "media/cast/transport/cast_transport_defines.h" | 26 #include "media/cast/transport/cast_transport_defines.h" |
26 #include "media/cast/transport/cast_transport_sender.h" | 27 #include "media/cast/transport/cast_transport_sender.h" |
27 #include "media/cast/transport/transport/udp_transport.h" | 28 #include "media/cast/transport/transport/udp_transport.h" |
28 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
29 | 30 |
30 namespace media { | 31 namespace media { |
31 namespace cast { | 32 namespace cast { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 << serializer.GetSerializedLength() - length_so_far; | 376 << serializer.GetSerializedLength() - length_so_far; |
376 | 377 |
377 scoped_ptr<std::string> serialized_string = | 378 scoped_ptr<std::string> serialized_string = |
378 serializer.GetSerializedLogAndReset(); | 379 serializer.GetSerializedLogAndReset(); |
379 VLOG(0) << "Serialized string size: " << serialized_string->size(); | 380 VLOG(0) << "Serialized string size: " << serialized_string->size(); |
380 | 381 |
381 size_t ret = fwrite( | 382 size_t ret = fwrite( |
382 &(*serialized_string)[0], 1, serialized_string->size(), log_file.get()); | 383 &(*serialized_string)[0], 1, serialized_string->size(), log_file.get()); |
383 if (ret != serialized_string->size()) | 384 if (ret != serialized_string->size()) |
384 VLOG(1) << "Failed to write logs to file."; | 385 VLOG(1) << "Failed to write logs to file."; |
386 | |
387 scoped_ptr<std::string> audio_stats_json(new std::string); | |
Alpha Left Google
2014/03/03 07:11:39
Stats updates every second so getting the stat onc
imcheng
2014/03/04 02:06:24
That sounds quite ambitious and that it'll take a
| |
388 bool success = media::cast::SerializeStats( | |
389 cast_environment->Logging()->GetFrameStatsData(media::cast::AUDIO_EVENT), | |
390 cast_environment->Logging()->GetPacketStatsData(media::cast::AUDIO_EVENT), | |
391 audio_stats_json.get()); | |
392 | |
393 // We can write this string to a file if needed. | |
394 if (success) | |
395 VLOG(0) << "Audio stats JSON string: " << *audio_stats_json; | |
396 else | |
397 VLOG(1) << "Failed to write audio stats JSON string."; | |
398 | |
399 scoped_ptr<std::string> video_stats_json(new std::string); | |
400 success = media::cast::SerializeStats( | |
401 cast_environment->Logging()->GetFrameStatsData(media::cast::VIDEO_EVENT), | |
402 cast_environment->Logging()->GetPacketStatsData(media::cast::VIDEO_EVENT), | |
403 video_stats_json.get()); | |
404 if (success) | |
405 VLOG(0) << "Video stats JSON string: " << *video_stats_json; | |
406 else | |
407 VLOG(1) << "Failed to write video stats JSON string."; | |
385 } | 408 } |
386 | 409 |
387 } // namespace | 410 } // namespace |
388 | 411 |
389 int main(int argc, char** argv) { | 412 int main(int argc, char** argv) { |
390 base::AtExitManager at_exit; | 413 base::AtExitManager at_exit; |
391 VLOG(1) << "Cast Sender"; | 414 VLOG(1) << "Cast Sender"; |
392 base::Thread test_thread("Cast sender test app thread"); | 415 base::Thread test_thread("Cast sender test app thread"); |
393 base::Thread audio_thread("Cast audio encoder thread"); | 416 base::Thread audio_thread("Cast audio encoder thread"); |
394 base::Thread video_thread("Cast video encoder thread"); | 417 base::Thread video_thread("Cast video encoder thread"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 | 514 |
492 test_thread.message_loop_proxy()->PostTask( | 515 test_thread.message_loop_proxy()->PostTask( |
493 FROM_HERE, | 516 FROM_HERE, |
494 base::Bind(&media::cast::SendProcess::SendFrame, | 517 base::Bind(&media::cast::SendProcess::SendFrame, |
495 base::Unretained(send_process.get()))); | 518 base::Unretained(send_process.get()))); |
496 | 519 |
497 io_message_loop.Run(); | 520 io_message_loop.Run(); |
498 | 521 |
499 return 0; | 522 return 0; |
500 } | 523 } |
OLD | NEW |