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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 public EncodedFrameObserver { | 127 public EncodedFrameObserver { |
128 public: | 128 public: |
129 VideoAnalyzer(test::LayerFilteringTransport* transport, | 129 VideoAnalyzer(test::LayerFilteringTransport* transport, |
130 const std::string& test_label, | 130 const std::string& test_label, |
131 double avg_psnr_threshold, | 131 double avg_psnr_threshold, |
132 double avg_ssim_threshold, | 132 double avg_ssim_threshold, |
133 int duration_frames, | 133 int duration_frames, |
134 FILE* graph_data_output_file, | 134 FILE* graph_data_output_file, |
135 const std::string& graph_title, | 135 const std::string& graph_title, |
136 uint32_t ssrc_to_analyze, | 136 uint32_t ssrc_to_analyze, |
| 137 uint32_t rtx_ssrc_to_analyze, |
137 uint32_t selected_width, | 138 uint32_t selected_width, |
138 uint32_t selected_height) | 139 uint32_t selected_height) |
139 : transport_(transport), | 140 : transport_(transport), |
140 receiver_(nullptr), | 141 receiver_(nullptr), |
141 send_stream_(nullptr), | 142 send_stream_(nullptr), |
142 receive_stream_(nullptr), | 143 receive_stream_(nullptr), |
143 captured_frame_forwarder_(this), | 144 captured_frame_forwarder_(this), |
144 test_label_(test_label), | 145 test_label_(test_label), |
145 graph_data_output_file_(graph_data_output_file), | 146 graph_data_output_file_(graph_data_output_file), |
146 graph_title_(graph_title), | 147 graph_title_(graph_title), |
147 ssrc_to_analyze_(ssrc_to_analyze), | 148 ssrc_to_analyze_(ssrc_to_analyze), |
| 149 rtx_ssrc_to_analyze_(rtx_ssrc_to_analyze), |
148 selected_width_(selected_width), | 150 selected_width_(selected_width), |
149 selected_height_(selected_height), | 151 selected_height_(selected_height), |
150 pre_encode_proxy_(this), | 152 pre_encode_proxy_(this), |
151 encode_timing_proxy_(this), | 153 encode_timing_proxy_(this), |
152 frames_to_process_(duration_frames), | 154 frames_to_process_(duration_frames), |
153 frames_recorded_(0), | 155 frames_recorded_(0), |
154 frames_processed_(0), | 156 frames_processed_(0), |
155 dropped_frames_(0), | 157 dropped_frames_(0), |
156 dropped_frames_before_first_encode_(0), | 158 dropped_frames_before_first_encode_(0), |
157 dropped_frames_before_rendering_(0), | 159 dropped_frames_before_rendering_(0), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 const PacketTime& packet_time) override { | 225 const PacketTime& packet_time) override { |
224 // Ignore timestamps of RTCP packets. They're not synchronized with | 226 // Ignore timestamps of RTCP packets. They're not synchronized with |
225 // RTP packet timestamps and so they would confuse wrap_handler_. | 227 // RTP packet timestamps and so they would confuse wrap_handler_. |
226 if (RtpHeaderParser::IsRtcp(packet, length)) { | 228 if (RtpHeaderParser::IsRtcp(packet, length)) { |
227 return receiver_->DeliverPacket(media_type, packet, length, packet_time); | 229 return receiver_->DeliverPacket(media_type, packet, length, packet_time); |
228 } | 230 } |
229 | 231 |
230 RtpUtility::RtpHeaderParser parser(packet, length); | 232 RtpUtility::RtpHeaderParser parser(packet, length); |
231 RTPHeader header; | 233 RTPHeader header; |
232 parser.Parse(&header); | 234 parser.Parse(&header); |
233 if (!IsFlexfec(header.payloadType) && header.ssrc == ssrc_to_analyze_) { | 235 if (!IsFlexfec(header.payloadType) && |
| 236 (header.ssrc == ssrc_to_analyze_ || |
| 237 header.ssrc == rtx_ssrc_to_analyze_)) { |
234 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. | 238 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. |
235 // (FlexFEC and media are sent on different SSRCs, which have different | 239 // (FlexFEC and media are sent on different SSRCs, which have different |
236 // timestamps spaces.) | 240 // timestamps spaces.) |
237 // Also ignore packets from wrong SSRC. | 241 // Also ignore packets from wrong SSRC, but include retransmits. |
238 rtc::CritScope lock(&crit_); | 242 rtc::CritScope lock(&crit_); |
239 int64_t timestamp = | 243 int64_t timestamp = |
240 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); | 244 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); |
241 recv_times_[timestamp] = | 245 recv_times_[timestamp] = |
242 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 246 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
243 } | 247 } |
244 | 248 |
245 return receiver_->DeliverPacket(media_type, packet, length, packet_time); | 249 return receiver_->DeliverPacket(media_type, packet, length, packet_time); |
246 } | 250 } |
247 | 251 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 rtc::CritScope lock(&crit_); | 290 rtc::CritScope lock(&crit_); |
287 if (rtp_timestamp_delta_ == 0 && header.ssrc == ssrc_to_analyze_) { | 291 if (rtp_timestamp_delta_ == 0 && header.ssrc == ssrc_to_analyze_) { |
288 RTC_CHECK(static_cast<bool>(first_sent_timestamp_)); | 292 RTC_CHECK(static_cast<bool>(first_sent_timestamp_)); |
289 rtp_timestamp_delta_ = header.timestamp - *first_sent_timestamp_; | 293 rtp_timestamp_delta_ = header.timestamp - *first_sent_timestamp_; |
290 } | 294 } |
291 | 295 |
292 if (!IsFlexfec(header.payloadType) && header.ssrc == ssrc_to_analyze_) { | 296 if (!IsFlexfec(header.payloadType) && header.ssrc == ssrc_to_analyze_) { |
293 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. | 297 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. |
294 // (FlexFEC and media are sent on different SSRCs, which have different | 298 // (FlexFEC and media are sent on different SSRCs, which have different |
295 // timestamps spaces.) | 299 // timestamps spaces.) |
296 // Also ignore packets from wrong SSRC. | 300 // Also ignore packets from wrong SSRC and retransmits. |
297 int64_t timestamp = | 301 int64_t timestamp = |
298 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); | 302 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); |
299 send_times_[timestamp] = current_time; | 303 send_times_[timestamp] = current_time; |
300 if (!transport_->DiscardedLastPacket() && | 304 if (!transport_->DiscardedLastPacket() && |
301 header.ssrc == ssrc_to_analyze_) { | 305 header.ssrc == ssrc_to_analyze_) { |
302 encoded_frame_sizes_[timestamp] += | 306 encoded_frame_sizes_[timestamp] += |
303 length - (header.headerLength + header.paddingLength); | 307 length - (header.headerLength + header.paddingLength); |
304 } | 308 } |
305 } | 309 } |
306 } | 310 } |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 frames_.push_back(video_frame); | 842 frames_.push_back(video_frame); |
839 } | 843 } |
840 | 844 |
841 VideoSendStream* send_stream_; | 845 VideoSendStream* send_stream_; |
842 VideoReceiveStream* receive_stream_; | 846 VideoReceiveStream* receive_stream_; |
843 CapturedFrameForwarder captured_frame_forwarder_; | 847 CapturedFrameForwarder captured_frame_forwarder_; |
844 const std::string test_label_; | 848 const std::string test_label_; |
845 FILE* const graph_data_output_file_; | 849 FILE* const graph_data_output_file_; |
846 const std::string graph_title_; | 850 const std::string graph_title_; |
847 const uint32_t ssrc_to_analyze_; | 851 const uint32_t ssrc_to_analyze_; |
| 852 const uint32_t rtx_ssrc_to_analyze_; |
848 const uint32_t selected_width_; | 853 const uint32_t selected_width_; |
849 const uint32_t selected_height_; | 854 const uint32_t selected_height_; |
850 PreEncodeProxy pre_encode_proxy_; | 855 PreEncodeProxy pre_encode_proxy_; |
851 OnEncodeTimingProxy encode_timing_proxy_; | 856 OnEncodeTimingProxy encode_timing_proxy_; |
852 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); | 857 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); |
853 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); | 858 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); |
854 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); | 859 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); |
855 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); | 860 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); |
856 test::Statistics psnr_ GUARDED_BY(comparison_lock_); | 861 test::Statistics psnr_ GUARDED_BY(comparison_lock_); |
857 test::Statistics ssim_ GUARDED_BY(comparison_lock_); | 862 test::Statistics ssim_ GUARDED_BY(comparison_lock_); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 "not implemented yet! Skipping PSNR and SSIM calculations!\n"); | 1339 "not implemented yet! Skipping PSNR and SSIM calculations!\n"); |
1335 } | 1340 } |
1336 | 1341 |
1337 VideoAnalyzer analyzer( | 1342 VideoAnalyzer analyzer( |
1338 &send_transport, params_.analyzer.test_label, | 1343 &send_transport, params_.analyzer.test_label, |
1339 disable_quality_check ? -1.1 : params_.analyzer.avg_psnr_threshold, | 1344 disable_quality_check ? -1.1 : params_.analyzer.avg_psnr_threshold, |
1340 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, | 1345 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, |
1341 params_.analyzer.test_durations_secs * params_.video.fps, | 1346 params_.analyzer.test_durations_secs * params_.video.fps, |
1342 graph_data_output_file, graph_title, | 1347 graph_data_output_file, graph_title, |
1343 kVideoSendSsrcs[params_.ss.selected_stream], | 1348 kVideoSendSsrcs[params_.ss.selected_stream], |
| 1349 kSendRtxSsrcs[params_.ss.selected_stream], |
1344 static_cast<uint32_t>(selected_stream.width), | 1350 static_cast<uint32_t>(selected_stream.width), |
1345 static_cast<uint32_t>(selected_stream.height)); | 1351 static_cast<uint32_t>(selected_stream.height)); |
1346 | 1352 |
1347 analyzer.SetReceiver(receiver_call_->Receiver()); | 1353 analyzer.SetReceiver(receiver_call_->Receiver()); |
1348 send_transport.SetReceiver(&analyzer); | 1354 send_transport.SetReceiver(&analyzer); |
1349 recv_transport.SetReceiver(sender_call_->Receiver()); | 1355 recv_transport.SetReceiver(sender_call_->Receiver()); |
1350 | 1356 |
1351 SetupVideo(&analyzer, &recv_transport); | 1357 SetupVideo(&analyzer, &recv_transport); |
1352 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; | 1358 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; |
1353 video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); | 1359 video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 std::ostringstream str; | 1597 std::ostringstream str; |
1592 str << receive_logs_++; | 1598 str << receive_logs_++; |
1593 std::string path = | 1599 std::string path = |
1594 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 1600 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
1595 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 1601 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
1596 10000000); | 1602 10000000); |
1597 } | 1603 } |
1598 } | 1604 } |
1599 | 1605 |
1600 } // namespace webrtc | 1606 } // namespace webrtc |
OLD | NEW |