| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 int main(int argc, char** argv) { | 301 int main(int argc, char** argv) { |
| 302 base::AtExitManager at_exit; | 302 base::AtExitManager at_exit; |
| 303 VLOG(1) << "Cast Sender"; | 303 VLOG(1) << "Cast Sender"; |
| 304 base::Thread test_thread("Cast sender test app thread"); | 304 base::Thread test_thread("Cast sender test app thread"); |
| 305 base::Thread audio_thread("Cast audio encoder thread"); | 305 base::Thread audio_thread("Cast audio encoder thread"); |
| 306 base::Thread video_thread("Cast video encoder thread"); | 306 base::Thread video_thread("Cast video encoder thread"); |
| 307 test_thread.Start(); | 307 test_thread.Start(); |
| 308 audio_thread.Start(); | 308 audio_thread.Start(); |
| 309 video_thread.Start(); | 309 video_thread.Start(); |
| 310 | 310 |
| 311 base::DefaultTickClock clock; | 311 scoped_ptr<base::TickClock> clock(new base::DefaultTickClock()); |
| 312 base::MessageLoopForIO io_message_loop; | 312 base::MessageLoopForIO io_message_loop; |
| 313 | 313 |
| 314 int remote_port, local_port; | 314 int remote_port, local_port; |
| 315 media::cast::GetPorts(&remote_port, &local_port); | 315 media::cast::GetPorts(&remote_port, &local_port); |
| 316 | 316 |
| 317 std::string remote_ip_address = | 317 std::string remote_ip_address = |
| 318 media::cast::GetIpAddress("Enter receiver IP."); | 318 media::cast::GetIpAddress("Enter receiver IP."); |
| 319 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); | 319 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); |
| 320 | 320 |
| 321 media::cast::AudioSenderConfig audio_config = | 321 media::cast::AudioSenderConfig audio_config = |
| 322 media::cast::GetAudioSenderConfig(); | 322 media::cast::GetAudioSenderConfig(); |
| 323 media::cast::VideoSenderConfig video_config = | 323 media::cast::VideoSenderConfig video_config = |
| 324 media::cast::GetVideoSenderConfig(); | 324 media::cast::GetVideoSenderConfig(); |
| 325 | 325 |
| 326 // Setting up transport config. | 326 // Setting up transport config. |
| 327 media::cast::transport::CastTransportConfig config; | 327 media::cast::transport::CastTransportConfig config; |
| 328 config.receiver_ip_address = remote_ip_address; | 328 config.receiver_ip_address = remote_ip_address; |
| 329 config.local_ip_address = local_ip_address; | 329 config.local_ip_address = local_ip_address; |
| 330 config.receive_port = local_port; | 330 config.receive_port = local_port; |
| 331 config.send_port = remote_port; | 331 config.send_port = remote_port; |
| 332 config.audio_ssrc = audio_config.sender_ssrc; | 332 config.audio_ssrc = audio_config.sender_ssrc; |
| 333 config.video_ssrc = video_config.sender_ssrc; | 333 config.video_ssrc = video_config.sender_ssrc; |
| 334 config.audio_rtp_payload_type = audio_config.rtp_payload_type; | 334 config.audio_rtp_payload_type = audio_config.rtp_payload_type; |
| 335 config.video_rtp_payload_type = video_config.rtp_payload_type; | 335 config.video_rtp_payload_type = video_config.rtp_payload_type; |
| 336 | 336 |
| 337 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( | 337 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( |
| 338 media::cast::transport:: | 338 media::cast::transport:: |
| 339 CastTransportSender::CreateCastTransportSender(&clock, config, | 339 CastTransportSender::CreateCastTransportSender(clock.get(), config, |
| 340 base::Bind(&UpdateCastTransportStatus), | 340 base::Bind(&UpdateCastTransportStatus), |
| 341 io_message_loop.message_loop_proxy())); | 341 io_message_loop.message_loop_proxy())); |
| 342 | 342 |
| 343 // Enable main and send side threads only. Disable logging. | 343 // Enable main and send side threads only. Disable logging. |
| 344 // Running transport on the main thread. | 344 // Running transport on the main thread. |
| 345 scoped_refptr<media::cast::CastEnvironment> cast_environment(new | 345 scoped_refptr<media::cast::CastEnvironment> cast_environment(new |
| 346 media::cast::CastEnvironment( | 346 media::cast::CastEnvironment( |
| 347 &clock, | 347 clock.Pass(), |
| 348 io_message_loop.message_loop_proxy(), | 348 io_message_loop.message_loop_proxy(), |
| 349 audio_thread.message_loop_proxy(), | 349 audio_thread.message_loop_proxy(), |
| 350 NULL, | 350 NULL, |
| 351 video_thread.message_loop_proxy(), | 351 video_thread.message_loop_proxy(), |
| 352 NULL, | 352 NULL, |
| 353 io_message_loop.message_loop_proxy(), | 353 io_message_loop.message_loop_proxy(), |
| 354 media::cast::GetDefaultCastSenderLoggingConfig())); | 354 media::cast::GetDefaultCastSenderLoggingConfig())); |
| 355 | 355 |
| 356 scoped_ptr<media::cast::CastSender> cast_sender( | 356 scoped_ptr<media::cast::CastSender> cast_sender( |
| 357 media::cast::CastSender::CreateCastSender(cast_environment, | 357 media::cast::CastSender::CreateCastSender(cast_environment, |
| 358 audio_config, | 358 audio_config, |
| 359 video_config, | 359 video_config, |
| 360 NULL, // gpu_factories. | 360 NULL, // gpu_factories. |
| 361 transport_sender.get())); | 361 transport_sender.get())); |
| 362 | 362 |
| 363 transport_sender->SetPacketReceiver(cast_sender->packet_receiver()); | 363 transport_sender->SetPacketReceiver(cast_sender->packet_receiver()); |
| 364 | 364 |
| 365 media::cast::FrameInput* frame_input = cast_sender->frame_input(); | 365 media::cast::FrameInput* frame_input = cast_sender->frame_input(); |
| 366 scoped_ptr<media::cast::SendProcess> send_process(new | 366 scoped_ptr<media::cast::SendProcess> send_process(new |
| 367 media::cast::SendProcess(test_thread.message_loop_proxy(), | 367 media::cast::SendProcess(test_thread.message_loop_proxy(), |
| 368 cast_environment->Clock(), | 368 cast_environment->Clock(), |
| 369 video_config, | 369 video_config, |
| 370 frame_input)); | 370 frame_input)); |
| 371 | 371 |
| 372 send_process->SendFrame(); | 372 send_process->SendFrame(); |
| 373 io_message_loop.Run(); | 373 io_message_loop.Run(); |
| 374 return 0; | 374 return 0; |
| 375 } | 375 } |
| OLD | NEW |