]> git.mxchange.org Git - flightgear.git/commitdiff
Use GSM and Speex libraries from system if they are installed by Saikrishna Arcot
authorClément de l'Hamaide <clemaez@hotmail.fr>
Thu, 23 Jan 2014 16:46:49 +0000 (17:46 +0100)
committerClément de l'Hamaide <clemaez@hotmail.fr>
Thu, 23 Jan 2014 16:46:49 +0000 (17:46 +0100)
3rdparty/iaxclient/lib/CMakeLists.txt
3rdparty/iaxclient/lib/audio_encode.c
CMakeLists.txt
CMakeModules/FindGsm.cmake [new file with mode: 0644]
CMakeModules/FindSpeex.cmake [new file with mode: 0644]
CMakeModules/FindSpeexdsp.cmake [new file with mode: 0644]

index 99f2b9441f1dc4d6febdc1befa056d43acc43b72..c5deb99708f483c4ef09e422d67300a28167a52d 100644 (file)
@@ -19,26 +19,37 @@ set(LIBIAX2_SOURCES
     libiax2/src/md5.c
 )
 
-set(GSM_SOURCES
-    gsm/src/add.c
-    gsm/src/code.c
-    gsm/src/debug.c
-    gsm/src/decode.c
-    gsm/src/gsm_create.c
-    gsm/src/gsm_decode.c
-    gsm/src/gsm_destroy.c
-    gsm/src/gsm_encode.c
-    gsm/src/gsm_explode.c
-    gsm/src/gsm_implode.c
-    gsm/src/gsm_option.c
-    gsm/src/gsm_print.c
-    gsm/src/long_term.c
-    gsm/src/lpc.c
-    gsm/src/preprocess.c
-    gsm/src/rpe.c
-    gsm/src/short_term.c
-    gsm/src/table.c
-)
+if (SYSTEM_GSM)
+    set(Gsm_FIND_REQUIRED TRUE)
+    find_package(Gsm)
+endif(SYSTEM_GSM)
+
+if (GSM_FOUND)
+    include_directories(${GSM_INCLUDE_DIR})
+    message(STATUS "Using GSM includes at: ${GSM_INCLUDE_DIR}")
+    message(STATUS "Using GSM libraries: ${GSM_LIBRARIES}")
+else(GSM_FOUND)
+    set(GSM_SOURCES
+        gsm/src/add.c
+        gsm/src/code.c
+        gsm/src/debug.c
+        gsm/src/decode.c
+        gsm/src/gsm_create.c
+        gsm/src/gsm_decode.c
+        gsm/src/gsm_destroy.c
+        gsm/src/gsm_encode.c
+        gsm/src/gsm_explode.c
+        gsm/src/gsm_implode.c
+        gsm/src/gsm_option.c
+        gsm/src/gsm_print.c
+        gsm/src/long_term.c
+        gsm/src/lpc.c
+        gsm/src/preprocess.c
+        gsm/src/rpe.c
+        gsm/src/short_term.c
+        gsm/src/table.c
+    )
+endif(GSM_FOUND)
 
 if (WIN32)
     list(APPEND IAXCLIENT_BASE_SOURCES winfuncs.c)
@@ -48,47 +59,62 @@ endif(WIN32)
 
 if (ENABLE_SPEXX)
     list(APPEND IAXCLIENT_BASE_SOURCES codec_speex.c)
+
+    if (SYSTEM_SPEEX)
+        set(Speex_FIND_REQUIRED TRUE)
+        set(Speexdsp_FIND_REQUIRED TRUE)
+        find_package(Speex)
+        find_package(Speexdsp)
+    endif(SYSTEM_SPEEX)
+
+    if (SPEEX_FOUND AND SPEEXDSP_FOUND)
+        include_directories(${SPEEX_INCLUDE_DIR} ${SPEEXDSP_INCLUDE_DIR})
+        message(STATUS "Using speex includes at: ${SPEEX_INCLUDE_DIR}")
+        message(STATUS "Using speex libraries: ${SPEEX_LIBRARIES}")
+        message(STATUS "Using speex extended library includes at: ${SPEEXDSP_INCLUDE_DIR}")
+        message(STATUS "Using speex extended library libraries: ${SPEEXDSP_LIBRARIES}")
+    else(SPEEX_FOUND AND SPEEXDSP_FOUND)
+        set(SPEEX_SOURCES
+            libspeex/bits.c
+            libspeex/cb_search.c
+            libspeex/exc_10_16_table.c
+            libspeex/exc_10_32_table.c
+            libspeex/exc_20_32_table.c
+            libspeex/exc_5_256_table.c
+            libspeex/exc_5_64_table.c
+            libspeex/exc_8_128_table.c
+            libspeex/filters.c
+            libspeex/gain_table.c
+            libspeex/gain_table_lbr.c
+            libspeex/hexc_10_32_table.c
+            libspeex/hexc_table.c
+            libspeex/high_lsp_tables.c
+            libspeex/jitter.c
+            libspeex/lbr_48k_tables.c
+            libspeex/lpc.c
+            libspeex/lsp.c
+            libspeex/lsp_tables_nb.c
+            libspeex/ltp.c
+            libspeex/math_approx.c
+            libspeex/mdf.c
+            libspeex/medfilter.c
+            libspeex/misc.c
+            libspeex/modes.c
+            libspeex/nb_celp.c
+            libspeex/preprocess.c
+            libspeex/quant_lsp.c
+            libspeex/sb_celp.c
+            libspeex/smallft.c
+            libspeex/speex.c
+            libspeex/speex_callbacks.c
+            libspeex/speex_header.c
+            libspeex/stereo.c
+            libspeex/vbr.c
+            libspeex/vq.c
+            )
     
-    set(SPEEX_SOURCES 
-        libspeex/bits.c
-        libspeex/cb_search.c
-        libspeex/exc_10_16_table.c
-        libspeex/exc_10_32_table.c
-        libspeex/exc_20_32_table.c
-        libspeex/exc_5_256_table.c
-        libspeex/exc_5_64_table.c
-        libspeex/exc_8_128_table.c
-        libspeex/filters.c
-        libspeex/gain_table.c
-        libspeex/gain_table_lbr.c
-        libspeex/hexc_10_32_table.c
-        libspeex/hexc_table.c
-        libspeex/high_lsp_tables.c
-        libspeex/jitter.c
-        libspeex/lbr_48k_tables.c
-        libspeex/lpc.c
-        libspeex/lsp.c
-        libspeex/lsp_tables_nb.c
-        libspeex/ltp.c
-        libspeex/math_approx.c
-        libspeex/mdf.c
-        libspeex/medfilter.c
-        libspeex/misc.c
-        libspeex/modes.c
-        libspeex/nb_celp.c
-        libspeex/preprocess.c
-        libspeex/quant_lsp.c
-        libspeex/sb_celp.c
-        libspeex/smallft.c
-        libspeex/speex.c
-        libspeex/speex_callbacks.c
-        libspeex/speex_header.c
-        libspeex/stereo.c
-        libspeex/vbr.c
-        libspeex/vq.c
-        )
-    
-    include_directories(${PROJECT_SOURCE_DIR}/3rdparty/iaxclient/lib/libspeex/include)
+        include_directories(${PROJECT_SOURCE_DIR}/3rdparty/iaxclient/lib/libspeex/include)
+    endif(SPEEX_FOUND AND SPEEXDSP_FOUND)
 endif(ENABLE_SPEXX)
 
 if (ENABLE_ALSA)
@@ -134,6 +160,6 @@ add_library(iaxclient_lib STATIC
     ${SPEEX_SOURCES}
     ${LIBIAX2_SOURCES})
 
-target_link_libraries(iaxclient_lib ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(iaxclient_lib ${CMAKE_THREAD_LIBS_INIT} ${SPEEX_LIBRARIES} ${SPEEXDSP_LIBRARIES} ${GSM_LIBRARIES})
 
 # eof
index e30757cbd902d2ce60c66826d9aac2ba63a60161..31eff2dcc24017c7fc810232c55b796eb4845933 100644 (file)
@@ -171,8 +171,12 @@ static int input_postprocess(void *audio, int len, int rate)
 
                if ( (i & 0x3f) == 0 )
                {
-                       float loudness = st->loudness2;
-                       // speex_preprocess_ctl(st, SPEEX_PREPROCESS_GET_AGC_LOUDNESS, &loudness);
+                       float loudness;
+#ifdef SPEEX_PREPROCESS_GET_AGC_LOUDNESS
+                       speex_preprocess_ctl(st, SPEEX_PREPROCESS_GET_AGC_LOUDNESS, &loudness);
+#else
+                       loudness = st->loudness2;
+#endif
                        if ( loudness > 8000.0f || loudness < 4000.0f )
                        {
                                const float level = iaxc_input_level_get();
index 510d779cb16bc04edb335845e3638cffdf2f1445..de01dfc140246c4455a59c78ee63b89ab48cbdf9 100644 (file)
@@ -116,6 +116,17 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
     if(UDEV_FOUND)
         set(EVENT_INPUT_DEFAULT 1)
     endif(UDEV_FOUND)
+
+    find_package(Speex)
+    find_package(Speexdsp)
+    if(SPEEX_FOUND AND SPEEXDSP_FOUND)
+        set(SYSTEM_SPEEX_DEFAULT 1)
+    endif(SPEEX_FOUND AND SPEEXDSP_FOUND)
+
+    find_package(Gsm)
+    if(GSM_FOUND)
+        set(SYSTEM_GSM_DEFAULT 1)
+    endif(GSM_FOUND)
 endif()
 
 find_package(Git)
@@ -143,6 +154,8 @@ option(JPEG_FACTORY      "Set to ON to build FlightGear with JPEG-factory suppor
 option(SYSTEM_SQLITE     "Set to ON to build FlightGear with the system's SQLite3 library" OFF)
 option(ENABLE_IAX        "Set to ON to build FlightGear with IAXClient/fgcom built-in (default)" ON)
 option(USE_DBUS          "Set to ON to build FlightGear with DBus screensaver interaction (default on Linux)" ${USE_DBUS_DEFAULT})
+option(SYSTEM_SPEEX      "Set to ON to build IAXClient with the system's speex and speexdsp library" ${SYSTEM_SPEEX_DEFAULT})
+option(SYSTEM_GSM        "Set to ON to build IAXClient with the system's GSM library" ${SYSTEM_GSM_DEFAULT})
 
 # additional utilities
 option(ENABLE_FGADMIN    "Set to ON to build the FGADMIN application (default)" ON)
diff --git a/CMakeModules/FindGsm.cmake b/CMakeModules/FindGsm.cmake
new file mode 100644 (file)
index 0000000..1add357
--- /dev/null
@@ -0,0 +1,88 @@
+# - Try to find GSM
+# Once done this will define
+#
+#  GSM_FOUND - system has GSM
+#  GSM_INCLUDE_DIRS - the GSM include directory
+#  GSM_LIBRARIES - Link these to use GSM
+#  GSM_DEFINITIONS - Compiler switches required for using GSM
+#
+#  Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+#  Edited by Saikrishna Arcot <saiarcot895@gmail.com> to find the GSM library
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+if (GSM_LIBRARIES AND GSM_INCLUDE_DIRS)
+  # in cache already
+  set(GSM_FOUND TRUE)
+else (GSM_LIBRARIES AND GSM_INCLUDE_DIRS)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  #include(UsePkgConfig)
+
+  #FIXME pkgconfig does not work: return a carriage return that makes compilation failed
+  #pkgconfig(speex _GsmIncDir _GsmLinkDir _GsmLinkFlags _GsmCflags)
+
+  #set(GSM_DEFINITIONS ${_GsmCflags})
+  set(GSM_DEFINITIONS "")
+
+  find_path(GSM_INCLUDE_DIR
+    NAMES
+      gsm/gsm.h
+      gsm.h
+    PATHS
+      ${_GsmIncDir}
+      /usr/include
+      /usr/local/include
+      /opt/local/include
+      /sw/include
+  )
+
+  find_library(GSM_LIBRARY
+    NAMES
+      gsm
+      Gsm
+    PATHS
+      ${_GsmLinkDir}
+      /usr/lib
+      /usr/local/lib
+      /opt/local/lib
+      /sw/lib
+  )
+
+  if (GSM_LIBRARY)
+    set(GSM_FOUND TRUE)
+  endif (GSM_LIBRARY)
+
+  set(GSM_INCLUDE_DIRS
+    ${GSM_INCLUDE_DIR}
+  )
+
+  if (GSM_FOUND)
+    set(GSM_LIBRARIES
+      ${GSM_LIBRARIES}
+      ${GSM_LIBRARY}
+    )
+  endif (GSM_FOUND)
+
+  if (GSM_INCLUDE_DIRS AND GSM_LIBRARIES)
+    set(GSM_FOUND TRUE)
+  endif (GSM_INCLUDE_DIRS AND GSM_LIBRARIES)
+
+  if (GSM_FOUND)
+    if (NOT Gsm_FIND_QUIETLY)
+      message(STATUS "Found GSM: ${GSM_LIBRARIES}")
+    endif (NOT Gsm_FIND_QUIETLY)
+  else (GSM_FOUND)
+    if (Gsm_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find GSM")
+    endif (Gsm_FIND_REQUIRED)
+  endif (GSM_FOUND)
+
+  # show the GSM_INCLUDE_DIRS and GSM_LIBRARIES variables only in the advanced view
+  mark_as_advanced(GSM_INCLUDE_DIRS GSM_LIBRARIES)
+
+endif (GSM_LIBRARIES AND GSM_INCLUDE_DIRS)
diff --git a/CMakeModules/FindSpeex.cmake b/CMakeModules/FindSpeex.cmake
new file mode 100644 (file)
index 0000000..95a8d1a
--- /dev/null
@@ -0,0 +1,87 @@
+# - Try to find Speex
+# Once done this will define
+#
+#  SPEEX_FOUND - system has Speex
+#  SPEEX_INCLUDE_DIRS - the Speex include directory
+#  SPEEX_LIBRARIES - Link these to use Speex
+#  SPEEX_DEFINITIONS - Compiler switches required for using Speex
+#
+#  Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+if (SPEEX_LIBRARIES AND SPEEX_INCLUDE_DIRS)
+  # in cache already
+  set(SPEEX_FOUND TRUE)
+else (SPEEX_LIBRARIES AND SPEEX_INCLUDE_DIRS)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  #include(UsePkgConfig)
+
+  #FIXME pkgconfig does not work: return a carriage return that makes compilation failed
+  #pkgconfig(speex _SpeexIncDir _SpeexLinkDir _SpeexLinkFlags _SpeexCflags)
+
+  #set(SPEEX_DEFINITIONS ${_SpeexCflags})
+  set(SPEEX_DEFINITIONS "")
+
+  find_path(SPEEX_INCLUDE_DIR
+    NAMES
+      speex/speex.h
+      speex.h
+    PATHS
+      ${_SpeexIncDir}
+      /usr/include
+      /usr/local/include
+      /opt/local/include
+      /sw/include
+  )
+
+  find_library(SPEEX_LIBRARY
+    NAMES
+      speex
+      Speex
+    PATHS
+      ${_SpeexLinkDir}
+      /usr/lib
+      /usr/local/lib
+      /opt/local/lib
+      /sw/lib
+  )
+
+  if (SPEEX_LIBRARY)
+    set(SPEEX_FOUND TRUE)
+  endif (SPEEX_LIBRARY)
+
+  set(SPEEX_INCLUDE_DIRS
+    ${SPEEX_INCLUDE_DIR}
+  )
+
+  if (SPEEX_FOUND)
+    set(SPEEX_LIBRARIES
+      ${SPEEX_LIBRARIES}
+      ${SPEEX_LIBRARY}
+    )
+  endif (SPEEX_FOUND)
+
+  if (SPEEX_INCLUDE_DIRS AND SPEEX_LIBRARIES)
+    set(SPEEX_FOUND TRUE)
+  endif (SPEEX_INCLUDE_DIRS AND SPEEX_LIBRARIES)
+
+  if (SPEEX_FOUND)
+    if (NOT Speex_FIND_QUIETLY)
+      message(STATUS "Found Speex: ${SPEEX_LIBRARIES}")
+    endif (NOT Speex_FIND_QUIETLY)
+  else (SPEEX_FOUND)
+    if (Speex_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find Speex")
+    endif (Speex_FIND_REQUIRED)
+  endif (SPEEX_FOUND)
+
+  # show the SPEEX_INCLUDE_DIRS and SPEEX_LIBRARIES variables only in the advanced view
+  mark_as_advanced(SPEEX_INCLUDE_DIRS SPEEX_LIBRARIES)
+
+endif (SPEEX_LIBRARIES AND SPEEX_INCLUDE_DIRS)
diff --git a/CMakeModules/FindSpeexdsp.cmake b/CMakeModules/FindSpeexdsp.cmake
new file mode 100644 (file)
index 0000000..84ebb56
--- /dev/null
@@ -0,0 +1,88 @@
+# - Try to find Speex extended library
+# Once done this will define
+#
+#  SPEEXDSP_FOUND - system has Speex extended library
+#  SPEEXDSP_INCLUDE_DIRS - the Speex extended library include directory
+#  SPEEXDSP_LIBRARIES - Link these to use Speex extended library
+#  SPEEXDSP_DEFINITIONS - Compiler switches required for using Speex extended library
+#
+#  Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+#  Edited by Saikrishna Arcot <saiarcot895@gmail.com> to find the Speex extended library
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+if (SPEEXDSP_LIBRARIES AND SPEEXDSP_INCLUDE_DIRS)
+  # in cache already
+  set(SPEEXDSP_FOUND TRUE)
+else (SPEEXDSP_LIBRARIES AND SPEEXDSP_INCLUDE_DIRS)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  #include(UsePkgConfig)
+
+  #FIXME pkgconfig does not work: return a carriage return that makes compilation failed
+  #pkgconfig(speexdsp _SpeexDspIncDir _SpeexDspLinkDir _SpeexDspLinkFlags _SpeexDspCflags)
+
+  #set(SPEEXDSP_DEFINITIONS ${_SpeexDspCflags})
+  set(SPEEXDSP_DEFINITIONS "")
+
+  find_path(SPEEXDSP_INCLUDE_DIR
+    NAMES
+      speex/speex_preprocess.h
+      speex_preprocess.h
+    PATHS
+      ${_SpeexDspIncDir}
+      /usr/include
+      /usr/local/include
+      /opt/local/include
+      /sw/include
+  )
+
+  find_library(SPEEXDSP_LIBRARY
+    NAMES
+      speexdsp
+      Speexdsp
+    PATHS
+      ${_SpeexDspLinkDir}
+      /usr/lib
+      /usr/local/lib
+      /opt/local/lib
+      /sw/lib
+  )
+
+  if (SPEEXDSP_LIBRARY)
+    set(SPEEXDSP_FOUND TRUE)
+  endif (SPEEXDSP_LIBRARY)
+
+  set(SPEEXDSP_INCLUDE_DIRS
+    ${SPEEXDSP_INCLUDE_DIR}
+  )
+
+  if (SPEEXDSP_FOUND)
+    set(SPEEXDSP_LIBRARIES
+      ${SPEEXDSP_LIBRARIES}
+      ${SPEEXDSP_LIBRARY}
+    )
+  endif (SPEEXDSP_FOUND)
+
+  if (SPEEXDSP_INCLUDE_DIRS AND SPEEXDSP_LIBRARIES)
+    set(SPEEXDSP_FOUND TRUE)
+  endif (SPEEXDSP_INCLUDE_DIRS AND SPEEXDSP_LIBRARIES)
+
+  if (SPEEXDSP_FOUND)
+    if (NOT Speexdsp_FIND_QUIETLY)
+      message(STATUS "Found Speex extended library: ${SPEEXDSP_LIBRARIES}")
+    endif (NOT Speexdsp_FIND_QUIETLY)
+  else (SPEEXDSP_FOUND)
+    if (Speexdsp_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find Speex extended library")
+    endif (Speexdsp_FIND_REQUIRED)
+  endif (SPEEXDSP_FOUND)
+
+  # show the SPEEXDSP_INCLUDE_DIRS and SPEEXDSP_LIBRARIES variables only in the advanced view
+  mark_as_advanced(SPEEXDSP_INCLUDE_DIRS SPEEXDSP_LIBRARIES)
+
+endif (SPEEXDSP_LIBRARIES AND SPEEXDSP_INCLUDE_DIRS)