OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 enum NetEqDecoder decoder_type) | 211 enum NetEqDecoder decoder_type) |
212 : decoder_type_(decoder_type), | 212 : decoder_type_(decoder_type), |
213 channels_(FLAGS_channels), | 213 channels_(FLAGS_channels), |
214 decoded_time_ms_(0), | 214 decoded_time_ms_(0), |
215 decodable_time_ms_(0), | 215 decodable_time_ms_(0), |
216 drift_factor_(FLAGS_drift_factor), | 216 drift_factor_(FLAGS_drift_factor), |
217 packet_loss_rate_(FLAGS_packet_loss_rate), | 217 packet_loss_rate_(FLAGS_packet_loss_rate), |
218 block_duration_ms_(block_duration_ms), | 218 block_duration_ms_(block_duration_ms), |
219 in_sampling_khz_(in_sampling_khz), | 219 in_sampling_khz_(in_sampling_khz), |
220 out_sampling_khz_(out_sampling_khz), | 220 out_sampling_khz_(out_sampling_khz), |
221 in_size_samples_(in_sampling_khz_ * block_duration_ms_), | 221 in_size_samples_( |
222 out_size_samples_(out_sampling_khz_ * kOutputSizeMs), | 222 static_cast<size_t>(in_sampling_khz_ * block_duration_ms_)), |
| 223 out_size_samples_(static_cast<size_t>(out_sampling_khz_ * kOutputSizeMs)), |
223 payload_size_bytes_(0), | 224 payload_size_bytes_(0), |
224 max_payload_bytes_(0), | 225 max_payload_bytes_(0), |
225 in_file_(new ResampleInputAudioFile(FLAGS_in_filename, | 226 in_file_(new ResampleInputAudioFile(FLAGS_in_filename, |
226 FLAGS_input_sample_rate, | 227 FLAGS_input_sample_rate, |
227 in_sampling_khz * 1000)), | 228 in_sampling_khz * 1000)), |
228 rtp_generator_( | 229 rtp_generator_( |
229 new RtpGenerator(in_sampling_khz_, 0, 0, decodable_time_ms_)), | 230 new RtpGenerator(in_sampling_khz_, 0, 0, decodable_time_ms_)), |
230 total_payload_size_bytes_(0) { | 231 total_payload_size_bytes_(0) { |
231 const std::string out_filename = FLAGS_out_filename; | 232 const std::string out_filename = FLAGS_out_filename; |
232 const std::string log_filename = out_filename + ".log"; | 233 const std::string log_filename = out_filename + ".log"; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } else { | 386 } else { |
386 Log() << "was lost."; | 387 Log() << "was lost."; |
387 } | 388 } |
388 } | 389 } |
389 Log() << std::endl; | 390 Log() << std::endl; |
390 return packet_input_time_ms; | 391 return packet_input_time_ms; |
391 } | 392 } |
392 | 393 |
393 int NetEqQualityTest::DecodeBlock() { | 394 int NetEqQualityTest::DecodeBlock() { |
394 int channels; | 395 int channels; |
395 int samples; | 396 size_t samples; |
396 int ret = neteq_->GetAudio(out_size_samples_ * channels_, &out_data_[0], | 397 int ret = neteq_->GetAudio(out_size_samples_ * channels_, &out_data_[0], |
397 &samples, &channels, NULL); | 398 &samples, &channels, NULL); |
398 | 399 |
399 if (ret != NetEq::kOK) { | 400 if (ret != NetEq::kOK) { |
400 return -1; | 401 return -1; |
401 } else { | 402 } else { |
402 assert(channels == channels_); | 403 assert(channels == channels_); |
403 assert(samples == kOutputSizeMs * out_sampling_khz_); | 404 assert(samples == static_cast<size_t>(kOutputSizeMs * out_sampling_khz_)); |
404 CHECK(output_->WriteArray(out_data_.get(), samples * channels)); | 405 CHECK(output_->WriteArray(out_data_.get(), samples * channels)); |
405 return samples; | 406 return static_cast<int>(samples); |
406 } | 407 } |
407 } | 408 } |
408 | 409 |
409 void NetEqQualityTest::Simulate() { | 410 void NetEqQualityTest::Simulate() { |
410 int audio_size_samples; | 411 int audio_size_samples; |
411 | 412 |
412 while (decoded_time_ms_ < FLAGS_runtime_ms) { | 413 while (decoded_time_ms_ < FLAGS_runtime_ms) { |
413 // Assume 10 packets in packets buffer. | 414 // Assume 10 packets in packets buffer. |
414 while (decodable_time_ms_ - 10 * block_duration_ms_ < decoded_time_ms_) { | 415 while (decodable_time_ms_ - 10 * block_duration_ms_ < decoded_time_ms_) { |
415 ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0])); | 416 ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0])); |
416 payload_size_bytes_ = EncodeBlock(&in_data_[0], | 417 payload_size_bytes_ = EncodeBlock(&in_data_[0], |
417 in_size_samples_, &payload_[0], | 418 in_size_samples_, &payload_[0], |
418 max_payload_bytes_); | 419 max_payload_bytes_); |
419 total_payload_size_bytes_ += payload_size_bytes_; | 420 total_payload_size_bytes_ += payload_size_bytes_; |
420 decodable_time_ms_ = Transmit() + block_duration_ms_; | 421 decodable_time_ms_ = Transmit() + block_duration_ms_; |
421 } | 422 } |
422 audio_size_samples = DecodeBlock(); | 423 audio_size_samples = DecodeBlock(); |
423 if (audio_size_samples > 0) { | 424 if (audio_size_samples > 0) { |
424 decoded_time_ms_ += audio_size_samples / out_sampling_khz_; | 425 decoded_time_ms_ += audio_size_samples / out_sampling_khz_; |
425 } | 426 } |
426 } | 427 } |
427 Log() << "Average bit rate was " | 428 Log() << "Average bit rate was " |
428 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms | 429 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms |
429 << " kbps" | 430 << " kbps" |
430 << std::endl; | 431 << std::endl; |
431 } | 432 } |
432 | 433 |
433 } // namespace test | 434 } // namespace test |
434 } // namespace webrtc | 435 } // namespace webrtc |
OLD | NEW |