From 39feb24d64b1d87a0a35ed0d3ede4e3ee0bcd3e9 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 3 Jul 2011 10:04:06 +0000 Subject: [PATCH] - possibly fixed #763 --- client/CVideoHandler.cpp | 12 ++++++++---- configure | 40 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp index 480a14300..314aa3f5b 100644 --- a/client/CVideoHandler.cpp +++ b/client/CVideoHandler.cpp @@ -5,7 +5,7 @@ #include #include "SDL_Extensions.h" #include "CPlayerInterface.h" -#include "boost/filesystem.hpp" +#include extern SystemOptions GDefaultOptions; //reads events and returns true on key down @@ -573,7 +573,7 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey) #endif #include -#include <../client/SDL_framerate.h> +#include "SDL_framerate.h" extern "C" { #include @@ -638,7 +638,7 @@ static URLProtocol lod_protocol = { lod_open, lod_read, NULL, // no write - lod_seek, + lod_seek, lod_close }; @@ -657,7 +657,11 @@ CVideoPlayer::CVideoPlayer() av_register_all(); // Register our protocol 'lod' so we can directly read from mmaped memory +#ifdef WITH_AV_REGISTER_PROTOCOL2 + av_register_protocol2(&lod_protocol, sizeof(lod_protocol)); +#else av_register_protocol(&lod_protocol); +#endif vidh = new CVidHandler(std::string(DATA_DIR "/Data/VIDEO.VID")); vidh_ab = new CVidHandler(std::string(DATA_DIR "/Data/H3ab_ahd.vid")); @@ -704,7 +708,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay) // Find the first video stream stream = -1; for(unsigned int i=0; inb_streams; i++) { - if (format->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) { + if (format->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) { stream = i; break; } diff --git a/configure b/configure index d85836fba..507931f79 100755 --- a/configure +++ b/configure @@ -16424,6 +16424,46 @@ if test "x$ac_cv_lib_avcodec_avcodec_decode_video2" = x""yes; then : AVCODEC_DECODE_VIDEO2="-DWITH_AVCODEC_DECODE_VIDEO2" fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_register_protocol2 in -lavcodec" >&5 +$as_echo_n "checking for av_register_protocol2 in -lavcodec... " >&6; } +if test "${ac_cv_lib_avcodec_av_register_protocol2+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavcodec $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 av_register_protocol2 (); +int +main () +{ +return av_register_protocol2 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avcodec_av_register_protocol2=yes +else + ac_cv_lib_avcodec_av_register_protocol2=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_av_register_protocol2" >&5 +$as_echo "$ac_cv_lib_avcodec_av_register_protocol2" >&6; } +if test "x$ac_cv_lib_avcodec_av_register_protocol2" = x""yes; then : + AVCODEC_DECODE_VIDEO2="-DWITH_AV_REGISTER_PROTOCOL2" +fi + FFMPEG_LIBS="$LIBS" FFMPEG_CXXFLAGS="$CFLAGS $AVCODEC_DECODE_VIDEO2" diff --git a/configure.ac b/configure.ac index 8cc361e1d..98106300c 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,7 @@ CFLAGS="$CFLAGS `pkg-config --cflags libavformat libswscale`" AC_CHECK_LIB(avformat,av_open_input_file,,AC_MSG_ERROR([FFMpeg avformat library not found. Please install it.])) AC_CHECK_LIB(swscale,sws_getContext,,AC_MSG_ERROR([FFMpeg swscale library not found. Please install it.])) AC_CHECK_LIB(avcodec,avcodec_decode_video2,AVCODEC_DECODE_VIDEO2="-DWITH_AVCODEC_DECODE_VIDEO2",) +AC_CHECK_LIB(avcodec,av_register_protocol2,AVCODEC_DECODE_VIDEO2="-DWITH_AV_REGISTER_PROTOCOL2",) FFMPEG_LIBS="$LIBS" FFMPEG_CXXFLAGS="$CFLAGS $AVCODEC_DECODE_VIDEO2"