| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 base::WeakPtrFactory<SendProcess> weak_factory_; | 289 base::WeakPtrFactory<SendProcess> weak_factory_; |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 } // namespace cast | 292 } // namespace cast |
| 293 } // namespace media | 293 } // namespace media |
| 294 | 294 |
| 295 namespace { | 295 namespace { |
| 296 void UpdateCastTransportStatus(media::cast::transport::CastTransportStatus | 296 void UpdateCastTransportStatus(media::cast::transport::CastTransportStatus |
| 297 status) { | 297 status) { |
| 298 } | 298 } |
| 299 |
| 300 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { |
| 301 net::IPAddressNumber ip_number; |
| 302 CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); |
| 303 return net::IPEndPoint(ip_number, port); |
| 299 } | 304 } |
| 300 | 305 |
| 306 } // namespace |
| 307 |
| 301 int main(int argc, char** argv) { | 308 int main(int argc, char** argv) { |
| 302 base::AtExitManager at_exit; | 309 base::AtExitManager at_exit; |
| 303 VLOG(1) << "Cast Sender"; | 310 VLOG(1) << "Cast Sender"; |
| 304 base::Thread test_thread("Cast sender test app thread"); | 311 base::Thread test_thread("Cast sender test app thread"); |
| 305 base::Thread audio_thread("Cast audio encoder thread"); | 312 base::Thread audio_thread("Cast audio encoder thread"); |
| 306 base::Thread video_thread("Cast video encoder thread"); | 313 base::Thread video_thread("Cast video encoder thread"); |
| 307 test_thread.Start(); | 314 test_thread.Start(); |
| 308 audio_thread.Start(); | 315 audio_thread.Start(); |
| 309 video_thread.Start(); | 316 video_thread.Start(); |
| 310 | 317 |
| 311 scoped_ptr<base::TickClock> clock(new base::DefaultTickClock()); | 318 scoped_ptr<base::TickClock> clock(new base::DefaultTickClock()); |
| 312 base::MessageLoopForIO io_message_loop; | 319 base::MessageLoopForIO io_message_loop; |
| 313 | 320 |
| 314 int remote_port, local_port; | 321 int remote_port, local_port; |
| 315 media::cast::GetPorts(&remote_port, &local_port); | 322 media::cast::GetPorts(&remote_port, &local_port); |
| 316 | 323 |
| 317 std::string remote_ip_address = | 324 std::string remote_ip_address = |
| 318 media::cast::GetIpAddress("Enter receiver IP."); | 325 media::cast::GetIpAddress("Enter receiver IP."); |
| 319 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); | 326 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); |
| 320 | 327 |
| 321 media::cast::AudioSenderConfig audio_config = | 328 media::cast::AudioSenderConfig audio_config = |
| 322 media::cast::GetAudioSenderConfig(); | 329 media::cast::GetAudioSenderConfig(); |
| 323 media::cast::VideoSenderConfig video_config = | 330 media::cast::VideoSenderConfig video_config = |
| 324 media::cast::GetVideoSenderConfig(); | 331 media::cast::GetVideoSenderConfig(); |
| 325 | 332 |
| 326 // Setting up transport config. | 333 // Setting up transport config. |
| 327 media::cast::transport::CastTransportConfig config; | 334 media::cast::transport::CastTransportConfig config; |
| 328 config.receiver_ip_address = remote_ip_address; | 335 config.receiver_endpoint = CreateUDPAddress(remote_ip_address, |
| 329 config.local_ip_address = local_ip_address; | 336 remote_port); |
| 330 config.receive_port = local_port; | 337 config.local_endpoint = CreateUDPAddress(local_ip_address, |
| 331 config.send_port = remote_port; | 338 local_port); |
| 332 config.audio_ssrc = audio_config.sender_ssrc; | 339 config.audio_ssrc = audio_config.sender_ssrc; |
| 333 config.video_ssrc = video_config.sender_ssrc; | 340 config.video_ssrc = video_config.sender_ssrc; |
| 334 config.audio_rtp_payload_type = audio_config.rtp_payload_type; | 341 config.audio_rtp_payload_type = audio_config.rtp_payload_type; |
| 335 config.video_rtp_payload_type = video_config.rtp_payload_type; | 342 config.video_rtp_payload_type = video_config.rtp_payload_type; |
| 336 | 343 |
| 337 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( | 344 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( |
| 338 media::cast::transport:: | 345 media::cast::transport:: |
| 339 CastTransportSender::CreateCastTransportSender(clock.get(), config, | 346 CastTransportSender::CreateCastTransportSender(clock.get(), config, |
| 340 base::Bind(&UpdateCastTransportStatus), | 347 base::Bind(&UpdateCastTransportStatus), |
| 341 io_message_loop.message_loop_proxy())); | 348 io_message_loop.message_loop_proxy())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 366 scoped_ptr<media::cast::SendProcess> send_process(new | 373 scoped_ptr<media::cast::SendProcess> send_process(new |
| 367 media::cast::SendProcess(test_thread.message_loop_proxy(), | 374 media::cast::SendProcess(test_thread.message_loop_proxy(), |
| 368 cast_environment->Clock(), | 375 cast_environment->Clock(), |
| 369 video_config, | 376 video_config, |
| 370 frame_input)); | 377 frame_input)); |
| 371 | 378 |
| 372 send_process->SendFrame(); | 379 send_process->SendFrame(); |
| 373 io_message_loop.Run(); | 380 io_message_loop.Run(); |
| 374 return 0; | 381 return 0; |
| 375 } | 382 } |
| OLD | NEW |