OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 out_file_b_.Open(file_name.c_str(), 32000, "wb"); | 173 out_file_b_.Open(file_name.c_str(), 32000, "wb"); |
174 } | 174 } |
175 | 175 |
176 void Run(int duration_sec, const char* output_prefix) { | 176 void Run(int duration_sec, const char* output_prefix) { |
177 OpenOutFile(output_prefix); | 177 OpenOutFile(output_prefix); |
178 AudioFrame audio_frame; | 178 AudioFrame audio_frame; |
179 uint32_t out_freq_hz_b = out_file_b_.SamplingFrequency(); | 179 uint32_t out_freq_hz_b = out_file_b_.SamplingFrequency(); |
180 | 180 |
181 int num_frames = 0; | 181 int num_frames = 0; |
182 int in_file_frames = 0; | 182 int in_file_frames = 0; |
183 uint32_t playout_ts; | |
184 uint32_t received_ts; | 183 uint32_t received_ts; |
185 double average_delay = 0; | 184 double average_delay = 0; |
186 double inst_delay_sec = 0; | 185 double inst_delay_sec = 0; |
187 while (num_frames < (duration_sec * 100)) { | 186 while (num_frames < (duration_sec * 100)) { |
188 if (in_file_a_.EndOfFile()) { | 187 if (in_file_a_.EndOfFile()) { |
189 in_file_a_.Rewind(); | 188 in_file_a_.Rewind(); |
190 } | 189 } |
191 | 190 |
192 // Print delay information every 16 frame | 191 // Print delay information every 16 frame |
193 if ((num_frames & 0x3F) == 0x3F) { | 192 if ((num_frames & 0x3F) == 0x3F) { |
194 NetworkStatistics statistics; | 193 NetworkStatistics statistics; |
195 acm_b_->GetNetworkStatistics(&statistics); | 194 acm_b_->GetNetworkStatistics(&statistics); |
196 fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d" | 195 fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d" |
197 " ts-based average = %6.3f, " | 196 " ts-based average = %6.3f, " |
198 "curr buff-lev = %4u opt buff-lev = %4u \n", | 197 "curr buff-lev = %4u opt buff-lev = %4u \n", |
199 statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs, | 198 statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs, |
200 statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs, | 199 statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs, |
201 average_delay, statistics.currentBufferSize, | 200 average_delay, statistics.currentBufferSize, |
202 statistics.preferredBufferSize); | 201 statistics.preferredBufferSize); |
203 fflush (stdout); | 202 fflush (stdout); |
204 } | 203 } |
205 | 204 |
206 in_file_a_.Read10MsData(audio_frame); | 205 in_file_a_.Read10MsData(audio_frame); |
207 ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0); | 206 ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0); |
208 ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); | 207 ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); |
209 out_file_b_.Write10MsData( | 208 out_file_b_.Write10MsData( |
210 audio_frame.data_, | 209 audio_frame.data_, |
211 audio_frame.samples_per_channel_ * audio_frame.num_channels_); | 210 audio_frame.samples_per_channel_ * audio_frame.num_channels_); |
212 acm_b_->PlayoutTimestamp(&playout_ts); | |
213 received_ts = channel_a2b_->LastInTimestamp(); | 211 received_ts = channel_a2b_->LastInTimestamp(); |
214 inst_delay_sec = static_cast<uint32_t>(received_ts - playout_ts) | 212 rtc::Optional<uint32_t> playout_timestamp = acm_b_->PlayoutTimestamp(); |
215 / static_cast<double>(encoding_sample_rate_hz_); | 213 ASSERT_TRUE(playout_timestamp); |
| 214 inst_delay_sec = static_cast<uint32_t>(received_ts - *playout_timestamp) / |
| 215 static_cast<double>(encoding_sample_rate_hz_); |
216 | 216 |
217 if (num_frames > 10) | 217 if (num_frames > 10) |
218 average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec; | 218 average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec; |
219 | 219 |
220 ++num_frames; | 220 ++num_frames; |
221 ++in_file_frames; | 221 ++in_file_frames; |
222 } | 222 } |
223 out_file_b_.Close(); | 223 out_file_b_.Close(); |
224 } | 224 } |
225 | 225 |
(...skipping 30 matching lines...) Expand all Loading... |
256 test_setting.codec.num_channels = FLAGS_num_channels; | 256 test_setting.codec.num_channels = FLAGS_num_channels; |
257 test_setting.acm.dtx = FLAGS_dtx; | 257 test_setting.acm.dtx = FLAGS_dtx; |
258 test_setting.acm.fec = FLAGS_fec; | 258 test_setting.acm.fec = FLAGS_fec; |
259 test_setting.packet_loss = FLAGS_packet_loss; | 259 test_setting.packet_loss = FLAGS_packet_loss; |
260 | 260 |
261 webrtc::DelayTest delay_test; | 261 webrtc::DelayTest delay_test; |
262 delay_test.Initialize(); | 262 delay_test.Initialize(); |
263 delay_test.Perform(&test_setting, 1, 240, "delay_test"); | 263 delay_test.Perform(&test_setting, 1, 240, "delay_test"); |
264 return 0; | 264 return 0; |
265 } | 265 } |
OLD | NEW |