Package: asterisk
Version: 1:1.6.1.0~dfsg-1
Severity: wishlist
Tags: patch
Asterisk 1.6 supports video on console channel if linked against FFmpeg
libraries. Unfortunately the autoconf code does not detect the location
of those libraries as packaged by Debian, and the console code expects
old organisation of header files.
The attached 2 patches fix these issues, so that simply build-depending
on libavcodec-dev and libswscale-dev makes Asterisk properly link
against FFmpeg.
- Jonas
Fix include FFmpeg headers from below /usr/include/ffmpeg/<libname>
(this change requires -I/usr/include/ffmpeg).
Jonas Smedegaard <[email protected]>
--- 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 \
The fact that FFmpeg is a _family_ of libraries sharing an optional base
subdir is not properly reflected in the autoconf detection logic. As a
workaround, this patch reuse and extend GTK2 logic to query pkg-config
files "libavcodec" and "libswscale", the family members currently used.
Ideally, the use of pkg-config should be optional, if used then family
members queried should be configurable/probed, if not used then both
library and include paths should be configurable and it should be
possible to declare multiple paths.
Suggested configure options:
--with-ffmpeg Base path for FFmpeg files
--with-avcodec=PATH use FFmpeg avcodec files in PATH,
otherwise try pkg-config or FFmpeg path
--with-avcodec-libs=PATH use FFmpeg avcodec library files in PATH,
otherwise probe avcodec path (as-is or with
"/ffmpeg" or "libs" appended)
--with-avcodec-headers=PATH use FFmpeg avcodec header files in PATH,
otherwise probe avcodec path (as-is or with
"/ffmpeg" or "/include" appended)
--with-swscale=PATH use FFmpeg swscale library files in PATH,
otherwise try pkg-config (of both libswscale
and libavcodec) or FFmpeg path
--with-avcodec-libs=PATH use FFmpeg avcodec library files in PATH,
otherwise probe avcodec path (as-is or with
"/ffmpeg" or "libs" appended)
--with-avcodec-headers=PATH use FFmpeg avcodec header files in PATH,
otherwise probe avcodec path (as-is or with
"/ffmpeg" or "/include" appended)
Jonas Smedegaard <[email protected]>
--- a/configure
+++ b/configure
@@ -1601,7 +1601,7 @@
--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 avcodec and swscale library files below PATH
--with-gsm=PATH use External GSM library files in PATH , use
'internal' GSM otherwise
--with-gtk=PATH use gtk libraries files in PATH
@@ -8166,12 +8166,12 @@
- FFMPEG_DESCRIP="Ffmpeg and avcodec library"
- FFMPEG_OPTION="avcodec"
+ FFMPEG_DESCRIP="avcodec and swscale libraries"
+ FFMPEG_OPTION="ffmpeg"
-# Check whether --with-avcodec was given.
-if test "${with_avcodec+set}" = set; then
- withval=$with_avcodec;
+# Check whether --with-ffmpeg was given.
+if test "${with_ffmpeg+set}" = set; then
+ withval=$with_ffmpeg;
case ${withval} in
n|no)
USE_FFMPEG=no
@@ -48837,264 +48837,112 @@
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=`echo "ac_cv_lib_avcodec_${pbxfuncname}" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for ${pbxfuncname} in -lavcodec" >&5
-echo $ECHO_N "checking for ${pbxfuncname} in -lavcodec... $ECHO_C" >&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
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_PKGCONFIG+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lavcodec ${pbxlibdir} -lpthread -lz -lm $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* 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
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext &&
- $as_test_x conftest$ac_exeext; then
- eval "$as_ac_Lib=yes"
+ if test -n "$PKGCONFIG"; then
+ ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test.
else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+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"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
- eval "$as_ac_Lib=no"
fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
- AST_FFMPEG_FOUND=yes
+PKGCONFIG=$ac_cv_prog_PKGCONFIG
+if test -n "$PKGCONFIG"; then
+ { echo "$as_me:$LINENO: result: $PKGCONFIG" >&5
+echo "${ECHO_T}$PKGCONFIG" >&6; }
else
- AST_FFMPEG_FOUND=no
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}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}"
- if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
- { echo "$as_me:$LINENO: checking for ffmpeg/avcodec.h" >&5
-echo $ECHO_N "checking for ffmpeg/avcodec.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_ffmpeg_avcodec_h" >&5
-echo "${ECHO_T}$ac_cv_header_ffmpeg_avcodec_h" >&6; }
+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
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_PKGCONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
else
- # Is the header compilable?
-{ echo "$as_me:$LINENO: checking ffmpeg/avcodec.h usability" >&5
-echo $ECHO_N "checking ffmpeg/avcodec.h usability... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <ffmpeg/avcodec.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_compile") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then
- ac_header_compiler=yes
+ if test -n "$ac_ct_PKGCONFIG"; then
+ ac_cv_prog_ac_ct_PKGCONFIG="$ac_ct_PKGCONFIG" # Let the user override the
test.
else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+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"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
- ac_header_compiler=no
fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ echo "$as_me:$LINENO: checking ffmpeg/avcodec.h presence" >&5
-echo $ECHO_N "checking ffmpeg/avcodec.h presence... $ECHO_C" >&6; }
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ffmpeg/avcodec.h>
-_ACEOF
-if { (ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null && {
- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
- test ! -s conftest.err
- }; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
fi
-
-rm -f conftest.err conftest.$ac_ext
-{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: accepted by the
compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: accepted by the compiler, rejected by
the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: proceeding with the
compiler's result" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: proceeding with the compiler's
result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: present but cannot be
compiled" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: check for missing
prerequisite headers?" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: check for missing prerequisite
headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: see the Autoconf
documentation" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: section \"Present
But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: section \"Present But Cannot Be
Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: proceeding with the
preprocessor's result" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: proceeding with the preprocessor's
result" >&2;}
- { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: in the future, the
compiler will take precedence" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: in the future, the compiler will take
precedence" >&2;}
- ( cat <<\_ASBOX
-## ------------------------------- ##
-## Report this to www.asterisk.org ##
-## ------------------------------- ##
-_ASBOX
- ) | sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-{ echo "$as_me:$LINENO: checking for ffmpeg/avcodec.h" >&5
-echo $ECHO_N "checking for ffmpeg/avcodec.h... $ECHO_C" >&6; }
-if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
+ac_ct_PKGCONFIG=$ac_cv_prog_ac_ct_PKGCONFIG
+if test -n "$ac_ct_PKGCONFIG"; then
+ { echo "$as_me:$LINENO: result: $ac_ct_PKGCONFIG" >&5
+echo "${ECHO_T}$ac_ct_PKGCONFIG" >&6; }
else
- ac_cv_header_ffmpeg_avcodec_h=$ac_header_preproc
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_header_ffmpeg_avcodec_h" >&5
-echo "${ECHO_T}$ac_cv_header_ffmpeg_avcodec_h" >&6; }
-fi
-if test $ac_cv_header_ffmpeg_avcodec_h = yes; then
- FFMPEG_HEADER_FOUND=1
+ if test "x$ac_ct_PKGCONFIG" = x; then
+ PKGCONFIG="No"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect
cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to [email protected]." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to [email protected]." >&2;}
+ac_tool_warned=yes ;;
+esac
+ PKGCONFIG=$ac_ct_PKGCONFIG
+ fi
else
- FFMPEG_HEADER_FOUND=0
+ 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
- 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
- # XXX don't know how to evaluate the description (third argument) in
AC_DEFINE_UNQUOTED
-
-cat >>confdefs.h <<_ACEOF
+cat >>confdefs.h <<\_ACEOF
#define HAVE_FFMPEG 1
_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_FFMPEG_VERSION
-_ACEOF
-
- fi
- fi
fi