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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 GetSsrcs(&audio_config); | 121 GetSsrcs(&audio_config); |
122 GetPayloadtype(&audio_config); | 122 GetPayloadtype(&audio_config); |
123 | 123 |
124 audio_config.rtcp_c_name = "audio_sender@a.b.c.d"; | 124 audio_config.rtcp_c_name = "audio_sender@a.b.c.d"; |
125 | 125 |
126 VLOG(0) << "Using OPUS 48Khz stereo at 64kbit/s"; | 126 VLOG(0) << "Using OPUS 48Khz stereo at 64kbit/s"; |
127 audio_config.use_external_encoder = false; | 127 audio_config.use_external_encoder = false; |
128 audio_config.frequency = kAudioSamplingFrequency; | 128 audio_config.frequency = kAudioSamplingFrequency; |
129 audio_config.channels = kAudioChannels; | 129 audio_config.channels = kAudioChannels; |
130 audio_config.bitrate = 64000; | 130 audio_config.bitrate = 64000; |
131 audio_config.codec = kOpus; | 131 audio_config.codec = transport::kOpus; |
132 return audio_config; | 132 return audio_config; |
133 } | 133 } |
134 | 134 |
135 void GetPayloadtype(VideoSenderConfig* video_config) { | 135 void GetPayloadtype(VideoSenderConfig* video_config) { |
136 test::InputBuilder input("Choose video sender payload type.", | 136 test::InputBuilder input("Choose video sender payload type.", |
137 DEFAULT_VIDEO_PAYLOAD_TYPE, 96, 127); | 137 DEFAULT_VIDEO_PAYLOAD_TYPE, 96, 127); |
138 video_config->rtp_payload_type = input.GetIntInput(); | 138 video_config->rtp_payload_type = input.GetIntInput(); |
139 } | 139 } |
140 | 140 |
141 void GetVideoCodecSize(VideoSenderConfig* video_config) { | 141 void GetVideoCodecSize(VideoSenderConfig* video_config) { |
(...skipping 29 matching lines...) Expand all Loading... |
171 GetVideoBitrates(&video_config); | 171 GetVideoBitrates(&video_config); |
172 | 172 |
173 video_config.rtcp_c_name = "video_sender@a.b.c.d"; | 173 video_config.rtcp_c_name = "video_sender@a.b.c.d"; |
174 | 174 |
175 video_config.use_external_encoder = false; | 175 video_config.use_external_encoder = false; |
176 | 176 |
177 VLOG(0) << "Using VP8 at 30 fps"; | 177 VLOG(0) << "Using VP8 at 30 fps"; |
178 video_config.min_qp = 4; | 178 video_config.min_qp = 4; |
179 video_config.max_qp = 40; | 179 video_config.max_qp = 40; |
180 video_config.max_frame_rate = 30; | 180 video_config.max_frame_rate = 30; |
181 video_config.codec = kVp8; | 181 video_config.codec = transport::kVp8; |
182 video_config.max_number_of_video_buffers_used = 1; | 182 video_config.max_number_of_video_buffers_used = 1; |
183 video_config.number_of_cores = 1; | 183 video_config.number_of_cores = 1; |
184 return video_config; | 184 return video_config; |
185 } | 185 } |
186 | 186 |
187 class SendProcess { | 187 class SendProcess { |
188 public: | 188 public: |
189 SendProcess(scoped_refptr<base::TaskRunner> thread_proxy, | 189 SendProcess(scoped_refptr<base::TaskRunner> thread_proxy, |
190 base::TickClock* clock, | 190 base::TickClock* clock, |
191 const VideoSenderConfig& video_config, | 191 const VideoSenderConfig& video_config, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 // Enable main and send side threads only. Disable logging. | 309 // Enable main and send side threads only. Disable logging. |
310 scoped_refptr<media::cast::CastEnvironment> cast_environment(new | 310 scoped_refptr<media::cast::CastEnvironment> cast_environment(new |
311 media::cast::CastEnvironment( | 311 media::cast::CastEnvironment( |
312 &clock, | 312 &clock, |
313 main_thread.message_loop_proxy(), | 313 main_thread.message_loop_proxy(), |
314 audio_thread.message_loop_proxy(), | 314 audio_thread.message_loop_proxy(), |
315 NULL, | 315 NULL, |
316 video_thread.message_loop_proxy(), | 316 video_thread.message_loop_proxy(), |
317 NULL, | 317 NULL, |
| 318 main_thread.message_loop_proxy(), |
318 media::cast::GetDefaultCastLoggingConfig())); | 319 media::cast::GetDefaultCastLoggingConfig())); |
319 | 320 |
320 media::cast::AudioSenderConfig audio_config = | 321 media::cast::AudioSenderConfig audio_config = |
321 media::cast::GetAudioSenderConfig(); | 322 media::cast::GetAudioSenderConfig(); |
322 media::cast::VideoSenderConfig video_config = | 323 media::cast::VideoSenderConfig video_config = |
323 media::cast::GetVideoSenderConfig(); | 324 media::cast::GetVideoSenderConfig(); |
324 | 325 |
325 scoped_ptr<media::cast::transport::Transport> transport( | 326 scoped_ptr<media::cast::transport::Transport> transport( |
326 new media::cast::transport::Transport( | 327 new media::cast::transport::Transport( |
327 io_message_loop.message_loop_proxy())); | 328 io_message_loop.message_loop_proxy())); |
328 scoped_ptr<media::cast::CastSender> cast_sender( | 329 scoped_ptr<media::cast::CastSender> cast_sender( |
329 media::cast::CastSender::CreateCastSender(cast_environment, | 330 media::cast::CastSender::CreateCastSender(cast_environment, |
330 audio_config, | 331 audio_config, |
331 video_config, | 332 video_config, |
332 NULL, // VideoEncoderController. | 333 NULL, // VideoEncoderController. |
333 transport->packet_sender())); | 334 transport->packet_sender())); |
334 | 335 |
335 media::cast::PacketReceiver* packet_receiver = cast_sender->packet_receiver(); | 336 media::cast::transport::PacketReceiver* packet_receiver = |
| 337 cast_sender->packet_receiver(); |
336 | 338 |
337 int send_to_port, receive_port; | 339 int send_to_port, receive_port; |
338 media::cast::GetPorts(&send_to_port, &receive_port); | 340 media::cast::GetPorts(&send_to_port, &receive_port); |
339 std::string ip_address = media::cast::GetIpAddress("Enter destination IP."); | 341 std::string ip_address = media::cast::GetIpAddress("Enter destination IP."); |
340 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); | 342 std::string local_ip_address = media::cast::GetIpAddress("Enter local IP."); |
341 | 343 |
342 transport->SetLocalReceiver(packet_receiver, ip_address, local_ip_address, | 344 transport->SetLocalReceiver(packet_receiver, ip_address, local_ip_address, |
343 receive_port); | 345 receive_port); |
344 transport->SetSendDestination(ip_address, send_to_port); | 346 transport->SetSendDestination(ip_address, send_to_port); |
345 | 347 |
346 media::cast::FrameInput* frame_input = cast_sender->frame_input(); | 348 media::cast::FrameInput* frame_input = cast_sender->frame_input(); |
347 scoped_ptr<media::cast::SendProcess> send_process(new | 349 scoped_ptr<media::cast::SendProcess> send_process(new |
348 media::cast::SendProcess(test_thread.message_loop_proxy(), | 350 media::cast::SendProcess(test_thread.message_loop_proxy(), |
349 cast_environment->Clock(), | 351 cast_environment->Clock(), |
350 video_config, | 352 video_config, |
351 frame_input)); | 353 frame_input)); |
352 | 354 |
353 send_process->SendFrame(); | 355 send_process->SendFrame(); |
354 io_message_loop.Run(); | 356 io_message_loop.Run(); |
355 transport->StopReceiving(); | 357 transport->StopReceiving(); |
356 return 0; | 358 return 0; |
357 } | 359 } |
OLD | NEW |