Skip to content

Commit

Permalink
Improve detection of av_register_protocol() for ffmpeg , real commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sackmotion committed Oct 22, 2011
1 parent 7aec4ba commit 58627b0
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Features
http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog (Angel Carpintero)
* Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. (Angel Carpintero)
* Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch (Wim Lewis)
* Improve detection of av_register_protocol() for ffmpeg (Angel Carpintero).


Bugfixes
* Avoid segfault detecting strerror_r() version GNU or SUSv3. (Angel Carpintero)
Expand Down
4 changes: 4 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,10 @@ Mike Lees
* Implemented the new brightness, contrast, hue, saturation features
http://www.lavrsen.dk/twiki/bin/view/Motion/BrightnessContrastPatch

Wim Lewis

* Added EXIF feature for jpeg images , http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch

Michal Licko
* Track pan/tilt support for uvcvideo ( Michal Licko ,Dirk Wesenberg and Angel Carpintero )
http://www.lavrsen.dk/twiki/bin/view/Motion/LinuxUvcTrackingPatch
Expand Down
35 changes: 28 additions & 7 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ $(DEPEND_FILE): *.h $(SRC)
################################################################################
dep depend fastdep: $(DEPEND_FILE)


################################################################################
# DEV, BUILD with developer flags #
################################################################################
dev: distclean autotools all


################################################################################
# GIT, BUILD with developer flags #
################################################################################
build-commit-git: distclean set-version-git all

################################################################################
# CURRENT, BUILD current svn trunk. #
################################################################################
Expand All @@ -148,15 +160,24 @@ set-version:
@sed -i 's/.\/commit-version.sh/.\/version.sh/g' configure.in
./configure --with-developer-flags

set-version-git:
@sed -i 's/.\/version.sh/.\/git-commit-version.sh/g' configure.in
autoconf
@sed -i 's/.\/git-commit-version.sh/.\/version.sh/g' configure.in
./configure --with-developer-flags


help:
@echo "--------------------------------------------------------------------------------"
@echo "make Build motion from local copy in your computer"
@echo "make current Build last version of motion from svn"
@echo "make build-commit Build last version of motion and prepare to commit to svn"
@echo "make clean Clean objects"
@echo "make distclean Clean everything"
@echo "make install Install binary , examples , docs and config files"
@echo "make uninstall Uninstall all installed files"
@echo "make Build motion from local copy in your computer"
@echo "make current Build last version of motion from svn"
@echo "make dev Build motion with dev flags"
@echo "make build-commit Build last version of motion and prepare to commit to svn"
@echo "make build-commit-git Build last version of motion and prepare to commit to git"
@echo "make clean Clean objects"
@echo "make distclean Clean everything"
@echo "make install Install binary , examples , docs and config files"
@echo "make uninstall Uninstall all installed files"
@echo "--------------------------------------------------------------------------------"
@echo

Expand Down
69 changes: 55 additions & 14 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.67 for motion trunkREVUNKNOWN.
# Generated by GNU Autoconf 2.67 for motion Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
Expand Down Expand Up @@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='motion'
PACKAGE_TARNAME='motion'
PACKAGE_VERSION='trunkREVUNKNOWN'
PACKAGE_STRING='motion trunkREVUNKNOWN'
PACKAGE_VERSION='Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee'
PACKAGE_STRING='motion Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

Expand Down Expand Up @@ -1216,7 +1216,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures motion trunkREVUNKNOWN to adapt to many kinds of systems.
\`configure' configures motion Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1277,7 +1277,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of motion trunkREVUNKNOWN:";;
short | recursive ) echo "Configuration of motion Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1419,7 +1419,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
motion configure trunkREVUNKNOWN
motion configure Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee
generated by GNU Autoconf 2.67
Copyright (C) 2010 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2016,7 +2016,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by motion $as_me trunkREVUNKNOWN, which was
It was created by motion $as_me Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee, which was
generated by GNU Autoconf 2.67. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -3633,8 +3633,8 @@ $as_echo "skipping" >&6; }
#
else if test "${FFMPEG_DIR}" = "yes"; then
# AUTODETECT STATIC/SHARED LIB
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting" >&5
$as_echo_n "checking for ffmpeg autodetecting... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg autodetecting libraries" >&5
$as_echo_n "checking for ffmpeg autodetecting libraries... " >&6; }

if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found in /usr/lib64" >&5
Expand Down Expand Up @@ -3669,8 +3669,8 @@ $as_echo "not found" >&6; }
echo ""
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg in -> ${FFMPEG_DIR} <-" >&5
$as_echo_n "checking for ffmpeg in -> ${FFMPEG_DIR} <-... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-" >&5
$as_echo_n "checking for ffmpeg libraries in -> ${FFMPEG_DIR} <-... " >&6; }
if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
Expand Down Expand Up @@ -3723,10 +3723,12 @@ $as_echo "found ${FFMPEG_DIR}/include/ffmpeg/avformat.h" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&5
$as_echo "found ${FFMPEG_DIR}/include/libavformat/avformat.h" >&6; }
FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES"
AVFORMAT="-I${FFMPEG_DIR}/include/libavformat"
elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&5
$as_echo "found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h" >&6; }
FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES"
AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
Expand Down Expand Up @@ -3757,7 +3759,9 @@ $as_echo "not found" >&6; }
$as_echo_n "checking file_protocol is defined in ffmpeg ?... " >&6; }
saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS="${FFMPEG_CFLAGS}"


CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
LIBS="$TEMP_LIBS"

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
Expand Down Expand Up @@ -3785,6 +3789,43 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking av_register_protocol is defined in ffmpeg ?" >&5
$as_echo_n "checking av_register_protocol is defined in ffmpeg ?... " >&6; }
saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
LIBS="$TEMP_LIBS"

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <avformat.h>
URLProtocol test_file_protocol;
int main(void){
av_register_protocol(&test_file_protocol);
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL"

else

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }


fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS

fi
fi
fi
Expand Down Expand Up @@ -5861,7 +5902,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by motion $as_me trunkREVUNKNOWN, which was
This file was extended by motion $as_me Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee, which was
generated by GNU Autoconf 2.67. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -5923,7 +5964,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
motion config.status trunkREVUNKNOWN
motion config.status Git-5bd495e48fd148bf73befc5763f8d29c5b2558ee
configured by $0, generated by GNU Autoconf 2.67,
with options \\"\$ac_cs_config\\"
Expand Down
44 changes: 38 additions & 6 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ if test "${FFMPEG_DIR}" = "no"; then
#
else if test "${FFMPEG_DIR}" = "yes"; then
# AUTODETECT STATIC/SHARED LIB
AC_MSG_CHECKING(for ffmpeg autodetecting)
AC_MSG_CHECKING(for ffmpeg autodetecting libraries)

if test -f /usr/lib64/libavcodec.a -o -f /usr/lib64/libavcodec.so && test -f /usr/lib64/libavformat.a -o -f /usr/lib64/libavformat.so ; then
AC_MSG_RESULT(found in /usr/lib64)
Expand Down Expand Up @@ -382,7 +382,7 @@ else if test "${FFMPEG_DIR}" = "yes"; then
echo ""
fi
else
AC_MSG_CHECKING(for ffmpeg in -> [${FFMPEG_DIR}] <-)
AC_MSG_CHECKING(for ffmpeg libraries in -> [${FFMPEG_DIR}] <-)
if test -f ${FFMPEG_DIR}/lib/libavcodec.a -o -f ${FFMPEG_DIR}/lib/libavcodec.so && test -f ${FFMPEG_DIR}/lib/libavformat.a -o -f ${FFMPEG_DIR}/lib/libavformat.so ; then
AC_MSG_RESULT(found)
FFMPEG_OK="found"
Expand Down Expand Up @@ -427,9 +427,11 @@ if test "${FFMPEG_OK}" = "found"; then
elif test -f ${FFMPEG_DIR}/include/libavformat/avformat.h; then
AC_MSG_RESULT(found ${FFMPEG_DIR}/include/libavformat/avformat.h)
FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include -DFFMPEG_NEW_INCLUDES"
AVFORMAT="-I${FFMPEG_DIR}/include/libavformat"
elif test -f ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h; then
AC_MSG_RESULT(found ${FFMPEG_DIR}/include/ffmpeg/libavformat/avformat.h)
FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES"
FFMPEG_CFLAGS="-I${FFMPEG_DIR}/include/ffmpeg -DFFMPEG_NEW_INCLUDES"
AVFORMAT="-I${FFMPEG_DIR}/include/ffmpeg/libavformat"
else
AC_MSG_RESULT(not found)
FFMPEG_OK="no_found"
Expand Down Expand Up @@ -458,9 +460,11 @@ if test "${FFMPEG_OK}" = "found"; then
AC_MSG_CHECKING([file_protocol is defined in ffmpeg ?])
saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS="${FFMPEG_CFLAGS}"


CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
LIBS="$TEMP_LIBS"
AC_COMPILE_IFELSE(
[
#include <avformat.h>
Expand All @@ -477,7 +481,35 @@ if test "${FFMPEG_OK}" = "found"; then
]
)
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS
LIBS=$saved_LIBS

AC_MSG_CHECKING([av_register_protocol is defined in ffmpeg ?])
saved_CFLAGS=$CFLAGS
saved_LIBS=$LIBS
CFLAGS="${FFMPEG_CFLAGS} ${AVFORMAT}"
LIBS="$TEMP_LIBS"

AC_COMPILE_IFELSE(
[
#include <avformat.h>
URLProtocol test_file_protocol;
int main(void){
av_register_protocol(&test_file_protocol);
return 0;
}
],
[
AC_MSG_RESULT(yes)
TEMP_CFLAGS="${TEMP_CFLAGS} -DHAVE_FFMPEG_AV_REGISTER_PROTOCOL"
],
[
AC_MSG_RESULT(no)
]
)

CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS

fi
fi
fi
Expand Down
18 changes: 15 additions & 3 deletions ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ void ffmpeg_init()
mpeg1_file_protocol.url_seek = file_protocol.url_seek;
mpeg1_file_protocol.url_close = file_protocol.url_close;

/* Register the append file protocol. */
#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
/* Register the append file protocol. */
#ifdef HAVE_FFMPEG_AV_REGISTER_PROTOCOL
av_register_protocol(&mpeg1_file_protocol);
#else
register_protocol(&mpeg1_file_protocol);
av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol));
#endif
}

Expand Down Expand Up @@ -472,7 +472,11 @@ struct ffmpeg *ffmpeg_open(char *ffmpeg_video_codec, char *filename,

ffmpeg->c = c = AVSTREAM_CODEC_PTR(ffmpeg->video_st);
c->codec_id = ffmpeg->oc->oformat->video_codec;
#if LIBAVCODEC_VERSION_MAJOR < 53
c->codec_type = CODEC_TYPE_VIDEO;
#else
c->codec_type = AVMEDIA_TYPE_VIDEO;
#endif
is_mpeg1 = c->codec_id == CODEC_ID_MPEG1VIDEO;

if (strcmp(ffmpeg_video_codec, "ffv1") == 0)
Expand Down Expand Up @@ -789,7 +793,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic)
if (ffmpeg->oc->oformat->flags & AVFMT_RAWPICTURE) {
/* Raw video case. The API will change slightly in the near future for that. */
#ifdef FFMPEG_AVWRITEFRAME_NEWAPI
#if LIBAVCODEC_VERSION_MAJOR < 53
pkt.flags |= PKT_FLAG_KEY;
#else
pkt.flags |= AV_PKT_FLAG_KEY;
#endif
pkt.data = (uint8_t *)pic;
pkt.size = sizeof(AVPicture);
ret = av_write_frame(ffmpeg->oc, &pkt);
Expand All @@ -813,7 +821,11 @@ int ffmpeg_put_frame(struct ffmpeg *ffmpeg, AVFrame *pic)
pkt.pts = AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->pts;

if (AVSTREAM_CODEC_PTR(ffmpeg->video_st)->coded_frame->key_frame)
#if LIBAVCODEC_VERSION_MAJOR < 53
pkt.flags |= PKT_FLAG_KEY;
#else
pkt.flags |= AV_PKT_FLAG_KEY;
#endif


pkt.data = ffmpeg->video_outbuf;
Expand Down

0 comments on commit 58627b0

Please sign in to comment.