| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Simulate end to end streaming. | 5 // Simulate end to end streaming. |
| 6 // | 6 // |
| 7 // Input: | 7 // Input: |
| 8 // --source= | 8 // --source= |
| 9 // WebM used as the source of video and audio frames. | 9 // WebM used as the source of video and audio frames. |
| 10 // --output= | 10 // --output= |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int as_int; | 106 int as_int; |
| 107 CHECK(base::StringToInt(as_str, &as_int)); | 107 CHECK(base::StringToInt(as_str, &as_int)); |
| 108 CHECK_GT(as_int, 0); | 108 CHECK_GT(as_int, 0); |
| 109 return as_int; | 109 return as_int; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void UpdateCastTransportStatus(CastTransportStatus status) { | 112 void UpdateCastTransportStatus(CastTransportStatus status) { |
| 113 LOG(INFO) << "Cast transport status: " << status; | 113 LOG(INFO) << "Cast transport status: " << status; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void AudioInitializationStatus(CastInitializationStatus status) { | 116 void LogAudioOperationalStatus(OperationalStatus status) { |
| 117 LOG(INFO) << "Audio status: " << status; | 117 LOG(INFO) << "Audio status: " << status; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void VideoInitializationStatus(CastInitializationStatus status) { | 120 void LogVideoOperationalStatus(OperationalStatus status) { |
| 121 LOG(INFO) << "Video status: " << status; | 121 LOG(INFO) << "Video status: " << status; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void LogTransportEvents(const scoped_refptr<CastEnvironment>& env, | 124 void LogTransportEvents(const scoped_refptr<CastEnvironment>& env, |
| 125 const std::vector<PacketEvent>& packet_events, | 125 const std::vector<PacketEvent>& packet_events, |
| 126 const std::vector<FrameEvent>& frame_events) { | 126 const std::vector<FrameEvent>& frame_events) { |
| 127 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 127 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 128 packet_events.begin(); | 128 packet_events.begin(); |
| 129 it != packet_events.end(); | 129 it != packet_events.end(); |
| 130 ++it) { | 130 ++it) { |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // Start receiver. | 495 // Start receiver. |
| 496 int audio_frame_count = 0; | 496 int audio_frame_count = 0; |
| 497 cast_receiver->RequestDecodedVideoFrame( | 497 cast_receiver->RequestDecodedVideoFrame( |
| 498 base::Bind(&GotVideoFrame, &metrics_output, yuv_output_path, | 498 base::Bind(&GotVideoFrame, &metrics_output, yuv_output_path, |
| 499 video_frame_tracker.get(), cast_receiver.get())); | 499 video_frame_tracker.get(), cast_receiver.get())); |
| 500 cast_receiver->RequestDecodedAudioFrame( | 500 cast_receiver->RequestDecodedAudioFrame( |
| 501 base::Bind(&GotAudioFrame, &audio_frame_count, cast_receiver.get())); | 501 base::Bind(&GotAudioFrame, &audio_frame_count, cast_receiver.get())); |
| 502 | 502 |
| 503 // Initializing audio and video senders. | 503 // Initializing audio and video senders. |
| 504 cast_sender->InitializeAudio(audio_sender_config, | 504 cast_sender->InitializeAudio(audio_sender_config, |
| 505 base::Bind(&AudioInitializationStatus)); | 505 base::Bind(&LogAudioOperationalStatus)); |
| 506 cast_sender->InitializeVideo(media_source.get_video_config(), | 506 cast_sender->InitializeVideo(media_source.get_video_config(), |
| 507 base::Bind(&VideoInitializationStatus), | 507 base::Bind(&LogVideoOperationalStatus), |
| 508 CreateDefaultVideoEncodeAcceleratorCallback(), | 508 CreateDefaultVideoEncodeAcceleratorCallback(), |
| 509 CreateDefaultVideoEncodeMemoryCallback()); | 509 CreateDefaultVideoEncodeMemoryCallback()); |
| 510 task_runner->RunTasks(); | 510 task_runner->RunTasks(); |
| 511 | 511 |
| 512 // Truncate YUV files to prepare for writing. | 512 // Truncate YUV files to prepare for writing. |
| 513 if (!yuv_output_path.empty()) { | 513 if (!yuv_output_path.empty()) { |
| 514 base::ScopedFILE file(base::OpenFile(yuv_output_path, "wb")); | 514 base::ScopedFILE file(base::OpenFile(yuv_output_path, "wb")); |
| 515 if (!file.get()) { | 515 if (!file.get()) { |
| 516 LOG(ERROR) << "Cannot save YUV output to file."; | 516 LOG(ERROR) << "Cannot save YUV output to file."; |
| 517 return; | 517 return; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 values.SetString("sim-id", sim_id); | 766 values.SetString("sim-id", sim_id); |
| 767 | 767 |
| 768 std::string extra_data; | 768 std::string extra_data; |
| 769 base::JSONWriter::Write(&values, &extra_data); | 769 base::JSONWriter::Write(&values, &extra_data); |
| 770 | 770 |
| 771 // Run. | 771 // Run. |
| 772 media::cast::RunSimulation(source_path, log_output_path, metrics_output_path, | 772 media::cast::RunSimulation(source_path, log_output_path, metrics_output_path, |
| 773 yuv_output_path, extra_data, model); | 773 yuv_output_path, extra_data, model); |
| 774 return 0; | 774 return 0; |
| 775 } | 775 } |
| OLD | NEW |