| 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> |
| 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/timeutils.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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 rtc::CritScope crit(&comparison_lock_); | 140 rtc::CritScope crit(&comparison_lock_); |
| 140 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; | 141 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; |
| 141 } | 142 } |
| 142 | 143 |
| 143 void IncomingCapturedFrame(const VideoFrame& video_frame) override { | 144 void IncomingCapturedFrame(const VideoFrame& video_frame) override { |
| 144 VideoFrame copy = video_frame; | 145 VideoFrame copy = video_frame; |
| 145 copy.set_timestamp(copy.ntp_time_ms() * 90); | 146 copy.set_timestamp(copy.ntp_time_ms() * 90); |
| 146 | 147 |
| 147 { | 148 { |
| 148 rtc::CritScope lock(&crit_); | 149 rtc::CritScope lock(&crit_); |
| 149 if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0) | 150 if (!first_send_timestamp_ && rtp_timestamp_delta_ == 0) |
| 150 first_send_frame_ = copy; | 151 first_send_timestamp_ = rtc::Optional<uint32_t>(copy.timestamp()); |
| 151 | 152 |
| 152 frames_.push_back(copy); | 153 frames_.push_back(copy); |
| 153 } | 154 } |
| 154 | 155 |
| 155 input_->IncomingCapturedFrame(video_frame); | 156 input_->IncomingCapturedFrame(video_frame); |
| 156 } | 157 } |
| 157 | 158 |
| 158 bool SendRtp(const uint8_t* packet, | 159 bool SendRtp(const uint8_t* packet, |
| 159 size_t length, | 160 size_t length, |
| 160 const PacketOptions& options) override { | 161 const PacketOptions& options) override { |
| 161 RtpUtility::RtpHeaderParser parser(packet, length); | 162 RtpUtility::RtpHeaderParser parser(packet, length); |
| 162 RTPHeader header; | 163 RTPHeader header; |
| 163 parser.Parse(&header); | 164 parser.Parse(&header); |
| 164 | 165 |
| 165 int64_t current_time = | 166 int64_t current_time = |
| 166 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 167 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
| 167 bool result = transport_->SendRtp(packet, length, options); | 168 bool result = transport_->SendRtp(packet, length, options); |
| 168 { | 169 { |
| 169 rtc::CritScope lock(&crit_); | 170 rtc::CritScope lock(&crit_); |
| 170 | 171 |
| 171 if (rtp_timestamp_delta_ == 0) { | 172 if (rtp_timestamp_delta_ == 0) { |
| 172 rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp(); | 173 rtp_timestamp_delta_ = header.timestamp - *first_send_timestamp_; |
| 173 first_send_frame_.Reset(); | 174 first_send_timestamp_ = rtc::Optional<uint32_t>(); |
| 174 } | 175 } |
| 175 int64_t timestamp = | 176 int64_t timestamp = |
| 176 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); | 177 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); |
| 177 send_times_[timestamp] = current_time; | 178 send_times_[timestamp] = current_time; |
| 178 if (!transport_->DiscardedLastPacket() && | 179 if (!transport_->DiscardedLastPacket() && |
| 179 header.ssrc == ssrc_to_analyze_) { | 180 header.ssrc == ssrc_to_analyze_) { |
| 180 encoded_frame_sizes_[timestamp] += | 181 encoded_frame_sizes_[timestamp] += |
| 181 length - (header.headerLength + header.paddingLength); | 182 length - (header.headerLength + header.paddingLength); |
| 182 } | 183 } |
| 183 } | 184 } |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 int64_t last_render_time_; | 616 int64_t last_render_time_; |
| 616 uint32_t rtp_timestamp_delta_; | 617 uint32_t rtp_timestamp_delta_; |
| 617 | 618 |
| 618 rtc::CriticalSection crit_; | 619 rtc::CriticalSection crit_; |
| 619 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); | 620 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); |
| 620 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); | 621 VideoFrame last_rendered_frame_ GUARDED_BY(crit_); |
| 621 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_); | 622 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_); |
| 622 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_); | 623 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_); |
| 623 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_); | 624 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_); |
| 624 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); | 625 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); |
| 625 VideoFrame first_send_frame_ GUARDED_BY(crit_); | 626 rtc::Optional<uint32_t> first_send_timestamp_ GUARDED_BY(crit_); |
| 626 const double avg_psnr_threshold_; | 627 const double avg_psnr_threshold_; |
| 627 const double avg_ssim_threshold_; | 628 const double avg_ssim_threshold_; |
| 628 | 629 |
| 629 rtc::CriticalSection comparison_lock_; | 630 rtc::CriticalSection comparison_lock_; |
| 630 std::vector<rtc::PlatformThread*> comparison_thread_pool_; | 631 std::vector<rtc::PlatformThread*> comparison_thread_pool_; |
| 631 rtc::PlatformThread stats_polling_thread_; | 632 rtc::PlatformThread stats_polling_thread_; |
| 632 rtc::Event comparison_available_event_; | 633 rtc::Event comparison_available_event_; |
| 633 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 634 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); |
| 634 rtc::Event done_; | 635 rtc::Event done_; |
| 635 }; | 636 }; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 video_send_stream_->Stop(); | 1099 video_send_stream_->Stop(); |
| 1099 receive_stream->Stop(); | 1100 receive_stream->Stop(); |
| 1100 | 1101 |
| 1101 call->DestroyVideoReceiveStream(receive_stream); | 1102 call->DestroyVideoReceiveStream(receive_stream); |
| 1102 call->DestroyVideoSendStream(video_send_stream_); | 1103 call->DestroyVideoSendStream(video_send_stream_); |
| 1103 | 1104 |
| 1104 transport.StopSending(); | 1105 transport.StopSending(); |
| 1105 } | 1106 } |
| 1106 | 1107 |
| 1107 } // namespace webrtc | 1108 } // namespace webrtc |
| OLD | NEW |