2010-10-29 09:38:54 +00:00
|
|
|
/* Formats handling */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of gapk (GSM Audio Pocket Knife).
|
|
|
|
*
|
|
|
|
* gapk is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* gapk is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with gapk. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h> /* for NULL */
|
2010-10-29 20:45:22 +00:00
|
|
|
#include <string.h>
|
2010-10-29 09:38:54 +00:00
|
|
|
|
2017-08-30 13:26:02 +00:00
|
|
|
#include <osmocom/gapk/formats.h>
|
2010-10-29 09:38:54 +00:00
|
|
|
|
|
|
|
/* Extern format descriptors */
|
2010-10-29 09:47:06 +00:00
|
|
|
extern const struct format_desc fmt_amr_efr;
|
2010-10-29 09:41:16 +00:00
|
|
|
extern const struct format_desc fmt_gsm;
|
2010-10-29 09:44:40 +00:00
|
|
|
extern const struct format_desc fmt_hr_ref_dec;
|
|
|
|
extern const struct format_desc fmt_hr_ref_enc;
|
2010-10-29 09:46:05 +00:00
|
|
|
extern const struct format_desc fmt_racal_hr;
|
|
|
|
extern const struct format_desc fmt_racal_fr;
|
|
|
|
extern const struct format_desc fmt_racal_efr;
|
2010-11-11 21:58:20 +00:00
|
|
|
extern const struct format_desc fmt_rawpcm_s16le;
|
2011-02-25 15:58:36 +00:00
|
|
|
extern const struct format_desc fmt_ti_hr;
|
2011-02-25 14:31:54 +00:00
|
|
|
extern const struct format_desc fmt_ti_fr;
|
2011-02-25 17:12:25 +00:00
|
|
|
extern const struct format_desc fmt_ti_efr;
|
2017-05-28 09:04:26 +00:00
|
|
|
extern const struct format_desc fmt_amr_opencore;
|
|
|
|
extern const struct format_desc fmt_rtp_amr;
|
2017-05-28 11:46:47 +00:00
|
|
|
extern const struct format_desc fmt_rtp_efr;
|
2017-05-28 12:09:00 +00:00
|
|
|
extern const struct format_desc fmt_rtp_hr_etsi;
|
2017-05-28 12:17:05 +00:00
|
|
|
extern const struct format_desc fmt_rtp_hr_ietf;
|
2010-10-29 09:41:16 +00:00
|
|
|
|
2010-10-29 09:38:54 +00:00
|
|
|
static const struct format_desc *supported_formats[_FMT_MAX] = {
|
|
|
|
[FMT_INVALID] = NULL,
|
2010-10-29 09:47:06 +00:00
|
|
|
[FMT_AMR_EFR] = &fmt_amr_efr,
|
2010-10-29 09:41:16 +00:00
|
|
|
[FMT_GSM] = &fmt_gsm,
|
2010-10-29 09:44:40 +00:00
|
|
|
[FMT_HR_REF_DEC] = &fmt_hr_ref_dec,
|
|
|
|
[FMT_HR_REF_ENC] = &fmt_hr_ref_enc,
|
2010-10-29 09:46:05 +00:00
|
|
|
[FMT_RACAL_HR] = &fmt_racal_hr,
|
|
|
|
[FMT_RACAL_FR] = &fmt_racal_fr,
|
|
|
|
[FMT_RACAL_EFR] = &fmt_racal_efr,
|
2010-11-11 21:58:20 +00:00
|
|
|
[FMT_RAWPCM_S16LE] = &fmt_rawpcm_s16le,
|
2011-02-25 15:58:36 +00:00
|
|
|
[FMT_TI_HR] = &fmt_ti_hr,
|
2011-02-25 14:31:54 +00:00
|
|
|
[FMT_TI_FR] = &fmt_ti_fr,
|
2011-02-25 17:12:25 +00:00
|
|
|
[FMT_TI_EFR] = &fmt_ti_efr,
|
2017-05-28 09:04:26 +00:00
|
|
|
[FMT_AMR_OPENCORE] = &fmt_amr_opencore,
|
|
|
|
[FMT_RTP_AMR] = &fmt_rtp_amr,
|
2017-05-28 11:46:47 +00:00
|
|
|
[FMT_RTP_EFR] = &fmt_rtp_efr,
|
2017-05-28 12:09:00 +00:00
|
|
|
[FMT_RTP_HR_ETSI] = &fmt_rtp_hr_etsi,
|
2017-05-28 12:17:05 +00:00
|
|
|
[FMT_RTP_HR_IETF] = &fmt_rtp_hr_ietf,
|
2010-10-29 09:38:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const struct format_desc *
|
|
|
|
fmt_get_from_type(enum format_type type)
|
|
|
|
{
|
|
|
|
if (type <= FMT_INVALID || type >= _FMT_MAX)
|
|
|
|
return NULL;
|
|
|
|
return supported_formats[type];
|
|
|
|
}
|
2010-10-29 20:45:22 +00:00
|
|
|
|
|
|
|
const struct format_desc *
|
|
|
|
fmt_get_from_name(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=FMT_INVALID+1; i<_FMT_MAX; i++) {
|
|
|
|
const struct format_desc *fmt = supported_formats[i];
|
|
|
|
if (!fmt)
|
|
|
|
continue;
|
|
|
|
if (!strcmp(fmt->name, name))
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|