Bug#531728: Updated patches to adjust FFmpeg paths for Debian needs

Jonas Smedegaard dr at jones.dk
Fri Feb 26 17:52:15 UTC 2010


Hi,

Attached are my updated patches to fix FFmpeg support.

Included is also an autoconf.ac patch (the one *without* trailing -ac) 
for upstream consumption.

I disagree that upstream FFmpeg-dependent code is unstable - this patch 
use their code as-is, just improve library detection as Debian store 
those libraries in different paths than other distros.

Beware that the debian.diff contains also other improvements. If 
considering those, I suggest to add sqlite3-dev as fallback instead of 
replacement as I did, as that approach will work both with Sid 
autobuilders and pbuilder backporting to Lenny.


As earlier stated, I claim no copyright for these tiny patches. Treat 
them as Public Domain, or adopt them as your own if that eases passing 
them upstream.


If anyone wants to easily try out the code, I have packages for i386 and 
amd64 with the patches applied available[1] here:

deb http://debian.jones.dk/ lenny voip voip+
deb http://debian.jones.dk/ squeeze voip voip+
deb http://debian.jones.dk/ sid voip voip+

The "voip" area also contains a (lower numbered) Lenny backport without 
these patches applied - so for a conservative backport just use this:

deb http://debian.jones.dk/ lenny voip


Regards,

  - Jonas


[1] Lenny backports are available now, Sid and Squeeze will follow in 
a couple of hours.

-- 
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136  Website: http://dr.jones.dk/

  [x] quote me freely  [ ] ask before reusing  [ ] keep private
-------------- next part --------------
Subject: Modernize autotools FFmpeg linking
 FFmpeg is a _family_ of libraries sharing an optional base subdir. This
 is not properly reflected in the autoconf detection logic, and makes it
 impossible to handle Debian location of these libraries.
 .
 This patch queries pkg-config, used with recent FFmpeg, for files
 "libavcodec" and "libswscale", the family members currently used.
Author: Jonas Smedegaard <dr at jones.dk>
Last-Update: 2010-02-26
--- a/configure.ac
+++ b/configure.ac
@@ -253,7 +253,7 @@
 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
 AST_EXT_LIB_SETUP([CRYPTO], [OpenSSL Cryptography support], [crypto])
 AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
-AST_EXT_LIB_SETUP([FFMPEG], [Ffmpeg and avcodec library], [avcodec])
+AST_EXT_LIB_SETUP([FFMPEG], [FFmpeg (avcodec and swscale) libraries], [ffmpeg])
 AST_EXT_LIB_SETUP([GSM], [External GSM library], [gsm], [, use 'internal' GSM otherwise])
 AST_EXT_LIB_SETUP([GTK], [gtk libraries], [gtk])
 AST_EXT_LIB_SETUP([GTK2], [gtk2 libraries], [gtk2])
@@ -1660,7 +1660,18 @@
 
 AST_EXT_TOOL_CHECK([SDL], [sdl])
 AST_EXT_LIB_CHECK([SDL_IMAGE], [SDL_image], [IMG_Load], [SDL_image.h], [${SDL_LIB}], [${SDL_INCLUDE}])
-AST_EXT_LIB_CHECK([FFMPEG], [avcodec], [sws_getContext], [ffmpeg/avcodec.h], [-lpthread -lz -lm])
+
+PBX_FFMPEG=0
+AC_CHECK_TOOL(PKGCONFIG, pkg-config, No)
+if test ! "x${PKGCONFIG}" = xNo; then
+   FFMPEG_INCLUDE=$(${PKGCONFIG} libavcodec libswscale --cflags 2>/dev/null)
+   FFMPEG_LIB=$(${PKGCONFIG} libavcodec libswscale --libs)
+   PBX_FFMPEG=1
+   AC_DEFINE([HAVE_FFMPEG], 1, [Define if your system has the FFmpeg libraries.])
+fi
+AC_SUBST(PBX_FFMPEG)
+AC_SUBST(FFMPEG_INCLUDE)
+AC_SUBST(FFMPEG_LIB)
 
 # possible places for video4linux version 1
 AC_CHECK_HEADER([linux/videodev.h],
-------------- next part --------------
Subject: Modernize autotools FFmpeg linking
 FFmpeg is a _family_ of libraries sharing an optional base subdir. This
 is not properly reflected in the autoconf detection logic, and makes it
 impossible to handle Debian location of these libraries.
 .
 This patch queries pkg-config, used with recent FFmpeg, for files
 "libavcodec" and "libswscale", the family members currently used.
 .
 This patch was created by applying ffmpeg-detection, autoreconf'ing and
 manually editing to keep only minimal changes.  Hence only
 ffmpeg-detection (not this patch) makes sense to pass upstream.
Author: Jonas Smedegaard <dr at jones.dk>
Forwarded: not-needed
Last-Update: 2010-02-26
--- a/configure
+++ b/configure
@@ -1020,7 +1023,7 @@
 with_curses
 with_crypto
 with_dahdi
-with_avcodec
+with_ffmpeg
 with_gsm
 with_gtk
 with_gtk2
@@ -1724,7 +1727,8 @@
   --with-curses=PATH      use curses files in PATH
   --with-crypto=PATH      use OpenSSL Cryptography support files in PATH
   --with-dahdi=PATH       use DAHDI files in PATH
-  --with-avcodec=PATH     use Ffmpeg and avcodec library files in PATH
+  --with-ffmpeg=PATH      use FFmpeg (avcodec and swscale) libraries files
+                          in PATH
   --with-gsm=PATH         use External GSM library files in PATH , use
                           'internal' GSM otherwise
   --with-gtk=PATH         use gtk libraries files in PATH
@@ -23130,107 +23164,111 @@
 fi
 
 
-if test "x${PBX_FFMPEG}" != "x1" -a "${USE_FFMPEG}" != "no"; then
-   pbxlibdir=""
-   # if --with-FFMPEG=DIR has been specified, use it.
-   if test "x${FFMPEG_DIR}" != "x"; then
-      if test -d ${FFMPEG_DIR}/lib; then
-      	 pbxlibdir="-L${FFMPEG_DIR}/lib"
-      else
-      	 pbxlibdir="-L${FFMPEG_DIR}"
-      fi
-   fi
-   pbxfuncname="sws_getContext"
-   if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
-      AST_FFMPEG_FOUND=yes
-   else
-      as_ac_Lib=`$as_echo "ac_cv_lib_avcodec_${pbxfuncname}" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lavcodec" >&5
-$as_echo_n "checking for ${pbxfuncname} in -lavcodec... " >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then :
+PBX_FFMPEG=0
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_PKGCONFIG+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lavcodec ${pbxlibdir} -lpthread -lz -lm $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char ${pbxfuncname} ();
-int
-main ()
-{
-return ${pbxfuncname} ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$as_ac_Lib=yes"
+  if test -n "$PKGCONFIG"; then
+  ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test.
 else
-  eval "$as_ac_Lib=no"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_PKGCONFIG="${ac_tool_prefix}pkg-config"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-eval ac_res=\$$as_ac_Lib
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-eval as_val=\$$as_ac_Lib
-   if test "x$as_val" = x""yes; then :
-  AST_FFMPEG_FOUND=yes
+PKGCONFIG=$ac_cv_prog_PKGCONFIG
+if test -n "$PKGCONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5
+$as_echo "$PKGCONFIG" >&6; }
 else
-  AST_FFMPEG_FOUND=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-   fi
 
-   # now check for the header.
-   if test "${AST_FFMPEG_FOUND}" = "yes"; then
-      FFMPEG_LIB="${pbxlibdir} -lavcodec -lpthread -lz -lm"
-      # if --with-FFMPEG=DIR has been specified, use it.
-      if test "x${FFMPEG_DIR}" != "x"; then
-         FFMPEG_INCLUDE="-I${FFMPEG_DIR}/include"
-      fi
-      FFMPEG_INCLUDE="${FFMPEG_INCLUDE} "
-      if test "xffmpeg/avcodec.h" = "x" ; then	# no header, assume found
-         FFMPEG_HEADER_FOUND="1"
-      else				# check for the header
-         saved_cppflags="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${FFMPEG_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "ffmpeg/avcodec.h" "ac_cv_header_ffmpeg_avcodec_h" "$ac_includes_default"
-if test "x$ac_cv_header_ffmpeg_avcodec_h" = x""yes; then :
-  FFMPEG_HEADER_FOUND=1
+fi
+if test -z "$ac_cv_prog_PKGCONFIG"; then
+  ac_ct_PKGCONFIG=$PKGCONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_PKGCONFIG+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_PKGCONFIG"; then
+  ac_cv_prog_ac_ct_PKGCONFIG="$ac_ct_PKGCONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_PKGCONFIG="pkg-config"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_PKGCONFIG=$ac_cv_prog_ac_ct_PKGCONFIG
+if test -n "$ac_ct_PKGCONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_PKGCONFIG" >&5
+$as_echo "$ac_ct_PKGCONFIG" >&6; }
 else
-  FFMPEG_HEADER_FOUND=0
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+  if test "x$ac_ct_PKGCONFIG" = x; then
+    PKGCONFIG="No"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKGCONFIG=$ac_ct_PKGCONFIG
+  fi
+else
+  PKGCONFIG="$ac_cv_prog_PKGCONFIG"
+fi
+
+if test ! "x${PKGCONFIG}" = xNo; then
+   FFMPEG_INCLUDE=$(${PKGCONFIG} libavcodec libswscale --cflags 2>/dev/null)
+   FFMPEG_LIB=$(${PKGCONFIG} libavcodec libswscale --libs)
+   PBX_FFMPEG=1
+
+$as_echo "#define HAVE_FFMPEG 1" >>confdefs.h
 
-         CPPFLAGS="${saved_cppflags}"
-      fi
-      if test "x${FFMPEG_HEADER_FOUND}" = "x0" ; then
-         FFMPEG_LIB=""
-         FFMPEG_INCLUDE=""
-      else
-         if test "x${pbxfuncname}" = "x" ; then		# only checking headers -> no library
-            FFMPEG_LIB=""
-         fi
-         PBX_FFMPEG=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_FFMPEG 1
-#define HAVE_FFMPEG_VERSION
-_ACEOF
-      fi
-   fi
 fi
 
 
+
+
 # possible places for video4linux version 1
 ac_fn_c_check_header_mongrel "$LINENO" "linux/videodev.h" "ac_cv_header_linux_videodev_h" "$ac_includes_default"
 if test "x$ac_cv_header_linux_videodev_h" = x""yes; then :
-------------- next part --------------
Subject: Include subdirs (not main dir) for FFmpeg paths
 Fix include FFmpeg headers from below /usr/include/ffmpeg/<libname>
 (this change requires -I/usr/include/ffmpeg).
Author: Jonas Smedegaard <dr at jones.dk>
Last-Update: 2010-02-26
  Jonas Smedegaard <dr at jones.dk>
--- a/channels/console_video.h
+++ b/channels/console_video.h
@@ -28,9 +28,9 @@
 		"console {device}"
 #else
 
-#include <ffmpeg/avcodec.h>
+#include <libavcodec/avcodec.h>
 #ifndef OLD_FFMPEG
-#include <ffmpeg/swscale.h>     /* requires a recent ffmpeg */
+#include <libswscale/swscale.h>     /* requires a recent ffmpeg */
 #endif
 
 #define CONSOLE_VIDEO_CMDS			\
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asterisk.diff
Type: text/x-diff
Size: 13624 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-voip-maintainers/attachments/20100226/1caabc95/attachment-0001.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-voip-maintainers/attachments/20100226/1caabc95/attachment-0001.pgp>


More information about the Pkg-voip-maintainers mailing list