Chromium Code Reviews| 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 <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 it->frame_id); | 148 it->frame_id); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void InitializationResult(media::cast::CastInitializationStatus result) { | 152 void InitializationResult(media::cast::CastInitializationStatus result) { |
| 153 bool end_result = result == media::cast::STATUS_AUDIO_INITIALIZED || | 153 bool end_result = result == media::cast::STATUS_AUDIO_INITIALIZED || |
| 154 result == media::cast::STATUS_VIDEO_INITIALIZED; | 154 result == media::cast::STATUS_VIDEO_INITIALIZED; |
| 155 CHECK(end_result) << "Cast sender uninitialized"; | 155 CHECK(end_result) << "Cast sender uninitialized"; |
| 156 } | 156 } |
| 157 | 157 |
| 158 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { | 158 net::IPEndPoint CreateUDPAddress(std::string ip_str, uint16 port) { |
| 159 net::IPAddressNumber ip_number; | 159 net::IPAddressNumber ip_number; |
| 160 CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); | 160 CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); |
| 161 return net::IPEndPoint(ip_number, port); | 161 return net::IPEndPoint(ip_number, port); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void DumpLoggingData(const media::cast::proto::LogMetadata& log_metadata, | 164 void DumpLoggingData(const media::cast::proto::LogMetadata& log_metadata, |
| 165 const media::cast::FrameEventList& frame_events, | 165 const media::cast::FrameEventList& frame_events, |
| 166 const media::cast::PacketEventList& packet_events, | 166 const media::cast::PacketEventList& packet_events, |
| 167 base::ScopedFILE log_file) { | 167 base::ScopedFILE log_file) { |
| 168 VLOG(0) << "Frame map size: " << frame_events.size(); | 168 VLOG(0) << "Frame map size: " << frame_events.size(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 video_thread.Start(); | 268 video_thread.Start(); |
| 269 | 269 |
| 270 base::MessageLoopForIO io_message_loop; | 270 base::MessageLoopForIO io_message_loop; |
| 271 | 271 |
| 272 // Default parameters. | 272 // Default parameters. |
| 273 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 273 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 274 std::string remote_ip_address = cmd->GetSwitchValueASCII(kSwitchAddress); | 274 std::string remote_ip_address = cmd->GetSwitchValueASCII(kSwitchAddress); |
| 275 if (remote_ip_address.empty()) | 275 if (remote_ip_address.empty()) |
| 276 remote_ip_address = "127.0.0.1"; | 276 remote_ip_address = "127.0.0.1"; |
| 277 int remote_port = 0; | 277 int remote_port = 0; |
| 278 if (!base::StringToInt(cmd->GetSwitchValueASCII(kSwitchPort), | 278 if (!base::StringToInt(cmd->GetSwitchValueASCII(kSwitchPort), &remote_port) || |
| 279 &remote_port)) { | 279 remote_port < 0 || remote_port > 65535) { |
|
Peter Kasting
2014/11/12 23:53:55
These conditions could have been violated before a
| |
| 280 remote_port = 2344; | 280 remote_port = 2344; |
| 281 } | 281 } |
| 282 LOG(INFO) << "Sending to " << remote_ip_address << ":" << remote_port | 282 LOG(INFO) << "Sending to " << remote_ip_address << ":" << remote_port |
| 283 << "."; | 283 << "."; |
| 284 | 284 |
| 285 media::cast::AudioSenderConfig audio_config = GetAudioSenderConfig(); | 285 media::cast::AudioSenderConfig audio_config = GetAudioSenderConfig(); |
| 286 media::cast::VideoSenderConfig video_config = GetVideoSenderConfig(); | 286 media::cast::VideoSenderConfig video_config = GetVideoSenderConfig(); |
| 287 | 287 |
| 288 // Running transport on the main thread. | 288 // Running transport on the main thread. |
| 289 // Setting up transport config. | 289 // Setting up transport config. |
| 290 net::IPEndPoint remote_endpoint = | 290 net::IPEndPoint remote_endpoint = |
| 291 CreateUDPAddress(remote_ip_address, remote_port); | 291 CreateUDPAddress(remote_ip_address, static_cast<uint16>(remote_port)); |
| 292 | 292 |
| 293 // Enable raw event and stats logging. | 293 // Enable raw event and stats logging. |
| 294 // Running transport on the main thread. | 294 // Running transport on the main thread. |
| 295 scoped_refptr<media::cast::CastEnvironment> cast_environment( | 295 scoped_refptr<media::cast::CastEnvironment> cast_environment( |
| 296 new media::cast::CastEnvironment( | 296 new media::cast::CastEnvironment( |
| 297 make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()), | 297 make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()), |
| 298 io_message_loop.message_loop_proxy(), | 298 io_message_loop.message_loop_proxy(), |
| 299 audio_thread.message_loop_proxy(), | 299 audio_thread.message_loop_proxy(), |
| 300 video_thread.message_loop_proxy())); | 300 video_thread.message_loop_proxy())); |
| 301 | 301 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 base::Passed(&audio_stats_subscriber), | 402 base::Passed(&audio_stats_subscriber), |
| 403 base::Passed(&offset_estimator)), | 403 base::Passed(&offset_estimator)), |
| 404 base::TimeDelta::FromSeconds(logging_duration_seconds)); | 404 base::TimeDelta::FromSeconds(logging_duration_seconds)); |
| 405 | 405 |
| 406 fake_media_source->Start(cast_sender->audio_frame_input(), | 406 fake_media_source->Start(cast_sender->audio_frame_input(), |
| 407 cast_sender->video_frame_input()); | 407 cast_sender->video_frame_input()); |
| 408 | 408 |
| 409 io_message_loop.Run(); | 409 io_message_loop.Run(); |
| 410 return 0; | 410 return 0; |
| 411 } | 411 } |
| OLD | NEW |