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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 void ComfortNoise::Reset() { | 23 void ComfortNoise::Reset() { |
24 first_call_ = true; | 24 first_call_ = true; |
25 } | 25 } |
26 | 26 |
27 int ComfortNoise::UpdateParameters(Packet* packet) { | 27 int ComfortNoise::UpdateParameters(Packet* packet) { |
28 assert(packet); // Existence is verified by caller. | 28 assert(packet); // Existence is verified by caller. |
29 // Get comfort noise decoder. | 29 // Get comfort noise decoder. |
30 if (decoder_database_->SetActiveCngDecoder(packet->header.payloadType) | 30 if (decoder_database_->SetActiveCngDecoder(packet->header.payloadType) |
31 != kOK) { | 31 != kOK) { |
32 delete [] packet->payload; | |
33 delete packet; | 32 delete packet; |
34 return kUnknownPayloadType; | 33 return kUnknownPayloadType; |
35 } | 34 } |
36 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); | 35 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); |
37 RTC_DCHECK(cng_decoder); | 36 RTC_DCHECK(cng_decoder); |
38 cng_decoder->UpdateSid(rtc::ArrayView<const uint8_t>( | 37 cng_decoder->UpdateSid(packet->payload); |
39 packet->payload, packet->payload_length)); | |
40 delete [] packet->payload; | |
41 delete packet; | 38 delete packet; |
42 return kOK; | 39 return kOK; |
43 } | 40 } |
44 | 41 |
45 int ComfortNoise::Generate(size_t requested_length, | 42 int ComfortNoise::Generate(size_t requested_length, |
46 AudioMultiVector* output) { | 43 AudioMultiVector* output) { |
47 // TODO(hlundin): Change to an enumerator and skip assert. | 44 // TODO(hlundin): Change to an enumerator and skip assert. |
48 assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || | 45 assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || |
49 fs_hz_ == 48000); | 46 fs_hz_ == 48000); |
50 // Not adapted for multi-channel yet. | 47 // Not adapted for multi-channel yet. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 119 } |
123 // Remove |overlap_length_| samples from the front of |output| since they | 120 // Remove |overlap_length_| samples from the front of |output| since they |
124 // were mixed into |sync_buffer_| above. | 121 // were mixed into |sync_buffer_| above. |
125 output->PopFront(overlap_length_); | 122 output->PopFront(overlap_length_); |
126 } | 123 } |
127 first_call_ = false; | 124 first_call_ = false; |
128 return kOK; | 125 return kOK; |
129 } | 126 } |
130 | 127 |
131 } // namespace webrtc | 128 } // namespace webrtc |
OLD | NEW |