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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 temporal_idx <= selected_tl_) && | 642 temporal_idx <= selected_tl_) && |
643 (selected_sl_ < 0 || spatial_idx == kNoSpatialIdx || | 643 (selected_sl_ < 0 || spatial_idx == kNoSpatialIdx || |
644 spatial_idx <= selected_sl_); | 644 spatial_idx <= selected_sl_); |
645 } | 645 } |
646 } | 646 } |
647 | 647 |
648 void AddFrameComparison(const VideoFrame& reference, | 648 void AddFrameComparison(const VideoFrame& reference, |
649 const VideoFrame& render, | 649 const VideoFrame& render, |
650 bool dropped, | 650 bool dropped, |
651 int64_t render_time_ms) | 651 int64_t render_time_ms) |
652 EXCLUSIVE_LOCKS_REQUIRED(crit_) { | 652 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_) { |
653 int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp()); | 653 int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp()); |
654 int64_t send_time_ms = send_times_[reference_timestamp]; | 654 int64_t send_time_ms = send_times_[reference_timestamp]; |
655 send_times_.erase(reference_timestamp); | 655 send_times_.erase(reference_timestamp); |
656 int64_t recv_time_ms = recv_times_[reference_timestamp]; | 656 int64_t recv_time_ms = recv_times_[reference_timestamp]; |
657 recv_times_.erase(reference_timestamp); | 657 recv_times_.erase(reference_timestamp); |
658 | 658 |
659 // TODO(ivica): Make this work for > 2 streams. | 659 // TODO(ivica): Make this work for > 2 streams. |
660 auto it = encoded_frame_sizes_.find(reference_timestamp); | 660 auto it = encoded_frame_sizes_.find(reference_timestamp); |
661 if (it == encoded_frame_sizes_.end()) | 661 if (it == encoded_frame_sizes_.end()) |
662 it = encoded_frame_sizes_.find(reference_timestamp - 1); | 662 it = encoded_frame_sizes_.find(reference_timestamp - 1); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 | 1025 |
1026 // Called by |send_stream_| when |send_stream_.SetSource()| is called. | 1026 // Called by |send_stream_| when |send_stream_.SetSource()| is called. |
1027 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override { | 1027 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override { |
1028 rtc::CritScope lock(&crit_); | 1028 rtc::CritScope lock(&crit_); |
1029 RTC_DCHECK(sink == send_stream_input_); | 1029 RTC_DCHECK(sink == send_stream_input_); |
1030 send_stream_input_ = nullptr; | 1030 send_stream_input_ = nullptr; |
1031 } | 1031 } |
1032 | 1032 |
1033 VideoAnalyzer* const analyzer_; | 1033 VideoAnalyzer* const analyzer_; |
1034 rtc::CriticalSection crit_; | 1034 rtc::CriticalSection crit_; |
1035 rtc::VideoSinkInterface<VideoFrame>* send_stream_input_ GUARDED_BY(crit_); | 1035 rtc::VideoSinkInterface<VideoFrame>* send_stream_input_ |
| 1036 RTC_GUARDED_BY(crit_); |
1036 test::VideoCapturer* video_capturer_; | 1037 test::VideoCapturer* video_capturer_; |
1037 Clock* clock_; | 1038 Clock* clock_; |
1038 }; | 1039 }; |
1039 | 1040 |
1040 void AddCapturedFrameForComparison(const VideoFrame& video_frame) { | 1041 void AddCapturedFrameForComparison(const VideoFrame& video_frame) { |
1041 rtc::CritScope lock(&crit_); | 1042 rtc::CritScope lock(&crit_); |
1042 frames_.push_back(video_frame); | 1043 frames_.push_back(video_frame); |
1043 } | 1044 } |
1044 | 1045 |
1045 Call* call_; | 1046 Call* call_; |
1046 VideoSendStream* send_stream_; | 1047 VideoSendStream* send_stream_; |
1047 VideoReceiveStream* receive_stream_; | 1048 VideoReceiveStream* receive_stream_; |
1048 CapturedFrameForwarder captured_frame_forwarder_; | 1049 CapturedFrameForwarder captured_frame_forwarder_; |
1049 const std::string test_label_; | 1050 const std::string test_label_; |
1050 FILE* const graph_data_output_file_; | 1051 FILE* const graph_data_output_file_; |
1051 const std::string graph_title_; | 1052 const std::string graph_title_; |
1052 const uint32_t ssrc_to_analyze_; | 1053 const uint32_t ssrc_to_analyze_; |
1053 const uint32_t rtx_ssrc_to_analyze_; | 1054 const uint32_t rtx_ssrc_to_analyze_; |
1054 const size_t selected_stream_; | 1055 const size_t selected_stream_; |
1055 const int selected_sl_; | 1056 const int selected_sl_; |
1056 const int selected_tl_; | 1057 const int selected_tl_; |
1057 PreEncodeProxy pre_encode_proxy_; | 1058 PreEncodeProxy pre_encode_proxy_; |
1058 OnEncodeTimingProxy encode_timing_proxy_; | 1059 OnEncodeTimingProxy encode_timing_proxy_; |
1059 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); | 1060 std::vector<Sample> samples_ RTC_GUARDED_BY(comparison_lock_); |
1060 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); | 1061 std::map<int64_t, int> samples_encode_time_ms_ |
1061 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); | 1062 RTC_GUARDED_BY(comparison_lock_); |
1062 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); | 1063 test::Statistics sender_time_ RTC_GUARDED_BY(comparison_lock_); |
1063 test::Statistics psnr_ GUARDED_BY(comparison_lock_); | 1064 test::Statistics receiver_time_ RTC_GUARDED_BY(comparison_lock_); |
1064 test::Statistics ssim_ GUARDED_BY(comparison_lock_); | 1065 test::Statistics psnr_ RTC_GUARDED_BY(comparison_lock_); |
1065 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); | 1066 test::Statistics ssim_ RTC_GUARDED_BY(comparison_lock_); |
1066 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); | 1067 test::Statistics end_to_end_ RTC_GUARDED_BY(comparison_lock_); |
1067 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); | 1068 test::Statistics rendered_delta_ RTC_GUARDED_BY(comparison_lock_); |
1068 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); | 1069 test::Statistics encoded_frame_size_ RTC_GUARDED_BY(comparison_lock_); |
1069 test::Statistics encode_time_ms_ GUARDED_BY(comparison_lock_); | 1070 test::Statistics encode_frame_rate_ RTC_GUARDED_BY(comparison_lock_); |
1070 test::Statistics encode_usage_percent_ GUARDED_BY(comparison_lock_); | 1071 test::Statistics encode_time_ms_ RTC_GUARDED_BY(comparison_lock_); |
1071 test::Statistics decode_time_ms_ GUARDED_BY(comparison_lock_); | 1072 test::Statistics encode_usage_percent_ RTC_GUARDED_BY(comparison_lock_); |
1072 test::Statistics decode_time_max_ms_ GUARDED_BY(comparison_lock_); | 1073 test::Statistics decode_time_ms_ RTC_GUARDED_BY(comparison_lock_); |
1073 test::Statistics media_bitrate_bps_ GUARDED_BY(comparison_lock_); | 1074 test::Statistics decode_time_max_ms_ RTC_GUARDED_BY(comparison_lock_); |
1074 test::Statistics fec_bitrate_bps_ GUARDED_BY(comparison_lock_); | 1075 test::Statistics media_bitrate_bps_ RTC_GUARDED_BY(comparison_lock_); |
1075 test::Statistics send_bandwidth_bps_ GUARDED_BY(comparison_lock_); | 1076 test::Statistics fec_bitrate_bps_ RTC_GUARDED_BY(comparison_lock_); |
1076 test::Statistics memory_usage_ GUARDED_BY(comparison_lock_); | 1077 test::Statistics send_bandwidth_bps_ RTC_GUARDED_BY(comparison_lock_); |
| 1078 test::Statistics memory_usage_ RTC_GUARDED_BY(comparison_lock_); |
1077 | 1079 |
1078 struct FrameWithPsnr { | 1080 struct FrameWithPsnr { |
1079 double psnr; | 1081 double psnr; |
1080 VideoFrame frame; | 1082 VideoFrame frame; |
1081 }; | 1083 }; |
1082 | 1084 |
1083 // Rendered frame with worst PSNR is saved for further analysis. | 1085 // Rendered frame with worst PSNR is saved for further analysis. |
1084 rtc::Optional<FrameWithPsnr> worst_frame_ GUARDED_BY(comparison_lock_); | 1086 rtc::Optional<FrameWithPsnr> worst_frame_ RTC_GUARDED_BY(comparison_lock_); |
1085 | 1087 |
1086 size_t last_fec_bytes_; | 1088 size_t last_fec_bytes_; |
1087 | 1089 |
1088 const int frames_to_process_; | 1090 const int frames_to_process_; |
1089 int frames_recorded_; | 1091 int frames_recorded_; |
1090 int frames_processed_; | 1092 int frames_processed_; |
1091 int dropped_frames_; | 1093 int dropped_frames_; |
1092 int dropped_frames_before_first_encode_; | 1094 int dropped_frames_before_first_encode_; |
1093 int dropped_frames_before_rendering_; | 1095 int dropped_frames_before_rendering_; |
1094 int64_t last_render_time_; | 1096 int64_t last_render_time_; |
1095 uint32_t rtp_timestamp_delta_; | 1097 uint32_t rtp_timestamp_delta_; |
1096 int64_t total_media_bytes_; | 1098 int64_t total_media_bytes_; |
1097 int64_t first_sending_time_; | 1099 int64_t first_sending_time_; |
1098 int64_t last_sending_time_; | 1100 int64_t last_sending_time_; |
1099 | 1101 |
1100 int64_t cpu_time_ GUARDED_BY(cpu_measurement_lock_); | 1102 int64_t cpu_time_ RTC_GUARDED_BY(cpu_measurement_lock_); |
1101 int64_t wallclock_time_ GUARDED_BY(cpu_measurement_lock_); | 1103 int64_t wallclock_time_ RTC_GUARDED_BY(cpu_measurement_lock_); |
1102 rtc::CriticalSection cpu_measurement_lock_; | 1104 rtc::CriticalSection cpu_measurement_lock_; |
1103 | 1105 |
1104 rtc::CriticalSection crit_; | 1106 rtc::CriticalSection crit_; |
1105 std::deque<VideoFrame> frames_ GUARDED_BY(crit_); | 1107 std::deque<VideoFrame> frames_ RTC_GUARDED_BY(crit_); |
1106 rtc::Optional<VideoFrame> last_rendered_frame_ GUARDED_BY(crit_); | 1108 rtc::Optional<VideoFrame> last_rendered_frame_ RTC_GUARDED_BY(crit_); |
1107 rtc::TimestampWrapAroundHandler wrap_handler_ GUARDED_BY(crit_); | 1109 rtc::TimestampWrapAroundHandler wrap_handler_ RTC_GUARDED_BY(crit_); |
1108 std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_); | 1110 std::map<int64_t, int64_t> send_times_ RTC_GUARDED_BY(crit_); |
1109 std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_); | 1111 std::map<int64_t, int64_t> recv_times_ RTC_GUARDED_BY(crit_); |
1110 std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_); | 1112 std::map<int64_t, size_t> encoded_frame_sizes_ RTC_GUARDED_BY(crit_); |
1111 rtc::Optional<uint32_t> first_encoded_timestamp_ GUARDED_BY(crit_); | 1113 rtc::Optional<uint32_t> first_encoded_timestamp_ RTC_GUARDED_BY(crit_); |
1112 rtc::Optional<uint32_t> first_sent_timestamp_ GUARDED_BY(crit_); | 1114 rtc::Optional<uint32_t> first_sent_timestamp_ RTC_GUARDED_BY(crit_); |
1113 const double avg_psnr_threshold_; | 1115 const double avg_psnr_threshold_; |
1114 const double avg_ssim_threshold_; | 1116 const double avg_ssim_threshold_; |
1115 bool is_quick_test_enabled_; | 1117 bool is_quick_test_enabled_; |
1116 | 1118 |
1117 rtc::CriticalSection comparison_lock_; | 1119 rtc::CriticalSection comparison_lock_; |
1118 std::vector<rtc::PlatformThread*> comparison_thread_pool_; | 1120 std::vector<rtc::PlatformThread*> comparison_thread_pool_; |
1119 rtc::PlatformThread stats_polling_thread_; | 1121 rtc::PlatformThread stats_polling_thread_; |
1120 rtc::Event comparison_available_event_; | 1122 rtc::Event comparison_available_event_; |
1121 std::deque<FrameComparison> comparisons_ GUARDED_BY(comparison_lock_); | 1123 std::deque<FrameComparison> comparisons_ RTC_GUARDED_BY(comparison_lock_); |
1122 rtc::Event done_; | 1124 rtc::Event done_; |
1123 | 1125 |
1124 std::unique_ptr<test::RtpFileWriter> rtp_file_writer_; | 1126 std::unique_ptr<test::RtpFileWriter> rtp_file_writer_; |
1125 Clock* const clock_; | 1127 Clock* const clock_; |
1126 const int64_t start_ms_; | 1128 const int64_t start_ms_; |
1127 }; | 1129 }; |
1128 | 1130 |
1129 class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory { | 1131 class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory { |
1130 public: | 1132 public: |
1131 Vp8EncoderFactory() { | 1133 Vp8EncoderFactory() { |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 if (!params_.logging.encoded_frame_base_path.empty()) { | 2173 if (!params_.logging.encoded_frame_base_path.empty()) { |
2172 std::ostringstream str; | 2174 std::ostringstream str; |
2173 str << receive_logs_++; | 2175 str << receive_logs_++; |
2174 std::string path = | 2176 std::string path = |
2175 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 2177 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
2176 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 2178 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
2177 100000000); | 2179 100000000); |
2178 } | 2180 } |
2179 } | 2181 } |
2180 } // namespace webrtc | 2182 } // namespace webrtc |
OLD | NEW |