niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Function were the sample rate is set. |
| 13 | */ |
| 14 | |
| 15 | #include "mcu.h" |
| 16 | |
| 17 | #include "dtmf_buffer.h" |
| 18 | #include "neteq_error_codes.h" |
| 19 | |
| 20 | int WebRtcNetEQ_McuSetFs(MCUInst_t *inst, WebRtc_UWord16 fs) |
| 21 | { |
| 22 | WebRtc_Word16 ok = 0; |
| 23 | |
| 24 | switch (fs) |
| 25 | { |
| 26 | case 8000: |
| 27 | { |
| 28 | #ifdef NETEQ_ATEVENT_DECODE |
| 29 | ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 8000, 560); |
| 30 | #endif |
| 31 | inst->timestampsPerCall = inst->millisecondsPerCall * 8; |
| 32 | break; |
| 33 | } |
| 34 | |
| 35 | #ifdef NETEQ_WIDEBAND |
| 36 | case 16000: |
| 37 | { |
| 38 | #ifdef NETEQ_ATEVENT_DECODE |
| 39 | ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 16000, 1120); |
| 40 | #endif |
| 41 | inst->timestampsPerCall = inst->millisecondsPerCall * 16; |
| 42 | break; |
| 43 | } |
| 44 | #endif |
| 45 | |
| 46 | #ifdef NETEQ_32KHZ_WIDEBAND |
| 47 | case 32000: |
| 48 | { |
| 49 | #ifdef NETEQ_ATEVENT_DECODE |
| 50 | ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 32000, 2240); |
| 51 | #endif |
| 52 | inst->timestampsPerCall = inst->millisecondsPerCall * 32; |
| 53 | break; |
| 54 | } |
| 55 | #endif |
| 56 | |
| 57 | #ifdef NETEQ_48KHZ_WIDEBAND |
| 58 | case 48000: |
| 59 | { |
| 60 | #ifdef NETEQ_ATEVENT_DECODE |
| 61 | ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 48000, 3360); |
| 62 | #endif |
| 63 | inst->timestampsPerCall = inst->millisecondsPerCall * 48; |
| 64 | break; |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | default: |
| 69 | { |
| 70 | /* Not supported yet */ |
| 71 | return CODEC_DB_UNSUPPORTED_FS; |
| 72 | } |
| 73 | } /* end switch */ |
| 74 | |
| 75 | inst->fs = fs; |
| 76 | |
| 77 | return ok; |
| 78 | } |