From 6952b81fe89a136c0d087aa98cfbfd8bfc965818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Tue, 13 Feb 2018 10:29:31 -0500 Subject: CMake: Check if libilbc links without 'extern "C"' (ILBC_CPP) This variable was originally set manually in configure.in. --- cmake/FindIlbc.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cmake') diff --git a/cmake/FindIlbc.cmake b/cmake/FindIlbc.cmake index f66ca55..7bbffa9 100644 --- a/cmake/FindIlbc.cmake +++ b/cmake/FindIlbc.cmake @@ -1,8 +1,27 @@ +include (CMakePushCheckState) +include (CheckCXXSourceCompiles) + FIND_PATH(ILBC_INCLUDE_DIR ilbc/iLBC_decode.h) FIND_LIBRARY(ILBC_LIBRARIES NAMES ilbc) IF(ILBC_INCLUDE_DIR AND ILBC_LIBRARIES) SET(ILBC_FOUND TRUE) + + # Check if libilbc can be used without 'extern "C"' + CMAKE_PUSH_CHECK_STATE() + LIST(APPEND CMAKE_REQUIRED_INCLUDES "${ILBC_INCLUDE_DIR}") + LIST(APPEND CMAKE_REQUIRED_LIBRARIES "-lilbc") + SET(CMAKE_REQUIRED_QUIET TRUE) + CHECK_CXX_SOURCE_COMPILES(" + #include + + int main() { + iLBC_Dec_Inst_t *iLBCdec_inst; + initDecode(iLBCdec_inst, 0, 0); + return 0; + } + " ILBC_CPP) + CMAKE_POP_CHECK_STATE() ENDIF(ILBC_INCLUDE_DIR AND ILBC_LIBRARIES) IF(ILBC_FOUND) -- cgit v1.2.3 From 46bee14d3cc49d4fb49eaf36a29dbcc7a11a5ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= Date: Sat, 6 Jul 2019 15:40:56 -0400 Subject: Add support for the new bcg729 API, introduced in version 1.0.2 Starting with version 1.0.2, bcg729 has changed its API to add support for G.729B, thus requiring us to adjust our function calls depending on which version is installed. When dealing with the new API, we merely need to add a few parameters to disable all G.729B features, namely: * On the decoder side: When `SIDFrameFlag` is not set, the decoder will behave just like before, decoding the payload as a standard G.729A voice frame (or concealing an erased frame). The other parameters, `rfc3389PayloadFlag` and `bitStreamLength`, are only of use when dealing with a SID frame sent as per RFC 3389, and are ignored if `SIDFrameFlag` is not set. * On the encoder side: When `enableVAD` is disabled, the encoder will behave just like before, producing only standard G.729A voice frames. The only API difference is the introduction of `*bitStreamLength`, to return the length of the encoded frame (0, 2 or 10 bytes). In our case, this will always be 10 bytes just like before; an assert() was added to guarantee this. Closes #104 --- cmake/FindG729.cmake | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'cmake') diff --git a/cmake/FindG729.cmake b/cmake/FindG729.cmake index 4a30ba0..1fbfeeb 100644 --- a/cmake/FindG729.cmake +++ b/cmake/FindG729.cmake @@ -1,14 +1,50 @@ +INCLUDE(CMakePushCheckState) +INCLUDE(CheckCSourceCompiles) + FIND_PATH(G729_INCLUDE_DIR bcg729/decoder.h) FIND_LIBRARY(G729_LIBRARY NAMES bcg729) IF(G729_INCLUDE_DIR AND G729_LIBRARY) SET(G729_FOUND TRUE) + + # The bcg729 API was changed in 1.0.2 to add support for G.729 Annex B. + # This checks whether we are dealing with the old or new API. + CMAKE_PUSH_CHECK_STATE() + SET(CMAKE_REQUIRED_INCLUDES "${INCLUDE_DIRECTORIES}" "${G729_INCLUDE_DIR}") + SET(CMAKE_REQUIRED_LIBRARIES "${G729_LIBRARY}") + SET(CMAKE_REQUIRED_QUIET TRUE) + # Try to compile something using the old (pre-1.0.2) API. + # + # We cannot do it the other way around, as initBcg729EncoderChannel() + # did not have a prototype before 1.0.2, thus compilation would not fail + # when passing it an extra argument. + CHECK_C_SOURCE_COMPILES(" + #include + + int main() { + /* This function requires an argument since 1.0.2 */ + initBcg729EncoderChannel(); + return 0; + } + " G729_OLD_API) + CMAKE_POP_CHECK_STATE() + + IF (G729_OLD_API) + SET(G729_ANNEX_B FALSE) + ELSE (G729_OLD_API) + SET(G729_ANNEX_B TRUE) + ENDIF (G729_OLD_API) ENDIF(G729_INCLUDE_DIR AND G729_LIBRARY) IF(G729_FOUND) IF (NOT G729_FIND_QUIETLY) MESSAGE(STATUS "Found bcg729 includes: ${G729_INCLUDE_DIR}/bcg729/decoder.h") MESSAGE(STATUS "Found bcg729 library: ${G729_LIBRARY}") + IF (G729_ANNEX_B) + MESSAGE(STATUS "bcg729 supports Annex B; using the new (1.0.2) API") + ELSE (G729_ANNEX_B) + MESSAGE(STATUS "bcg729 does not support Annex B; using the old (pre-1.0.2) API") + ENDIF (G729_ANNEX_B) ENDIF (NOT G729_FIND_QUIETLY) ELSE(G729_FOUND) IF (G729_FIND_REQUIRED) -- cgit v1.2.3