aboutsummaryrefslogtreecommitdiffstats
path: root/src/fmt_amr_opencore.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-05-28 11:04:26 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-28 14:29:59 +0200
commit8b01f0ca05d92c593d9f33e40bae3f6dbb78a521 (patch)
tree1feb93efd06b9d1f920da49bcad764dc1f570b9f /src/fmt_amr_opencore.c
parent494d92c3c7c2197381807f999d9d2a6ba23299e4 (diff)
Add AMR codec support
After merging this change, there is support for the AMR codec (by means of libopencore-amr, which is already used for EFR). In terms of gapk formats, we introdude * the "amr-opencore" format, which serves both as the canonical format, and as the input format to opencore-amrnb itself. * the "rtp-amr" format, which is the payload of RFC4867 octet-aligned mode You can use the following command for a real-time RTP playback for AMR frames: ./gapk -I 0.0.0.0/30000 -f rtp-amr -A default -g rawpcm-s16le
Diffstat (limited to 'src/fmt_amr_opencore.c')
-rw-r--r--src/fmt_amr_opencore.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/fmt_amr_opencore.c b/src/fmt_amr_opencore.c
new file mode 100644
index 0000000..3fa547b
--- /dev/null
+++ b/src/fmt_amr_opencore.c
@@ -0,0 +1,51 @@
+/* Input format to libopencore-amrnb: Exactly like our canonical AMR */
+/* (C) 2017 Harald Welte <laforge@gnumonks.org> */
+
+/*
+ * 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 <stdint.h>
+#include <string.h>
+
+#include <gapk/codecs.h>
+#include <gapk/formats.h>
+#include <gapk/utils.h>
+
+static int
+amr_opencore_from_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
+{
+ memcpy(dst, src, src_len);
+ return src_len;
+}
+
+static int
+amr_opencore_to_canon(uint8_t *dst, const uint8_t *src, unsigned int src_len)
+{
+ memcpy(dst, src, src_len);
+ return src_len;
+}
+
+const struct format_desc fmt_amr_opencore = {
+ .type = FMT_AMR_OPENCORE,
+ .codec_type = CODEC_AMR,
+ .name = "amr-opencore",
+ .description = "Input format to libopencore-amrnb",
+
+ .frame_len = 0,
+ .conv_from_canon = amr_opencore_from_canon,
+ .conv_to_canon = amr_opencore_to_canon,
+};