blob: 2267ea00d2b713a826027a9d954bc7d6d0488a24 [file] [log] [blame]
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +08001/*
2 * Copyrightm (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <string.h>
18
19#include "AudioCodec.h"
20
Chia-chi Yeh78c11b32010-09-29 05:46:19 +080021extern AudioCodec *newAlawCodec();
22extern AudioCodec *newUlawCodec();
Chia-chi Yeha6f950c2010-09-29 10:36:52 +080023extern AudioCodec *newGsmCodec();
Chia-chi Yehf88fc1f2010-09-30 08:51:59 +080024extern AudioCodec *newAmrCodec();
Chia-chi Yehf4ae9422010-09-30 03:04:06 +080025extern AudioCodec *newGsmEfrCodec();
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080026
27struct AudioCodecType {
28 const char *name;
29 AudioCodec *(*create)();
30} gAudioCodecTypes[] = {
31 {"PCMA", newAlawCodec},
32 {"PCMU", newUlawCodec},
Chia-chi Yeha6f950c2010-09-29 10:36:52 +080033 {"GSM", newGsmCodec},
Chia-chi Yehf88fc1f2010-09-30 08:51:59 +080034 {"AMR", newAmrCodec},
Chia-chi Yehf4ae9422010-09-30 03:04:06 +080035 {"GSM-EFR", newGsmEfrCodec},
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080036 {NULL, NULL},
37};
38
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080039AudioCodec *newAudioCodec(const char *codecName)
40{
41 AudioCodecType *type = gAudioCodecTypes;
42 while (type->name != NULL) {
Chia-chi Yeh4033a672010-09-16 18:36:45 +080043 if (strcasecmp(codecName, type->name) == 0) {
44 AudioCodec *codec = type->create();
45 codec->name = type->name;
46 return codec;
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080047 }
48 ++type;
49 }
50 return NULL;
51}