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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const char kNoSimulation[] = "no-simulation"; | 93 const char kNoSimulation[] = "no-simulation"; |
94 const char kRunTime[] = "run-time"; | 94 const char kRunTime[] = "run-time"; |
95 const char kSimulationId[] = "sim-id"; | 95 const char kSimulationId[] = "sim-id"; |
96 const char kSourcePath[] = "source"; | 96 const char kSourcePath[] = "source"; |
97 const char kSourceFrameRate[] = "source-frame-rate"; | 97 const char kSourceFrameRate[] = "source-frame-rate"; |
98 const char kTargetDelay[] = "target-delay-ms"; | 98 const char kTargetDelay[] = "target-delay-ms"; |
99 const char kYuvOutputPath[] = "yuv-output"; | 99 const char kYuvOutputPath[] = "yuv-output"; |
100 | 100 |
101 int GetIntegerSwitchValue(const char* switch_name, int default_value) { | 101 int GetIntegerSwitchValue(const char* switch_name, int default_value) { |
102 const std::string as_str = | 102 const std::string as_str = |
103 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name); | 103 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name); |
104 if (as_str.empty()) | 104 if (as_str.empty()) |
105 return default_value; | 105 return default_value; |
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; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 for (int i = 0; i < ipp.average_rate_size(); i++) { | 685 for (int i = 0; i < ipp.average_rate_size(); i++) { |
686 if (ipp.average_rate(i) <= 0.0) | 686 if (ipp.average_rate(i) <= 0.0) |
687 return false; | 687 return false; |
688 } | 688 } |
689 } | 689 } |
690 | 690 |
691 return true; | 691 return true; |
692 } | 692 } |
693 | 693 |
694 NetworkSimulationModel LoadModel(const base::FilePath& model_path) { | 694 NetworkSimulationModel LoadModel(const base::FilePath& model_path) { |
695 if (CommandLine::ForCurrentProcess()->HasSwitch(kNoSimulation)) { | 695 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kNoSimulation)) { |
696 NetworkSimulationModel model; | 696 NetworkSimulationModel model; |
697 model.set_type(media::cast::proto::NO_SIMULATION); | 697 model.set_type(media::cast::proto::NO_SIMULATION); |
698 return model; | 698 return model; |
699 } | 699 } |
700 if (model_path.empty()) { | 700 if (model_path.empty()) { |
701 LOG(ERROR) << "Model path not set; Using default model."; | 701 LOG(ERROR) << "Model path not set; Using default model."; |
702 return DefaultModel(); | 702 return DefaultModel(); |
703 } | 703 } |
704 std::string model_str; | 704 std::string model_str; |
705 if (!base::ReadFileToString(model_path, &model_str)) { | 705 if (!base::ReadFileToString(model_path, &model_str)) { |
(...skipping 13 matching lines...) Expand all Loading... |
719 | 719 |
720 return model; | 720 return model; |
721 } | 721 } |
722 | 722 |
723 } // namespace | 723 } // namespace |
724 } // namespace cast | 724 } // namespace cast |
725 } // namespace media | 725 } // namespace media |
726 | 726 |
727 int main(int argc, char** argv) { | 727 int main(int argc, char** argv) { |
728 base::AtExitManager at_exit; | 728 base::AtExitManager at_exit; |
729 CommandLine::Init(argc, argv); | 729 base::CommandLine::Init(argc, argv); |
730 InitLogging(logging::LoggingSettings()); | 730 InitLogging(logging::LoggingSettings()); |
731 | 731 |
732 const CommandLine* cmd = CommandLine::ForCurrentProcess(); | 732 const base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
733 base::FilePath media_path = cmd->GetSwitchValuePath(media::cast::kLibDir); | 733 base::FilePath media_path = cmd->GetSwitchValuePath(media::cast::kLibDir); |
734 if (media_path.empty()) { | 734 if (media_path.empty()) { |
735 if (!PathService::Get(base::DIR_MODULE, &media_path)) { | 735 if (!PathService::Get(base::DIR_MODULE, &media_path)) { |
736 LOG(ERROR) << "Failed to load FFmpeg."; | 736 LOG(ERROR) << "Failed to load FFmpeg."; |
737 return 1; | 737 return 1; |
738 } | 738 } |
739 } | 739 } |
740 | 740 |
741 if (!media::InitializeMediaLibrary(media_path)) { | 741 if (!media::InitializeMediaLibrary(media_path)) { |
742 LOG(ERROR) << "Failed to initialize FFmpeg."; | 742 LOG(ERROR) << "Failed to initialize FFmpeg."; |
(...skipping 22 matching lines...) Expand all Loading... |
765 values.SetString("sim-id", sim_id); | 765 values.SetString("sim-id", sim_id); |
766 | 766 |
767 std::string extra_data; | 767 std::string extra_data; |
768 base::JSONWriter::Write(&values, &extra_data); | 768 base::JSONWriter::Write(&values, &extra_data); |
769 | 769 |
770 // Run. | 770 // Run. |
771 media::cast::RunSimulation(source_path, log_output_path, metrics_output_path, | 771 media::cast::RunSimulation(source_path, log_output_path, metrics_output_path, |
772 yuv_output_path, extra_data, model); | 772 yuv_output_path, extra_data, model); |
773 return 0; | 773 return 0; |
774 } | 774 } |
OLD | NEW |