浏览代码

- (linux) use empty video player if av_register_protocol function was not found

Ivan Savenko 13 年之前
父节点
当前提交
deb22b3674
共有 6 个文件被更改,包括 116 次插入5 次删除
  1. 4 0
      Global.h
  2. 3 3
      client/CMT.cpp
  3. 4 0
      client/CVideoHandler.cpp
  4. 4 0
      client/CVideoHandler.h
  5. 96 1
      configure
  6. 5 1
      configure.ac

+ 4 - 0
Global.h

@@ -92,6 +92,10 @@ typedef boost::int32_t si32; //signed int 32 bits (4 bytes)
 typedef boost::int16_t si16; //signed int 16 bits (2 bytes)
 typedef boost::int8_t si8; //signed int 8 bits (1 byte)
 
+#if defined _M_X64 && defined _WIN32 //Win64 -> cannot load 32-bit DLLs for video handling
+	#define DISABLE_VIDEO
+#endif
+
 #ifdef __GNUC__
 #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ )
 #endif

+ 3 - 3
client/CMT.cpp

@@ -269,15 +269,15 @@ int main(int argc, char** argv)
 	tlog0 <<"\tInitializing screen: "<<pomtime.getDiff() << std::endl;
 
 	// Initialize video
-#if defined _M_X64 && defined _WIN32 //Win64 -> cannot load 32-bit DLLs for video handling
+#if DISABLE_VIDEO
 	CCS->videoh = new CEmptyVideoPlayer;
 #else
 	if (!vm.count("disable-video"))
 		CCS->videoh = new CVideoPlayer;
 	else
 		CCS->videoh = new CEmptyVideoPlayer;
-
 #endif
+
 	tlog0<<"\tInitializing video: "<<pomtime.getDiff()<<std::endl;
 
 	//we can properly play intro only in the main thread, so we have to move loading to the separate thread
@@ -866,4 +866,4 @@ void requestChangingResolution()
 	ev.user.code = CHANGE_SCREEN_RESOLUTION;
 	SDL_PushEvent(&ev);
 }
-*/
+*/

+ 4 - 0
client/CVideoHandler.cpp

@@ -567,6 +567,8 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey)
 
 #else
 
+#ifndef DISABLE_VIDEO
+
 //Workaround for compile error in ffmpeg (UINT_64C was not declared)
 #define __STDC_CONSTANT_MACROS
 #ifdef _STDINT_H
@@ -1035,3 +1037,5 @@ CVideoPlayer::~CVideoPlayer()
 }
 
 #endif
+
+#endif

+ 4 - 0
client/CVideoHandler.h

@@ -223,6 +223,8 @@ public:
 
 #else
 
+#ifndef DISABLE_VIDEO
+
 #include <SDL.h>
 #include <SDL_video.h>
 #if SDL_VERSION_ATLEAST(1,3,0)
@@ -284,6 +286,8 @@ public:
 	ui32 offset;		// current data offset
 };
 
+#endif
+
 #define VIDEO_TAVERN "tavern.mjpg"
 #define VIDEO_WIN "win3.mjpg"
 #define VIDEO_LOSE_BATTLE_START "lbstart.mjpg"

+ 96 - 1
configure

@@ -17359,8 +17359,103 @@ else
 fi
 
 
+#check for one of register_protocol functions
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_register_protocol in -lavformat" >&5
+$as_echo_n "checking for av_register_protocol in -lavformat... " >&6; }
+if ${ac_cv_lib_avformat_av_register_protocol+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lavformat  $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_protocol ();
+int
+main ()
+{
+return av_register_protocol ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_avformat_av_register_protocol=yes
+else
+  ac_cv_lib_avformat_av_register_protocol=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_avformat_av_register_protocol" >&5
+$as_echo "$ac_cv_lib_avformat_av_register_protocol" >&6; }
+if test "x$ac_cv_lib_avformat_av_register_protocol" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBAVFORMAT 1
+_ACEOF
+
+  LIBS="-lavformat $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_register_protocol2 in -lavformat" >&5
+$as_echo_n "checking for av_register_protocol2 in -lavformat... " >&6; }
+if ${ac_cv_lib_avformat_av_register_protocol2+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lavformat  $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_avformat_av_register_protocol2=yes
+else
+  ac_cv_lib_avformat_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_avformat_av_register_protocol2" >&5
+$as_echo "$ac_cv_lib_avformat_av_register_protocol2" >&6; }
+if test "x$ac_cv_lib_avformat_av_register_protocol2" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBAVFORMAT 1
+_ACEOF
+
+  LIBS="-lavformat $LIBS"
+
+else
+  DISABLE_VIDEO="-DDISABLE_VIDEO"
+fi
+
+fi
+
+
 FFMPEG_LIBS="$LIBS"
-FFMPEG_CXXFLAGS="$CFLAGS $AVCODEC_DECODE_VIDEO2 $AV_REGISTER_PROTOCOL2"
+FFMPEG_CXXFLAGS="$CFLAGS $DISABLE_VIDEO"
 
 LIBS=$saved_LIBS
 CFLAGS=$saved_CFLAGS

+ 5 - 1
configure.ac

@@ -82,8 +82,12 @@ CFLAGS="$CFLAGS `pkg-config --cflags libavformat libswscale`"
 AC_CHECK_LIB(avformat,av_register_all,,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.]))
 
+#check for one of register_protocol functions
+AC_CHECK_LIB(avformat, av_register_protocol,,
+	AC_CHECK_LIB(avformat, av_register_protocol2,, DISABLE_VIDEO="-DDISABLE_VIDEO")) 
+
 FFMPEG_LIBS="$LIBS"
-FFMPEG_CXXFLAGS="$CFLAGS $AVCODEC_DECODE_VIDEO2 $AV_REGISTER_PROTOCOL2"
+FFMPEG_CXXFLAGS="$CFLAGS $DISABLE_VIDEO"
 
 LIBS=$saved_LIBS
 CFLAGS=$saved_CFLAGS