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

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

Issue 1645463002: Unwrap timestamps in VideoAnalyzer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scoped_ptr.h" 24 #include "webrtc/base/scoped_ptr.h"
25 #include "webrtc/base/timeutils.h"
25 #include "webrtc/call.h" 26 #include "webrtc/call.h"
26 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 27 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
27 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 28 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
29 #include "webrtc/system_wrappers/include/cpu_info.h" 30 #include "webrtc/system_wrappers/include/cpu_info.h"
30 #include "webrtc/test/layer_filtering_transport.h" 31 #include "webrtc/test/layer_filtering_transport.h"
31 #include "webrtc/test/run_loop.h" 32 #include "webrtc/test/run_loop.h"
32 #include "webrtc/test/statistics.h" 33 #include "webrtc/test/statistics.h"
33 #include "webrtc/test/testsupport/fileutils.h" 34 #include "webrtc/test/testsupport/fileutils.h"
34 #include "webrtc/test/video_renderer.h" 35 #include "webrtc/test/video_renderer.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 114
114 DeliveryStatus DeliverPacket(MediaType media_type, 115 DeliveryStatus DeliverPacket(MediaType media_type,
115 const uint8_t* packet, 116 const uint8_t* packet,
116 size_t length, 117 size_t length,
117 const PacketTime& packet_time) override { 118 const PacketTime& packet_time) override {
118 RtpUtility::RtpHeaderParser parser(packet, length); 119 RtpUtility::RtpHeaderParser parser(packet, length);
119 RTPHeader header; 120 RTPHeader header;
120 parser.Parse(&header); 121 parser.Parse(&header);
121 { 122 {
122 rtc::CritScope lock(&crit_); 123 rtc::CritScope lock(&crit_);
123 recv_times_[header.timestamp - rtp_timestamp_delta_] = 124 int64_t timestamp = wrap_handler_.Unwrap(header.timestamp);
125 recv_times_[timestamp - rtp_timestamp_delta_] =
124 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); 126 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
125 } 127 }
126 128
127 return receiver_->DeliverPacket(media_type, packet, length, packet_time); 129 return receiver_->DeliverPacket(media_type, packet, length, packet_time);
128 } 130 }
129 131
130 // EncodingTimeObserver. 132 // EncodingTimeObserver.
131 void OnReportEncodedTime(int64_t ntp_time_ms, int encode_time_ms) override { 133 void OnReportEncodedTime(int64_t ntp_time_ms, int encode_time_ms) override {
132 rtc::CritScope crit(&comparison_lock_); 134 rtc::CritScope crit(&comparison_lock_);
133 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; 135 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms;
(...skipping 19 matching lines...) Expand all
153 const PacketOptions& options) override { 155 const PacketOptions& options) override {
154 RtpUtility::RtpHeaderParser parser(packet, length); 156 RtpUtility::RtpHeaderParser parser(packet, length);
155 RTPHeader header; 157 RTPHeader header;
156 parser.Parse(&header); 158 parser.Parse(&header);
157 159
158 int64_t current_time = 160 int64_t current_time =
159 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); 161 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
160 bool result = transport_->SendRtp(packet, length, options); 162 bool result = transport_->SendRtp(packet, length, options);
161 { 163 {
162 rtc::CritScope lock(&crit_); 164 rtc::CritScope lock(&crit_);
165 int64_t timestamp = wrap_handler_.Unwrap(header.timestamp);
166
163 if (rtp_timestamp_delta_ == 0) { 167 if (rtp_timestamp_delta_ == 0) {
164 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp(); 168 rtp_timestamp_delta_ = timestamp - first_send_frame_.timestamp();
165 first_send_frame_.Reset(); 169 first_send_frame_.Reset();
166 } 170 }
167 uint32_t timestamp = header.timestamp - rtp_timestamp_delta_; 171 timestamp -= rtp_timestamp_delta_;
168 send_times_[timestamp] = current_time; 172 send_times_[timestamp] = current_time;
169 if (!transport_->DiscardedLastPacket() && 173 if (!transport_->DiscardedLastPacket() &&
170 header.ssrc == ssrc_to_analyze_) { 174 header.ssrc == ssrc_to_analyze_) {
171 encoded_frame_sizes_[timestamp] += 175 encoded_frame_sizes_[timestamp] +=
172 length - (header.headerLength + header.paddingLength); 176 length - (header.headerLength + header.paddingLength);
173 } 177 }
174 } 178 }
175 return result; 179 return result;
176 } 180 }
177 181
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 size_t encoded_frame_size; 327 size_t encoded_frame_size;
324 double psnr; 328 double psnr;
325 double ssim; 329 double ssim;
326 }; 330 };
327 331
328 void AddFrameComparison(const VideoFrame& reference, 332 void AddFrameComparison(const VideoFrame& reference,
329 const VideoFrame& render, 333 const VideoFrame& render,
330 bool dropped, 334 bool dropped,
331 int64_t render_time_ms) 335 int64_t render_time_ms)
332 EXCLUSIVE_LOCKS_REQUIRED(crit_) { 336 EXCLUSIVE_LOCKS_REQUIRED(crit_) {
333 int64_t send_time_ms = send_times_[reference.timestamp()]; 337 int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp());
334 send_times_.erase(reference.timestamp()); 338 int64_t send_time_ms = send_times_[reference_timestamp];
335 int64_t recv_time_ms = recv_times_[reference.timestamp()]; 339 send_times_.erase(reference_timestamp);
336 recv_times_.erase(reference.timestamp()); 340 int64_t recv_time_ms = recv_times_[reference_timestamp];
341 recv_times_.erase(reference_timestamp);
337 342
338 // TODO(ivica): Make this work for > 2 streams. 343 // TODO(ivica): Make this work for > 2 streams.
339 auto it = encoded_frame_sizes_.find(reference.timestamp()); 344 auto it = encoded_frame_sizes_.find(reference_timestamp);
340 if (it == encoded_frame_sizes_.end()) 345 if (it == encoded_frame_sizes_.end())
341 it = encoded_frame_sizes_.find(reference.timestamp() - 1); 346 it = encoded_frame_sizes_.find(reference_timestamp - 1);
342 size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second; 347 size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second;
343 if (it != encoded_frame_sizes_.end()) 348 if (it != encoded_frame_sizes_.end())
344 encoded_frame_sizes_.erase(it); 349 encoded_frame_sizes_.erase(it);
345 350
346 VideoFrame reference_copy; 351 VideoFrame reference_copy;
347 VideoFrame render_copy; 352 VideoFrame render_copy;
348 reference_copy.CopyFrame(reference); 353 reference_copy.CopyFrame(reference);
349 render_copy.CopyFrame(render); 354 render_copy.CopyFrame(render);
350 355
351 rtc::CritScope crit(&comparison_lock_); 356 rtc::CritScope crit(&comparison_lock_);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 const int frames_to_process_; 583 const int frames_to_process_;
579 int frames_recorded_; 584 int frames_recorded_;
580 int frames_processed_; 585 int frames_processed_;
581 int dropped_frames_; 586 int dropped_frames_;
582 int64_t last_render_time_; 587 int64_t last_render_time_;
583 uint32_t rtp_timestamp_delta_; 588 uint32_t rtp_timestamp_delta_;
584 589
585 rtc::CriticalSection crit_; 590 rtc::CriticalSection crit_;
586 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); 591 std::deque<VideoFrame> frames_ GUARDED_BY(crit_);
587 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); 592 VideoFrame last_rendered_frame_ GUARDED_BY(crit_);
588 std::map<uint32_t, int64_t> send_times_ GUARDED_BY(crit_); 593 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_);
589 std::map<uint32_t, int64_t> recv_times_ GUARDED_BY(crit_); 594 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_);
590 std::map<uint32_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); 595 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_);
596 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_);
591 VideoFrame first_send_frame_ GUARDED_BY(crit_); 597 VideoFrame first_send_frame_ GUARDED_BY(crit_);
592 const double avg_psnr_threshold_; 598 const double avg_psnr_threshold_;
593 const double avg_ssim_threshold_; 599 const double avg_ssim_threshold_;
594 600
595 rtc::CriticalSection comparison_lock_; 601 rtc::CriticalSection comparison_lock_;
596 std::vector<rtc::PlatformThread*> comparison_thread_pool_; 602 std::vector<rtc::PlatformThread*> comparison_thread_pool_;
597 rtc::PlatformThread stats_polling_thread_; 603 rtc::PlatformThread stats_polling_thread_;
598 rtc::Event comparison_available_event_; 604 rtc::Event comparison_available_event_;
599 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); 605 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_);
600 rtc::Event done_; 606 rtc::Event done_;
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 video_send_stream_->Stop(); 1070 video_send_stream_->Stop();
1065 receive_stream->Stop(); 1071 receive_stream->Stop();
1066 1072
1067 call->DestroyVideoReceiveStream(receive_stream); 1073 call->DestroyVideoReceiveStream(receive_stream);
1068 call->DestroyVideoSendStream(video_send_stream_); 1074 call->DestroyVideoSendStream(video_send_stream_);
1069 1075
1070 transport.StopSending(); 1076 transport.StopSending();
1071 } 1077 }
1072 1078
1073 } // namespace webrtc 1079 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698