forked from osmocom/wireshark
CMake: Check for and use system SpeexDSP library
Change-Id: I8443379d23a2946dd21c12e5e0bd5464ab73ca25 Reviewed-on: https://code.wireshark.org/review/31857 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
parent
854479a7dc
commit
186f985793
|
@ -1162,6 +1162,18 @@ find_package(POD REQUIRED)
|
|||
|
||||
find_package(DOXYGEN)
|
||||
|
||||
# The SpeexDSP resampler is required iff building wireshark or sharkd.
|
||||
if(BUILD_wireshark OR BUILD_sharkd)
|
||||
find_package(SpeexDSP)
|
||||
if(SpeexDSP_FOUND)
|
||||
set(HAVE_SPEEXDSP 1)
|
||||
else()
|
||||
add_subdirectory(speexdsp)
|
||||
set(SPEEXDSP_INCLUDE_DIRS "")
|
||||
set(SPEEXDSP_LIBRARIES "speexresampler")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# dist target that prepares source dir
|
||||
# XXX Duplicated in the RPM section below.
|
||||
add_custom_target(dist
|
||||
|
@ -1558,6 +1570,11 @@ set_package_properties(MaxMindDB PROPERTIES
|
|||
DESCRIPTION "C library for the MaxMind DB file format"
|
||||
PURPOSE "Support for GeoIP lookup"
|
||||
)
|
||||
set_package_properties(SpeexDSP PROPERTIES
|
||||
URL "https://www.speex.org/"
|
||||
DESCRIPTION "SpeexDSP is a patent-free, Open Source/Free Software DSP library"
|
||||
PURPOSE "RTP audio resampling"
|
||||
)
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
|
||||
message(STATUS "C-Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}")
|
||||
|
@ -2180,6 +2197,7 @@ if(BUILD_wireshark AND QT_FOUND)
|
|||
${WIN_VERSION_LIBRARY}
|
||||
${WINSPARKLE_LIBRARIES}
|
||||
$<$<BOOL:${WIN32}>:UxTheme.lib>
|
||||
${SPEEXDSP_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_BUNDLE_FILES})
|
||||
|
@ -2368,6 +2386,7 @@ if(BUILD_sharkd)
|
|||
${APPLE_CORE_FOUNDATION_LIBRARY}
|
||||
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
|
||||
${WIN_WS2_32_LIBRARY}
|
||||
${SPEEXDSP_LIBRARIES}
|
||||
)
|
||||
set(sharkd_FILES
|
||||
#
|
||||
|
@ -2384,6 +2403,10 @@ if(BUILD_sharkd)
|
|||
add_executable(sharkd ${sharkd_FILES})
|
||||
set_extra_executable_properties(sharkd "Executables")
|
||||
target_link_libraries(sharkd ${sharkd_LIBS})
|
||||
target_include_directories(sharkd SYSTEM
|
||||
PUBLIC
|
||||
${SPEEXDSP_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
install(TARGETS sharkd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# - Find speexdsp libraries
|
||||
#
|
||||
# SPEEXDSP_INCLUDE_DIRS - where to find speexdsp headers.
|
||||
# SPEEXDSP_LIBRARIES - List of libraries when using speexdsp.
|
||||
# SPEEXDSP_FOUND - True if speexdsp is found.
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(PC_SPEEXDSP QUIET speexdsp)
|
||||
|
||||
find_path(SPEEXDSP_INCLUDE_DIR
|
||||
NAMES
|
||||
speex/speex_resampler.h
|
||||
HINTS
|
||||
${PC_SPEEXDSP_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(SPEEXDSP_LIBRARY
|
||||
NAMES
|
||||
speexdsp
|
||||
HINTS
|
||||
${PC_SPEEXDSP_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SpeexDSP
|
||||
REQUIRED_VARS SPEEXDSP_LIBRARY SPEEXDSP_INCLUDE_DIR
|
||||
VERSION_VAR PC_SPEEXDSP_VERSION)
|
||||
|
||||
if(SPEEXDSP_FOUND)
|
||||
set(SPEEXDSP_LIBRARIES ${SPEEXDSP_LIBRARY})
|
||||
set(SPEEXDSP_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR})
|
||||
else()
|
||||
set(SPEEXDSP_LIBRARIES)
|
||||
set(SPEEXDSP_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(SPEEXDSP_LIBRARIES SPEEXDSP_INCLUDE_DIRS)
|
|
@ -275,6 +275,9 @@
|
|||
/* Define to 1 if you have the bcg729 library. */
|
||||
#cmakedefine HAVE_BCG729 1
|
||||
|
||||
/* Define to 1 if you have the speexdsp library. */
|
||||
#cmakedefine HAVE_SPEEXDSP 1
|
||||
|
||||
/* Define to 1 if you have the lixbml2 library. */
|
||||
#cmakedefine HAVE_LIBXML2 1
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ set(WSCODECS_FILES
|
|||
codecs.c
|
||||
G711a/G711adecode.c
|
||||
G711u/G711udecode.c
|
||||
speex/resample.c
|
||||
)
|
||||
|
||||
# Enables visibility in IDEs
|
||||
|
@ -23,9 +22,6 @@ file(GLOB EXTRA_CODEC_HEADERS
|
|||
codecs.h
|
||||
G711a/G711adecode.h G711a/G711atable.h
|
||||
G711u/G711udecode.h G711u/G711utable.h
|
||||
speex/arch.h
|
||||
speex/speex_resampler.h
|
||||
speex/stack_alloc.h
|
||||
)
|
||||
|
||||
if(SBC_FOUND)
|
||||
|
|
|
@ -11,25 +11,3 @@ libwscodecs.so.0 libwscodecs0 #MINVER#
|
|||
codecs_register_plugin@Base 2.5.0
|
||||
codec_get_compiled_version_info@Base 2.3.0
|
||||
register_codec@Base 2.1.0
|
||||
ws_codec_resampler_destroy@Base 2.1.0
|
||||
ws_codec_resampler_get_input_latency@Base 2.1.0
|
||||
ws_codec_resampler_get_input_stride@Base 2.1.0
|
||||
ws_codec_resampler_get_output_latency@Base 2.1.0
|
||||
ws_codec_resampler_get_output_stride@Base 2.1.0
|
||||
ws_codec_resampler_get_quality@Base 2.1.0
|
||||
ws_codec_resampler_get_rate@Base 2.1.0
|
||||
ws_codec_resampler_get_ratio@Base 2.1.0
|
||||
ws_codec_resampler_init@Base 2.1.0
|
||||
ws_codec_resampler_init_frac@Base 2.1.0
|
||||
ws_codec_resampler_process_float@Base 2.1.0
|
||||
ws_codec_resampler_process_int@Base 2.1.0
|
||||
ws_codec_resampler_process_interleaved_float@Base 2.1.0
|
||||
ws_codec_resampler_process_interleaved_int@Base 2.1.0
|
||||
ws_codec_resampler_reset_mem@Base 2.1.0
|
||||
ws_codec_resampler_set_input_stride@Base 2.1.0
|
||||
ws_codec_resampler_set_output_stride@Base 2.1.0
|
||||
ws_codec_resampler_set_quality@Base 2.1.0
|
||||
ws_codec_resampler_set_rate@Base 2.1.0
|
||||
ws_codec_resampler_set_rate_frac@Base 2.1.0
|
||||
ws_codec_resampler_skip_zeros@Base 2.1.0
|
||||
ws_codec_resampler_strerror@Base 2.1.0
|
||||
|
|
|
@ -35,6 +35,8 @@ The following features are new (or have been significantly updated)
|
|||
since version 3.0.0:
|
||||
|
||||
* Brotli decompression support in HTTP/HTTP2 (requires the brotli library).
|
||||
* The build system now checks for a SpeexDSP system library installation. The
|
||||
bundled Speex resampler code is still provided as a fallback.
|
||||
|
||||
// === Removed Features and Support
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#ifdef HAVE_SPEEXDSP
|
||||
# include <speex/speex_resampler.h>
|
||||
#else
|
||||
# include <codecs/speex/speex_resampler.h>
|
||||
# include "speexdsp/speex_resampler.h"
|
||||
#endif /* HAVE_SPEEXDSP */
|
||||
|
||||
#include <epan/maxmind_db.h>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# CMakeLists.txt
|
||||
#
|
||||
# Wireshark - Network traffic analyzer
|
||||
# By Gerald Combs <gerald@wireshark.org>
|
||||
# Copyright 1998 Gerald Combs
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
|
||||
add_library(speexresampler STATIC resample.c)
|
||||
|
||||
set_target_properties(speexresampler PROPERTIES
|
||||
LINK_FLAGS "${WS_LINK_FLAGS}"
|
||||
FOLDER "Libs"
|
||||
)
|
|
@ -124,7 +124,7 @@ typedef struct SpeexResamplerState_ SpeexResamplerState;
|
|||
* @return Newly created resampler state
|
||||
* @retval NULL Error: not enough memory
|
||||
*/
|
||||
WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
|
||||
SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate,
|
||||
int quality,
|
||||
|
@ -143,7 +143,7 @@ WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels
|
|||
* @return Newly created resampler state
|
||||
* @retval NULL Error: not enough memory
|
||||
*/
|
||||
WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
|
||||
SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
|
||||
spx_uint32_t ratio_num,
|
||||
spx_uint32_t ratio_den,
|
||||
spx_uint32_t in_rate,
|
||||
|
@ -154,7 +154,7 @@ WS_DLL_PUBLIC SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_cha
|
|||
/** Destroy a resampler state.
|
||||
* @param st Resampler state
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_destroy(SpeexResamplerState *st);
|
||||
void speex_resampler_destroy(SpeexResamplerState *st);
|
||||
|
||||
/** Resample a float array. The input and output buffers must *not* overlap.
|
||||
* @param st Resampler state
|
||||
|
@ -166,7 +166,7 @@ WS_DLL_PUBLIC void speex_resampler_destroy(SpeexResamplerState *st);
|
|||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_process_float(SpeexResamplerState *st,
|
||||
int speex_resampler_process_float(SpeexResamplerState *st,
|
||||
spx_uint32_t channel_index,
|
||||
const float *in,
|
||||
spx_uint32_t *in_len,
|
||||
|
@ -183,7 +183,7 @@ WS_DLL_PUBLIC int speex_resampler_process_float(SpeexResamplerState *st,
|
|||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_process_int(SpeexResamplerState *st,
|
||||
int speex_resampler_process_int(SpeexResamplerState *st,
|
||||
spx_uint32_t channel_index,
|
||||
const spx_int16_t *in,
|
||||
spx_uint32_t *in_len,
|
||||
|
@ -199,7 +199,7 @@ WS_DLL_PUBLIC int speex_resampler_process_int(SpeexResamplerState *st,
|
|||
* @param out_len Size of the output buffer. Returns the number of samples written.
|
||||
* This is all per-channel.
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
|
||||
int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
|
||||
const float *in,
|
||||
spx_uint32_t *in_len,
|
||||
float *out,
|
||||
|
@ -214,7 +214,7 @@ WS_DLL_PUBLIC int speex_resampler_process_interleaved_float(SpeexResamplerState
|
|||
* @param out_len Size of the output buffer. Returns the number of samples written.
|
||||
* This is all per-channel.
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
|
||||
int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
|
||||
const spx_int16_t *in,
|
||||
spx_uint32_t *in_len,
|
||||
spx_int16_t *out,
|
||||
|
@ -225,7 +225,7 @@ WS_DLL_PUBLIC int speex_resampler_process_interleaved_int(SpeexResamplerState *s
|
|||
* @param in_rate Input sampling rate (integer number of Hz).
|
||||
* @param out_rate Output sampling rate (integer number of Hz).
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_set_rate(SpeexResamplerState *st,
|
||||
int speex_resampler_set_rate(SpeexResamplerState *st,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate);
|
||||
|
||||
|
@ -234,7 +234,7 @@ WS_DLL_PUBLIC int speex_resampler_set_rate(SpeexResamplerState *st,
|
|||
* @param in_rate Input sampling rate (integer number of Hz) copied.
|
||||
* @param out_rate Output sampling rate (integer number of Hz) copied.
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_get_rate(SpeexResamplerState *st,
|
||||
void speex_resampler_get_rate(SpeexResamplerState *st,
|
||||
spx_uint32_t *in_rate,
|
||||
spx_uint32_t *out_rate);
|
||||
|
||||
|
@ -246,7 +246,7 @@ WS_DLL_PUBLIC void speex_resampler_get_rate(SpeexResamplerState *st,
|
|||
* @param in_rate Input sampling rate rounded to the nearest integer (in Hz).
|
||||
* @param out_rate Output sampling rate rounded to the nearest integer (in Hz).
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_set_rate_frac(SpeexResamplerState *st,
|
||||
int speex_resampler_set_rate_frac(SpeexResamplerState *st,
|
||||
spx_uint32_t ratio_num,
|
||||
spx_uint32_t ratio_den,
|
||||
spx_uint32_t in_rate,
|
||||
|
@ -258,7 +258,7 @@ WS_DLL_PUBLIC int speex_resampler_set_rate_frac(SpeexResamplerState *st,
|
|||
* @param ratio_num Numerator of the sampling rate ratio copied
|
||||
* @param ratio_den Denominator of the sampling rate ratio copied
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_get_ratio(SpeexResamplerState *st,
|
||||
void speex_resampler_get_ratio(SpeexResamplerState *st,
|
||||
spx_uint32_t *ratio_num,
|
||||
spx_uint32_t *ratio_den);
|
||||
|
||||
|
@ -267,7 +267,7 @@ WS_DLL_PUBLIC void speex_resampler_get_ratio(SpeexResamplerState *st,
|
|||
* @param quality Resampling quality between 0 and 10, where 0 has poor
|
||||
* quality and 10 has very high quality.
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_set_quality(SpeexResamplerState *st,
|
||||
int speex_resampler_set_quality(SpeexResamplerState *st,
|
||||
int quality);
|
||||
|
||||
/** Get the conversion quality.
|
||||
|
@ -275,46 +275,46 @@ WS_DLL_PUBLIC int speex_resampler_set_quality(SpeexResamplerState *st,
|
|||
* @param quality Resampling quality between 0 and 10, where 0 has poor
|
||||
* quality and 10 has very high quality.
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_get_quality(SpeexResamplerState *st,
|
||||
void speex_resampler_get_quality(SpeexResamplerState *st,
|
||||
int *quality);
|
||||
|
||||
/** Set (change) the input stride.
|
||||
* @param st Resampler state
|
||||
* @param stride Input stride
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_set_input_stride(SpeexResamplerState *st,
|
||||
void speex_resampler_set_input_stride(SpeexResamplerState *st,
|
||||
spx_uint32_t stride);
|
||||
|
||||
/** Get the input stride.
|
||||
* @param st Resampler state
|
||||
* @param stride Input stride copied
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_get_input_stride(SpeexResamplerState *st,
|
||||
void speex_resampler_get_input_stride(SpeexResamplerState *st,
|
||||
spx_uint32_t *stride);
|
||||
|
||||
/** Set (change) the output stride.
|
||||
* @param st Resampler state
|
||||
* @param stride Output stride
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_set_output_stride(SpeexResamplerState *st,
|
||||
void speex_resampler_set_output_stride(SpeexResamplerState *st,
|
||||
spx_uint32_t stride);
|
||||
|
||||
/** Get the output stride.
|
||||
* @param st Resampler state copied
|
||||
* @param stride Output stride
|
||||
*/
|
||||
WS_DLL_PUBLIC void speex_resampler_get_output_stride(SpeexResamplerState *st,
|
||||
void speex_resampler_get_output_stride(SpeexResamplerState *st,
|
||||
spx_uint32_t *stride);
|
||||
|
||||
/** Get the latency introduced by the resampler measured in input samples.
|
||||
* @param st Resampler state
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_get_input_latency(SpeexResamplerState *st);
|
||||
int speex_resampler_get_input_latency(SpeexResamplerState *st);
|
||||
|
||||
/** Get the latency introduced by the resampler measured in output samples.
|
||||
* @param st Resampler state
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_get_output_latency(SpeexResamplerState *st);
|
||||
int speex_resampler_get_output_latency(SpeexResamplerState *st);
|
||||
|
||||
/** Make sure that the first samples to go out of the resamplers don't have
|
||||
* leading zeros. This is only useful before starting to use a newly created
|
||||
|
@ -324,18 +324,18 @@ WS_DLL_PUBLIC int speex_resampler_get_output_latency(SpeexResamplerState *st);
|
|||
* is the same for the first frame).
|
||||
* @param st Resampler state
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_skip_zeros(SpeexResamplerState *st);
|
||||
int speex_resampler_skip_zeros(SpeexResamplerState *st);
|
||||
|
||||
/** Reset a resampler so a new (unrelated) stream can be processed.
|
||||
* @param st Resampler state
|
||||
*/
|
||||
WS_DLL_PUBLIC int speex_resampler_reset_mem(SpeexResamplerState *st);
|
||||
int speex_resampler_reset_mem(SpeexResamplerState *st);
|
||||
|
||||
/** Returns the English meaning for an error code
|
||||
* @param err Error code
|
||||
* @return English string
|
||||
*/
|
||||
WS_DLL_PUBLIC const char *speex_resampler_strerror(int err);
|
||||
const char *speex_resampler_strerror(int err);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -663,6 +663,7 @@ target_include_directories(qtui SYSTEM
|
|||
PUBLIC
|
||||
${QT_INCLUDE_DIRS}
|
||||
${WINSPARKLE_INCLUDE_DIRS}
|
||||
${SPEEXDSP_INCLUDE_DIRS}
|
||||
PRIVATE
|
||||
${PCAP_INCLUDE_DIRS}
|
||||
)
|
||||
|
|
|
@ -235,6 +235,12 @@ get_gui_compiled_info(GString *str)
|
|||
#endif
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef HAVE_SPEEXDSP
|
||||
g_string_append(str, ", with SpeexDSP (using system library)");
|
||||
#else
|
||||
g_string_append(str, ", with SpeexDSP (using bundled resampler)");
|
||||
#endif
|
||||
|
||||
codec_get_compiled_version_info(str);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#ifdef HAVE_SPEEXDSP
|
||||
#include <speex/speex_resampler.h>
|
||||
#else
|
||||
#include <codecs/speex/speex_resampler.h>
|
||||
#include "../../speexdsp/speex_resampler.h"
|
||||
#endif /* HAVE_SPEEXDSP */
|
||||
|
||||
#include <epan/rtp_pt.h>
|
||||
|
|
Loading…
Reference in New Issue