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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 void MeasuredEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) { | 236 void MeasuredEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) { |
237 rtc::CritScope crit(&comparison_lock_); | 237 rtc::CritScope crit(&comparison_lock_); |
238 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; | 238 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; |
239 } | 239 } |
240 | 240 |
241 void PreEncodeOnFrame(const VideoFrame& video_frame) { | 241 void PreEncodeOnFrame(const VideoFrame& video_frame) { |
242 rtc::CritScope lock(&crit_); | 242 rtc::CritScope lock(&crit_); |
243 if (!first_send_timestamp_ && rtp_timestamp_delta_ == 0) { | 243 if (!first_send_timestamp_ && rtp_timestamp_delta_ == 0) { |
| 244 printf("pre-encode: setting first_send_timestamp\n"); |
244 while (frames_.front().timestamp() != video_frame.timestamp()) { | 245 while (frames_.front().timestamp() != video_frame.timestamp()) { |
245 ++dropped_frames_before_first_encode_; | 246 ++dropped_frames_before_first_encode_; |
246 frames_.pop_front(); | 247 frames_.pop_front(); |
247 RTC_CHECK(!frames_.empty()); | 248 RTC_CHECK(!frames_.empty()); |
248 } | 249 } |
249 first_send_timestamp_ = rtc::Optional<uint32_t>(video_frame.timestamp()); | 250 first_send_timestamp_ = rtc::Optional<uint32_t>(video_frame.timestamp()); |
250 } | 251 } |
251 } | 252 } |
252 | 253 |
253 bool SendRtp(const uint8_t* packet, | 254 bool SendRtp(const uint8_t* packet, |
254 size_t length, | 255 size_t length, |
255 const PacketOptions& options) override { | 256 const PacketOptions& options) override { |
256 RtpUtility::RtpHeaderParser parser(packet, length); | 257 RtpUtility::RtpHeaderParser parser(packet, length); |
257 RTPHeader header; | 258 RTPHeader header; |
258 parser.Parse(&header); | 259 parser.Parse(&header); |
259 | 260 |
260 int64_t current_time = | 261 int64_t current_time = |
261 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 262 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
262 bool result = transport_->SendRtp(packet, length, options); | 263 bool result = transport_->SendRtp(packet, length, options); |
263 { | 264 { |
264 rtc::CritScope lock(&crit_); | 265 rtc::CritScope lock(&crit_); |
265 | 266 |
266 if (rtp_timestamp_delta_ == 0) { | 267 if (rtp_timestamp_delta_ == 0) { |
| 268 printf("Now setting delta\n"); |
267 rtp_timestamp_delta_ = header.timestamp - *first_send_timestamp_; | 269 rtp_timestamp_delta_ = header.timestamp - *first_send_timestamp_; |
268 first_send_timestamp_ = rtc::Optional<uint32_t>(); | 270 first_send_timestamp_ = rtc::Optional<uint32_t>(); |
269 } | 271 } |
270 if (!IsFlexfec(header.payloadType)) { | 272 if (!IsFlexfec(header.payloadType)) { |
271 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. | 273 // Ignore FlexFEC timestamps, to avoid collisions with media timestamps. |
272 // (FlexFEC and media are sent on different SSRCs, which have different | 274 // (FlexFEC and media are sent on different SSRCs, which have different |
273 // timestamps spaces.) | 275 // timestamps spaces.) |
274 int64_t timestamp = | 276 int64_t timestamp = |
275 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); | 277 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); |
276 send_times_[timestamp] = current_time; | 278 send_times_[timestamp] = current_time; |
(...skipping 23 matching lines...) Expand all Loading... |
300 | 302 |
301 rtc::CritScope lock(&crit_); | 303 rtc::CritScope lock(&crit_); |
302 int64_t send_timestamp = | 304 int64_t send_timestamp = |
303 wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_); | 305 wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_); |
304 | 306 |
305 while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) { | 307 while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) { |
306 if (!last_rendered_frame_) { | 308 if (!last_rendered_frame_) { |
307 // No previous frame rendered, this one was dropped after sending but | 309 // No previous frame rendered, this one was dropped after sending but |
308 // before rendering. | 310 // before rendering. |
309 ++dropped_frames_before_rendering_; | 311 ++dropped_frames_before_rendering_; |
310 frames_.pop_front(); | 312 } else { |
311 RTC_CHECK(!frames_.empty()); | 313 AddFrameComparison(frames_.front(), *last_rendered_frame_, true, |
312 continue; | 314 render_time_ms); |
313 } | 315 } |
314 AddFrameComparison(frames_.front(), *last_rendered_frame_, true, | |
315 render_time_ms); | |
316 frames_.pop_front(); | 316 frames_.pop_front(); |
317 RTC_DCHECK(!frames_.empty()); | 317 RTC_DCHECK(!frames_.empty()); |
318 } | 318 } |
319 | 319 |
| 320 printf("send_timestamp: %ld\n", send_timestamp); |
| 321 printf("frame_timestamp: %ld\n", |
| 322 wrap_handler_.Unwrap(frames_.front().timestamp())); |
| 323 |
320 VideoFrame reference_frame = frames_.front(); | 324 VideoFrame reference_frame = frames_.front(); |
321 frames_.pop_front(); | 325 frames_.pop_front(); |
322 int64_t reference_timestamp = | 326 int64_t reference_timestamp = |
323 wrap_handler_.Unwrap(reference_frame.timestamp()); | 327 wrap_handler_.Unwrap(reference_frame.timestamp()); |
324 if (send_timestamp == reference_timestamp - 1) { | 328 if (send_timestamp == reference_timestamp - 1) { |
325 // TODO(ivica): Make this work for > 2 streams. | 329 // TODO(ivica): Make this work for > 2 streams. |
326 // Look at RTPSender::BuildRTPHeader. | 330 // Look at RTPSender::BuildRTPHeader. |
327 ++send_timestamp; | 331 ++send_timestamp; |
328 } | 332 } |
| 333 printf("diff: %ld\n", reference_timestamp - send_timestamp); |
329 ASSERT_EQ(reference_timestamp, send_timestamp); | 334 ASSERT_EQ(reference_timestamp, send_timestamp); |
330 | 335 |
331 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); | 336 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); |
332 | 337 |
333 last_rendered_frame_ = rtc::Optional<VideoFrame>(video_frame); | 338 last_rendered_frame_ = rtc::Optional<VideoFrame>(video_frame); |
334 } | 339 } |
335 | 340 |
336 void Wait() { | 341 void Wait() { |
337 // Frame comparisons can be very expensive. Wait for test to be done, but | 342 // Frame comparisons can be very expensive. Wait for test to be done, but |
338 // at time-out check if frames_processed is going up. If so, give it more | 343 // at time-out check if frames_processed is going up. If so, give it more |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 .rtp.ulpfec.red_rtx_payload_type = | 1154 .rtp.ulpfec.red_rtx_payload_type = |
1150 video_send_config_.rtp.ulpfec.red_rtx_payload_type; | 1155 video_send_config_.rtp.ulpfec.red_rtx_payload_type; |
1151 } | 1156 } |
1152 } | 1157 } |
1153 | 1158 |
1154 void VideoQualityTest::SetupScreenshare() { | 1159 void VideoQualityTest::SetupScreenshare() { |
1155 RTC_CHECK(params_.screenshare.enabled); | 1160 RTC_CHECK(params_.screenshare.enabled); |
1156 | 1161 |
1157 // Fill out codec settings. | 1162 // Fill out codec settings. |
1158 video_encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 1163 video_encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 1164 degradation_preference_ = |
| 1165 VideoSendStream::DegradationPreference::kMaintainResolution; |
1159 if (params_.video.codec == "VP8") { | 1166 if (params_.video.codec == "VP8") { |
1160 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); | 1167 VideoCodecVP8 vp8_settings = VideoEncoder::GetDefaultVp8Settings(); |
1161 vp8_settings.denoisingOn = false; | 1168 vp8_settings.denoisingOn = false; |
1162 vp8_settings.frameDroppingOn = false; | 1169 vp8_settings.frameDroppingOn = false; |
1163 vp8_settings.numberOfTemporalLayers = | 1170 vp8_settings.numberOfTemporalLayers = |
1164 static_cast<unsigned char>(params_.video.num_temporal_layers); | 1171 static_cast<unsigned char>(params_.video.num_temporal_layers); |
1165 video_encoder_config_.encoder_specific_settings = new rtc::RefCountedObject< | 1172 video_encoder_config_.encoder_specific_settings = new rtc::RefCountedObject< |
1166 VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); | 1173 VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings); |
1167 } else if (params_.video.codec == "VP9") { | 1174 } else if (params_.video.codec == "VP9") { |
1168 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); | 1175 VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 config.pre_decode_callback = &analyzer; | 1309 config.pre_decode_callback = &analyzer; |
1303 RTC_DCHECK(!video_send_config_.post_encode_callback); | 1310 RTC_DCHECK(!video_send_config_.post_encode_callback); |
1304 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); | 1311 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); |
1305 | 1312 |
1306 if (params_.screenshare.enabled) | 1313 if (params_.screenshare.enabled) |
1307 SetupScreenshare(); | 1314 SetupScreenshare(); |
1308 | 1315 |
1309 CreateFlexfecStreams(); | 1316 CreateFlexfecStreams(); |
1310 CreateVideoStreams(); | 1317 CreateVideoStreams(); |
1311 analyzer.SetSendStream(video_send_stream_); | 1318 analyzer.SetSendStream(video_send_stream_); |
1312 video_send_stream_->SetSource( | 1319 video_send_stream_->SetSource(analyzer.OutputInterface(), |
1313 analyzer.OutputInterface(), | 1320 degradation_preference_); |
1314 VideoSendStream::DegradationPreference::kBalanced); | |
1315 | 1321 |
1316 CreateCapturer(); | 1322 CreateCapturer(); |
1317 rtc::VideoSinkWants wants; | 1323 rtc::VideoSinkWants wants; |
1318 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants); | 1324 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants); |
1319 | 1325 |
1320 StartEncodedFrameLogs(video_send_stream_); | 1326 StartEncodedFrameLogs(video_send_stream_); |
1321 StartEncodedFrameLogs(video_receive_streams_[0]); | 1327 StartEncodedFrameLogs(video_receive_streams_[0]); |
1322 video_send_stream_->Start(); | 1328 video_send_stream_->Start(); |
1323 for (VideoReceiveStream* receive_stream : video_receive_streams_) | 1329 for (VideoReceiveStream* receive_stream : video_receive_streams_) |
1324 receive_stream->Start(); | 1330 receive_stream->Start(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 video_send_stream_ = call->CreateVideoSendStream( | 1452 video_send_stream_ = call->CreateVideoSendStream( |
1447 video_send_config_.Copy(), video_encoder_config_.Copy()); | 1453 video_send_config_.Copy(), video_encoder_config_.Copy()); |
1448 if (params_.video.flexfec) { | 1454 if (params_.video.flexfec) { |
1449 RTC_DCHECK(!flexfec_receive_configs_.empty()); | 1455 RTC_DCHECK(!flexfec_receive_configs_.empty()); |
1450 flexfec_receive_stream = | 1456 flexfec_receive_stream = |
1451 call->CreateFlexfecReceiveStream(flexfec_receive_configs_[0]); | 1457 call->CreateFlexfecReceiveStream(flexfec_receive_configs_[0]); |
1452 } | 1458 } |
1453 video_receive_stream = call->CreateVideoReceiveStream( | 1459 video_receive_stream = call->CreateVideoReceiveStream( |
1454 video_receive_configs_[stream_id].Copy()); | 1460 video_receive_configs_[stream_id].Copy()); |
1455 CreateCapturer(); | 1461 CreateCapturer(); |
1456 video_send_stream_->SetSource( | 1462 video_send_stream_->SetSource(video_capturer_.get(), |
1457 video_capturer_.get(), | 1463 degradation_preference_); |
1458 VideoSendStream::DegradationPreference::kBalanced); | |
1459 } | 1464 } |
1460 | 1465 |
1461 AudioReceiveStream* audio_receive_stream = nullptr; | 1466 AudioReceiveStream* audio_receive_stream = nullptr; |
1462 if (params_.audio.enabled) { | 1467 if (params_.audio.enabled) { |
1463 SetupAudio(voe.send_channel_id, voe.receive_channel_id, call.get(), | 1468 SetupAudio(voe.send_channel_id, voe.receive_channel_id, call.get(), |
1464 &transport, &audio_receive_stream); | 1469 &transport, &audio_receive_stream); |
1465 } | 1470 } |
1466 | 1471 |
1467 StartEncodedFrameLogs(video_receive_stream); | 1472 StartEncodedFrameLogs(video_receive_stream); |
1468 StartEncodedFrameLogs(video_send_stream_); | 1473 StartEncodedFrameLogs(video_send_stream_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 std::ostringstream str; | 1542 std::ostringstream str; |
1538 str << receive_logs_++; | 1543 str << receive_logs_++; |
1539 std::string path = | 1544 std::string path = |
1540 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 1545 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
1541 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 1546 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
1542 10000000); | 1547 10000000); |
1543 } | 1548 } |
1544 } | 1549 } |
1545 | 1550 |
1546 } // namespace webrtc | 1551 } // namespace webrtc |
OLD | NEW |