| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 AudioFrame::kMaxDataSizeSamples); | 46 AudioFrame::kMaxDataSizeSamples); |
| 47 acm_->RegisterTransportCallback(this); | 47 acm_->RegisterTransportCallback(this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool AcmSendTestOldApi::RegisterCodec(const char* payload_name, | 50 bool AcmSendTestOldApi::RegisterCodec(const char* payload_name, |
| 51 int sampling_freq_hz, | 51 int sampling_freq_hz, |
| 52 int channels, | 52 int channels, |
| 53 int payload_type, | 53 int payload_type, |
| 54 int frame_size_samples) { | 54 int frame_size_samples) { |
| 55 CodecInst codec; | 55 CodecInst codec; |
| 56 CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec, sampling_freq_hz, | 56 RTC_CHECK_EQ(0, AudioCodingModule::Codec(payload_name, &codec, |
| 57 channels)); | 57 sampling_freq_hz, channels)); |
| 58 codec.pltype = payload_type; | 58 codec.pltype = payload_type; |
| 59 codec.pacsize = frame_size_samples; | 59 codec.pacsize = frame_size_samples; |
| 60 codec_registered_ = (acm_->RegisterSendCodec(codec) == 0); | 60 codec_registered_ = (acm_->RegisterSendCodec(codec) == 0); |
| 61 input_frame_.num_channels_ = channels; | 61 input_frame_.num_channels_ = channels; |
| 62 assert(input_block_size_samples_ * input_frame_.num_channels_ <= | 62 assert(input_block_size_samples_ * input_frame_.num_channels_ <= |
| 63 AudioFrame::kMaxDataSizeSamples); | 63 AudioFrame::kMaxDataSizeSamples); |
| 64 return codec_registered_; | 64 return codec_registered_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool AcmSendTestOldApi::RegisterExternalCodec( | 67 bool AcmSendTestOldApi::RegisterExternalCodec( |
| 68 AudioEncoder* external_speech_encoder) { | 68 AudioEncoder* external_speech_encoder) { |
| 69 acm_->RegisterExternalSendCodec(external_speech_encoder); | 69 acm_->RegisterExternalSendCodec(external_speech_encoder); |
| 70 input_frame_.num_channels_ = external_speech_encoder->NumChannels(); | 70 input_frame_.num_channels_ = external_speech_encoder->NumChannels(); |
| 71 assert(input_block_size_samples_ * input_frame_.num_channels_ <= | 71 assert(input_block_size_samples_ * input_frame_.num_channels_ <= |
| 72 AudioFrame::kMaxDataSizeSamples); | 72 AudioFrame::kMaxDataSizeSamples); |
| 73 return codec_registered_ = true; | 73 return codec_registered_ = true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 Packet* AcmSendTestOldApi::NextPacket() { | 76 Packet* AcmSendTestOldApi::NextPacket() { |
| 77 assert(codec_registered_); | 77 assert(codec_registered_); |
| 78 if (filter_.test(static_cast<size_t>(payload_type_))) { | 78 if (filter_.test(static_cast<size_t>(payload_type_))) { |
| 79 // This payload type should be filtered out. Since the payload type is the | 79 // This payload type should be filtered out. Since the payload type is the |
| 80 // same throughout the whole test run, no packet at all will be delivered. | 80 // same throughout the whole test run, no packet at all will be delivered. |
| 81 // We can just as well signal that the test is over by returning NULL. | 81 // We can just as well signal that the test is over by returning NULL. |
| 82 return NULL; | 82 return NULL; |
| 83 } | 83 } |
| 84 // Insert audio and process until one packet is produced. | 84 // Insert audio and process until one packet is produced. |
| 85 while (clock_.TimeInMilliseconds() < test_duration_ms_) { | 85 while (clock_.TimeInMilliseconds() < test_duration_ms_) { |
| 86 clock_.AdvanceTimeMilliseconds(kBlockSizeMs); | 86 clock_.AdvanceTimeMilliseconds(kBlockSizeMs); |
| 87 CHECK(audio_source_->Read(input_block_size_samples_, input_frame_.data_)); | 87 RTC_CHECK( |
| 88 audio_source_->Read(input_block_size_samples_, input_frame_.data_)); |
| 88 if (input_frame_.num_channels_ > 1) { | 89 if (input_frame_.num_channels_ > 1) { |
| 89 InputAudioFile::DuplicateInterleaved(input_frame_.data_, | 90 InputAudioFile::DuplicateInterleaved(input_frame_.data_, |
| 90 input_block_size_samples_, | 91 input_block_size_samples_, |
| 91 input_frame_.num_channels_, | 92 input_frame_.num_channels_, |
| 92 input_frame_.data_); | 93 input_frame_.data_); |
| 93 } | 94 } |
| 94 data_to_send_ = false; | 95 data_to_send_ = false; |
| 95 CHECK_GE(acm_->Add10MsData(input_frame_), 0); | 96 RTC_CHECK_GE(acm_->Add10MsData(input_frame_), 0); |
| 96 input_frame_.timestamp_ += static_cast<uint32_t>(input_block_size_samples_); | 97 input_frame_.timestamp_ += static_cast<uint32_t>(input_block_size_samples_); |
| 97 if (data_to_send_) { | 98 if (data_to_send_) { |
| 98 // Encoded packet received. | 99 // Encoded packet received. |
| 99 return CreatePacket(); | 100 return CreatePacket(); |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 // Test ended. | 103 // Test ended. |
| 103 return NULL; | 104 return NULL; |
| 104 } | 105 } |
| 105 | 106 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 last_payload_vec_.size()); | 149 last_payload_vec_.size()); |
| 149 Packet* packet = | 150 Packet* packet = |
| 150 new Packet(packet_memory, allocated_bytes, clock_.TimeInMilliseconds()); | 151 new Packet(packet_memory, allocated_bytes, clock_.TimeInMilliseconds()); |
| 151 assert(packet); | 152 assert(packet); |
| 152 assert(packet->valid_header()); | 153 assert(packet->valid_header()); |
| 153 return packet; | 154 return packet; |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace test | 157 } // namespace test |
| 157 } // namespace webrtc | 158 } // namespace webrtc |
| OLD | NEW |