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 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 static const int kSendStatsPollingIntervalMs = 1000; | 40 static const int kSendStatsPollingIntervalMs = 1000; |
41 static const int kPayloadTypeH264 = 122; | 41 static const int kPayloadTypeH264 = 122; |
42 static const int kPayloadTypeVP8 = 123; | 42 static const int kPayloadTypeVP8 = 123; |
43 static const int kPayloadTypeVP9 = 124; | 43 static const int kPayloadTypeVP9 = 124; |
44 | 44 |
45 class VideoAnalyzer : public PacketReceiver, | 45 class VideoAnalyzer : public PacketReceiver, |
46 public Transport, | 46 public Transport, |
47 public VideoRenderer, | 47 public VideoRenderer, |
48 public VideoCaptureInput, | 48 public VideoCaptureInput, |
49 public EncodedFrameObserver, | 49 public EncodedFrameObserver { |
50 public EncodingTimeObserver { | |
51 public: | 50 public: |
52 VideoAnalyzer(test::LayerFilteringTransport* transport, | 51 VideoAnalyzer(test::LayerFilteringTransport* transport, |
53 const std::string& test_label, | 52 const std::string& test_label, |
54 double avg_psnr_threshold, | 53 double avg_psnr_threshold, |
55 double avg_ssim_threshold, | 54 double avg_ssim_threshold, |
56 int duration_frames, | 55 int duration_frames, |
57 FILE* graph_data_output_file, | 56 FILE* graph_data_output_file, |
58 const std::string& graph_title, | 57 const std::string& graph_title, |
59 uint32_t ssrc_to_analyze) | 58 uint32_t ssrc_to_analyze) |
60 : input_(nullptr), | 59 : input_(nullptr), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 { | 121 { |
123 rtc::CritScope lock(&crit_); | 122 rtc::CritScope lock(&crit_); |
124 int64_t timestamp = wrap_handler_.Unwrap(header.timestamp); | 123 int64_t timestamp = wrap_handler_.Unwrap(header.timestamp); |
125 recv_times_[timestamp - rtp_timestamp_delta_] = | 124 recv_times_[timestamp - rtp_timestamp_delta_] = |
126 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 125 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
127 } | 126 } |
128 | 127 |
129 return receiver_->DeliverPacket(media_type, packet, length, packet_time); | 128 return receiver_->DeliverPacket(media_type, packet, length, packet_time); |
130 } | 129 } |
131 | 130 |
132 // EncodingTimeObserver. | 131 void OnEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) override { |
133 void OnReportEncodedTime(int64_t ntp_time_ms, int encode_time_ms) override { | |
134 rtc::CritScope crit(&comparison_lock_); | 132 rtc::CritScope crit(&comparison_lock_); |
135 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; | 133 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; |
136 } | 134 } |
137 | 135 |
138 void IncomingCapturedFrame(const VideoFrame& video_frame) override { | 136 void IncomingCapturedFrame(const VideoFrame& video_frame) override { |
139 VideoFrame copy = video_frame; | 137 VideoFrame copy = video_frame; |
140 copy.set_timestamp(copy.ntp_time_ms() * 90); | 138 copy.set_timestamp(copy.ntp_time_ms() * 90); |
141 | 139 |
142 { | 140 { |
143 rtc::CritScope lock(&crit_); | 141 rtc::CritScope lock(&crit_); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 AddFrameComparison(frames_.front(), last_rendered_frame_, true, | 199 AddFrameComparison(frames_.front(), last_rendered_frame_, true, |
202 render_time_ms); | 200 render_time_ms); |
203 frames_.pop_front(); | 201 frames_.pop_front(); |
204 } | 202 } |
205 | 203 |
206 VideoFrame reference_frame = frames_.front(); | 204 VideoFrame reference_frame = frames_.front(); |
207 frames_.pop_front(); | 205 frames_.pop_front(); |
208 assert(!reference_frame.IsZeroSize()); | 206 assert(!reference_frame.IsZeroSize()); |
209 if (send_timestamp == reference_frame.timestamp() - 1) { | 207 if (send_timestamp == reference_frame.timestamp() - 1) { |
210 // TODO(ivica): Make this work for > 2 streams. | 208 // TODO(ivica): Make this work for > 2 streams. |
211 // Look at rtp_sender.c:RTPSender::BuildRTPHeader. | 209 // Look at RTPSender::BuildRTPHeader. |
212 ++send_timestamp; | 210 ++send_timestamp; |
213 } | 211 } |
214 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); | 212 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); |
215 assert(reference_frame.timestamp() == send_timestamp); | 213 assert(reference_frame.timestamp() == send_timestamp); |
216 | 214 |
217 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); | 215 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); |
218 | 216 |
219 last_rendered_frame_ = video_frame; | 217 last_rendered_frame_ = video_frame; |
220 } | 218 } |
221 | 219 |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, | 968 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, |
971 params_.analyzer.test_durations_secs * params_.common.fps, | 969 params_.analyzer.test_durations_secs * params_.common.fps, |
972 graph_data_output_file, graph_title, | 970 graph_data_output_file, graph_title, |
973 kVideoSendSsrcs[params_.ss.selected_stream]); | 971 kVideoSendSsrcs[params_.ss.selected_stream]); |
974 | 972 |
975 analyzer.SetReceiver(receiver_call_->Receiver()); | 973 analyzer.SetReceiver(receiver_call_->Receiver()); |
976 send_transport.SetReceiver(&analyzer); | 974 send_transport.SetReceiver(&analyzer); |
977 recv_transport.SetReceiver(sender_call_->Receiver()); | 975 recv_transport.SetReceiver(sender_call_->Receiver()); |
978 | 976 |
979 SetupCommon(&analyzer, &recv_transport); | 977 SetupCommon(&analyzer, &recv_transport); |
980 video_send_config_.encoding_time_observer = &analyzer; | |
åsapersson
2016/02/04 11:17:55
set video_send_config_.post_encode_callback?
pbos-webrtc
2016/02/04 12:38:04
Done, had to add a proxy class because analyzer is
| |
981 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; | 978 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; |
982 for (auto& config : video_receive_configs_) | 979 for (auto& config : video_receive_configs_) |
983 config.pre_decode_callback = &analyzer; | 980 config.pre_decode_callback = &analyzer; |
984 | 981 |
985 if (params_.screenshare.enabled) | 982 if (params_.screenshare.enabled) |
986 SetupScreenshare(); | 983 SetupScreenshare(); |
987 | 984 |
988 CreateVideoStreams(); | 985 CreateVideoStreams(); |
989 analyzer.input_ = video_send_stream_->Input(); | 986 analyzer.input_ = video_send_stream_->Input(); |
990 analyzer.send_stream_ = video_send_stream_; | 987 analyzer.send_stream_ = video_send_stream_; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 video_send_stream_->Stop(); | 1067 video_send_stream_->Stop(); |
1071 receive_stream->Stop(); | 1068 receive_stream->Stop(); |
1072 | 1069 |
1073 call->DestroyVideoReceiveStream(receive_stream); | 1070 call->DestroyVideoReceiveStream(receive_stream); |
1074 call->DestroyVideoSendStream(video_send_stream_); | 1071 call->DestroyVideoSendStream(video_send_stream_); |
1075 | 1072 |
1076 transport.StopSending(); | 1073 transport.StopSending(); |
1077 } | 1074 } |
1078 | 1075 |
1079 } // namespace webrtc | 1076 } // namespace webrtc |
OLD | NEW |