blob: 8f51c2d8b8ba5f98ae20c2175c7d8fcce61880d3 [file] [log] [blame]
Sylvain Munaut0f7e52d2010-10-29 11:38:54 +02001/* Formats handling */
2
3/*
4 * This file is part of gapk (GSM Audio Pocket Knife).
5 *
6 * gapk is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * gapk is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with gapk. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <stdio.h> /* for NULL */
Sylvain Munaut24b76122010-10-29 22:45:22 +020021#include <string.h>
Sylvain Munaut0f7e52d2010-10-29 11:38:54 +020022
23#include <gapk/formats.h>
24
25/* Extern format descriptors */
Sylvain Munaut723df062010-10-29 11:47:06 +020026extern const struct format_desc fmt_amr_efr;
Sylvain Munaut5e380d02010-10-29 11:41:16 +020027extern const struct format_desc fmt_gsm;
Sylvain Munautf9059832010-10-29 11:44:40 +020028extern const struct format_desc fmt_hr_ref_dec;
29extern const struct format_desc fmt_hr_ref_enc;
Sylvain Munaut6c96cc22010-10-29 11:46:05 +020030extern const struct format_desc fmt_racal_hr;
31extern const struct format_desc fmt_racal_fr;
32extern const struct format_desc fmt_racal_efr;
Sylvain Munaut5e380d02010-10-29 11:41:16 +020033
Sylvain Munaut0f7e52d2010-10-29 11:38:54 +020034static const struct format_desc *supported_formats[_FMT_MAX] = {
35 [FMT_INVALID] = NULL,
Sylvain Munaut723df062010-10-29 11:47:06 +020036 [FMT_AMR_EFR] = &fmt_amr_efr,
Sylvain Munaut5e380d02010-10-29 11:41:16 +020037 [FMT_GSM] = &fmt_gsm,
Sylvain Munautf9059832010-10-29 11:44:40 +020038 [FMT_HR_REF_DEC] = &fmt_hr_ref_dec,
39 [FMT_HR_REF_ENC] = &fmt_hr_ref_enc,
Sylvain Munaut6c96cc22010-10-29 11:46:05 +020040 [FMT_RACAL_HR] = &fmt_racal_hr,
41 [FMT_RACAL_FR] = &fmt_racal_fr,
42 [FMT_RACAL_EFR] = &fmt_racal_efr,
Sylvain Munaut0f7e52d2010-10-29 11:38:54 +020043};
44
45
46const struct format_desc *
47fmt_get_from_type(enum format_type type)
48{
49 if (type <= FMT_INVALID || type >= _FMT_MAX)
50 return NULL;
51 return supported_formats[type];
52}
Sylvain Munaut24b76122010-10-29 22:45:22 +020053
54const struct format_desc *
55fmt_get_from_name(const char *name)
56{
57 int i;
58 for (i=FMT_INVALID+1; i<_FMT_MAX; i++) {
59 const struct format_desc *fmt = supported_formats[i];
60 if (!fmt)
61 continue;
62 if (!strcmp(fmt->name, name))
63 return fmt;
64 }
65 return NULL;
66}