forked from osmocom/wireshark
Add AMR codec support
CMake work and rebase on current wireshark master by Harald Welte Change-Id: I5ec963b910f8f271aa2e5d680ea33e2170a6f367
This commit is contained in:
parent
8d000e9e78
commit
585d240fbe
|
@ -1288,6 +1288,8 @@ ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
|
||||||
|
|
||||||
ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
|
ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
|
||||||
|
|
||||||
|
ws_find_package(AMRNB ENABLE_AMRNB HAVE_AMRNB)
|
||||||
|
|
||||||
ws_find_package(ILBC ENABLE_ILBC HAVE_ILBC)
|
ws_find_package(ILBC ENABLE_ILBC HAVE_ILBC)
|
||||||
|
|
||||||
ws_find_package(OPUS ENABLE_OPUS HAVE_OPUS)
|
ws_find_package(OPUS ENABLE_OPUS HAVE_OPUS)
|
||||||
|
@ -1628,6 +1630,11 @@ if(ENABLE_PLUGINS)
|
||||||
plugins/codecs/G729
|
plugins/codecs/G729
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
if(AMRNB_FOUND)
|
||||||
|
list(APPEND PLUGIN_SRC_DIRS
|
||||||
|
plugins/codecs/amrnb
|
||||||
|
)
|
||||||
|
endif()
|
||||||
if(ILBC_FOUND)
|
if(ILBC_FOUND)
|
||||||
list(APPEND PLUGIN_SRC_DIRS
|
list(APPEND PLUGIN_SRC_DIRS
|
||||||
plugins/codecs/iLBC
|
plugins/codecs/iLBC
|
||||||
|
@ -1767,6 +1774,11 @@ set_package_properties(BCG729 PROPERTIES
|
||||||
URL "https://www.linphone.org/technical-corner/bcg729"
|
URL "https://www.linphone.org/technical-corner/bcg729"
|
||||||
PURPOSE "Support for G.729 codec in RTP player"
|
PURPOSE "Support for G.729 codec in RTP player"
|
||||||
)
|
)
|
||||||
|
set_package_properties(AMRNB PROPERTIES
|
||||||
|
DESCRIPTION "AMRNB decoder"
|
||||||
|
URL "https://sourceforge.net/p/opencore-amr"
|
||||||
|
PURPOSE "Support for AMRNB codec in RTP player"
|
||||||
|
)
|
||||||
set_package_properties(ILBC PROPERTIES
|
set_package_properties(ILBC PROPERTIES
|
||||||
DESCRIPTION "iLBC decoder"
|
DESCRIPTION "iLBC decoder"
|
||||||
URL "https://github.com/TimothyGu/libilbc"
|
URL "https://github.com/TimothyGu/libilbc"
|
||||||
|
@ -2088,6 +2100,9 @@ if(USE_REPOSITORY)
|
||||||
if (BCG729_FOUND)
|
if (BCG729_FOUND)
|
||||||
list (APPEND THIRD_PARTY_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
|
list (APPEND THIRD_PARTY_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
|
||||||
endif(BCG729_FOUND)
|
endif(BCG729_FOUND)
|
||||||
|
if (AMRNB_FOUND)
|
||||||
|
list (APPEND OPTIONAL_DLLS "${AMRNB_DLL_DIR}/${AMRNB_DLL}")
|
||||||
|
endif(AMRNB_FOUND)
|
||||||
if (ILBC_FOUND)
|
if (ILBC_FOUND)
|
||||||
list (APPEND THIRD_PARTY_DLLS "${ILBC_DLL_DIR}/${ILBC_DLL}")
|
list (APPEND THIRD_PARTY_DLLS "${ILBC_DLL_DIR}/${ILBC_DLL}")
|
||||||
endif(ILBC_FOUND)
|
endif(ILBC_FOUND)
|
||||||
|
@ -3623,6 +3638,9 @@ if(RPMBUILD_EXECUTABLE)
|
||||||
if (BCG729_FOUND)
|
if (BCG729_FOUND)
|
||||||
list(APPEND _rpmbuild_with_args --with bcg729)
|
list(APPEND _rpmbuild_with_args --with bcg729)
|
||||||
endif()
|
endif()
|
||||||
|
if (AMRNB_FOUND)
|
||||||
|
list(APPEND _rpmbuild_with_args --with amrnb)
|
||||||
|
endif()
|
||||||
if (ILBC_FOUND)
|
if (ILBC_FOUND)
|
||||||
list(APPEND _rpmbuild_with_args --with ilbc)
|
list(APPEND _rpmbuild_with_args --with ilbc)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -121,6 +121,7 @@ option(ENABLE_KERBEROS "Build with Kerberos support" ON)
|
||||||
option(ENABLE_SBC "Build with SBC Codec support in RTP Player" 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_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_BCG729 "Build with G.729 codec support in RTP Player" ON)
|
||||||
|
option(ENABLE_AMRNB "Build with AMRNB codec support in RTP Player" ON)
|
||||||
option(ENABLE_ILBC "Build with iLBC codec support in RTP Player" ON)
|
option(ENABLE_ILBC "Build with iLBC codec support in RTP Player" ON)
|
||||||
option(ENABLE_LIBXML2 "Build with libxml2 support" ON)
|
option(ENABLE_LIBXML2 "Build with libxml2 support" ON)
|
||||||
option(ENABLE_OPUS "Build with opus support" ON)
|
option(ENABLE_OPUS "Build with opus support" ON)
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
# Find the system's opencore-amrnb includes and library
|
||||||
|
#
|
||||||
|
# AMRNB_INCLUDE_DIRS - where to find amrnb/decoder.h
|
||||||
|
# AMRNB_LIBRARIES - List of libraries when using amrnb
|
||||||
|
# AMRNB_FOUND - True if amrnb found
|
||||||
|
# AMRNB_DLL_DIR - (Windows) Path to the amrnb DLL
|
||||||
|
# AMRNB_DLL - (Windows) Name of the amrnb DLL
|
||||||
|
|
||||||
|
include( FindWSWinLibs )
|
||||||
|
FindWSWinLibs( "opencore-amrnb-.*" "AMRNB_HINTS" )
|
||||||
|
|
||||||
|
if (NOT WIN32)
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_search_module(AMRNB opencore-amrnb)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path( AMRNB_INCLUDE_DIR
|
||||||
|
NAMES opencore-amrnb/interf_dec.h
|
||||||
|
HINTS
|
||||||
|
"${AMRNB_INCLUDE_DIR}"
|
||||||
|
"${AMRNB_HINTS}/include"
|
||||||
|
PATHS /usr/local/include /usr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library( AMRNB_LIBRARY
|
||||||
|
NAMES opencore-amrnb
|
||||||
|
HINTS
|
||||||
|
"${AMRNB_LIBDIR}"
|
||||||
|
"${AMRNB_HINTS}/lib"
|
||||||
|
PATHS /usr/local/lib /usr/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
include( FindPackageHandleStandardArgs )
|
||||||
|
find_package_handle_standard_args( amrnb DEFAULT_MSG AMRNB_INCLUDE_DIR AMRNB_LIBRARY )
|
||||||
|
|
||||||
|
if( AMRNB_FOUND )
|
||||||
|
set( AMRNB_INCLUDE_DIRS ${AMRNB_INCLUDE_DIR} )
|
||||||
|
set( AMRNB_LIBRARIES ${AMRNB_LIBRARY} )
|
||||||
|
if (WIN32)
|
||||||
|
set ( AMRNB_DLL_DIR "${AMRNB_HINTS}/bin"
|
||||||
|
CACHE PATH "Path to amrnb DLL"
|
||||||
|
)
|
||||||
|
file( GLOB _amrnb_dll RELATIVE "${AMRNB_DLL_DIR}"
|
||||||
|
"${AMRNB_DLL_DIR}/libamrnb.dll"
|
||||||
|
)
|
||||||
|
set ( AMRNB_DLL ${_amrnb_dll}
|
||||||
|
# We're storing filenames only. Should we use STRING instead?
|
||||||
|
CACHE FILEPATH "amrnb DLL file name"
|
||||||
|
)
|
||||||
|
mark_as_advanced( AMRNB_DLL_DIR AMRNB_DLL )
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set( AMRNB_INCLUDE_DIRS )
|
||||||
|
set( AMRNB_LIBRARIES )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced( AMRNB_LIBRARIES AMRNB_INCLUDE_DIRS )
|
|
@ -232,6 +232,9 @@
|
||||||
/* Define to 1 if you have the bcg729 library. */
|
/* Define to 1 if you have the bcg729 library. */
|
||||||
#cmakedefine HAVE_BCG729 1
|
#cmakedefine HAVE_BCG729 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the opencore-amrnb library. */
|
||||||
|
#cmakedefine HAVE_AMRNB 1
|
||||||
|
|
||||||
/* Define to 1 if you have the ilbc library. */
|
/* Define to 1 if you have the ilbc library. */
|
||||||
#cmakedefine HAVE_ILBC 1
|
#cmakedefine HAVE_ILBC 1
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
# CMakeLists.txt
|
||||||
|
#
|
||||||
|
# Wireshark - Network traffic analyzer
|
||||||
|
# By Gerald Combs <gerald@wireshark.org>
|
||||||
|
# Copyright 1998 Gerald Combs
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
#
|
||||||
|
|
||||||
|
include(WiresharkPlugin)
|
||||||
|
|
||||||
|
# Plugin name and version info (major minor micro extra)
|
||||||
|
set_module_info(amrnb 0 1 0 0)
|
||||||
|
|
||||||
|
set(CODEC_SRC
|
||||||
|
amrdecode.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PLUGIN_FILES
|
||||||
|
plugin.c
|
||||||
|
${CODEC_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_source_files_properties(
|
||||||
|
${PLUGIN_FILES}
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
register_plugin_files(plugin.c
|
||||||
|
plugin_codec
|
||||||
|
${CODEC_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_wireshark_plugin_library(amrnb codecs)
|
||||||
|
|
||||||
|
target_include_directories(amrnb PRIVATE ${CMAKE_SOURCE_DIR}/codecs)
|
||||||
|
|
||||||
|
target_link_libraries(amrnb wsutil ${AMRNB_LIBRARIES})
|
||||||
|
|
||||||
|
target_include_directories(amrnb SYSTEM PRIVATE ${AMRNB_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
install_plugin(amrnb codecs)
|
||||||
|
|
||||||
|
file(GLOB CODEC_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h")
|
||||||
|
CHECKAPI(
|
||||||
|
NAME
|
||||||
|
amrnb
|
||||||
|
SWITCHES
|
||||||
|
SOURCES
|
||||||
|
${CODEC_SRC}
|
||||||
|
${CODEC_HEADERS}
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||||
|
#
|
||||||
|
# Local variables:
|
||||||
|
# c-basic-offset: 8
|
||||||
|
# tab-width: 8
|
||||||
|
# indent-tabs-mode: t
|
||||||
|
# End:
|
||||||
|
#
|
||||||
|
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||||
|
# :indentSize=8:tabSize=8:noTabs=false:
|
||||||
|
#
|
|
@ -0,0 +1,107 @@
|
||||||
|
/* amrdecode.c
|
||||||
|
* AMR 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>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "wsutil/codecs.h"
|
||||||
|
#include "ws_attributes.h"
|
||||||
|
|
||||||
|
#include <opencore-amrnb/interf_dec.h>
|
||||||
|
|
||||||
|
void codec_register_amr(void);
|
||||||
|
|
||||||
|
void *
|
||||||
|
codec_amr_init(void)
|
||||||
|
{
|
||||||
|
void *state;
|
||||||
|
state = Decoder_Interface_init();
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
codec_amr_release(void *state)
|
||||||
|
{
|
||||||
|
Decoder_Interface_exit(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
codec_amr_get_channels(void *ctx _U_)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
codec_amr_get_frequency(void *ctx _U_)
|
||||||
|
{
|
||||||
|
return 8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
codec_amr_decode(void *state, const void *input, size_t inputSizeBytes, void *output,
|
||||||
|
size_t *outputSizeBytes)
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
unsigned packet_size;
|
||||||
|
static const guint8 block_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
/* First byte is CMR, second is the Payload TOC */
|
||||||
|
mode = (((guint8 *)input)[1] >> 3) & 0x0F;
|
||||||
|
packet_size = block_size[mode] + 2;
|
||||||
|
|
||||||
|
if (!output || !outputSizeBytes)
|
||||||
|
return 160*2;
|
||||||
|
|
||||||
|
*outputSizeBytes = 160 * 2; /* 160 frames, two byte per frame, 20ms */
|
||||||
|
|
||||||
|
/* If the size is screwed up, insert silence */
|
||||||
|
if (packet_size > inputSizeBytes) {
|
||||||
|
memset(output, 0, *outputSizeBytes);
|
||||||
|
return *outputSizeBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
Decoder_Interface_Decode(state, (const unsigned char *)input+1, (short *)output, 0);
|
||||||
|
return *outputSizeBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
codec_register_amr(void)
|
||||||
|
{
|
||||||
|
register_codec("AMR", codec_amr_init, codec_amr_release,
|
||||||
|
codec_amr_get_channels, codec_amr_get_frequency, codec_amr_decode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
*/
|
Loading…
Reference in New Issue