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>
This commit is contained in:
Pascal Quantin 2017-07-26 23:23:12 +02:00 committed by Anders Broman
parent 32b446d5a8
commit 3e54cabf81
15 changed files with 333 additions and 6 deletions

View File

@ -932,6 +932,10 @@ if(ENABLE_SPANDSP)
set(PACKAGELIST ${PACKAGELIST} SPANDSP)
endif()
if(ENABLE_BCG729)
set(PACKAGELIST ${PACKAGELIST} BCG729)
endif()
if(ENABLE_LIBXML2)
set(PACKAGELIST ${PACKAGELIST} LibXml2)
endif()
@ -1059,6 +1063,9 @@ endif()
if(SPANDSP_FOUND)
set(HAVE_SPANDSP 1)
endif()
if(BCG729_FOUND)
set(HAVE_BCG729 1)
endif()
if(LIBXML2_FOUND)
set(HAVE_LIBXML2 1)
else()
@ -1454,6 +1461,11 @@ set_package_properties(SPANDSP PROPERTIES
URL "http://www.soft-switch.org/"
PURPOSE "Support for G.722 and G.726 codecs in RTP player"
)
set_package_properties(BCG729 PROPERTIES
DESCRIPTION "G.729 decoder"
URL "https://www.linphone.org/technical-corner/bcg729/overview"
PURPOSE "Support for G.729 codec in RTP player"
)
set_package_properties(LIBXML2 PROPERTIES
DESCRIPTION "XML parsing library"
URL "http://xmlsoft.org/"
@ -1762,6 +1774,13 @@ if(WIN32)
"${_dll_output_dir}"
)
endif(SPANDSP_FOUND)
if (BCG729_FOUND)
add_custom_command(TARGET copy_cli_dlls PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${BCG729_DLL_DIR}/${BCG729_DLL}"
"${_dll_output_dir}"
)
endif(BCG729_FOUND)
if (LIBXML2_FOUND)
add_custom_command(TARGET copy_cli_dlls PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different

View File

@ -89,6 +89,7 @@ endif()
option(ENABLE_KERBEROS "Build with Kerberos support" ON)
option(ENABLE_SBC "Build with SBC Codec support in RTP Player" ON)
option(ENABLE_SPANDSP "Build with G.722/G.726 codecs support in RTP Player" ON)
option(ENABLE_BCG729 "Build with G.729 codec support in RTP Player" ON)
option(ENABLE_LIBXML2 "Build with libxml2 support" ON)
# How to install
set(DUMPCAP_INSTALL_OPTION "normal" CACHE STRING "Permissions to install")

View File

@ -2129,3 +2129,31 @@ AC_DEFUN([AC_WIRESHARK_SNAPPY_CHECK],
AC_WIRESHARK_POP_FLAGS
])
#
# AC_WIRESHARK_BCG729_CHECK
#
AC_DEFUN([AC_WIRESHARK_BCG729_CHECK],
[
want_bcg729=defaultyes
if test "x$want_bcg729" = "xdefaultyes"; then
want_bcg729=yes
fi
if test "x$want_bcg729" = "xyes"; then
AC_CHECK_LIB(bcg729, bcg729Decoder,
[
AC_CHECK_HEADERS(bcg729/decoder.h,
[
BCG729_LIBS=-lbcg729
AC_DEFINE(HAVE_BCG729, 1, [Define to use bcg729 library])
have_good_bcg729=yes
],,
)
],,
)
else
AC_MSG_RESULT(not required)
fi
])

View File

@ -0,0 +1,55 @@
# Find the system's bcg729 includes and library
#
# BCG729_INCLUDE_DIRS - where to find bcg729/decoder.h
# BCG729_LIBRARIES - List of libraries when using bcg729
# BCG729_FOUND - True if bcg729 found
# BCG729_DLL_DIR - (Windows) Path to the bcg729 DLL
# BCG729_DLL - (Windows) Name of the bcg729 DLL
include( FindWSWinLibs )
FindWSWinLibs( "bcg729-.*" "BCG729_HINTS" )
find_package(PkgConfig)
pkg_search_module(BCG729 bcg729)
find_path( BCG729_INCLUDE_DIR
NAMES bcg729/decoder.h
HINTS
"${BCG729_INCLUDE_DIR}"
"${BCG729_HINTS}/include"
PATHS /usr/local/include /usr/include
)
find_library( BCG729_LIBRARY
NAMES bcg729
HINTS
"${BCG729_LIBDIR}"
"${BCG729_HINTS}/lib"
PATHS /usr/local/lib /usr/lib
)
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( bcg729 DEFAULT_MSG BCG729_INCLUDE_DIR BCG729_LIBRARY )
if( BCG729_FOUND )
set( BCG729_INCLUDE_DIRS ${BCG729_INCLUDE_DIR} )
set( BCG729_LIBRARIES ${BCG729_LIBRARY} )
if (WIN32)
set ( BCG729_DLL_DIR "${BCG729_HINTS}/bin"
CACHE PATH "Path to bcg729 DLL"
)
file( GLOB _bcg729_dll RELATIVE "${BCG729_DLL_DIR}"
"${BCG729_DLL_DIR}/libbcg729.dll"
)
set ( BCG729_DLL ${_bcg729_dll}
# We're storing filenames only. Should we use STRING instead?
CACHE FILEPATH "bcg729 DLL file name"
)
mark_as_advanced( BCG729_DLL_DIR BCG729_DLL )
endif()
else()
set( BCG729_INCLUDE_DIRS )
set( BCG729_LIBRARIES )
endif()
mark_as_advanced( BCG729_LIBRARIES BCG729_INCLUDE_DIRS )

View File

@ -299,6 +299,9 @@
/* Define to 1 if you have the SpanDSP library. */
#cmakedefine HAVE_SPANDSP 1
/* Define to 1 if you have the bcg729 library. */
#cmakedefine HAVE_BCG729 1
/* Define to 1 if you have the lixbml2 library. */
#cmakedefine HAVE_LIBXML2 1

View File

@ -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

95
codecs/G729/G729decode.c Normal file
View File

@ -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:
*/

46
codecs/G729/G729decode.h Normal file
View File

@ -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:
*/

View File

@ -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 \

View File

@ -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
}
/*

View File

@ -2566,6 +2566,35 @@ else
fi
AM_CONDITIONAL(HAVE_SPANDSP, test "x$have_spandsp" = "xyes")
#`
# Check bcg729 library for RTP Player
# https://www.linphone.org/technical-corner/bcg729/overview
dnl bcg729 Check
BCG729_LIBS=''
AC_MSG_CHECKING(whether to use the bcg729 library if available)
AC_ARG_WITH([bcg729],
AC_HELP_STRING( [--with-bcg729=@<:@=DIR@:>@],
[use bcg729 to play G.729 codec(located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
[
if test "x$withval" = "xno"; then
want_bcg729=no
elif test "x$withval" = "xyes"; then
want_bcg729=yes
elif test -d "$withval"; then
want_bcg729=yes
AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
fi
])
if test "x$want_bcg729" = "xno"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
AC_WIRESHARK_BCG729_CHECK
fi
AC_SUBST(BCG729_LIBS)
AM_CONDITIONAL(HAVE_BCG729, test "x$have_good_bcg729" = "xyes")
#`
# Libxml2 check
AC_ARG_WITH(libxml2,
@ -3146,6 +3175,12 @@ else
nghttp2_message="no"
fi
if test "x$have_good_bcg729" = "xyes" ; then
bcg729_message="yes"
else
bcg729_message="no"
fi
echo ""
echo " CPPFLAGS: $WS_CPPFLAGS $CPPFLAGS"
echo ""
@ -3206,6 +3241,7 @@ echo " Have ssh_userauth_agent : $ssh_userauth_agent_message"
echo " Use nl library : $libnl_message"
echo " Use SBC codec library : $have_sbc"
echo " Use SpanDSP library : $have_spandsp"
echo " Use bcg729 library : $bcg729_message"
echo " Use libxml2 library : $have_libxml2"
echo " Use nghttp2 library : $nghttp2_message"
echo " Use LZ4 library : $have_lz4"

View File

@ -150,7 +150,7 @@ set(_all_manifest_contents "# Files required for all sections. Generated by CMak
foreach(_dll ${GLIB2_DLLS} ${CARES_DLL} ${GCRYPT_DLLS} ${GEOIP_DLL}
${GNUTLS_DLLS} ${KERBEROS_DLLS} ${LIBSSH_DLL} ${LUA_DLL}
${LZ4_DLL} ${NGHTTP2_DLL} ${SBC_DLL} ${SMI_DLL} ${SNAPPY_DLL}
${SPANDSP_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
${SPANDSP_DLL} ${BCG729_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
)
set(_all_manifest_contents "${_all_manifest_contents}File \"\${STAGING_DIR}\\${_dll}\"\n")
endforeach()

View File

@ -13,6 +13,7 @@
%global with_c_ares 1
%global with_portaudio 0
%global with_spandsp 0
%global with_bcg729 0
%global with_libxml2 1
%global with_nghttp2 1
%global with_extcap 1
@ -241,6 +242,10 @@ Requires: portaudio
BuildRequires: spandsp-devel
Requires: spandsp
%endif
%if %{with_bcg729}
BuildRequires: bcg729-devel
Requires: bcg729
%endif
%if %{with_libxml2}
BuildRequires: libxml2-devel
Requires: libxml2
@ -282,6 +287,9 @@ This package contains the GTK+ Wireshark GUI and desktop integration files.
%if %{with_spandsp}
--with-spandsp \
%endif
%if %{with_bcg729}
--with-bcg729 \
%endif
%if %{with_libxml2}
--with-libxml2 \
%else
@ -486,6 +494,9 @@ fi
%endif
%changelog
* Wed Jul 26 2017 Pascal Quantin
- Added bcg729 (as an option, defaulting to not required).
* Tue Apr 4 2017 Ahmad Fatoum
- Added libxml2 (as an option, defaulting to required).

View File

@ -140,7 +140,7 @@ SET(unique_component "")
foreach(_dll ${GLIB2_DLLS} ${CARES_DLL} ${GCRYPT_DLLS} ${GEOIP_DLL}
${GNUTLS_DLLS} ${KERBEROS_DLLS} ${LIBSSH_DLL} ${LUA_DLL}
${LZ4_DLL} ${NGHTTP2_DLL} ${SBC_DLL} ${SMI_DLL} ${SNAPPY_DLL}
${SPANDSP_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
${SPANDSP_DLL} ${BCG729_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
)
#ensure uniqueness of files
IF(NOT "${unique_component}" MATCHES "(^|;)${_dll}(;|$)")
@ -165,7 +165,7 @@ SET(unique_file "")
foreach(_dll ${GLIB2_DLLS} ${CARES_DLL} ${GCRYPT_DLLS} ${GEOIP_DLL}
${GNUTLS_DLLS} ${KERBEROS_DLLS} ${LIBSSH_DLL} ${LUA_DLL}
${LZ4_DLL} ${NGHTTP2_DLL} ${SBC_DLL} ${SMI_DLL} ${SNAPPY_DLL}
${SPANDSP_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
${SPANDSP_DLL} ${BCG729_DLL} ${LIBXML2_DLL} ${WINSPARKLE_DLL} ${ZLIB_DLL}
)
#ensure uniqueness of files
IF(NOT "${unique_file}" MATCHES "(^|;)${_dll}(;|$)")

View File

@ -99,12 +99,13 @@ Param(
# trouble instead of trying to catch exceptions everywhere.
$ErrorActionPreference = "Stop"
$Win64CurrentTag = "2017-07-19"
$Win32CurrentTag = "2017-07-19"
$Win64CurrentTag = "2017-07-28"
$Win32CurrentTag = "2017-07-28"
# Archive file / subdir.
$Win64Archives = @{
"AirPcap_Devpack_4_1_0_1622.zip" = "AirPcap_Devpack_4_1_0_1622";
"bcg729-1.0.4-win64ws.zip" = "";
"c-ares-1.13.0-win64ws.zip" = "";
"GeoIP-1.6.10-win64ws.zip" = "";
"gnutls-3.4.11-1.35-win64ws.zip" = "";
@ -130,6 +131,7 @@ $Win64Archives = @{
$Win32Archives = @{
"AirPcap_Devpack_4_1_0_1622.zip" = "AirPcap_Devpack_4_1_0_1622";
"bcg729-1.0.4-win32ws.zip" = "";
"c-ares-1.13.0-win32ws.zip" = "";
"GeoIP-1.6.10-win32ws.zip" = "";
"gnutls-3.4.11-1.36-win32ws.zip" = "";
@ -176,6 +178,7 @@ if ($Platform -eq "win32") {
}
$CleanupItems = @(
"bcg729-1.0.4-win??ws"
"c-ares-1.9.1-1-win??ws"
"c-ares-1.1*-win??ws"
"gnutls-3.1.22-*-win??ws"