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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } else { | 242 } else { |
243 // Open a pcm file. | 243 // Open a pcm file. |
244 output_.reset(new webrtc::test::OutputAudioFile(out_filename)); | 244 output_.reset(new webrtc::test::OutputAudioFile(out_filename)); |
245 } | 245 } |
246 | 246 |
247 NetEq::Config config; | 247 NetEq::Config config; |
248 config.sample_rate_hz = out_sampling_khz_ * 1000; | 248 config.sample_rate_hz = out_sampling_khz_ * 1000; |
249 neteq_.reset(NetEq::Create(config)); | 249 neteq_.reset(NetEq::Create(config)); |
250 max_payload_bytes_ = in_size_samples_ * channels_ * sizeof(int16_t); | 250 max_payload_bytes_ = in_size_samples_ * channels_ * sizeof(int16_t); |
251 in_data_.reset(new int16_t[in_size_samples_ * channels_]); | 251 in_data_.reset(new int16_t[in_size_samples_ * channels_]); |
252 payload_.reset(new uint8_t[max_payload_bytes_]); | |
253 out_data_.reset(new int16_t[out_size_samples_ * channels_]); | 252 out_data_.reset(new int16_t[out_size_samples_ * channels_]); |
254 } | 253 } |
255 | 254 |
256 NetEqQualityTest::~NetEqQualityTest() { | 255 NetEqQualityTest::~NetEqQualityTest() { |
257 log_file_.close(); | 256 log_file_.close(); |
258 } | 257 } |
259 | 258 |
260 bool NoLoss::Lost() { | 259 bool NoLoss::Lost() { |
261 return false; | 260 return false; |
262 } | 261 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 &rtp_header_); | 372 &rtp_header_); |
374 Log() << "Packet of size " | 373 Log() << "Packet of size " |
375 << payload_size_bytes_ | 374 << payload_size_bytes_ |
376 << " bytes, for frame at " | 375 << " bytes, for frame at " |
377 << packet_input_time_ms | 376 << packet_input_time_ms |
378 << " ms "; | 377 << " ms "; |
379 if (payload_size_bytes_ > 0) { | 378 if (payload_size_bytes_ > 0) { |
380 if (!PacketLost()) { | 379 if (!PacketLost()) { |
381 int ret = neteq_->InsertPacket( | 380 int ret = neteq_->InsertPacket( |
382 rtp_header_, | 381 rtp_header_, |
383 rtc::ArrayView<const uint8_t>(payload_.get(), payload_size_bytes_), | 382 rtc::ArrayView<const uint8_t>(payload_.data(), payload_size_bytes_), |
384 packet_input_time_ms * in_sampling_khz_); | 383 packet_input_time_ms * in_sampling_khz_); |
385 if (ret != NetEq::kOK) | 384 if (ret != NetEq::kOK) |
386 return -1; | 385 return -1; |
387 Log() << "was sent."; | 386 Log() << "was sent."; |
388 } else { | 387 } else { |
389 Log() << "was lost."; | 388 Log() << "was lost."; |
390 } | 389 } |
391 } | 390 } |
392 Log() << std::endl; | 391 Log() << std::endl; |
393 return packet_input_time_ms; | 392 return packet_input_time_ms; |
(...skipping 15 matching lines...) Expand all Loading... |
409 } | 408 } |
410 } | 409 } |
411 | 410 |
412 void NetEqQualityTest::Simulate() { | 411 void NetEqQualityTest::Simulate() { |
413 int audio_size_samples; | 412 int audio_size_samples; |
414 | 413 |
415 while (decoded_time_ms_ < FLAGS_runtime_ms) { | 414 while (decoded_time_ms_ < FLAGS_runtime_ms) { |
416 // Assume 10 packets in packets buffer. | 415 // Assume 10 packets in packets buffer. |
417 while (decodable_time_ms_ - 10 * block_duration_ms_ < decoded_time_ms_) { | 416 while (decodable_time_ms_ - 10 * block_duration_ms_ < decoded_time_ms_) { |
418 ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0])); | 417 ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0])); |
| 418 payload_.Clear(); |
419 payload_size_bytes_ = EncodeBlock(&in_data_[0], | 419 payload_size_bytes_ = EncodeBlock(&in_data_[0], |
420 in_size_samples_, &payload_[0], | 420 in_size_samples_, &payload_, |
421 max_payload_bytes_); | 421 max_payload_bytes_); |
422 total_payload_size_bytes_ += payload_size_bytes_; | 422 total_payload_size_bytes_ += payload_size_bytes_; |
423 decodable_time_ms_ = Transmit() + block_duration_ms_; | 423 decodable_time_ms_ = Transmit() + block_duration_ms_; |
424 } | 424 } |
425 audio_size_samples = DecodeBlock(); | 425 audio_size_samples = DecodeBlock(); |
426 if (audio_size_samples > 0) { | 426 if (audio_size_samples > 0) { |
427 decoded_time_ms_ += audio_size_samples / out_sampling_khz_; | 427 decoded_time_ms_ += audio_size_samples / out_sampling_khz_; |
428 } | 428 } |
429 } | 429 } |
430 Log() << "Average bit rate was " | 430 Log() << "Average bit rate was " |
431 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms | 431 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms |
432 << " kbps" | 432 << " kbps" |
433 << std::endl; | 433 << std::endl; |
434 } | 434 } |
435 | 435 |
436 } // namespace test | 436 } // namespace test |
437 } // namespace webrtc | 437 } // namespace webrtc |
OLD | NEW |