Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: webrtc/video/video_quality_test.cc

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

Powered by Google App Engine
This is Rietveld 408576698