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 <stdio.h> | 10 #include <stdio.h> |
(...skipping 197 matching lines...) Loading... |
208 | 208 |
209 void OnFrame(const VideoFrame& video_frame) override { | 209 void OnFrame(const VideoFrame& video_frame) override { |
210 int64_t render_time_ms = | 210 int64_t render_time_ms = |
211 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 211 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
212 | 212 |
213 rtc::CritScope lock(&crit_); | 213 rtc::CritScope lock(&crit_); |
214 int64_t send_timestamp = | 214 int64_t send_timestamp = |
215 wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_); | 215 wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_); |
216 | 216 |
217 while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) { | 217 while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) { |
218 if (last_rendered_frame_.IsZeroSize()) { | 218 if (!last_rendered_frame_) { |
219 // No previous frame rendered, this one was dropped after sending but | 219 // No previous frame rendered, this one was dropped after sending but |
220 // before rendering. | 220 // before rendering. |
221 ++dropped_frames_before_rendering_; | 221 ++dropped_frames_before_rendering_; |
222 frames_.pop_front(); | 222 frames_.pop_front(); |
223 RTC_CHECK(!frames_.empty()); | 223 RTC_CHECK(!frames_.empty()); |
224 continue; | 224 continue; |
225 } | 225 } |
226 AddFrameComparison(frames_.front(), last_rendered_frame_, true, | 226 AddFrameComparison(frames_.front(), *last_rendered_frame_, true, |
227 render_time_ms); | 227 render_time_ms); |
228 frames_.pop_front(); | 228 frames_.pop_front(); |
229 RTC_DCHECK(!frames_.empty()); | 229 RTC_DCHECK(!frames_.empty()); |
230 } | 230 } |
231 | 231 |
232 VideoFrame reference_frame = frames_.front(); | 232 VideoFrame reference_frame = frames_.front(); |
233 frames_.pop_front(); | 233 frames_.pop_front(); |
234 assert(!reference_frame.IsZeroSize()); | |
235 int64_t reference_timestamp = | 234 int64_t reference_timestamp = |
236 wrap_handler_.Unwrap(reference_frame.timestamp()); | 235 wrap_handler_.Unwrap(reference_frame.timestamp()); |
237 if (send_timestamp == reference_timestamp - 1) { | 236 if (send_timestamp == reference_timestamp - 1) { |
238 // TODO(ivica): Make this work for > 2 streams. | 237 // TODO(ivica): Make this work for > 2 streams. |
239 // Look at RTPSender::BuildRTPHeader. | 238 // Look at RTPSender::BuildRTPHeader. |
240 ++send_timestamp; | 239 ++send_timestamp; |
241 } | 240 } |
242 ASSERT_EQ(reference_timestamp, send_timestamp); | 241 ASSERT_EQ(reference_timestamp, send_timestamp); |
243 | 242 |
244 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); | 243 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); |
245 | 244 |
246 last_rendered_frame_ = video_frame; | 245 last_rendered_frame_ = rtc::Optional<VideoFrame>(video_frame); |
247 } | 246 } |
248 | 247 |
249 void Wait() { | 248 void Wait() { |
250 // Frame comparisons can be very expensive. Wait for test to be done, but | 249 // Frame comparisons can be very expensive. Wait for test to be done, but |
251 // at time-out check if frames_processed is going up. If so, give it more | 250 // at time-out check if frames_processed is going up. If so, give it more |
252 // time, otherwise fail. Hopefully this will reduce test flakiness. | 251 // time, otherwise fail. Hopefully this will reduce test flakiness. |
253 | 252 |
254 stats_polling_thread_.Start(); | 253 stats_polling_thread_.Start(); |
255 | 254 |
256 int last_frames_processed = -1; | 255 int last_frames_processed = -1; |
(...skipping 129 matching lines...) Loading... |
386 | 385 |
387 private: | 386 private: |
388 VideoAnalyzer* const parent_; | 387 VideoAnalyzer* const parent_; |
389 }; | 388 }; |
390 | 389 |
391 void AddFrameComparison(const VideoFrame& reference, | 390 void AddFrameComparison(const VideoFrame& reference, |
392 const VideoFrame& render, | 391 const VideoFrame& render, |
393 bool dropped, | 392 bool dropped, |
394 int64_t render_time_ms) | 393 int64_t render_time_ms) |
395 EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 394 EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
396 RTC_DCHECK(!render.IsZeroSize()); | |
397 int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp()); | 395 int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp()); |
398 int64_t send_time_ms = send_times_[reference_timestamp]; | 396 int64_t send_time_ms = send_times_[reference_timestamp]; |
399 send_times_.erase(reference_timestamp); | 397 send_times_.erase(reference_timestamp); |
400 int64_t recv_time_ms = recv_times_[reference_timestamp]; | 398 int64_t recv_time_ms = recv_times_[reference_timestamp]; |
401 recv_times_.erase(reference_timestamp); | 399 recv_times_.erase(reference_timestamp); |
402 | 400 |
403 // TODO(ivica): Make this work for > 2 streams. | 401 // TODO(ivica): Make this work for > 2 streams. |
404 auto it = encoded_frame_sizes_.find(reference_timestamp); | 402 auto it = encoded_frame_sizes_.find(reference_timestamp); |
405 if (it == encoded_frame_sizes_.end()) | 403 if (it == encoded_frame_sizes_.end()) |
406 it = encoded_frame_sizes_.find(reference_timestamp - 1); | 404 it = encoded_frame_sizes_.find(reference_timestamp - 1); |
(...skipping 250 matching lines...) Loading... |
657 int frames_recorded_; | 655 int frames_recorded_; |
658 int frames_processed_; | 656 int frames_processed_; |
659 int dropped_frames_; | 657 int dropped_frames_; |
660 int dropped_frames_before_first_encode_; | 658 int dropped_frames_before_first_encode_; |
661 int dropped_frames_before_rendering_; | 659 int dropped_frames_before_rendering_; |
662 int64_t last_render_time_; | 660 int64_t last_render_time_; |
663 uint32_t rtp_timestamp_delta_; | 661 uint32_t rtp_timestamp_delta_; |
664 | 662 |
665 rtc::CriticalSection crit_; | 663 rtc::CriticalSection crit_; |
666 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); | 664 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); |
667 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); | 665 rtc::Optional<VideoFrame> last_rendered_frame_ GUARDED_BY(crit_); |
668 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_); | 666 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_); |
669 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_); | 667 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_); |
670 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_); | 668 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_); |
671 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); | 669 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); |
672 rtc::Optional<uint32_t> first_send_timestamp_ GUARDED_BY(crit_); | 670 rtc::Optional<uint32_t> first_send_timestamp_ GUARDED_BY(crit_); |
673 const double avg_psnr_threshold_; | 671 const double avg_psnr_threshold_; |
674 const double avg_ssim_threshold_; | 672 const double avg_ssim_threshold_; |
675 | 673 |
676 rtc::CriticalSection comparison_lock_; | 674 rtc::CriticalSection comparison_lock_; |
677 std::vector<rtc::PlatformThread*> comparison_thread_pool_; | 675 std::vector<rtc::PlatformThread*> comparison_thread_pool_; |
(...skipping 477 matching lines...) Loading... |
1155 video_send_stream_->Stop(); | 1153 video_send_stream_->Stop(); |
1156 receive_stream->Stop(); | 1154 receive_stream->Stop(); |
1157 | 1155 |
1158 call->DestroyVideoReceiveStream(receive_stream); | 1156 call->DestroyVideoReceiveStream(receive_stream); |
1159 call->DestroyVideoSendStream(video_send_stream_); | 1157 call->DestroyVideoSendStream(video_send_stream_); |
1160 | 1158 |
1161 transport.StopSending(); | 1159 transport.StopSending(); |
1162 } | 1160 } |
1163 | 1161 |
1164 } // namespace webrtc | 1162 } // namespace webrtc |
OLD | NEW |