| 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 <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 AudioSenderConfig GetAudioSenderConfig() { | 93 AudioSenderConfig GetAudioSenderConfig() { |
| 94 AudioSenderConfig audio_config; | 94 AudioSenderConfig audio_config; |
| 95 | 95 |
| 96 audio_config.rtcp_c_name = "audio_sender@a.b.c.d"; | 96 audio_config.rtcp_c_name = "audio_sender@a.b.c.d"; |
| 97 | 97 |
| 98 audio_config.use_external_encoder = false; | 98 audio_config.use_external_encoder = false; |
| 99 audio_config.frequency = kAudioSamplingFrequency; | 99 audio_config.frequency = kAudioSamplingFrequency; |
| 100 audio_config.channels = kAudioChannels; | 100 audio_config.channels = kAudioChannels; |
| 101 audio_config.bitrate = 64000; | 101 audio_config.bitrate = 64000; |
| 102 audio_config.codec = transport::kOpus; | 102 audio_config.codec = transport::kOpus; |
| 103 audio_config.sender_ssrc = 1; | 103 audio_config.rtp_config.ssrc = 1; |
| 104 audio_config.incoming_feedback_ssrc = 2; | 104 audio_config.incoming_feedback_ssrc = 2; |
| 105 audio_config.rtp_config.payload_type = 127; | 105 audio_config.rtp_config.payload_type = 127; |
| 106 audio_config.rtp_config.max_delay_ms = 300; | 106 audio_config.rtp_config.max_delay_ms = 300; |
| 107 return audio_config; | 107 return audio_config; |
| 108 } | 108 } |
| 109 | 109 |
| 110 VideoSenderConfig GetVideoSenderConfig() { | 110 VideoSenderConfig GetVideoSenderConfig() { |
| 111 VideoSenderConfig video_config; | 111 VideoSenderConfig video_config; |
| 112 | 112 |
| 113 video_config.rtcp_c_name = "video_sender@a.b.c.d"; | 113 video_config.rtcp_c_name = "video_sender@a.b.c.d"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 126 // Codec. | 126 // Codec. |
| 127 video_config.codec = transport::kVp8; | 127 video_config.codec = transport::kVp8; |
| 128 video_config.max_number_of_video_buffers_used = 1; | 128 video_config.max_number_of_video_buffers_used = 1; |
| 129 video_config.number_of_encode_threads = 2; | 129 video_config.number_of_encode_threads = 2; |
| 130 | 130 |
| 131 // Quality options. | 131 // Quality options. |
| 132 video_config.min_qp = 4; | 132 video_config.min_qp = 4; |
| 133 video_config.max_qp = 40; | 133 video_config.max_qp = 40; |
| 134 | 134 |
| 135 // SSRCs and payload type. Don't change them. | 135 // SSRCs and payload type. Don't change them. |
| 136 video_config.sender_ssrc = 11; | 136 video_config.rtp_config.ssrc = 11; |
| 137 video_config.incoming_feedback_ssrc = 12; | 137 video_config.incoming_feedback_ssrc = 12; |
| 138 video_config.rtp_config.payload_type = 96; | 138 video_config.rtp_config.payload_type = 96; |
| 139 video_config.rtp_config.max_delay_ms = 300; | 139 video_config.rtp_config.max_delay_ms = 300; |
| 140 return video_config; | 140 return video_config; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void AVFreeFrame(AVFrame* frame) { avcodec_free_frame(&frame); } | 143 void AVFreeFrame(AVFrame* frame) { avcodec_free_frame(&frame); } |
| 144 | 144 |
| 145 class SendProcess { | 145 class SendProcess { |
| 146 public: | 146 public: |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 std::queue<AudioBus*> audio_bus_queue_; | 739 std::queue<AudioBus*> audio_bus_queue_; |
| 740 | 740 |
| 741 DISALLOW_COPY_AND_ASSIGN(SendProcess); | 741 DISALLOW_COPY_AND_ASSIGN(SendProcess); |
| 742 }; | 742 }; |
| 743 | 743 |
| 744 } // namespace cast | 744 } // namespace cast |
| 745 } // namespace media | 745 } // namespace media |
| 746 | 746 |
| 747 namespace { | 747 namespace { |
| 748 void UpdateCastTransportStatus( | 748 void UpdateCastTransportStatus( |
| 749 media::cast::transport::CastTransportStatus status) {} | 749 media::cast::transport::CastTransportStatus status) { |
| 750 VLOG(21) << "Transport status: " << status; |
| 751 } |
| 750 | 752 |
| 751 void LogRawEvents( | 753 void LogRawEvents( |
| 752 const scoped_refptr<media::cast::CastEnvironment>& cast_environment, | 754 const scoped_refptr<media::cast::CastEnvironment>& cast_environment, |
| 753 const std::vector<media::cast::PacketEvent>& packet_events) { | 755 const std::vector<media::cast::PacketEvent>& packet_events) { |
| 754 VLOG(1) << "Got packet events from transport, size: " << packet_events.size(); | 756 VLOG(1) << "Got packet events from transport, size: " << packet_events.size(); |
| 755 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 757 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 756 packet_events.begin(); | 758 packet_events.begin(); |
| 757 it != packet_events.end(); | 759 it != packet_events.end(); |
| 758 ++it) { | 760 ++it) { |
| 759 cast_environment->Logging()->InsertPacketEvent(it->timestamp, | 761 cast_environment->Logging()->InsertPacketEvent(it->timestamp, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 LOG(INFO) << "Sending to " << remote_ip_address << ":" << remote_port | 901 LOG(INFO) << "Sending to " << remote_ip_address << ":" << remote_port |
| 900 << "."; | 902 << "."; |
| 901 | 903 |
| 902 media::cast::AudioSenderConfig audio_config = | 904 media::cast::AudioSenderConfig audio_config = |
| 903 media::cast::GetAudioSenderConfig(); | 905 media::cast::GetAudioSenderConfig(); |
| 904 media::cast::VideoSenderConfig video_config = | 906 media::cast::VideoSenderConfig video_config = |
| 905 media::cast::GetVideoSenderConfig(); | 907 media::cast::GetVideoSenderConfig(); |
| 906 | 908 |
| 907 // Running transport on the main thread. | 909 // Running transport on the main thread. |
| 908 // Setting up transport config. | 910 // Setting up transport config. |
| 909 media::cast::transport::CastTransportAudioConfig transport_audio_config; | |
| 910 media::cast::transport::CastTransportVideoConfig transport_video_config; | |
| 911 net::IPEndPoint remote_endpoint = | 911 net::IPEndPoint remote_endpoint = |
| 912 CreateUDPAddress(remote_ip_address, remote_port); | 912 CreateUDPAddress(remote_ip_address, remote_port); |
| 913 transport_audio_config.base.ssrc = audio_config.sender_ssrc; | |
| 914 transport_audio_config.base.rtp_config = audio_config.rtp_config; | |
| 915 transport_video_config.base.ssrc = video_config.sender_ssrc; | |
| 916 transport_video_config.base.rtp_config = video_config.rtp_config; | |
| 917 | 913 |
| 918 // Enable raw event and stats logging. | 914 // Enable raw event and stats logging. |
| 919 // Running transport on the main thread. | 915 // Running transport on the main thread. |
| 920 scoped_refptr<media::cast::CastEnvironment> cast_environment( | 916 scoped_refptr<media::cast::CastEnvironment> cast_environment( |
| 921 new media::cast::CastEnvironment( | 917 new media::cast::CastEnvironment( |
| 922 make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()), | 918 make_scoped_ptr<base::TickClock>(new base::DefaultTickClock()), |
| 923 io_message_loop.message_loop_proxy(), | 919 io_message_loop.message_loop_proxy(), |
| 924 audio_thread.message_loop_proxy(), | 920 audio_thread.message_loop_proxy(), |
| 925 video_thread.message_loop_proxy())); | 921 video_thread.message_loop_proxy())); |
| 926 | 922 |
| 927 // SendProcess initialization. | 923 // SendProcess initialization. |
| 928 scoped_ptr<media::cast::SendProcess> send_process( | 924 scoped_ptr<media::cast::SendProcess> send_process( |
| 929 new media::cast::SendProcess(test_thread.message_loop_proxy(), | 925 new media::cast::SendProcess(test_thread.message_loop_proxy(), |
| 930 cast_environment->Clock(), | 926 cast_environment->Clock(), |
| 931 video_config)); | 927 video_config)); |
| 932 | 928 |
| 933 // CastTransportSender initialization. | 929 // CastTransportSender initialization. |
| 934 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender = | 930 scoped_ptr<media::cast::transport::CastTransportSender> transport_sender = |
| 935 media::cast::transport::CastTransportSender::Create( | 931 media::cast::transport::CastTransportSender::Create( |
| 936 NULL, // net log. | 932 NULL, // net log. |
| 937 cast_environment->Clock(), | 933 cast_environment->Clock(), |
| 938 remote_endpoint, | 934 remote_endpoint, |
| 939 base::Bind(&UpdateCastTransportStatus), | 935 base::Bind(&UpdateCastTransportStatus), |
| 940 base::Bind(&LogRawEvents, cast_environment), | 936 base::Bind(&LogRawEvents, cast_environment), |
| 941 base::TimeDelta::FromSeconds(1), | 937 base::TimeDelta::FromSeconds(1), |
| 942 io_message_loop.message_loop_proxy()); | 938 io_message_loop.message_loop_proxy()); |
| 943 transport_sender->InitializeAudio(transport_audio_config); | |
| 944 transport_sender->InitializeVideo(transport_video_config); | |
| 945 | 939 |
| 946 // CastSender initialization. | 940 // CastSender initialization. |
| 947 scoped_ptr<media::cast::CastSender> cast_sender = | 941 scoped_ptr<media::cast::CastSender> cast_sender = |
| 948 media::cast::CastSender::Create(cast_environment, transport_sender.get()); | 942 media::cast::CastSender::Create(cast_environment, transport_sender.get()); |
| 949 cast_sender->InitializeVideo( | 943 cast_sender->InitializeVideo( |
| 950 send_process->get_video_config(), | 944 send_process->get_video_config(), |
| 951 base::Bind(&InitializationResult), | 945 base::Bind(&InitializationResult), |
| 952 media::cast::CreateDefaultVideoEncodeAcceleratorCallback(), | 946 media::cast::CreateDefaultVideoEncodeAcceleratorCallback(), |
| 953 media::cast::CreateDefaultVideoEncodeMemoryCallback()); | 947 media::cast::CreateDefaultVideoEncodeMemoryCallback()); |
| 954 cast_sender->InitializeAudio(audio_config, base::Bind(&InitializationResult)); | 948 cast_sender->InitializeAudio(audio_config, base::Bind(&InitializationResult)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 base::Passed(&audio_stats_subscriber), | 1012 base::Passed(&audio_stats_subscriber), |
| 1019 base::Passed(&offset_estimator)), | 1013 base::Passed(&offset_estimator)), |
| 1020 base::TimeDelta::FromSeconds(logging_duration_seconds)); | 1014 base::TimeDelta::FromSeconds(logging_duration_seconds)); |
| 1021 | 1015 |
| 1022 send_process->Start(cast_sender->audio_frame_input(), | 1016 send_process->Start(cast_sender->audio_frame_input(), |
| 1023 cast_sender->video_frame_input()); | 1017 cast_sender->video_frame_input()); |
| 1024 | 1018 |
| 1025 io_message_loop.Run(); | 1019 io_message_loop.Run(); |
| 1026 return 0; | 1020 return 0; |
| 1027 } | 1021 } |
| OLD | NEW |