OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/video/video_quality_test.h" | 10 #include "webrtc/video/video_quality_test.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | 31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
33 #include "webrtc/rtc_base/checks.h" | 33 #include "webrtc/rtc_base/checks.h" |
34 #include "webrtc/rtc_base/cpu_time.h" | 34 #include "webrtc/rtc_base/cpu_time.h" |
35 #include "webrtc/rtc_base/event.h" | 35 #include "webrtc/rtc_base/event.h" |
36 #include "webrtc/rtc_base/format_macros.h" | 36 #include "webrtc/rtc_base/format_macros.h" |
37 #include "webrtc/rtc_base/memory_usage.h" | 37 #include "webrtc/rtc_base/memory_usage.h" |
38 #include "webrtc/rtc_base/optional.h" | 38 #include "webrtc/rtc_base/optional.h" |
39 #include "webrtc/rtc_base/platform_file.h" | 39 #include "webrtc/rtc_base/platform_file.h" |
| 40 #include "webrtc/rtc_base/ptr_util.h" |
40 #include "webrtc/rtc_base/timeutils.h" | 41 #include "webrtc/rtc_base/timeutils.h" |
41 #include "webrtc/system_wrappers/include/cpu_info.h" | 42 #include "webrtc/system_wrappers/include/cpu_info.h" |
42 #include "webrtc/system_wrappers/include/field_trial.h" | 43 #include "webrtc/system_wrappers/include/field_trial.h" |
43 #include "webrtc/test/gtest.h" | 44 #include "webrtc/test/gtest.h" |
44 #include "webrtc/test/layer_filtering_transport.h" | 45 #include "webrtc/test/layer_filtering_transport.h" |
45 #include "webrtc/test/run_loop.h" | 46 #include "webrtc/test/run_loop.h" |
46 #include "webrtc/test/statistics.h" | 47 #include "webrtc/test/statistics.h" |
47 #include "webrtc/test/testsupport/fileutils.h" | 48 #include "webrtc/test/testsupport/fileutils.h" |
48 #include "webrtc/test/testsupport/frame_writer.h" | 49 #include "webrtc/test/testsupport/frame_writer.h" |
49 #include "webrtc/test/vcm_capturer.h" | 50 #include "webrtc/test/vcm_capturer.h" |
(...skipping 1594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 | 1645 |
1645 void VideoQualityTest::DestroyThumbnailStreams() { | 1646 void VideoQualityTest::DestroyThumbnailStreams() { |
1646 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) | 1647 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) |
1647 receiver_call_->DestroyVideoSendStream(thumbnail_send_stream); | 1648 receiver_call_->DestroyVideoSendStream(thumbnail_send_stream); |
1648 thumbnail_send_streams_.clear(); | 1649 thumbnail_send_streams_.clear(); |
1649 for (VideoReceiveStream* thumbnail_receive_stream : | 1650 for (VideoReceiveStream* thumbnail_receive_stream : |
1650 thumbnail_receive_streams_) | 1651 thumbnail_receive_streams_) |
1651 sender_call_->DestroyVideoReceiveStream(thumbnail_receive_stream); | 1652 sender_call_->DestroyVideoReceiveStream(thumbnail_receive_stream); |
1652 thumbnail_send_streams_.clear(); | 1653 thumbnail_send_streams_.clear(); |
1653 thumbnail_receive_streams_.clear(); | 1654 thumbnail_receive_streams_.clear(); |
| 1655 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : |
| 1656 thumbnail_capturers_) { |
| 1657 video_caputurer.reset(); |
| 1658 } |
1654 } | 1659 } |
1655 | 1660 |
1656 void VideoQualityTest::SetupScreenshareOrSVC() { | 1661 void VideoQualityTest::SetupScreenshareOrSVC() { |
1657 if (params_.screenshare.enabled) { | 1662 if (params_.screenshare.enabled) { |
1658 // Fill out codec settings. | 1663 // Fill out codec settings. |
1659 video_encoder_config_.content_type = | 1664 video_encoder_config_.content_type = |
1660 VideoEncoderConfig::ContentType::kScreen; | 1665 VideoEncoderConfig::ContentType::kScreen; |
1661 degradation_preference_ = | 1666 degradation_preference_ = |
1662 VideoSendStream::DegradationPreference::kMaintainResolution; | 1667 VideoSendStream::DegradationPreference::kMaintainResolution; |
1663 if (params_.video.codec == "VP8") { | 1668 if (params_.video.codec == "VP8") { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 clock_)); | 1767 clock_)); |
1763 ASSERT_TRUE(video_capturer_) << "Could not create capturer for " | 1768 ASSERT_TRUE(video_capturer_) << "Could not create capturer for " |
1764 << params_.video.clip_name | 1769 << params_.video.clip_name |
1765 << ".yuv. Is this resource file present?"; | 1770 << ".yuv. Is this resource file present?"; |
1766 } | 1771 } |
1767 } | 1772 } |
1768 RTC_DCHECK(video_capturer_.get()); | 1773 RTC_DCHECK(video_capturer_.get()); |
1769 } | 1774 } |
1770 | 1775 |
1771 void VideoQualityTest::RunWithAnalyzer(const Params& params) { | 1776 void VideoQualityTest::RunWithAnalyzer(const Params& params) { |
| 1777 std::unique_ptr<test::LayerFilteringTransport> send_transport; |
| 1778 std::unique_ptr<test::DirectTransport> recv_transport; |
| 1779 FILE* graph_data_output_file = nullptr; |
| 1780 std::unique_ptr<VideoAnalyzer> analyzer; |
| 1781 |
1772 params_ = params; | 1782 params_ = params; |
1773 | 1783 |
1774 RTC_CHECK(!params_.audio.enabled); | 1784 RTC_CHECK(!params_.audio.enabled); |
1775 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to | 1785 // TODO(ivica): Merge with RunWithRenderer and use a flag / argument to |
1776 // differentiate between the analyzer and the renderer case. | 1786 // differentiate between the analyzer and the renderer case. |
1777 CheckParams(); | 1787 CheckParams(); |
1778 | 1788 |
1779 FILE* graph_data_output_file = nullptr; | |
1780 if (!params_.analyzer.graph_data_output_filename.empty()) { | 1789 if (!params_.analyzer.graph_data_output_filename.empty()) { |
1781 graph_data_output_file = | 1790 graph_data_output_file = |
1782 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); | 1791 fopen(params_.analyzer.graph_data_output_filename.c_str(), "w"); |
1783 RTC_CHECK(graph_data_output_file) | 1792 RTC_CHECK(graph_data_output_file) |
1784 << "Can't open the file " << params_.analyzer.graph_data_output_filename | 1793 << "Can't open the file " << params_.analyzer.graph_data_output_filename |
1785 << "!"; | 1794 << "!"; |
1786 } | 1795 } |
1787 | 1796 |
1788 if (!params.logging.rtc_event_log_name.empty()) { | 1797 if (!params.logging.rtc_event_log_name.empty()) { |
1789 event_log_ = RtcEventLog::Create(clock_); | 1798 event_log_ = RtcEventLog::Create(clock_); |
1790 bool event_log_started = | 1799 bool event_log_started = |
1791 event_log_->StartLogging(params.logging.rtc_event_log_name, -1); | 1800 event_log_->StartLogging(params.logging.rtc_event_log_name, -1); |
1792 RTC_DCHECK(event_log_started); | 1801 RTC_DCHECK(event_log_started); |
1793 } | 1802 } |
1794 | 1803 |
1795 Call::Config call_config(event_log_.get()); | 1804 Call::Config call_config(event_log_.get()); |
1796 call_config.bitrate_config = params.call.call_bitrate_config; | 1805 call_config.bitrate_config = params.call.call_bitrate_config; |
1797 CreateCalls(call_config, call_config); | |
1798 | 1806 |
1799 test::LayerFilteringTransport send_transport( | 1807 task_queue_.SendTask([this, &call_config, &send_transport, |
1800 params_.pipe, sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9, | 1808 &recv_transport]() { |
1801 params_.video.selected_tl, params_.ss.selected_sl, payload_type_map_); | 1809 CreateCalls(call_config, call_config); |
1802 | 1810 |
1803 test::DirectTransport recv_transport(params_.pipe, receiver_call_.get(), | 1811 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>( |
1804 payload_type_map_); | 1812 &task_queue_, params_.pipe, sender_call_.get(), kPayloadTypeVP8, |
| 1813 kPayloadTypeVP9, params_.video.selected_tl, params_.ss.selected_sl, |
| 1814 payload_type_map_); |
| 1815 |
| 1816 recv_transport = rtc::MakeUnique<test::DirectTransport>( |
| 1817 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_); |
| 1818 }); |
1805 | 1819 |
1806 std::string graph_title = params_.analyzer.graph_title; | 1820 std::string graph_title = params_.analyzer.graph_title; |
1807 if (graph_title.empty()) | 1821 if (graph_title.empty()) |
1808 graph_title = VideoQualityTest::GenerateGraphTitle(); | 1822 graph_title = VideoQualityTest::GenerateGraphTitle(); |
1809 | |
1810 bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest"); | 1823 bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest"); |
1811 VideoAnalyzer analyzer( | 1824 analyzer = rtc::MakeUnique<VideoAnalyzer>( |
1812 &send_transport, params_.analyzer.test_label, | 1825 send_transport.get(), params_.analyzer.test_label, |
1813 params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold, | 1826 params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold, |
1814 is_quick_test_enabled | 1827 is_quick_test_enabled |
1815 ? kFramesSentInQuickTest | 1828 ? kFramesSentInQuickTest |
1816 : params_.analyzer.test_durations_secs * params_.video.fps, | 1829 : params_.analyzer.test_durations_secs * params_.video.fps, |
1817 graph_data_output_file, graph_title, | 1830 graph_data_output_file, graph_title, |
1818 kVideoSendSsrcs[params_.ss.selected_stream], | 1831 kVideoSendSsrcs[params_.ss.selected_stream], |
1819 kSendRtxSsrcs[params_.ss.selected_stream], | 1832 kSendRtxSsrcs[params_.ss.selected_stream], |
1820 static_cast<size_t>(params_.ss.selected_stream), params.ss.selected_sl, | 1833 static_cast<size_t>(params_.ss.selected_stream), params.ss.selected_sl, |
1821 params_.video.selected_tl, is_quick_test_enabled, clock_, | 1834 params_.video.selected_tl, is_quick_test_enabled, clock_, |
1822 params_.logging.rtp_dump_name); | 1835 params_.logging.rtp_dump_name); |
1823 analyzer.SetCall(sender_call_.get()); | |
1824 analyzer.SetReceiver(receiver_call_->Receiver()); | |
1825 send_transport.SetReceiver(&analyzer); | |
1826 recv_transport.SetReceiver(sender_call_->Receiver()); | |
1827 | 1836 |
1828 SetupVideo(&analyzer, &recv_transport); | 1837 task_queue_.SendTask([&]() { |
1829 SetupThumbnails(&analyzer, &recv_transport); | 1838 analyzer->SetCall(sender_call_.get()); |
1830 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; | 1839 analyzer->SetReceiver(receiver_call_->Receiver()); |
1831 video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); | 1840 send_transport->SetReceiver(analyzer.get()); |
1832 RTC_DCHECK(!video_send_config_.post_encode_callback); | 1841 recv_transport->SetReceiver(sender_call_->Receiver()); |
1833 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); | |
1834 | 1842 |
1835 SetupScreenshareOrSVC(); | 1843 SetupVideo(analyzer.get(), recv_transport.get()); |
| 1844 SetupThumbnails(analyzer.get(), recv_transport.get()); |
| 1845 video_receive_configs_[params_.ss.selected_stream].renderer = |
| 1846 analyzer.get(); |
| 1847 video_send_config_.pre_encode_callback = analyzer->pre_encode_proxy(); |
| 1848 RTC_DCHECK(!video_send_config_.post_encode_callback); |
| 1849 video_send_config_.post_encode_callback = analyzer->encode_timing_proxy(); |
1836 | 1850 |
1837 CreateFlexfecStreams(); | 1851 SetupScreenshareOrSVC(); |
1838 CreateVideoStreams(); | |
1839 analyzer.SetSendStream(video_send_stream_); | |
1840 if (video_receive_streams_.size() == 1) | |
1841 analyzer.SetReceiveStream(video_receive_streams_[0]); | |
1842 | 1852 |
1843 video_send_stream_->SetSource(analyzer.OutputInterface(), | 1853 CreateFlexfecStreams(); |
1844 degradation_preference_); | 1854 CreateVideoStreams(); |
| 1855 analyzer->SetSendStream(video_send_stream_); |
| 1856 if (video_receive_streams_.size() == 1) |
| 1857 analyzer->SetReceiveStream(video_receive_streams_[0]); |
1845 | 1858 |
1846 SetupThumbnailCapturers(params_.call.num_thumbnails); | 1859 video_send_stream_->SetSource(analyzer->OutputInterface(), |
1847 for (size_t i = 0; i < thumbnail_send_streams_.size(); ++i) { | 1860 degradation_preference_); |
1848 thumbnail_send_streams_[i]->SetSource(thumbnail_capturers_[i].get(), | |
1849 degradation_preference_); | |
1850 } | |
1851 | 1861 |
1852 CreateCapturer(); | 1862 SetupThumbnailCapturers(params_.call.num_thumbnails); |
| 1863 for (size_t i = 0; i < thumbnail_send_streams_.size(); ++i) { |
| 1864 thumbnail_send_streams_[i]->SetSource(thumbnail_capturers_[i].get(), |
| 1865 degradation_preference_); |
| 1866 } |
1853 | 1867 |
1854 analyzer.SetSource(video_capturer_.get(), params_.ss.infer_streams); | 1868 CreateCapturer(); |
1855 | 1869 |
1856 StartEncodedFrameLogs(video_send_stream_); | 1870 analyzer->SetSource(video_capturer_.get(), params_.ss.infer_streams); |
1857 StartEncodedFrameLogs(video_receive_streams_[params_.ss.selected_stream]); | |
1858 video_send_stream_->Start(); | |
1859 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) | |
1860 thumbnail_send_stream->Start(); | |
1861 for (VideoReceiveStream* receive_stream : video_receive_streams_) | |
1862 receive_stream->Start(); | |
1863 for (VideoReceiveStream* thumbnail_receive_stream : | |
1864 thumbnail_receive_streams_) | |
1865 thumbnail_receive_stream->Start(); | |
1866 | 1871 |
1867 analyzer.StartMeasuringCpuProcessTime(); | 1872 StartEncodedFrameLogs(video_send_stream_); |
| 1873 StartEncodedFrameLogs(video_receive_streams_[params_.ss.selected_stream]); |
| 1874 video_send_stream_->Start(); |
| 1875 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) |
| 1876 thumbnail_send_stream->Start(); |
| 1877 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
| 1878 receive_stream->Start(); |
| 1879 for (VideoReceiveStream* thumbnail_receive_stream : |
| 1880 thumbnail_receive_streams_) |
| 1881 thumbnail_receive_stream->Start(); |
1868 | 1882 |
1869 video_capturer_->Start(); | 1883 analyzer->StartMeasuringCpuProcessTime(); |
1870 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : | |
1871 thumbnail_capturers_) { | |
1872 video_caputurer->Start(); | |
1873 } | |
1874 | 1884 |
1875 analyzer.Wait(); | 1885 video_capturer_->Start(); |
| 1886 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : |
| 1887 thumbnail_capturers_) { |
| 1888 video_caputurer->Start(); |
| 1889 } |
| 1890 }); |
1876 | 1891 |
1877 send_transport.StopSending(); | 1892 analyzer->Wait(); |
1878 recv_transport.StopSending(); | |
1879 | 1893 |
1880 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : | 1894 task_queue_.SendTask([&]() { |
1881 thumbnail_capturers_) | 1895 for (std::unique_ptr<test::VideoCapturer>& video_caputurer : |
1882 video_caputurer->Stop(); | 1896 thumbnail_capturers_) |
1883 video_capturer_->Stop(); | 1897 video_caputurer->Stop(); |
1884 for (VideoReceiveStream* thumbnail_receive_stream : | 1898 video_capturer_->Stop(); |
1885 thumbnail_receive_streams_) | 1899 for (VideoReceiveStream* thumbnail_receive_stream : |
1886 thumbnail_receive_stream->Stop(); | 1900 thumbnail_receive_streams_) |
1887 for (VideoReceiveStream* receive_stream : video_receive_streams_) | 1901 thumbnail_receive_stream->Stop(); |
1888 receive_stream->Stop(); | 1902 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
1889 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) | 1903 receive_stream->Stop(); |
1890 thumbnail_send_stream->Stop(); | 1904 for (VideoSendStream* thumbnail_send_stream : thumbnail_send_streams_) |
1891 video_send_stream_->Stop(); | 1905 thumbnail_send_stream->Stop(); |
| 1906 video_send_stream_->Stop(); |
1892 | 1907 |
1893 DestroyStreams(); | 1908 DestroyStreams(); |
1894 DestroyThumbnailStreams(); | 1909 DestroyThumbnailStreams(); |
1895 | 1910 |
1896 event_log_->StopLogging(); | 1911 event_log_->StopLogging(); |
1897 if (graph_data_output_file) | 1912 if (graph_data_output_file) |
1898 fclose(graph_data_output_file); | 1913 fclose(graph_data_output_file); |
| 1914 |
| 1915 video_capturer_.reset(); |
| 1916 send_transport.reset(); |
| 1917 recv_transport.reset(); |
| 1918 |
| 1919 DestroyCalls(); |
| 1920 }); |
1899 } | 1921 } |
1900 | 1922 |
1901 void VideoQualityTest::SetupAudio(int send_channel_id, | 1923 void VideoQualityTest::SetupAudio(int send_channel_id, |
1902 int receive_channel_id, | 1924 int receive_channel_id, |
1903 Transport* transport, | 1925 Transport* transport, |
1904 AudioReceiveStream** audio_receive_stream) { | 1926 AudioReceiveStream** audio_receive_stream) { |
1905 audio_send_config_ = AudioSendStream::Config(transport); | 1927 audio_send_config_ = AudioSendStream::Config(transport); |
1906 audio_send_config_.voe_channel_id = send_channel_id; | 1928 audio_send_config_.voe_channel_id = send_channel_id; |
1907 audio_send_config_.rtp.ssrc = kAudioSendSsrc; | 1929 audio_send_config_.rtp.ssrc = kAudioSendSsrc; |
1908 | 1930 |
(...skipping 26 matching lines...) Expand all Loading... |
1935 audio_config.decoder_factory = decoder_factory_; | 1957 audio_config.decoder_factory = decoder_factory_; |
1936 audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}}; | 1958 audio_config.decoder_map = {{kAudioSendPayloadType, {"OPUS", 48000, 2}}}; |
1937 if (params_.video.enabled && params_.audio.sync_video) | 1959 if (params_.video.enabled && params_.audio.sync_video) |
1938 audio_config.sync_group = kSyncGroup; | 1960 audio_config.sync_group = kSyncGroup; |
1939 | 1961 |
1940 *audio_receive_stream = | 1962 *audio_receive_stream = |
1941 receiver_call_->CreateAudioReceiveStream(audio_config); | 1963 receiver_call_->CreateAudioReceiveStream(audio_config); |
1942 } | 1964 } |
1943 | 1965 |
1944 void VideoQualityTest::RunWithRenderers(const Params& params) { | 1966 void VideoQualityTest::RunWithRenderers(const Params& params) { |
1945 params_ = params; | 1967 std::unique_ptr<test::LayerFilteringTransport> send_transport; |
1946 CheckParams(); | 1968 std::unique_ptr<test::DirectTransport> recv_transport; |
| 1969 ::VoiceEngineState voe; |
| 1970 std::unique_ptr<test::VideoRenderer> local_preview; |
| 1971 std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers; |
| 1972 AudioReceiveStream* audio_receive_stream = nullptr; |
1947 | 1973 |
1948 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to | 1974 task_queue_.SendTask([&]() { |
1949 // match the full stack tests. | 1975 params_ = params; |
1950 Call::Config call_config(event_log_.get()); | 1976 CheckParams(); |
1951 call_config.bitrate_config = params_.call.call_bitrate_config; | |
1952 | 1977 |
1953 ::VoiceEngineState voe; | 1978 // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to |
1954 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing( | 1979 // match the full stack tests. |
1955 webrtc::AudioProcessing::Create()); | 1980 Call::Config call_config(event_log_.get()); |
| 1981 call_config.bitrate_config = params_.call.call_bitrate_config; |
1956 | 1982 |
1957 if (params_.audio.enabled) { | 1983 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing( |
1958 CreateVoiceEngine(&voe, audio_processing.get(), decoder_factory_); | 1984 webrtc::AudioProcessing::Create()); |
1959 AudioState::Config audio_state_config; | |
1960 audio_state_config.voice_engine = voe.voice_engine; | |
1961 audio_state_config.audio_mixer = AudioMixerImpl::Create(); | |
1962 audio_state_config.audio_processing = audio_processing; | |
1963 call_config.audio_state = AudioState::Create(audio_state_config); | |
1964 } | |
1965 | 1985 |
1966 CreateCalls(call_config, call_config); | 1986 if (params_.audio.enabled) { |
1967 | 1987 CreateVoiceEngine(&voe, audio_processing.get(), decoder_factory_); |
1968 // TODO(minyue): consider if this is a good transport even for audio only | 1988 AudioState::Config audio_state_config; |
1969 // calls. | 1989 audio_state_config.voice_engine = voe.voice_engine; |
1970 test::LayerFilteringTransport send_transport( | 1990 audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
1971 params.pipe, sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9, | 1991 audio_state_config.audio_processing = audio_processing; |
1972 params.video.selected_tl, params_.ss.selected_sl, payload_type_map_); | 1992 call_config.audio_state = AudioState::Create(audio_state_config); |
1973 | |
1974 test::DirectTransport recv_transport(params_.pipe, receiver_call_.get(), | |
1975 payload_type_map_); | |
1976 | |
1977 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at | |
1978 // least share as much code as possible. That way this test would also match | |
1979 // the full stack tests better. | |
1980 send_transport.SetReceiver(receiver_call_->Receiver()); | |
1981 recv_transport.SetReceiver(sender_call_->Receiver()); | |
1982 | |
1983 std::unique_ptr<test::VideoRenderer> local_preview; | |
1984 std::vector<std::unique_ptr<test::VideoRenderer>> loopback_renderers_; | |
1985 if (params_.video.enabled) { | |
1986 // Create video renderers. | |
1987 local_preview.reset(test::VideoRenderer::Create( | |
1988 "Local Preview", params_.video.width, params_.video.height)); | |
1989 | |
1990 const size_t selected_stream_id = params_.ss.selected_stream; | |
1991 const size_t num_streams = params_.ss.streams.size(); | |
1992 | |
1993 if (selected_stream_id == num_streams) { | |
1994 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { | |
1995 std::ostringstream oss; | |
1996 oss << "Loopback Video - Stream #" << static_cast<int>(stream_id); | |
1997 loopback_renderers_.emplace_back(test::VideoRenderer::Create( | |
1998 oss.str().c_str(), params_.ss.streams[stream_id].width, | |
1999 params_.ss.streams[stream_id].height)); | |
2000 } | |
2001 } else { | |
2002 loopback_renderers_.emplace_back(test::VideoRenderer::Create( | |
2003 "Loopback Video", params_.ss.streams[selected_stream_id].width, | |
2004 params_.ss.streams[selected_stream_id].height)); | |
2005 } | 1993 } |
2006 | 1994 |
2007 SetupVideo(&send_transport, &recv_transport); | 1995 CreateCalls(call_config, call_config); |
2008 | 1996 |
2009 video_send_config_.pre_encode_callback = local_preview.get(); | 1997 // TODO(minyue): consider if this is a good transport even for audio only |
2010 if (selected_stream_id == num_streams) { | 1998 // calls. |
2011 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { | 1999 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>( |
2012 video_receive_configs_[stream_id].renderer = | 2000 &task_queue_, params.pipe, sender_call_.get(), kPayloadTypeVP8, |
2013 loopback_renderers_[stream_id].get(); | 2001 kPayloadTypeVP9, params.video.selected_tl, params_.ss.selected_sl, |
| 2002 payload_type_map_); |
| 2003 |
| 2004 recv_transport = rtc::MakeUnique<test::DirectTransport>( |
| 2005 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_); |
| 2006 |
| 2007 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at |
| 2008 // least share as much code as possible. That way this test would also match |
| 2009 // the full stack tests better. |
| 2010 send_transport->SetReceiver(receiver_call_->Receiver()); |
| 2011 recv_transport->SetReceiver(sender_call_->Receiver()); |
| 2012 |
| 2013 if (params_.video.enabled) { |
| 2014 // Create video renderers. |
| 2015 local_preview.reset(test::VideoRenderer::Create( |
| 2016 "Local Preview", params_.video.width, params_.video.height)); |
| 2017 |
| 2018 const size_t selected_stream_id = params_.ss.selected_stream; |
| 2019 const size_t num_streams = params_.ss.streams.size(); |
| 2020 |
| 2021 if (selected_stream_id == num_streams) { |
| 2022 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { |
| 2023 std::ostringstream oss; |
| 2024 oss << "Loopback Video - Stream #" << static_cast<int>(stream_id); |
| 2025 loopback_renderers.emplace_back(test::VideoRenderer::Create( |
| 2026 oss.str().c_str(), params_.ss.streams[stream_id].width, |
| 2027 params_.ss.streams[stream_id].height)); |
| 2028 } |
| 2029 } else { |
| 2030 loopback_renderers.emplace_back(test::VideoRenderer::Create( |
| 2031 "Loopback Video", params_.ss.streams[selected_stream_id].width, |
| 2032 params_.ss.streams[selected_stream_id].height)); |
| 2033 } |
| 2034 |
| 2035 SetupVideo(send_transport.get(), recv_transport.get()); |
| 2036 |
| 2037 video_send_config_.pre_encode_callback = local_preview.get(); |
| 2038 if (selected_stream_id == num_streams) { |
| 2039 for (size_t stream_id = 0; stream_id < num_streams; ++stream_id) { |
| 2040 video_receive_configs_[stream_id].renderer = |
| 2041 loopback_renderers[stream_id].get(); |
| 2042 if (params_.audio.enabled && params_.audio.sync_video) |
| 2043 video_receive_configs_[stream_id].sync_group = kSyncGroup; |
| 2044 } |
| 2045 } else { |
| 2046 video_receive_configs_[selected_stream_id].renderer = |
| 2047 loopback_renderers.back().get(); |
2014 if (params_.audio.enabled && params_.audio.sync_video) | 2048 if (params_.audio.enabled && params_.audio.sync_video) |
2015 video_receive_configs_[stream_id].sync_group = kSyncGroup; | 2049 video_receive_configs_[selected_stream_id].sync_group = kSyncGroup; |
2016 } | 2050 } |
2017 } else { | 2051 |
2018 video_receive_configs_[selected_stream_id].renderer = | 2052 if (params_.screenshare.enabled) |
2019 loopback_renderers_.back().get(); | 2053 SetupScreenshareOrSVC(); |
2020 if (params_.audio.enabled && params_.audio.sync_video) | 2054 |
2021 video_receive_configs_[selected_stream_id].sync_group = kSyncGroup; | 2055 CreateFlexfecStreams(); |
| 2056 CreateVideoStreams(); |
| 2057 |
| 2058 CreateCapturer(); |
| 2059 video_send_stream_->SetSource(video_capturer_.get(), |
| 2060 degradation_preference_); |
2022 } | 2061 } |
2023 | 2062 |
2024 if (params_.screenshare.enabled) | 2063 if (params_.audio.enabled) { |
2025 SetupScreenshareOrSVC(); | 2064 SetupAudio(voe.send_channel_id, voe.receive_channel_id, |
| 2065 send_transport.get(), &audio_receive_stream); |
| 2066 } |
2026 | 2067 |
2027 CreateFlexfecStreams(); | 2068 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
2028 CreateVideoStreams(); | 2069 StartEncodedFrameLogs(receive_stream); |
| 2070 StartEncodedFrameLogs(video_send_stream_); |
2029 | 2071 |
2030 CreateCapturer(); | 2072 // Start sending and receiving video. |
2031 video_send_stream_->SetSource(video_capturer_.get(), | 2073 if (params_.video.enabled) { |
2032 degradation_preference_); | 2074 for (VideoReceiveStream* video_receive_stream : video_receive_streams_) |
2033 } | 2075 video_receive_stream->Start(); |
2034 | 2076 |
2035 AudioReceiveStream* audio_receive_stream = nullptr; | 2077 video_send_stream_->Start(); |
2036 if (params_.audio.enabled) { | 2078 video_capturer_->Start(); |
2037 SetupAudio(voe.send_channel_id, voe.receive_channel_id, &send_transport, | 2079 } |
2038 &audio_receive_stream); | |
2039 } | |
2040 | 2080 |
2041 for (VideoReceiveStream* receive_stream : video_receive_streams_) | 2081 if (params_.audio.enabled) { |
2042 StartEncodedFrameLogs(receive_stream); | 2082 // Start receiving audio. |
2043 StartEncodedFrameLogs(video_send_stream_); | 2083 audio_receive_stream->Start(); |
| 2084 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); |
2044 | 2085 |
2045 // Start sending and receiving video. | 2086 // Start sending audio. |
2046 if (params_.video.enabled) { | 2087 audio_send_stream_->Start(); |
2047 for (VideoReceiveStream* video_receive_stream : video_receive_streams_) | 2088 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id)); |
2048 video_receive_stream->Start(); | 2089 } |
2049 | 2090 }); |
2050 video_send_stream_->Start(); | |
2051 video_capturer_->Start(); | |
2052 } | |
2053 | |
2054 if (params_.audio.enabled) { | |
2055 // Start receiving audio. | |
2056 audio_receive_stream->Start(); | |
2057 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); | |
2058 | |
2059 // Start sending audio. | |
2060 audio_send_stream_->Start(); | |
2061 EXPECT_EQ(0, voe.base->StartSend(voe.send_channel_id)); | |
2062 } | |
2063 | 2091 |
2064 test::PressEnterToContinue(); | 2092 test::PressEnterToContinue(); |
2065 | 2093 |
2066 if (params_.audio.enabled) { | 2094 task_queue_.SendTask([&]() { |
2067 // Stop sending audio. | 2095 if (params_.audio.enabled) { |
2068 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id)); | 2096 // Stop sending audio. |
2069 audio_send_stream_->Stop(); | 2097 EXPECT_EQ(0, voe.base->StopSend(voe.send_channel_id)); |
| 2098 audio_send_stream_->Stop(); |
2070 | 2099 |
2071 // Stop receiving audio. | 2100 // Stop receiving audio. |
2072 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id)); | 2101 EXPECT_EQ(0, voe.base->StopPlayout(voe.receive_channel_id)); |
2073 audio_receive_stream->Stop(); | 2102 audio_receive_stream->Stop(); |
2074 sender_call_->DestroyAudioSendStream(audio_send_stream_); | 2103 sender_call_->DestroyAudioSendStream(audio_send_stream_); |
2075 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); | 2104 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); |
2076 } | 2105 } |
2077 | 2106 |
2078 // Stop receiving and sending video. | 2107 // Stop receiving and sending video. |
2079 if (params_.video.enabled) { | 2108 if (params_.video.enabled) { |
2080 video_capturer_->Stop(); | 2109 video_capturer_->Stop(); |
2081 video_send_stream_->Stop(); | 2110 video_send_stream_->Stop(); |
2082 for (FlexfecReceiveStream* flexfec_receive_stream : | 2111 for (FlexfecReceiveStream* flexfec_receive_stream : |
2083 flexfec_receive_streams_) { | 2112 flexfec_receive_streams_) { |
2084 for (VideoReceiveStream* video_receive_stream : video_receive_streams_) { | 2113 for (VideoReceiveStream* video_receive_stream : |
2085 video_receive_stream->RemoveSecondarySink(flexfec_receive_stream); | 2114 video_receive_streams_) { |
| 2115 video_receive_stream->RemoveSecondarySink(flexfec_receive_stream); |
| 2116 } |
| 2117 receiver_call_->DestroyFlexfecReceiveStream(flexfec_receive_stream); |
2086 } | 2118 } |
2087 receiver_call_->DestroyFlexfecReceiveStream(flexfec_receive_stream); | 2119 for (VideoReceiveStream* receive_stream : video_receive_streams_) { |
| 2120 receive_stream->Stop(); |
| 2121 receiver_call_->DestroyVideoReceiveStream(receive_stream); |
| 2122 } |
| 2123 sender_call_->DestroyVideoSendStream(video_send_stream_); |
2088 } | 2124 } |
2089 for (VideoReceiveStream* receive_stream : video_receive_streams_) { | |
2090 receive_stream->Stop(); | |
2091 receiver_call_->DestroyVideoReceiveStream(receive_stream); | |
2092 } | |
2093 sender_call_->DestroyVideoSendStream(video_send_stream_); | |
2094 } | |
2095 | 2125 |
2096 send_transport.StopSending(); | 2126 video_capturer_.reset(); |
2097 recv_transport.StopSending(); | 2127 send_transport.reset(); |
| 2128 recv_transport.reset(); |
2098 | 2129 |
2099 if (params_.audio.enabled) | 2130 if (params_.audio.enabled) |
2100 DestroyVoiceEngine(&voe); | 2131 DestroyVoiceEngine(&voe); |
| 2132 |
| 2133 local_preview.reset(); |
| 2134 loopback_renderers.clear(); |
| 2135 |
| 2136 DestroyCalls(); |
| 2137 }); |
2101 } | 2138 } |
2102 | 2139 |
2103 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { | 2140 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) { |
2104 if (!params_.logging.encoded_frame_base_path.empty()) { | 2141 if (!params_.logging.encoded_frame_base_path.empty()) { |
2105 std::ostringstream str; | 2142 std::ostringstream str; |
2106 str << send_logs_++; | 2143 str << send_logs_++; |
2107 std::string prefix = | 2144 std::string prefix = |
2108 params_.logging.encoded_frame_base_path + "." + str.str() + ".send."; | 2145 params_.logging.encoded_frame_base_path + "." + str.str() + ".send."; |
2109 stream->EnableEncodedFrameRecording( | 2146 stream->EnableEncodedFrameRecording( |
2110 std::vector<rtc::PlatformFile>( | 2147 std::vector<rtc::PlatformFile>( |
2111 {rtc::CreatePlatformFile(prefix + "1.ivf"), | 2148 {rtc::CreatePlatformFile(prefix + "1.ivf"), |
2112 rtc::CreatePlatformFile(prefix + "2.ivf"), | 2149 rtc::CreatePlatformFile(prefix + "2.ivf"), |
2113 rtc::CreatePlatformFile(prefix + "3.ivf")}), | 2150 rtc::CreatePlatformFile(prefix + "3.ivf")}), |
2114 100000000); | 2151 100000000); |
2115 } | 2152 } |
2116 } | 2153 } |
2117 | 2154 |
2118 void VideoQualityTest::StartEncodedFrameLogs(VideoReceiveStream* stream) { | 2155 void VideoQualityTest::StartEncodedFrameLogs(VideoReceiveStream* stream) { |
2119 if (!params_.logging.encoded_frame_base_path.empty()) { | 2156 if (!params_.logging.encoded_frame_base_path.empty()) { |
2120 std::ostringstream str; | 2157 std::ostringstream str; |
2121 str << receive_logs_++; | 2158 str << receive_logs_++; |
2122 std::string path = | 2159 std::string path = |
2123 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 2160 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
2124 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 2161 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
2125 100000000); | 2162 100000000); |
2126 } | 2163 } |
2127 } | 2164 } |
2128 } // namespace webrtc | 2165 } // namespace webrtc |
OLD | NEW |