diff options
-rw-r--r-- | include/gapk/Makefile.am | 3 | ||||
-rw-r--r-- | include/gapk/codecs.h | 41 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/codec_efr.c | 27 | ||||
-rw-r--r-- | src/codec_fr.c | 27 | ||||
-rw-r--r-- | src/codec_hr.c | 27 | ||||
-rw-r--r-- | src/codec_pcm.c | 27 | ||||
-rw-r--r-- | src/codecs.c | 42 |
8 files changed, 195 insertions, 2 deletions
diff --git a/include/gapk/Makefile.am b/include/gapk/Makefile.am index ef8800a..19dcc9d 100644 --- a/include/gapk/Makefile.am +++ b/include/gapk/Makefile.am @@ -1 +1,2 @@ -noinst_HEADERS = utils.h +noinst_HEADERS = codecs.h \ + utils.h diff --git a/include/gapk/codecs.h b/include/gapk/codecs.h new file mode 100644 index 0000000..984d91a --- /dev/null +++ b/include/gapk/codecs.h @@ -0,0 +1,41 @@ +/* Codecs 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/>. + */ + +#ifndef __GAPK_CODECS_H__ +#define __GAPK_CODECS_H__ + +enum codec_type { + CODEC_INVALID = 0, + CODEC_PCM, /* 16 bits PCM samples */ + CODEC_HR, /* GSM Half Rate codec GSM 06.20 */ + CODEC_FR, /* GSM Full Rate codec GSM 06.10 */ + CODEC_EFR, /* GSM Enhanced Full Rate codec GSM 06.60 */ + _CODEC_MAX, +}; + +struct codec_desc { + enum codec_type type; + const char * name; + const char * description; + unsigned int canon_frame_len; +}; + +const struct codec_desc *codec_get_from_type(enum codec_type type); + +#endif /* __GAPK_CODECS_H__ */ diff --git a/src/Makefile.am b/src/Makefile.am index a8fe29d..13b69bd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,4 +2,5 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall bin_PROGRAMS = gapk -gapk_SOURCES = main.c +gapk_SOURCES = main.c \ + codecs.c codec_pcm.c codec_hr.c codec_fr.c codec_efr.c diff --git a/src/codec_efr.c b/src/codec_efr.c new file mode 100644 index 0000000..6c9b59e --- /dev/null +++ b/src/codec_efr.c @@ -0,0 +1,27 @@ +/* EFR (GSM 06.60) codec */ + +/* + * 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 <gapk/codecs.h> + +const struct codec_desc codec_efr_desc = { + .type = CODEC_EFR, + .name = "efr", + .description = "GSM 06.60 Enhanced Full Rate codec", + .canon_frame_len = 31, +}; diff --git a/src/codec_fr.c b/src/codec_fr.c new file mode 100644 index 0000000..6f11269 --- /dev/null +++ b/src/codec_fr.c @@ -0,0 +1,27 @@ +/* FR (GSM 06.10) codec */ + +/* + * 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 <gapk/codecs.h> + +const struct codec_desc codec_fr_desc = { + .type = CODEC_FR, + .name = "fr", + .description = "GSM 06.10 Full Rate codec (classic gsm codec)", + .canon_frame_len = 33, +}; diff --git a/src/codec_hr.c b/src/codec_hr.c new file mode 100644 index 0000000..ac77ade --- /dev/null +++ b/src/codec_hr.c @@ -0,0 +1,27 @@ +/* HR (GSM 06.20) codec */ + +/* + * 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 <gapk/codecs.h> + +const struct codec_desc codec_hr_desc = { + .type = CODEC_HR, + .name = "hr", + .description = "GSM 06.20 Half Rate codec", + .canon_frame_len = 14, +}; diff --git a/src/codec_pcm.c b/src/codec_pcm.c new file mode 100644 index 0000000..34517b5 --- /dev/null +++ b/src/codec_pcm.c @@ -0,0 +1,27 @@ +/* Null codec: Raw PCM data (16 bits signed) */ + +/* + * 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 <gapk/codecs.h> + +const struct codec_desc codec_pcm_desc = { + .type = CODEC_PCM, + .name = "pcm", + .description = "Raw PCM signed 16 bits samples", + .canon_frame_len = 320, +}; diff --git a/src/codecs.c b/src/codecs.c new file mode 100644 index 0000000..7a9a6d3 --- /dev/null +++ b/src/codecs.c @@ -0,0 +1,42 @@ +/* Codecs 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 */ + +#include <gapk/codecs.h> + +/* Extern codec descriptors */ +extern const struct codec_desc codec_pcm_desc; +extern const struct codec_desc codec_hr_desc; +extern const struct codec_desc codec_fr_desc; +extern const struct codec_desc codec_efr_desc; + + +const struct codec_desc * +codec_get_from_type(enum codec_type type) +{ + switch (type) { + case CODEC_PCM: return &codec_pcm_desc; + case CODEC_HR: return &codec_hr_desc; + case CODEC_FR: return &codec_fr_desc; + case CODEC_EFR: return &codec_efr_desc; + default: + return NULL; + } +} |