| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 22 matching lines...) Expand all Loading... |
| 33 // the channel, and decodes at "b". | 33 // the channel, and decodes at "b". |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 const size_t kVariableSize = std::numeric_limits<size_t>::max(); | 36 const size_t kVariableSize = std::numeric_limits<size_t>::max(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace webrtc { | 39 namespace webrtc { |
| 40 | 40 |
| 41 // Class for simulating packet handling. | 41 // Class for simulating packet handling. |
| 42 TestPack::TestPack() | 42 TestPack::TestPack() |
| 43 : receiver_acm_(NULL), | 43 : receiver_acm_(nullptr), |
| 44 sequence_number_(0), | 44 sequence_number_(0), |
| 45 timestamp_diff_(0), | 45 timestamp_diff_(0), |
| 46 last_in_timestamp_(0), | 46 last_in_timestamp_(0), |
| 47 total_bytes_(0), | 47 total_bytes_(0), |
| 48 payload_size_(0) { | 48 payload_size_(0) {} |
| 49 } | |
| 50 | 49 |
| 51 TestPack::~TestPack() { | 50 TestPack::~TestPack() { |
| 52 } | 51 } |
| 53 | 52 |
| 54 void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { | 53 void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { |
| 55 receiver_acm_ = acm; | 54 receiver_acm_ = acm; |
| 56 return; | 55 return; |
| 57 } | 56 } |
| 58 | 57 |
| 59 int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, | 58 int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return timestamp_diff_; | 98 return timestamp_diff_; |
| 100 } | 99 } |
| 101 | 100 |
| 102 void TestPack::reset_payload_size() { | 101 void TestPack::reset_payload_size() { |
| 103 payload_size_ = 0; | 102 payload_size_ = 0; |
| 104 } | 103 } |
| 105 | 104 |
| 106 TestAllCodecs::TestAllCodecs(int test_mode) | 105 TestAllCodecs::TestAllCodecs(int test_mode) |
| 107 : acm_a_(AudioCodingModule::Create(0)), | 106 : acm_a_(AudioCodingModule::Create(0)), |
| 108 acm_b_(AudioCodingModule::Create(1)), | 107 acm_b_(AudioCodingModule::Create(1)), |
| 109 channel_a_to_b_(NULL), | 108 channel_a_to_b_(nullptr), |
| 110 test_count_(0), | 109 test_count_(0), |
| 111 packet_size_samples_(0), | 110 packet_size_samples_(0), |
| 112 packet_size_bytes_(0) { | 111 packet_size_bytes_(0) { |
| 113 // test_mode = 0 for silent test (auto test) | 112 // test_mode = 0 for silent test (auto test) |
| 114 test_mode_ = test_mode; | 113 test_mode_ = test_mode; |
| 115 } | 114 } |
| 116 | 115 |
| 117 TestAllCodecs::~TestAllCodecs() { | 116 TestAllCodecs::~TestAllCodecs() { |
| 118 if (channel_a_to_b_ != NULL) { | 117 if (channel_a_to_b_ != nullptr) { |
| 119 delete channel_a_to_b_; | 118 delete channel_a_to_b_; |
| 120 channel_a_to_b_ = NULL; | 119 channel_a_to_b_ = nullptr; |
| 121 } | 120 } |
| 122 } | 121 } |
| 123 | 122 |
| 124 void TestAllCodecs::Perform() { | 123 void TestAllCodecs::Perform() { |
| 125 const std::string file_name = webrtc::test::ResourcePath( | 124 const std::string file_name = webrtc::test::ResourcePath( |
| 126 "audio_coding/testfile32kHz", "pcm"); | 125 "audio_coding/testfile32kHz", "pcm"); |
| 127 infile_a_.Open(file_name, 32000, "rb"); | 126 infile_a_.Open(file_name, 32000, "rb"); |
| 128 | 127 |
| 129 if (test_mode_ == 0) { | 128 if (test_mode_ == 0) { |
| 130 WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, | 129 WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // Add 0.875 to always round up to a whole byte | 381 // Add 0.875 to always round up to a whole byte |
| 383 packet_size_bytes_ = static_cast<size_t>( | 382 packet_size_bytes_ = static_cast<size_t>( |
| 384 static_cast<float>(packet_size * rate) / | 383 static_cast<float>(packet_size * rate) / |
| 385 static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte; | 384 static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte; |
| 386 } else { | 385 } else { |
| 387 // Packets will have a variable size. | 386 // Packets will have a variable size. |
| 388 packet_size_bytes_ = kVariableSize; | 387 packet_size_bytes_ = kVariableSize; |
| 389 } | 388 } |
| 390 | 389 |
| 391 // Set pointer to the ACM where to register the codec. | 390 // Set pointer to the ACM where to register the codec. |
| 392 AudioCodingModule* my_acm = NULL; | 391 AudioCodingModule* my_acm = nullptr; |
| 393 switch (side) { | 392 switch (side) { |
| 394 case 'A': { | 393 case 'A': { |
| 395 my_acm = acm_a_.get(); | 394 my_acm = acm_a_.get(); |
| 396 break; | 395 break; |
| 397 } | 396 } |
| 398 case 'B': { | 397 case 'B': { |
| 399 my_acm = acm_b_.get(); | 398 my_acm = acm_b_.get(); |
| 400 break; | 399 break; |
| 401 } | 400 } |
| 402 default: { | 401 default: { |
| 403 break; | 402 break; |
| 404 } | 403 } |
| 405 } | 404 } |
| 406 ASSERT_TRUE(my_acm != NULL); | 405 ASSERT_TRUE(my_acm != nullptr); |
| 407 | 406 |
| 408 // Get all codec parameters before registering | 407 // Get all codec parameters before registering |
| 409 CodecInst my_codec_param; | 408 CodecInst my_codec_param; |
| 410 CHECK_ERROR(AudioCodingModule::Codec(codec_name, &my_codec_param, | 409 CHECK_ERROR(AudioCodingModule::Codec(codec_name, &my_codec_param, |
| 411 sampling_freq_hz, 1)); | 410 sampling_freq_hz, 1)); |
| 412 my_codec_param.rate = rate; | 411 my_codec_param.rate = rate; |
| 413 my_codec_param.pacsize = packet_size; | 412 my_codec_param.pacsize = packet_size; |
| 414 CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param)); | 413 CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param)); |
| 415 } | 414 } |
| 416 | 415 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 481 } |
| 483 | 482 |
| 484 void TestAllCodecs::DisplaySendReceiveCodec() { | 483 void TestAllCodecs::DisplaySendReceiveCodec() { |
| 485 CodecInst my_codec_param; | 484 CodecInst my_codec_param; |
| 486 printf("%s -> ", acm_a_->SendCodec()->plname); | 485 printf("%s -> ", acm_a_->SendCodec()->plname); |
| 487 acm_b_->ReceiveCodec(&my_codec_param); | 486 acm_b_->ReceiveCodec(&my_codec_param); |
| 488 printf("%s\n", my_codec_param.plname); | 487 printf("%s\n", my_codec_param.plname); |
| 489 } | 488 } |
| 490 | 489 |
| 491 } // namespace webrtc | 490 } // namespace webrtc |
| OLD | NEW |