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 |
11 #include "webrtc/modules/audio_coding/neteq/comfort_noise.h" | 11 #include "webrtc/modules/audio_coding/neteq/comfort_noise.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 16 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
17 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" | 17 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" |
18 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" | 18 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" |
19 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" | 19 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
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(const Packet& packet) { |
28 assert(packet); // Existence is verified by caller. | |
29 // Get comfort noise decoder. | 28 // Get comfort noise decoder. |
30 if (decoder_database_->SetActiveCngDecoder(packet->payload_type) != kOK) { | 29 if (decoder_database_->SetActiveCngDecoder(packet.payload_type) != kOK) { |
31 delete packet; | |
32 return kUnknownPayloadType; | 30 return kUnknownPayloadType; |
33 } | 31 } |
34 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); | 32 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); |
35 RTC_DCHECK(cng_decoder); | 33 RTC_DCHECK(cng_decoder); |
36 cng_decoder->UpdateSid(packet->payload); | 34 cng_decoder->UpdateSid(packet.payload); |
37 delete packet; | |
38 return kOK; | 35 return kOK; |
39 } | 36 } |
40 | 37 |
41 int ComfortNoise::Generate(size_t requested_length, | 38 int ComfortNoise::Generate(size_t requested_length, |
42 AudioMultiVector* output) { | 39 AudioMultiVector* output) { |
43 // TODO(hlundin): Change to an enumerator and skip assert. | 40 // TODO(hlundin): Change to an enumerator and skip assert. |
44 assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || | 41 assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 || |
45 fs_hz_ == 48000); | 42 fs_hz_ == 48000); |
46 // Not adapted for multi-channel yet. | 43 // Not adapted for multi-channel yet. |
47 if (output->Channels() != 1) { | 44 if (output->Channels() != 1) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 115 } |
119 // Remove |overlap_length_| samples from the front of |output| since they | 116 // Remove |overlap_length_| samples from the front of |output| since they |
120 // were mixed into |sync_buffer_| above. | 117 // were mixed into |sync_buffer_| above. |
121 output->PopFront(overlap_length_); | 118 output->PopFront(overlap_length_); |
122 } | 119 } |
123 first_call_ = false; | 120 first_call_ = false; |
124 return kOK; | 121 return kOK; |
125 } | 122 } |
126 | 123 |
127 } // namespace webrtc | 124 } // namespace webrtc |
OLD | NEW |