blob: afc193c461e8a23846e3afb502ea43e62ff075f1 [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 Yehf4ae9422010-09-30 03:04:06 +080024extern AudioCodec *newGsmEfrCodec();
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080025
26struct AudioCodecType {
27 const char *name;
28 AudioCodec *(*create)();
29} gAudioCodecTypes[] = {
30 {"PCMA", newAlawCodec},
31 {"PCMU", newUlawCodec},
Chia-chi Yeha6f950c2010-09-29 10:36:52 +080032 {"GSM", newGsmCodec},
Chia-chi Yehf4ae9422010-09-30 03:04:06 +080033 {"GSM-EFR", newGsmEfrCodec},
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080034 {NULL, NULL},
35};
36
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080037AudioCodec *newAudioCodec(const char *codecName)
38{
39 AudioCodecType *type = gAudioCodecTypes;
40 while (type->name != NULL) {
Chia-chi Yeh4033a672010-09-16 18:36:45 +080041 if (strcasecmp(codecName, type->name) == 0) {
42 AudioCodec *codec = type->create();
43 codec->name = type->name;
44 return codec;
Chia-chi Yeh4c5d28c2010-08-06 14:12:05 +080045 }
46 ++type;
47 }
48 return NULL;
49}