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

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

Issue 2997393002: Move rtp dump writer from quality test to test transport (Closed)
Patch Set: Remove forgotten temp code 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "webrtc/test/gtest.h" 44 #include "webrtc/test/gtest.h"
45 #include "webrtc/test/layer_filtering_transport.h" 45 #include "webrtc/test/layer_filtering_transport.h"
46 #include "webrtc/test/run_loop.h" 46 #include "webrtc/test/run_loop.h"
47 #include "webrtc/test/statistics.h" 47 #include "webrtc/test/statistics.h"
48 #include "webrtc/test/testsupport/fileutils.h" 48 #include "webrtc/test/testsupport/fileutils.h"
49 #include "webrtc/test/testsupport/frame_writer.h" 49 #include "webrtc/test/testsupport/frame_writer.h"
50 #include "webrtc/test/vcm_capturer.h" 50 #include "webrtc/test/vcm_capturer.h"
51 #include "webrtc/test/video_renderer.h" 51 #include "webrtc/test/video_renderer.h"
52 #include "webrtc/voice_engine/include/voe_base.h" 52 #include "webrtc/voice_engine/include/voe_base.h"
53 53
54 #include "webrtc/test/rtp_file_writer.h" 54 #include "webrtc/test/rtp_file_writer.h"
ilnik 2017/08/23 08:24:25 This include should go after line 45.
sprang_webrtc 2017/08/23 10:32:05 Done.
55 55
56 namespace { 56 namespace {
57 57
58 constexpr int kSendStatsPollingIntervalMs = 1000; 58 constexpr int kSendStatsPollingIntervalMs = 1000;
59 59
60 constexpr size_t kMaxComparisons = 10; 60 constexpr size_t kMaxComparisons = 10;
61 constexpr char kSyncGroup[] = "av_sync"; 61 constexpr char kSyncGroup[] = "av_sync";
62 constexpr int kOpusMinBitrateBps = 6000; 62 constexpr int kOpusMinBitrateBps = 6000;
63 constexpr int kOpusBitrateFbBps = 32000; 63 constexpr int kOpusBitrateFbBps = 32000;
64 constexpr int kFramesSentInQuickTest = 1; 64 constexpr int kFramesSentInQuickTest = 1;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 double avg_ssim_threshold, 146 double avg_ssim_threshold,
147 int duration_frames, 147 int duration_frames,
148 FILE* graph_data_output_file, 148 FILE* graph_data_output_file,
149 const std::string& graph_title, 149 const std::string& graph_title,
150 uint32_t ssrc_to_analyze, 150 uint32_t ssrc_to_analyze,
151 uint32_t rtx_ssrc_to_analyze, 151 uint32_t rtx_ssrc_to_analyze,
152 size_t selected_stream, 152 size_t selected_stream,
153 int selected_sl, 153 int selected_sl,
154 int selected_tl, 154 int selected_tl,
155 bool is_quick_test_enabled, 155 bool is_quick_test_enabled,
156 Clock* clock, 156 Clock* clock)
157 std::string rtp_dump_name)
158 : transport_(transport), 157 : transport_(transport),
159 receiver_(nullptr), 158 receiver_(nullptr),
160 call_(nullptr), 159 call_(nullptr),
161 send_stream_(nullptr), 160 send_stream_(nullptr),
162 receive_stream_(nullptr), 161 receive_stream_(nullptr),
163 captured_frame_forwarder_(this, clock), 162 captured_frame_forwarder_(this, clock),
164 test_label_(test_label), 163 test_label_(test_label),
165 graph_data_output_file_(graph_data_output_file), 164 graph_data_output_file_(graph_data_output_file),
166 graph_title_(graph_title), 165 graph_title_(graph_title),
167 ssrc_to_analyze_(ssrc_to_analyze), 166 ssrc_to_analyze_(ssrc_to_analyze),
(...skipping 15 matching lines...) Expand all
183 total_media_bytes_(0), 182 total_media_bytes_(0),
184 first_sending_time_(0), 183 first_sending_time_(0),
185 last_sending_time_(0), 184 last_sending_time_(0),
186 cpu_time_(0), 185 cpu_time_(0),
187 wallclock_time_(0), 186 wallclock_time_(0),
188 avg_psnr_threshold_(avg_psnr_threshold), 187 avg_psnr_threshold_(avg_psnr_threshold),
189 avg_ssim_threshold_(avg_ssim_threshold), 188 avg_ssim_threshold_(avg_ssim_threshold),
190 is_quick_test_enabled_(is_quick_test_enabled), 189 is_quick_test_enabled_(is_quick_test_enabled),
191 stats_polling_thread_(&PollStatsThread, this, "StatsPoller"), 190 stats_polling_thread_(&PollStatsThread, this, "StatsPoller"),
192 comparison_available_event_(false, false), 191 comparison_available_event_(false, false),
193 done_(true, false), 192 done_(true, false) {
194 clock_(clock),
195 start_ms_(clock->TimeInMilliseconds()) {
196 // Create thread pool for CPU-expensive PSNR/SSIM calculations. 193 // Create thread pool for CPU-expensive PSNR/SSIM calculations.
197 194
198 // Try to use about as many threads as cores, but leave kMinCoresLeft alone, 195 // Try to use about as many threads as cores, but leave kMinCoresLeft alone,
199 // so that we don't accidentally starve "real" worker threads (codec etc). 196 // so that we don't accidentally starve "real" worker threads (codec etc).
200 // Also, don't allocate more than kMaxComparisonThreads, even if there are 197 // Also, don't allocate more than kMaxComparisonThreads, even if there are
201 // spare cores. 198 // spare cores.
202 199
203 uint32_t num_cores = CpuInfo::DetectNumberOfCores(); 200 uint32_t num_cores = CpuInfo::DetectNumberOfCores();
204 RTC_DCHECK_GE(num_cores, 1); 201 RTC_DCHECK_GE(num_cores, 1);
205 static const uint32_t kMinCoresLeft = 4; 202 static const uint32_t kMinCoresLeft = 4;
206 static const uint32_t kMaxComparisonThreads = 8; 203 static const uint32_t kMaxComparisonThreads = 8;
207 204
208 if (num_cores <= kMinCoresLeft) { 205 if (num_cores <= kMinCoresLeft) {
209 num_cores = 1; 206 num_cores = 1;
210 } else { 207 } else {
211 num_cores -= kMinCoresLeft; 208 num_cores -= kMinCoresLeft;
212 num_cores = std::min(num_cores, kMaxComparisonThreads); 209 num_cores = std::min(num_cores, kMaxComparisonThreads);
213 } 210 }
214 211
215 for (uint32_t i = 0; i < num_cores; ++i) { 212 for (uint32_t i = 0; i < num_cores; ++i) {
216 rtc::PlatformThread* thread = 213 rtc::PlatformThread* thread =
217 new rtc::PlatformThread(&FrameComparisonThread, this, "Analyzer"); 214 new rtc::PlatformThread(&FrameComparisonThread, this, "Analyzer");
218 thread->Start(); 215 thread->Start();
219 comparison_thread_pool_.push_back(thread); 216 comparison_thread_pool_.push_back(thread);
220 } 217 }
221
222 if (!rtp_dump_name.empty()) {
223 fprintf(stdout, "Writing rtp dump to %s\n", rtp_dump_name.c_str());
224 rtp_file_writer_.reset(test::RtpFileWriter::Create(
225 test::RtpFileWriter::kRtpDump, rtp_dump_name));
226 }
227 } 218 }
228 219
229 ~VideoAnalyzer() { 220 ~VideoAnalyzer() {
230 for (rtc::PlatformThread* thread : comparison_thread_pool_) { 221 for (rtc::PlatformThread* thread : comparison_thread_pool_) {
231 thread->Stop(); 222 thread->Stop();
232 delete thread; 223 delete thread;
233 } 224 }
234 } 225 }
235 226
236 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; } 227 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 DeliveryStatus DeliverPacket(MediaType media_type, 261 DeliveryStatus DeliverPacket(MediaType media_type,
271 const uint8_t* packet, 262 const uint8_t* packet,
272 size_t length, 263 size_t length,
273 const PacketTime& packet_time) override { 264 const PacketTime& packet_time) override {
274 // Ignore timestamps of RTCP packets. They're not synchronized with 265 // Ignore timestamps of RTCP packets. They're not synchronized with
275 // RTP packet timestamps and so they would confuse wrap_handler_. 266 // RTP packet timestamps and so they would confuse wrap_handler_.
276 if (RtpHeaderParser::IsRtcp(packet, length)) { 267 if (RtpHeaderParser::IsRtcp(packet, length)) {
277 return receiver_->DeliverPacket(media_type, packet, length, packet_time); 268 return receiver_->DeliverPacket(media_type, packet, length, packet_time);
278 } 269 }
279 270
280 if (rtp_file_writer_) {
281 test::RtpPacket p;
282 memcpy(p.data, packet, length);
283 p.length = length;
284 p.original_length = length;
285 p.time_ms = clock_->TimeInMilliseconds() - start_ms_;
286 rtp_file_writer_->WritePacket(&p);
287 }
288
289 RtpUtility::RtpHeaderParser parser(packet, length); 271 RtpUtility::RtpHeaderParser parser(packet, length);
290 RTPHeader header; 272 RTPHeader header;
291 parser.Parse(&header); 273 parser.Parse(&header);
292 if (!IsFlexfec(header.payloadType) && 274 if (!IsFlexfec(header.payloadType) &&
293 (header.ssrc == ssrc_to_analyze_ || 275 (header.ssrc == ssrc_to_analyze_ ||
294 header.ssrc == rtx_ssrc_to_analyze_)) { 276 header.ssrc == rtx_ssrc_to_analyze_)) {
295 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. 277 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps.
296 // (FlexFEC and media are sent on different SSRCs, which have different 278 // (FlexFEC and media are sent on different SSRCs, which have different
297 // timestamps spaces.) 279 // timestamps spaces.)
298 // Also ignore packets from wrong SSRC, but include retransmits. 280 // Also ignore packets from wrong SSRC, but include retransmits.
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 const double avg_psnr_threshold_; 1095 const double avg_psnr_threshold_;
1114 const double avg_ssim_threshold_; 1096 const double avg_ssim_threshold_;
1115 bool is_quick_test_enabled_; 1097 bool is_quick_test_enabled_;
1116 1098
1117 rtc::CriticalSection comparison_lock_; 1099 rtc::CriticalSection comparison_lock_;
1118 std::vector<rtc::PlatformThread*> comparison_thread_pool_; 1100 std::vector<rtc::PlatformThread*> comparison_thread_pool_;
1119 rtc::PlatformThread stats_polling_thread_; 1101 rtc::PlatformThread stats_polling_thread_;
1120 rtc::Event comparison_available_event_; 1102 rtc::Event comparison_available_event_;
1121 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); 1103 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
1122 rtc::Event done_; 1104 rtc::Event done_;
1123
1124 std::unique_ptr<test::RtpFileWriter> rtp_file_writer_;
1125 Clock* const clock_;
1126 const int64_t start_ms_;
1127 }; 1105 };
1128 1106
1129 class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory { 1107 class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory {
1130 public: 1108 public:
1131 Vp8EncoderFactory() { 1109 Vp8EncoderFactory() {
1132 supported_codecs_.push_back(cricket::VideoCodec("VP8")); 1110 supported_codecs_.push_back(cricket::VideoCodec("VP8"));
1133 } 1111 }
1134 ~Vp8EncoderFactory() override { RTC_CHECK(live_encoders_.empty()); } 1112 ~Vp8EncoderFactory() override { RTC_CHECK(live_encoders_.empty()); }
1135 1113
1136 const std::vector<cricket::VideoCodec>& supported_codecs() const override { 1114 const std::vector<cricket::VideoCodec>& supported_codecs() const override {
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 RTC_DCHECK(event_log_started); 1779 RTC_DCHECK(event_log_started);
1802 } 1780 }
1803 1781
1804 Call::Config call_config(event_log_.get()); 1782 Call::Config call_config(event_log_.get());
1805 call_config.bitrate_config = params.call.call_bitrate_config; 1783 call_config.bitrate_config = params.call.call_bitrate_config;
1806 1784
1807 task_queue_.SendTask([this, &call_config, &send_transport, 1785 task_queue_.SendTask([this, &call_config, &send_transport,
1808 &recv_transport]() { 1786 &recv_transport]() {
1809 CreateCalls(call_config, call_config); 1787 CreateCalls(call_config, call_config);
1810 1788
1789 std::unique_ptr<test::RtpFileWriter> rtp_file_writer;
1790 if (!params_.logging.rtp_dump_name.empty()) {
1791 LOG(LS_INFO) << "Writing rtp dump to " << params_.logging.rtp_dump_name;
1792 rtp_file_writer.reset(test::RtpFileWriter::Create(
1793 test::RtpFileWriter::kRtpDump, params_.logging.rtp_dump_name));
1794 }
1795
1811 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>( 1796 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>(
1812 &task_queue_, params_.pipe, sender_call_.get(), kPayloadTypeVP8, 1797 &task_queue_, params_.pipe, sender_call_.get(), kPayloadTypeVP8,
1813 kPayloadTypeVP9, params_.video.selected_tl, params_.ss.selected_sl, 1798 kPayloadTypeVP9, params_.video.selected_tl, params_.ss.selected_sl,
1814 payload_type_map_); 1799 payload_type_map_, std::move(rtp_file_writer));
1815 1800
1816 recv_transport = rtc::MakeUnique<test::DirectTransport>( 1801 recv_transport = rtc::MakeUnique<test::DirectTransport>(
1817 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_); 1802 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_);
1818 }); 1803 });
1819 1804
1820 std::string graph_title = params_.analyzer.graph_title; 1805 std::string graph_title = params_.analyzer.graph_title;
1821 if (graph_title.empty()) 1806 if (graph_title.empty())
1822 graph_title = VideoQualityTest::GenerateGraphTitle(); 1807 graph_title = VideoQualityTest::GenerateGraphTitle();
1823 bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest"); 1808 bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest");
1824 analyzer = rtc::MakeUnique<VideoAnalyzer>( 1809 analyzer = rtc::MakeUnique<VideoAnalyzer>(
1825 send_transport.get(), params_.analyzer.test_label, 1810 send_transport.get(), params_.analyzer.test_label,
1826 params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold, 1811 params_.analyzer.avg_psnr_threshold, params_.analyzer.avg_ssim_threshold,
1827 is_quick_test_enabled 1812 is_quick_test_enabled
1828 ? kFramesSentInQuickTest 1813 ? kFramesSentInQuickTest
1829 : params_.analyzer.test_durations_secs * params_.video.fps, 1814 : params_.analyzer.test_durations_secs * params_.video.fps,
1830 graph_data_output_file, graph_title, 1815 graph_data_output_file, graph_title,
1831 kVideoSendSsrcs[params_.ss.selected_stream], 1816 kVideoSendSsrcs[params_.ss.selected_stream],
1832 kSendRtxSsrcs[params_.ss.selected_stream], 1817 kSendRtxSsrcs[params_.ss.selected_stream],
1833 static_cast<size_t>(params_.ss.selected_stream), params.ss.selected_sl, 1818 static_cast<size_t>(params_.ss.selected_stream), params.ss.selected_sl,
1834 params_.video.selected_tl, is_quick_test_enabled, clock_, 1819 params_.video.selected_tl, is_quick_test_enabled, clock_);
1835 params_.logging.rtp_dump_name);
1836 1820
1837 task_queue_.SendTask([&]() { 1821 task_queue_.SendTask([&]() {
1838 analyzer->SetCall(sender_call_.get()); 1822 analyzer->SetCall(sender_call_.get());
1839 analyzer->SetReceiver(receiver_call_->Receiver()); 1823 analyzer->SetReceiver(receiver_call_->Receiver());
1840 send_transport->SetReceiver(analyzer.get()); 1824 send_transport->SetReceiver(analyzer.get());
1841 recv_transport->SetReceiver(sender_call_->Receiver()); 1825 recv_transport->SetReceiver(sender_call_->Receiver());
1842 1826
1843 SetupVideo(analyzer.get(), recv_transport.get()); 1827 SetupVideo(analyzer.get(), recv_transport.get());
1844 SetupThumbnails(analyzer.get(), recv_transport.get()); 1828 SetupThumbnails(analyzer.get(), recv_transport.get());
1845 video_receive_configs_[params_.ss.selected_stream].renderer = 1829 video_receive_configs_[params_.ss.selected_stream].renderer =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 CreateVoiceEngine(&voe, audio_processing.get(), decoder_factory_); 1971 CreateVoiceEngine(&voe, audio_processing.get(), decoder_factory_);
1988 AudioState::Config audio_state_config; 1972 AudioState::Config audio_state_config;
1989 audio_state_config.voice_engine = voe.voice_engine; 1973 audio_state_config.voice_engine = voe.voice_engine;
1990 audio_state_config.audio_mixer = AudioMixerImpl::Create(); 1974 audio_state_config.audio_mixer = AudioMixerImpl::Create();
1991 audio_state_config.audio_processing = audio_processing; 1975 audio_state_config.audio_processing = audio_processing;
1992 call_config.audio_state = AudioState::Create(audio_state_config); 1976 call_config.audio_state = AudioState::Create(audio_state_config);
1993 } 1977 }
1994 1978
1995 CreateCalls(call_config, call_config); 1979 CreateCalls(call_config, call_config);
1996 1980
1981 std::unique_ptr<test::RtpFileWriter> rtp_file_writer;
1982 if (!params_.logging.rtp_dump_name.empty()) {
1983 LOG(LS_INFO) << "Writing rtp dump to " << params_.logging.rtp_dump_name;
1984 rtp_file_writer.reset(test::RtpFileWriter::Create(
1985 test::RtpFileWriter::kRtpDump, params_.logging.rtp_dump_name));
1986 }
1987
1997 // TODO(minyue): consider if this is a good transport even for audio only 1988 // TODO(minyue): consider if this is a good transport even for audio only
1998 // calls. 1989 // calls.
1999 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>( 1990 send_transport = rtc::MakeUnique<test::LayerFilteringTransport>(
2000 &task_queue_, params.pipe, sender_call_.get(), kPayloadTypeVP8, 1991 &task_queue_, params.pipe, sender_call_.get(), kPayloadTypeVP8,
2001 kPayloadTypeVP9, params.video.selected_tl, params_.ss.selected_sl, 1992 kPayloadTypeVP9, params.video.selected_tl, params_.ss.selected_sl,
2002 payload_type_map_); 1993 payload_type_map_, std::move(rtp_file_writer));
2003 1994
2004 recv_transport = rtc::MakeUnique<test::DirectTransport>( 1995 recv_transport = rtc::MakeUnique<test::DirectTransport>(
2005 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_); 1996 &task_queue_, params_.pipe, receiver_call_.get(), payload_type_map_);
2006 1997
2007 // TODO(ivica): Use two calls to be able to merge with RunWithAnalyzer or at 1998 // 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 1999 // least share as much code as possible. That way this test would also match
2009 // the full stack tests better. 2000 // the full stack tests better.
2010 send_transport->SetReceiver(receiver_call_->Receiver()); 2001 send_transport->SetReceiver(receiver_call_->Receiver());
2011 recv_transport->SetReceiver(sender_call_->Receiver()); 2002 recv_transport->SetReceiver(sender_call_->Receiver());
2012 2003
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 if (!params_.logging.encoded_frame_base_path.empty()) { 2147 if (!params_.logging.encoded_frame_base_path.empty()) {
2157 std::ostringstream str; 2148 std::ostringstream str;
2158 str << receive_logs_++; 2149 str << receive_logs_++;
2159 std::string path = 2150 std::string path =
2160 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; 2151 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
2161 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), 2152 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path),
2162 100000000); 2153 100000000);
2163 } 2154 }
2164 } 2155 }
2165 } // namespace webrtc 2156 } // namespace webrtc
OLDNEW
« webrtc/test/layer_filtering_transport.cc ('K') | « webrtc/video/video_loopback.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698