Sylvain Munaut | 0f7e52d | 2010-10-29 11:38:54 +0200 | [diff] [blame] | 1 | /* 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 Munaut | 24b7612 | 2010-10-29 22:45:22 +0200 | [diff] [blame] | 21 | #include <string.h> |
Sylvain Munaut | 0f7e52d | 2010-10-29 11:38:54 +0200 | [diff] [blame] | 22 | |
| 23 | #include <gapk/formats.h> |
| 24 | |
| 25 | /* Extern format descriptors */ |
Sylvain Munaut | 723df06 | 2010-10-29 11:47:06 +0200 | [diff] [blame] | 26 | extern const struct format_desc fmt_amr_efr; |
Sylvain Munaut | 5e380d0 | 2010-10-29 11:41:16 +0200 | [diff] [blame] | 27 | extern const struct format_desc fmt_gsm; |
Sylvain Munaut | f905983 | 2010-10-29 11:44:40 +0200 | [diff] [blame] | 28 | extern const struct format_desc fmt_hr_ref_dec; |
| 29 | extern const struct format_desc fmt_hr_ref_enc; |
Sylvain Munaut | 6c96cc2 | 2010-10-29 11:46:05 +0200 | [diff] [blame] | 30 | extern const struct format_desc fmt_racal_hr; |
| 31 | extern const struct format_desc fmt_racal_fr; |
| 32 | extern const struct format_desc fmt_racal_efr; |
Sylvain Munaut | 456758c | 2010-11-11 22:58:20 +0100 | [diff] [blame] | 33 | extern const struct format_desc fmt_rawpcm_s16le; |
Sylvain Munaut | b1525d6 | 2011-02-25 16:58:36 +0100 | [diff] [blame] | 34 | extern const struct format_desc fmt_ti_hr; |
Sylvain Munaut | cfaec3a | 2011-02-25 15:31:54 +0100 | [diff] [blame] | 35 | extern const struct format_desc fmt_ti_fr; |
Sylvain Munaut | e2c5719 | 2011-02-25 18:12:25 +0100 | [diff] [blame] | 36 | extern const struct format_desc fmt_ti_efr; |
Harald Welte | 8b01f0c | 2017-05-28 11:04:26 +0200 | [diff] [blame] | 37 | extern const struct format_desc fmt_amr_opencore; |
| 38 | extern const struct format_desc fmt_rtp_amr; |
Harald Welte | f62e7a4 | 2017-05-28 13:46:47 +0200 | [diff] [blame] | 39 | extern const struct format_desc fmt_rtp_efr; |
Harald Welte | dc3589a | 2017-05-28 14:09:00 +0200 | [diff] [blame] | 40 | extern const struct format_desc fmt_rtp_hr_etsi; |
Harald Welte | 848db7b | 2017-05-28 14:17:05 +0200 | [diff] [blame^] | 41 | extern const struct format_desc fmt_rtp_hr_ietf; |
Sylvain Munaut | 5e380d0 | 2010-10-29 11:41:16 +0200 | [diff] [blame] | 42 | |
Sylvain Munaut | 0f7e52d | 2010-10-29 11:38:54 +0200 | [diff] [blame] | 43 | static const struct format_desc *supported_formats[_FMT_MAX] = { |
| 44 | [FMT_INVALID] = NULL, |
Sylvain Munaut | 723df06 | 2010-10-29 11:47:06 +0200 | [diff] [blame] | 45 | [FMT_AMR_EFR] = &fmt_amr_efr, |
Sylvain Munaut | 5e380d0 | 2010-10-29 11:41:16 +0200 | [diff] [blame] | 46 | [FMT_GSM] = &fmt_gsm, |
Sylvain Munaut | f905983 | 2010-10-29 11:44:40 +0200 | [diff] [blame] | 47 | [FMT_HR_REF_DEC] = &fmt_hr_ref_dec, |
| 48 | [FMT_HR_REF_ENC] = &fmt_hr_ref_enc, |
Sylvain Munaut | 6c96cc2 | 2010-10-29 11:46:05 +0200 | [diff] [blame] | 49 | [FMT_RACAL_HR] = &fmt_racal_hr, |
| 50 | [FMT_RACAL_FR] = &fmt_racal_fr, |
| 51 | [FMT_RACAL_EFR] = &fmt_racal_efr, |
Sylvain Munaut | 456758c | 2010-11-11 22:58:20 +0100 | [diff] [blame] | 52 | [FMT_RAWPCM_S16LE] = &fmt_rawpcm_s16le, |
Sylvain Munaut | b1525d6 | 2011-02-25 16:58:36 +0100 | [diff] [blame] | 53 | [FMT_TI_HR] = &fmt_ti_hr, |
Sylvain Munaut | cfaec3a | 2011-02-25 15:31:54 +0100 | [diff] [blame] | 54 | [FMT_TI_FR] = &fmt_ti_fr, |
Sylvain Munaut | e2c5719 | 2011-02-25 18:12:25 +0100 | [diff] [blame] | 55 | [FMT_TI_EFR] = &fmt_ti_efr, |
Harald Welte | 8b01f0c | 2017-05-28 11:04:26 +0200 | [diff] [blame] | 56 | [FMT_AMR_OPENCORE] = &fmt_amr_opencore, |
| 57 | [FMT_RTP_AMR] = &fmt_rtp_amr, |
Harald Welte | f62e7a4 | 2017-05-28 13:46:47 +0200 | [diff] [blame] | 58 | [FMT_RTP_EFR] = &fmt_rtp_efr, |
Harald Welte | dc3589a | 2017-05-28 14:09:00 +0200 | [diff] [blame] | 59 | [FMT_RTP_HR_ETSI] = &fmt_rtp_hr_etsi, |
Harald Welte | 848db7b | 2017-05-28 14:17:05 +0200 | [diff] [blame^] | 60 | [FMT_RTP_HR_IETF] = &fmt_rtp_hr_ietf, |
Sylvain Munaut | 0f7e52d | 2010-10-29 11:38:54 +0200 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | |
| 64 | const struct format_desc * |
| 65 | fmt_get_from_type(enum format_type type) |
| 66 | { |
| 67 | if (type <= FMT_INVALID || type >= _FMT_MAX) |
| 68 | return NULL; |
| 69 | return supported_formats[type]; |
| 70 | } |
Sylvain Munaut | 24b7612 | 2010-10-29 22:45:22 +0200 | [diff] [blame] | 71 | |
| 72 | const struct format_desc * |
| 73 | fmt_get_from_name(const char *name) |
| 74 | { |
| 75 | int i; |
| 76 | for (i=FMT_INVALID+1; i<_FMT_MAX; i++) { |
| 77 | const struct format_desc *fmt = supported_formats[i]; |
| 78 | if (!fmt) |
| 79 | continue; |
| 80 | if (!strcmp(fmt->name, name)) |
| 81 | return fmt; |
| 82 | } |
| 83 | return NULL; |
| 84 | } |