aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/G729
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2017-07-26 23:23:12 +0200
committerAnders Broman <a.broman58@gmail.com>2017-07-30 05:22:35 +0000
commit3e54cabf8193e6a8cd607b1671defb8b6800b53d (patch)
tree63297098c0c26c1c875ab0959d9679d70b3c6e65 /codecs/G729
parent32b446d5a8f146565b81324d1a18bcb053e07c5f (diff)
Add G.729 decoding based on bcg729 library
Bug: 13635 Change-Id: Ic22a0719a59da13e51425aeb747e88caca0d6512 Reviewed-on: https://code.wireshark.org/review/22808 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'codecs/G729')
-rw-r--r--codecs/G729/G729decode.c95
-rw-r--r--codecs/G729/G729decode.h46
2 files changed, 141 insertions, 0 deletions
diff --git a/codecs/G729/G729decode.c b/codecs/G729/G729decode.c
new file mode 100644
index 0000000000..e5bb2ea61c
--- /dev/null
+++ b/codecs/G729/G729decode.c
@@ -0,0 +1,95 @@
+/* G729decode.c
+ * G.729 codec
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#ifdef HAVE_BCG729
+#include "bcg729/decoder.h"
+#include "G729decode.h"
+
+void *
+codec_g729_init(void)
+{
+ return initBcg729DecoderChannel();
+}
+
+void
+codec_g729_release(void *ctx)
+{
+ closeBcg729DecoderChannel((bcg729DecoderChannelContextStruct *)ctx);
+}
+
+unsigned
+codec_g729_get_channels(void *ctx _U_)
+{
+ return 1;
+}
+
+unsigned
+codec_g729_get_frequency(void *ctx _U_)
+{
+ return 8000;
+}
+
+size_t
+codec_g729_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output,
+ size_t *outputSizeBytes)
+{
+ bcg729DecoderChannelContextStruct *state = (bcg729DecoderChannelContextStruct *)ctx;
+ guint8 *dataIn = (guint8 *) input;
+ gint16 *dataOut = (gint16 *) output;
+ size_t i;
+
+ if (!ctx) {
+ return 0;
+ }
+
+ if (!output || !outputSizeBytes) {
+ return 80*2*(inputSizeBytes/10);
+ }
+
+ /* The G729 algorithm encodes 10ms of voice into 80bit (10 bytes).
+ Based on the RTP packetization period (usually 20ms), we need to
+ pass to the bcg729 decoder chunks of 10ms (10 bytes)
+ */
+ for (i = 0; i < (inputSizeBytes/10); i++) {
+ bcg729Decoder(state, dataIn + i*10, 10, 0, 0, 0, dataOut + i*80);
+ }
+ *outputSizeBytes = 80*2*(inputSizeBytes/10);
+ return *outputSizeBytes;
+}
+
+#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/codecs/G729/G729decode.h b/codecs/G729/G729decode.h
new file mode 100644
index 0000000000..5ccd1a9782
--- /dev/null
+++ b/codecs/G729/G729decode.h
@@ -0,0 +1,46 @@
+/* G729decode.h
+ * Definitions for G.729 codec
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __CODECS_G729DECODE_H__
+#define __CODECS_G729DECODE_H__
+
+void *codec_g729_init(void);
+void codec_g729_release(void *ctx);
+unsigned codec_g729_get_channels(void *ctx);
+unsigned codec_g729_get_frequency(void *ctx);
+size_t codec_g729_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output,
+ size_t *outputSizeBytes);
+
+#endif /* G729decode.h */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */