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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 base::WeakPtrFactory<SendProcess> weak_factory_; | 311 base::WeakPtrFactory<SendProcess> weak_factory_; |
312 }; | 312 }; |
313 | 313 |
314 } // namespace cast | 314 } // namespace cast |
315 } // namespace media | 315 } // namespace media |
316 | 316 |
317 namespace { | 317 namespace { |
318 void UpdateCastTransportStatus( | 318 void UpdateCastTransportStatus( |
319 media::cast::transport::CastTransportStatus status) {} | 319 media::cast::transport::CastTransportStatus status) {} |
320 | 320 |
| 321 void LogRawEvents( |
| 322 const scoped_refptr<media::cast::CastEnvironment>& cast_environment, |
| 323 const std::vector<media::cast::PacketEvent>& packet_events) { |
| 324 VLOG(1) << "Got packet events from transport, size: " << packet_events.size(); |
| 325 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 326 packet_events.begin(); |
| 327 it != packet_events.end(); |
| 328 ++it) { |
| 329 cast_environment->Logging()->InsertPacketEvent(it->timestamp, |
| 330 it->type, |
| 331 it->rtp_timestamp, |
| 332 it->frame_id, |
| 333 it->packet_id, |
| 334 it->max_packet_id, |
| 335 it->size); |
| 336 } |
| 337 } |
| 338 |
321 void InitializationResult(media::cast::CastInitializationStatus result) { | 339 void InitializationResult(media::cast::CastInitializationStatus result) { |
322 CHECK_EQ(result, media::cast::STATUS_INITIALIZED); | 340 CHECK_EQ(result, media::cast::STATUS_INITIALIZED); |
323 VLOG(1) << "Cast Sender initialized"; | 341 VLOG(1) << "Cast Sender initialized"; |
324 } | 342 } |
325 | 343 |
326 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { | 344 net::IPEndPoint CreateUDPAddress(std::string ip_str, int port) { |
327 net::IPAddressNumber ip_number; | 345 net::IPAddressNumber ip_number; |
328 CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); | 346 CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); |
329 return net::IPEndPoint(ip_number, port); | 347 return net::IPEndPoint(ip_number, port); |
330 } | 348 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 433 |
416 // Setting up transport config. | 434 // Setting up transport config. |
417 media::cast::transport::CastTransportConfig config; | 435 media::cast::transport::CastTransportConfig config; |
418 config.receiver_endpoint = CreateUDPAddress(remote_ip_address, remote_port); | 436 config.receiver_endpoint = CreateUDPAddress(remote_ip_address, remote_port); |
419 config.local_endpoint = CreateUDPAddress("0.0.0.0", 0); | 437 config.local_endpoint = CreateUDPAddress("0.0.0.0", 0); |
420 config.audio_ssrc = audio_config.sender_ssrc; | 438 config.audio_ssrc = audio_config.sender_ssrc; |
421 config.video_ssrc = video_config.sender_ssrc; | 439 config.video_ssrc = video_config.sender_ssrc; |
422 config.audio_rtp_config = audio_config.rtp_config; | 440 config.audio_rtp_config = audio_config.rtp_config; |
423 config.video_rtp_config = video_config.rtp_config; | 441 config.video_rtp_config = video_config.rtp_config; |
424 | 442 |
425 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( | |
426 media::cast::transport::CastTransportSender::CreateCastTransportSender( | |
427 clock.get(), | |
428 config, | |
429 base::Bind(&UpdateCastTransportStatus), | |
430 io_message_loop.message_loop_proxy())); | |
431 | |
432 // Enable main and send side threads only. Enable raw event logging. | 443 // Enable main and send side threads only. Enable raw event logging. |
433 // Running transport on the main thread. | 444 // Running transport on the main thread. |
| 445 config.enable_raw_event_logging = true; |
434 media::cast::CastLoggingConfig logging_config; | 446 media::cast::CastLoggingConfig logging_config; |
435 logging_config.enable_raw_data_collection = true; | 447 logging_config.enable_raw_data_collection = true; |
436 | 448 |
437 scoped_refptr<media::cast::CastEnvironment> cast_environment( | 449 scoped_refptr<media::cast::CastEnvironment> cast_environment( |
438 new media::cast::CastEnvironment(clock.Pass(), | 450 new media::cast::CastEnvironment(clock.Pass(), |
439 io_message_loop.message_loop_proxy(), | 451 io_message_loop.message_loop_proxy(), |
440 audio_thread.message_loop_proxy(), | 452 audio_thread.message_loop_proxy(), |
441 NULL, | 453 NULL, |
442 video_thread.message_loop_proxy(), | 454 video_thread.message_loop_proxy(), |
443 NULL, | 455 NULL, |
444 io_message_loop.message_loop_proxy(), | 456 io_message_loop.message_loop_proxy(), |
445 logging_config)); | 457 logging_config)); |
446 | 458 |
| 459 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender( |
| 460 media::cast::transport::CastTransportSender::CreateCastTransportSender( |
| 461 cast_environment->Clock(), |
| 462 config, |
| 463 base::Bind(&UpdateCastTransportStatus), |
| 464 base::Bind(&LogRawEvents, cast_environment), |
| 465 io_message_loop.message_loop_proxy())); |
| 466 |
447 scoped_ptr<media::cast::CastSender> cast_sender( | 467 scoped_ptr<media::cast::CastSender> cast_sender( |
448 media::cast::CastSender::CreateCastSender( | 468 media::cast::CastSender::CreateCastSender( |
449 cast_environment, | 469 cast_environment, |
450 &audio_config, | 470 &audio_config, |
451 &video_config, | 471 &video_config, |
452 NULL, // gpu_factories. | 472 NULL, // gpu_factories. |
453 base::Bind(&InitializationResult), | 473 base::Bind(&InitializationResult), |
454 transport_sender.get())); | 474 transport_sender.get())); |
455 | 475 |
456 transport_sender->SetPacketReceiver(cast_sender->packet_receiver()); | 476 transport_sender->SetPacketReceiver(cast_sender->packet_receiver()); |
457 | 477 |
458 media::cast::FrameInput* frame_input = cast_sender->frame_input(); | 478 media::cast::FrameInput* frame_input = cast_sender->frame_input(); |
459 scoped_ptr<media::cast::SendProcess> send_process( | 479 scoped_ptr<media::cast::SendProcess> send_process( |
460 new media::cast::SendProcess(test_thread.message_loop_proxy(), | 480 new media::cast::SendProcess(test_thread.message_loop_proxy(), |
461 cast_environment->Clock(), | 481 cast_environment->Clock(), |
462 video_config, | 482 video_config, |
463 frame_input)); | 483 frame_input)); |
464 | 484 |
465 // Set up event subscribers. | 485 // Set up event subscribers. |
466 // TODO(imcheng): Set up separate subscribers for audio / video / other. | |
467 int logging_duration = media::cast::GetLoggingDuration(); | 486 int logging_duration = media::cast::GetLoggingDuration(); |
468 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber; | 487 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber; |
469 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber; | 488 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber; |
470 if (logging_duration > 0) { | 489 if (logging_duration > 0) { |
471 std::string log_file_name(media::cast::GetLogFileDestination()); | 490 std::string log_file_name(media::cast::GetLogFileDestination()); |
472 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber( | 491 video_event_subscriber.reset(new media::cast::EncodingEventSubscriber( |
473 media::cast::VIDEO_EVENT, 10000)); | 492 media::cast::VIDEO_EVENT, 10000)); |
474 audio_event_subscriber.reset(new media::cast::EncodingEventSubscriber( | 493 audio_event_subscriber.reset(new media::cast::EncodingEventSubscriber( |
475 media::cast::AUDIO_EVENT, 10000)); | 494 media::cast::AUDIO_EVENT, 10000)); |
476 cast_environment->Logging()->AddRawEventSubscriber( | 495 cast_environment->Logging()->AddRawEventSubscriber( |
(...skipping 18 matching lines...) Expand all Loading... |
495 | 514 |
496 test_thread.message_loop_proxy()->PostTask( | 515 test_thread.message_loop_proxy()->PostTask( |
497 FROM_HERE, | 516 FROM_HERE, |
498 base::Bind(&media::cast::SendProcess::SendFrame, | 517 base::Bind(&media::cast::SendProcess::SendFrame, |
499 base::Unretained(send_process.get()))); | 518 base::Unretained(send_process.get()))); |
500 | 519 |
501 io_message_loop.Run(); | 520 io_message_loop.Run(); |
502 | 521 |
503 return 0; | 522 return 0; |
504 } | 523 } |
OLD | NEW |