aboutsummaryrefslogtreecommitdiffstats
path: root/codecs
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
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')
-rw-r--r--codecs/CMakeLists.txt5
-rw-r--r--codecs/G729/G729decode.c95
-rw-r--r--codecs/G729/G729decode.h46
-rw-r--r--codecs/Makefile.am8
-rw-r--r--codecs/codecs.c19
5 files changed, 172 insertions, 1 deletions
diff --git a/codecs/CMakeLists.txt b/codecs/CMakeLists.txt
index 4595054059..9c47ff69d0 100644
--- a/codecs/CMakeLists.txt
+++ b/codecs/CMakeLists.txt
@@ -52,6 +52,11 @@ if(HAVE_SPANDSP)
list(APPEND wscodecs_LIBS ${SPANDSP_LIBRARIES})
endif()
+if(HAVE_BCG729)
+ list(APPEND WSCODECS_FILES G729/G729decode.c)
+ list(APPEND wscodecs_LIBS ${BCG729_LIBRARIES})
+endif()
+
add_library(wscodecs ${LINK_MODE_LIB}
${WSCODECS_FILES}
${CMAKE_BINARY_DIR}/image/libwscodecs.rc
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:
+ */
diff --git a/codecs/Makefile.am b/codecs/Makefile.am
index 46c4190a99..42aea554e3 100644
--- a/codecs/Makefile.am
+++ b/codecs/Makefile.am
@@ -40,6 +40,10 @@ if HAVE_SPANDSP
libwscodecs_la_SOURCES += G722/G722decode.c G726/G726decode.c
endif
+if HAVE_BCG729
+libwscodecs_la_SOURCES += G729/G729decode.c
+endif
+
if !HAVE_SPEEXDSP
libwscodecs_la_SOURCES += speex/resample.c
endif
@@ -47,7 +51,8 @@ endif
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
libwscodecs_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@
-libwscodecs_la_LIBADD = $(top_builddir)/wsutil/libwsutil.la $(GLIB_LIBS) $(SBC_LIBS) $(SPANDSP_LIBS)
+libwscodecs_la_LIBADD = $(top_builddir)/wsutil/libwsutil.la $(GLIB_LIBS) \
+ $(SBC_LIBS) $(SPANDSP_LIBS) $(BCG729_LIBS)
libwscodecs_la_DEPENDENCIES = $(top_builddir)/wsutil/libwsutil.la
@@ -59,6 +64,7 @@ noinst_HEADERS = \
G711u/G711utable.h \
G722/G722decode.h \
G726/G726decode.h \
+ G729/G729decode.h \
sbc/sbc_private.h \
speex/arch.h \
speex/speex_resampler.h \
diff --git a/codecs/codecs.c b/codecs/codecs.c
index 4001a8d426..93350237f1 100644
--- a/codecs/codecs.c
+++ b/codecs/codecs.c
@@ -37,6 +37,10 @@
#include "G726/G726decode.h"
#endif
+#ifdef HAVE_BCG729
+#include "G729/G729decode.h"
+#endif
+
#ifdef HAVE_PLUGINS
#include <gmodule.h>
@@ -130,6 +134,14 @@ register_all_codecs(void)
register_codec("AAL2-G726-40", codec_aal2_g726_40_init, codec_g726_release,
codec_g726_get_channels, codec_g726_get_frequency, codec_g726_decode);
#endif
+#ifdef HAVE_BCG729
+ register_codec("g729", codec_g729_init, codec_g729_release,
+ codec_g729_get_channels, codec_g729_get_frequency, codec_g729_decode);
+#endif
+#ifdef HAVE_SBC
+ register_codec("SBC", codec_sbc_init, codec_sbc_release,
+ codec_sbc_get_channels, codec_sbc_get_frequency, codec_sbc_decode);
+#endif
#ifdef HAVE_SBC
register_codec("SBC", codec_sbc_init, codec_sbc_release,
codec_sbc_get_channels, codec_sbc_get_frequency, codec_sbc_decode);
@@ -253,6 +265,13 @@ void codec_get_compiled_version_info(GString *str)
#else
g_string_append(str, ", without SpanDSP");
#endif
+
+ /* BCG729 (G.729) */
+#ifdef HAVE_BCG729
+ g_string_append(str, ", with bcg729");
+#else
+ g_string_append(str, ", without bcg729");
+#endif
}
/*