| 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" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "base/time/default_tick_clock.h" | 12 #include "base/time/default_tick_clock.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "media/cast/cast_config.h" | 14 #include "media/cast/cast_config.h" |
| 15 #include "media/cast/cast_environment.h" | 15 #include "media/cast/cast_environment.h" |
| 16 #include "media/cast/cast_sender.h" | 16 #include "media/cast/cast_sender.h" |
| 17 #include "media/cast/logging/logging_defines.h" | 17 #include "media/cast/logging/logging_defines.h" |
| 18 #include "media/cast/net/transport/transport.h" | |
| 19 #include "media/cast/test/audio_utility.h" | 18 #include "media/cast/test/audio_utility.h" |
| 20 #include "media/cast/test/utility/input_helper.h" | 19 #include "media/cast/test/utility/input_helper.h" |
| 21 #include "media/cast/test/video_utility.h" | 20 #include "media/cast/test/video_utility.h" |
| 21 #include "media/cast/transport/transport/transport.h" |
| 22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 | 23 |
| 24 namespace media { | 24 namespace media { |
| 25 namespace cast { | 25 namespace cast { |
| 26 // Settings chosen to match default receiver settings. | 26 // Settings chosen to match default receiver settings. |
| 27 #define DEFAULT_SEND_PORT "2344" | 27 #define DEFAULT_SEND_PORT "2344" |
| 28 #define DEFAULT_RECEIVE_PORT "2346" | 28 #define DEFAULT_RECEIVE_PORT "2346" |
| 29 #define DEFAULT_SEND_IP "127.0.0.1" | 29 #define DEFAULT_SEND_IP "127.0.0.1" |
| 30 #define DEFAULT_READ_FROM_FILE "0" | 30 #define DEFAULT_READ_FROM_FILE "0" |
| 31 #define DEFAULT_AUDIO_SENDER_SSRC "1" | 31 #define DEFAULT_AUDIO_SENDER_SSRC "1" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 NULL, | 315 NULL, |
| 316 video_thread.message_loop_proxy(), | 316 video_thread.message_loop_proxy(), |
| 317 NULL, | 317 NULL, |
| 318 media::cast::GetDefaultCastLoggingConfig())); | 318 media::cast::GetDefaultCastLoggingConfig())); |
| 319 | 319 |
| 320 media::cast::AudioSenderConfig audio_config = | 320 media::cast::AudioSenderConfig audio_config = |
| 321 media::cast::GetAudioSenderConfig(); | 321 media::cast::GetAudioSenderConfig(); |
| 322 media::cast::VideoSenderConfig video_config = | 322 media::cast::VideoSenderConfig video_config = |
| 323 media::cast::GetVideoSenderConfig(); | 323 media::cast::GetVideoSenderConfig(); |
| 324 | 324 |
| 325 scoped_ptr<media::cast::Transport> transport( | 325 scoped_ptr<media::cast::transport::Transport> transport( |
| 326 new media::cast::Transport(io_message_loop.message_loop_proxy())); | 326 new media::cast::transport::Transport( |
| 327 io_message_loop.message_loop_proxy())); |
| 327 scoped_ptr<media::cast::CastSender> cast_sender( | 328 scoped_ptr<media::cast::CastSender> cast_sender( |
| 328 media::cast::CastSender::CreateCastSender(cast_environment, | 329 media::cast::CastSender::CreateCastSender(cast_environment, |
| 329 audio_config, | 330 audio_config, |
| 330 video_config, | 331 video_config, |
| 331 NULL, // VideoEncoderController. | 332 NULL, // VideoEncoderController. |
| 332 transport->packet_sender())); | 333 transport->packet_sender())); |
| 333 | 334 |
| 334 media::cast::PacketReceiver* packet_receiver = cast_sender->packet_receiver(); | 335 media::cast::PacketReceiver* packet_receiver = cast_sender->packet_receiver(); |
| 335 | 336 |
| 336 int send_to_port, receive_port; | 337 int send_to_port, receive_port; |
| 337 media::cast::GetPorts(&send_to_port, &receive_port); | 338 media::cast::GetPorts(&send_to_port, &receive_port); |
| 338 std::string ip_address = media::cast::GetIpAddress("Enter destination IP."); | 339 std::string ip_address = media::cast::GetIpAddress("Enter destination IP."); |
| 339 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); | 340 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); |
| 340 | 341 |
| 341 transport->SetLocalReceiver(packet_receiver, ip_address, local_ip_address, | 342 transport->SetLocalReceiver(packet_receiver, ip_address, local_ip_address, |
| 342 receive_port); | 343 receive_port); |
| 343 transport->SetSendDestination(ip_address, send_to_port); | 344 transport->SetSendDestination(ip_address, send_to_port); |
| 344 // TODO(mikhal): Add option to simulate packet loss. | |
| 345 | 345 |
| 346 media::cast::FrameInput* frame_input = cast_sender->frame_input(); | 346 media::cast::FrameInput* frame_input = cast_sender->frame_input(); |
| 347 scoped_ptr<media::cast::SendProcess> send_process(new | 347 scoped_ptr<media::cast::SendProcess> send_process(new |
| 348 media::cast::SendProcess(test_thread.message_loop_proxy(), | 348 media::cast::SendProcess(test_thread.message_loop_proxy(), |
| 349 cast_environment->Clock(), | 349 cast_environment->Clock(), |
| 350 video_config, | 350 video_config, |
| 351 frame_input)); | 351 frame_input)); |
| 352 | 352 |
| 353 send_process->SendFrame(); | 353 send_process->SendFrame(); |
| 354 io_message_loop.Run(); | 354 io_message_loop.Run(); |
| 355 transport->StopReceiving(); | 355 transport->StopReceiving(); |
| 356 return 0; | 356 return 0; |
| 357 } | 357 } |
| OLD | NEW |