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

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

Issue 2303273002: Expose Ivf logging through the native API (Closed)
Patch Set: Don't make a change in base here, make a separate CL Created 4 years, 3 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 <stdio.h> 10 #include <stdio.h>
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <deque> 13 #include <deque>
14 #include <map> 14 #include <map>
15 #include <sstream> 15 #include <sstream>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 #include "webrtc/base/checks.h" 21 #include "webrtc/base/checks.h"
22 #include "webrtc/base/event.h" 22 #include "webrtc/base/event.h"
23 #include "webrtc/base/format_macros.h" 23 #include "webrtc/base/format_macros.h"
24 #include "webrtc/base/optional.h" 24 #include "webrtc/base/optional.h"
25 #include "webrtc/base/platform_file.h"
25 #include "webrtc/base/timeutils.h" 26 #include "webrtc/base/timeutils.h"
26 #include "webrtc/call.h" 27 #include "webrtc/call.h"
27 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 28 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
28 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 29 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
30 #include "webrtc/system_wrappers/include/cpu_info.h" 31 #include "webrtc/system_wrappers/include/cpu_info.h"
31 #include "webrtc/test/layer_filtering_transport.h" 32 #include "webrtc/test/layer_filtering_transport.h"
32 #include "webrtc/test/run_loop.h" 33 #include "webrtc/test/run_loop.h"
33 #include "webrtc/test/statistics.h" 34 #include "webrtc/test/statistics.h"
34 #include "webrtc/test/testsupport/fileutils.h" 35 #include "webrtc/test/testsupport/fileutils.h"
35 #include "webrtc/test/video_renderer.h" 36 #include "webrtc/test/video_renderer.h"
36 #include "webrtc/video/video_quality_test.h" 37 #include "webrtc/video/video_quality_test.h"
37 #include "webrtc/voice_engine/include/voe_base.h" 38 #include "webrtc/voice_engine/include/voe_base.h"
38 #include "webrtc/voice_engine/include/voe_codec.h" 39 #include "webrtc/voice_engine/include/voe_codec.h"
39 40
41 #if defined(WEBRTC_WIN)
42 #include "webrtc/base/win32.h"
43 #else
44 #include <fcntl.h>
45 #endif
46
40 namespace { 47 namespace {
41 48
42 constexpr int kSendStatsPollingIntervalMs = 1000; 49 constexpr int kSendStatsPollingIntervalMs = 1000;
43 constexpr int kPayloadTypeH264 = 122; 50 constexpr int kPayloadTypeH264 = 122;
44 constexpr int kPayloadTypeVP8 = 123; 51 constexpr int kPayloadTypeVP8 = 123;
45 constexpr int kPayloadTypeVP9 = 124; 52 constexpr int kPayloadTypeVP9 = 124;
46 constexpr size_t kMaxComparisons = 10; 53 constexpr size_t kMaxComparisons = 10;
47 constexpr char kSyncGroup[] = "av_sync"; 54 constexpr char kSyncGroup[] = "av_sync";
48 constexpr int kOpusMinBitrate = 6000; 55 constexpr int kOpusMinBitrate = 6000;
49 constexpr int kOpusBitrateFb = 32000; 56 constexpr int kOpusBitrateFb = 32000;
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 const double avg_ssim_threshold_; 745 const double avg_ssim_threshold_;
739 746
740 rtc::CriticalSection comparison_lock_; 747 rtc::CriticalSection comparison_lock_;
741 std::vector<rtc::PlatformThread*> comparison_thread_pool_; 748 std::vector<rtc::PlatformThread*> comparison_thread_pool_;
742 rtc::PlatformThread stats_polling_thread_; 749 rtc::PlatformThread stats_polling_thread_;
743 rtc::Event comparison_available_event_; 750 rtc::Event comparison_available_event_;
744 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); 751 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
745 rtc::Event done_; 752 rtc::Event done_;
746 }; 753 };
747 754
748 VideoQualityTest::VideoQualityTest() : clock_(Clock::GetRealTimeClock()) {} 755 VideoQualityTest::VideoQualityTest()
756 : clock_(Clock::GetRealTimeClock()), receive_logs_(0), send_logs_(0) {}
749 757
750 void VideoQualityTest::TestBody() {} 758 void VideoQualityTest::TestBody() {}
751 759
752 std::string VideoQualityTest::GenerateGraphTitle() const { 760 std::string VideoQualityTest::GenerateGraphTitle() const {
753 std::stringstream ss; 761 std::stringstream ss;
754 ss << params_.common.codec; 762 ss << params_.common.codec;
755 ss << " (" << params_.common.target_bitrate_bps / 1000 << "kbps"; 763 ss << " (" << params_.common.target_bitrate_bps / 1000 << "kbps";
756 ss << ", " << params_.common.fps << " FPS"; 764 ss << ", " << params_.common.fps << " FPS";
757 if (params_.screenshare.scroll_duration) 765 if (params_.screenshare.scroll_duration)
758 ss << ", " << params_.screenshare.scroll_duration << "s scroll"; 766 ss << ", " << params_.screenshare.scroll_duration << "s scroll";
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 1133
1126 if (params_.screenshare.enabled) 1134 if (params_.screenshare.enabled)
1127 SetupScreenshare(); 1135 SetupScreenshare();
1128 1136
1129 CreateVideoStreams(); 1137 CreateVideoStreams();
1130 analyzer.input_ = video_send_stream_->Input(); 1138 analyzer.input_ = video_send_stream_->Input();
1131 analyzer.send_stream_ = video_send_stream_; 1139 analyzer.send_stream_ = video_send_stream_;
1132 1140
1133 CreateCapturer(&analyzer); 1141 CreateCapturer(&analyzer);
1134 1142
1143 StartEncodedFrameLogs(video_send_stream_);
1144 StartEncodedFrameLogs(video_receive_streams_[0]);
1135 video_send_stream_->Start(); 1145 video_send_stream_->Start();
1136 for (VideoReceiveStream* receive_stream : video_receive_streams_) 1146 for (VideoReceiveStream* receive_stream : video_receive_streams_)
1137 receive_stream->Start(); 1147 receive_stream->Start();
1138 capturer_->Start(); 1148 capturer_->Start();
1139 1149
1140 analyzer.Wait(); 1150 analyzer.Wait();
1141 1151
1142 send_transport.StopSending(); 1152 send_transport.StopSending();
1143 recv_transport.StopSending(); 1153 recv_transport.StopSending();
1144 1154
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; 1257 audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc;
1248 audio_config.rtcp_send_transport = &transport; 1258 audio_config.rtcp_send_transport = &transport;
1249 audio_config.voe_channel_id = voe.receive_channel_id; 1259 audio_config.voe_channel_id = voe.receive_channel_id;
1250 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; 1260 audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc;
1251 audio_config.rtp.transport_cc = params_.common.send_side_bwe; 1261 audio_config.rtp.transport_cc = params_.common.send_side_bwe;
1252 audio_config.rtp.extensions = audio_send_config_.rtp.extensions; 1262 audio_config.rtp.extensions = audio_send_config_.rtp.extensions;
1253 audio_config.decoder_factory = decoder_factory_; 1263 audio_config.decoder_factory = decoder_factory_;
1254 if (params_.audio_video_sync) 1264 if (params_.audio_video_sync)
1255 audio_config.sync_group = kSyncGroup; 1265 audio_config.sync_group = kSyncGroup;
1256 1266
1257 audio_receive_stream =call->CreateAudioReceiveStream(audio_config); 1267 audio_receive_stream = call->CreateAudioReceiveStream(audio_config);
1258 1268
1259 const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000}; 1269 const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000};
1260 EXPECT_EQ(0, voe.codec->SetSendCodec(voe.send_channel_id, kOpusInst)); 1270 EXPECT_EQ(0, voe.codec->SetSendCodec(voe.send_channel_id, kOpusInst));
1261 } 1271 }
1262 1272
1273 StartEncodedFrameLogs(video_receive_stream);
1274 StartEncodedFrameLogs(video_send_stream_);
1275
1263 // Start sending and receiving video. 1276 // Start sending and receiving video.
1264 video_receive_stream->Start(); 1277 video_receive_stream->Start();
1265 video_send_stream_->Start(); 1278 video_send_stream_->Start();
1266 capturer_->Start(); 1279 capturer_->Start();
1267 1280
1268 if (params_.audio) { 1281 if (params_.audio) {
1269 // Start receiving audio. 1282 // Start receiving audio.
1270 audio_receive_stream->Start(); 1283 audio_receive_stream->Start();
1271 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id)); 1284 EXPECT_EQ(0, voe.base->StartPlayout(voe.receive_channel_id));
1272 EXPECT_EQ(0, voe.base->StartReceive(voe.receive_channel_id)); 1285 EXPECT_EQ(0, voe.base->StartReceive(voe.receive_channel_id));
(...skipping 27 matching lines...) Expand all
1300 if (params_.audio) { 1313 if (params_.audio) {
1301 call->DestroyAudioSendStream(audio_send_stream_); 1314 call->DestroyAudioSendStream(audio_send_stream_);
1302 call->DestroyAudioReceiveStream(audio_receive_stream); 1315 call->DestroyAudioReceiveStream(audio_receive_stream);
1303 } 1316 }
1304 1317
1305 transport.StopSending(); 1318 transport.StopSending();
1306 if (params_.audio) 1319 if (params_.audio)
1307 DestroyVoiceEngine(&voe); 1320 DestroyVoiceEngine(&voe);
1308 } 1321 }
1309 1322
1323 rtc::PlatformFile CreateFile(const std::string& path) {
1324 #if defined(WEBRTC_WIN)
1325 return ::CreateFile(rtc::ToUtf16(path).c_str(), GENERIC_READ | GENERIC_WRITE,
1326 0, nullptr, OPEN_ALWAYS, 0, nullptr);
1327 #else
1328 return ::open(path.c_str(), O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
1329 #endif
stefan-webrtc 2016/09/13 10:53:17 Break out to platform independent function or clas
palmkvist 2016/09/13 11:59:37 Also intended to be put in base, but in a separate
1330 }
1331
1332 void VideoQualityTest::StartEncodedFrameLogs(VideoSendStream* stream) {
1333 if (!params_.common.encoded_frame_base_path.empty()) {
1334 std::ostringstream str;
1335 str << send_logs_++;
1336 std::string prefix =
1337 params_.common.encoded_frame_base_path + "." + str.str() + ".send.";
1338 stream->EnableEncodedFrameRecording(
1339 std::vector<rtc::PlatformFile>({CreateFile(prefix + "1.ivf"),
1340 CreateFile(prefix + "2.ivf"),
1341 CreateFile(prefix + "3.ivf")}),
1342 10000000);
1343 }
1344 }
1345 void VideoQualityTest::StartEncodedFrameLogs(VideoReceiveStream* stream) {
1346 if (!params_.common.encoded_frame_base_path.empty()) {
1347 std::ostringstream str;
1348 str << receive_logs_++;
1349 std::string path =
1350 params_.common.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
1351 stream->EnableEncodedFrameRecording(CreateFile(path), 10000000);
1352 }
1353 }
1354
1310 } // namespace webrtc 1355 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698