diff options
| -rw-r--r-- | .in | 25 | ||||
| -rw-r--r-- | AUTHORS | 0 | ||||
| -rw-r--r-- | ChangeLog | 0 | ||||
| -rw-r--r-- | Makefile.am | 3 | ||||
| -rw-r--r-- | NEWS | 0 | ||||
| -rw-r--r-- | README | 0 | ||||
| -rw-r--r-- | TODO | 22 | ||||
| -rw-r--r-- | acinclude.m4 | 1868 | ||||
| -rw-r--r-- | acinclude.m4.mine | 475 | ||||
| -rwxr-xr-x | autogen.sh | 71 | ||||
| -rw-r--r-- | configure.in | 166 | ||||
| -rw-r--r-- | pixmaps/camera.png | bin | 0 -> 2716 bytes | |||
| -rw-r--r-- | pixmaps/dummy.png | bin | 0 -> 2640 bytes | |||
| -rw-r--r-- | pixmaps/miav-logo-256x256.png | bin | 0 -> 39580 bytes | |||
| -rw-r--r-- | pixmaps/miav-logo-512x512.png | bin | 0 -> 91627 bytes | |||
| -rw-r--r-- | pixmaps/miav-logo-64x64.png | bin | 0 -> 5827 bytes | |||
| -rw-r--r-- | pixmaps/record.png | bin | 0 -> 1190 bytes | |||
| -rw-r--r-- | pixmaps/stop.png | bin | 0 -> 339 bytes | |||
| -rw-r--r-- | src/Makefile.am | 1 | ||||
| -rw-r--r-- | src/aboutwindow.cc | 89 | ||||
| -rw-r--r-- | src/aboutwindow.h | 77 | ||||
| -rw-r--r-- | src/camera.cc | 131 | ||||
| -rw-r--r-- | src/camera.h | 81 | ||||
| -rw-r--r-- | src/cprquerydialog.cc | 376 | ||||
| -rw-r--r-- | src/cprquerydialog.h | 136 | ||||
| -rw-r--r-- | src/decoder.cc | 171 | ||||
| -rw-r--r-- | src/decoder.h | 65 | ||||
| -rw-r--r-- | src/dvframe.cc | 41 | ||||
| -rw-r--r-- | src/dvframe.h | 47 | ||||
| -rw-r--r-- | src/encoder.cc | 158 | ||||
| -rw-r--r-- | src/encoder.h | 89 | ||||
| -rw-r--r-- | src/ffframe.cc | 38 | ||||
| -rw-r--r-- | src/ffframe.h | 38 | ||||
| -rw-r--r-- | src/img_encoder.cc | 161 | ||||
| -rw-r--r-- | src/img_encoder.h | 63 | ||||
| -rw-r--r-- | src/mainwindow.cc | 305 | ||||
| -rw-r--r-- | src/mainwindow.h | 100 | ||||
| -rw-r--r-- | src/messagebox.cc | 197 | ||||
| -rw-r--r-- | src/messagebox.h | 66 | ||||
| -rw-r--r-- | src/miav.cc | 120 | ||||
| -rw-r--r-- | src/miav.h | 36 | ||||
| -rw-r--r-- | src/miav_config.cc | 99 | ||||
| -rw-r--r-- | src/miav_config.h | 57 | ||||
| -rw-r--r-- | src/mov_encoder.cc | 207 | ||||
| -rw-r--r-- | src/mov_encoder.h | 57 | ||||
| -rw-r--r-- | src/network.cc | 139 | ||||
| -rw-r--r-- | src/network.h | 52 | ||||
| -rw-r--r-- | src/package.h | 53 | ||||
| -rw-r--r-- | src/player.cc | 155 | ||||
| -rw-r--r-- | src/player.h | 77 | ||||
| -rw-r--r-- | src/queue.h | 130 | ||||
| -rw-r--r-- | src/server.cc | 129 | ||||
| -rw-r--r-- | src/server.h | 44 | ||||
| -rw-r--r-- | src/socket.cc | 134 | ||||
| -rw-r--r-- | src/socket.h | 56 | ||||
| -rw-r--r-- | src/thread.cc | 34 | ||||
| -rw-r--r-- | src/thread.h | 42 | ||||
| -rw-r--r-- | src/util.cc | 56 | ||||
| -rw-r--r-- | src/util.h | 36 | ||||
| -rw-r--r-- | src/videowidget.cc | 46 | ||||
| -rw-r--r-- | src/videowidget.h | 45 | ||||
| -rwxr-xr-x | tools/CPUMaker | 27 | ||||
| -rwxr-xr-x | tools/MIaVAdd | 64 | ||||
| -rwxr-xr-x | tools/MocList | 11 | ||||
| -rwxr-xr-x | tools/MocMaker | 3 | 
65 files changed, 6968 insertions, 1 deletions
@@ -0,0 +1,25 @@ +/* .in.  Generated from configure.in by autoheader.  */ + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Version number of package */ +#undef VERSION + +/* Defined if on Win32 platform */ +#undef WIN32 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ChangeLog diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..bd780f0 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,3 @@ +AUTOMAKE_OPTIONS = gnu +SUBDIRS = src +DISTDIRS = pixmaps ffmpeg src
\ No newline at end of file @@ -0,0 +1,22 @@ + +Make generic gui + - Reorganize widgets to fit 19" display.			[done] + - Create button icons, to replace text.			[in progress] + +Make isolated cprquerydialog					[in progress] + - To replace mgui + +Clean up cprquerydialog + - merge code into a single file, for simplicity.		[done] + +Finish config parser. + +Make library detection in configure script + - LibSDL							[done] + - LibJpeg							[done] + - ffmpeg + +Include ffmpeg in project					[ NO ] + +Incorporate server into project + - Make it standalone compilable (through flag to configure)	[done] diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..694ec25 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,1868 @@ +# as.m4 +# Figure out how to run the assembler. + +# AM_PROG_AS +AC_DEFUN([AM_PROG_AS], +[# By default we simply use the C compiler to build assembly code. +AC_REQUIRE([AC_PROG_CC]) +: ${AS='$(CC)'} +# Set ASFLAGS if not already set. +: ${ASFLAGS='$(CFLAGS)'} +AC_SUBST(AS) +AC_SUBST(ASFLAGS) +]) + +dnl AC_GCC_VERSION +dnl check for compiler version +dnl sets COMPILER_VERSION and GCC_VERSION + +AC_DEFUN([AC_CC_VERSION], +[ +    AC_MSG_CHECKING([C compiler version]) +    COMPILER_VERSION=`$CC -v 2>&1 | grep version` +    if test -z "`echo $COMPILER_VERSION | grep gcc`" ; then +	GCC_VERSION=unknown +	AC_MSG_RESULT([unknown]) +    else +        dnl Ok, how to turn $3 into the real $3 +	GCC_VERSION=`echo $COMPILER_VERSION | sed -e 's/.*\ .*\ \(.*\)\ .*/\1/'` +	echo gcc $GCC_VERSION +    fi +]) + +dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) +dnl check if $CC supports a given set of cflags + +AC_DEFUN([AC_TRY_CFLAGS], +[ +    AC_MSG_CHECKING([if $CC supports $1 flag(s)]) +    ac_save_CFLAGS=$CFLAGS +    CFLAGS=$1 +    AC_TRY_COMPILE([], [], [ ac_cv_try_cflags_ok=yes ],[ ac_cv_try_cflags_ok=no ]) +    CFLAGS=$ac_save_CFLAGS +    AC_MSG_RESULT([$ac_cv_try_cflags_ok]) +    if test x$ac_cv_try_cflags_ok = xyes; then +        ifelse([$2], [], [:], [$2]) +    else +        ifelse([$3], [], [:], [$3]) +    fi +]) + +dnl AC_TRY_CXXFLAGS (CXXFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) +dnl check if $CXX supports a given set of cxxflags + +AC_DEFUN([AC_TRY_CXXFLAGS], +[ +    AC_MSG_CHECKING([if $CXX supports $1 flag(s)]) +    AC_LANG_SAVE +    AC_LANG_CPLUSPLUS +    ac_save_CXXFLAGS=$CXXFLAGS +    CXXFLAGS=$1 +    AC_TRY_COMPILE([], [], [ ac_cv_try_cxxflags_ok=yes ],[ ac_cv_try_cxxflags_ok=no ]) +    CXXFLAGS=$ac_save_CXXFLAGS +    AC_MSG_RESULT([$ac_cv_try_cxxflags_ok]) +    AC_LANG_RESTORE +    if test x$ac_cv_try_cxxflags_ok = xyes; then +        ifelse([$2], [], [:], [$2]) +    else +        ifelse([$3], [], [:], [$3]) +    fi +]) + +dnl AC_CHECK_GNU_EXTENSIONS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) + +AC_DEFUN([AC_CHECK_GNU_EXTENSIONS], +[ +    AC_CACHE_CHECK([if you need GNU extensions], ac_cv_gnu_extensions, +    [ AC_TRY_COMPILE([#include <features.h>], [ +#ifndef __GNU_LIBRARY__ +gnuneeded +#endif +    ], [ ac_cv_gnu_extensions=yes ], [ ac_cv_gnu_extensions=no ]) +    ]) +    if test x$ac_cv_gnu_extensions = xyes; then +        ifelse([$1], [], [:], [$1]) +    dnl AC_DEFINE_UNQUOTED(_GNU_SOURCE) +    else +        ifelse([$2], [], [:], [$2]) +    fi +]) + +dnl +dnl AC_CHECK_GNU_VECTOR([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl +AC_DEFUN([AC_CHECK_GNU_VECTOR], +[ +    AC_CACHE_CHECK([if gcc supports vector builtins], ac_cv_gnu_builtins, +    [ AC_TRY_COMPILE([#include <features.h>], [ +int main(void) {  +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) +return 0; +#else +#error no vector builtins +#endif +} +    ], [ ac_cv_gnu_builtins=yes ], [ ac_cv_gnu_builtins=no ]) +    ]) +    if test x$ac_cv_gnu_builtins = xyes; then +        ifelse([$1], [], [:], [$1]) +    else +        ifelse([$2], [], [:], [$2]) +    fi +]) +# Configure paths for DivX + +dnl Usage: +dnl AM_PATH_DIVX([ACTION-IF-FOUND-DECORE [, ACTION-IF-NOT-FOUND-DECORE +dnl		 [, ACTION-IF-FOUND-ENCORE, [ACTION-IF-NOT-FOUND-DECORE]]]] ) +dnl Test for libdivxdecore, libdivxencore, and define XVID_CFLAGS and XVID_LIBS +dnl +AC_DEFUN([AM_PATH_DIVX], +[ +    AC_ARG_WITH(divx4_prefix, [  --with-divx4-prefix=PFX where divx4linux is installed. (optional)], +	    [], with_divx4_prefix=) + +    have_divx_decore=no +    have_divx_encore=no +    DIVX_CFLAGS="" +    DIVX_LIBS="" +    save_CPPFLAGS=$CPPFLAGS +    if test -n "$with_divx4_prefix" ; then +	dnl user has specified extra path for DivX4 instalation +	CPPFLAGS="-I$with_divx4_prefix $CPPFLAGS" +	AC_CHECK_HEADER(include/decore.h, +			DIVX_CFLAGS="-I$with_divx4_prefix/include" +			DIVX_LIBS="-L$with_divx4_prefix/lib" +			have_divx_decore=yes) +	if test x$have_divx_decore = xno ; then +	    CPPFLAGS="-I$with_divx4_prefix $CPPFLAGS" +	    AC_CHECK_HEADER(decore.h, +			    DIVX_CFLAGS="-I$with_divx4_prefix" +			    DIVX_LIBS="-L$with_divx4_prefix" +			    have_divx_decore=yes) +	fi +    else +	AC_CHECK_HEADER(decore.h, have_divx_decore=yes) +    fi + +    AC_CHECK_HEADER(encore2.h, have_divx_encore=yes) +    CPPFLAGS=$save_CPPFLAGS + +    if test x$have_divx_decore = xyes ; then +	AC_CHECK_LIB(divxdecore, decore, +		     DIVX_LIBS="$DIVX_LIBS -ldivxdecore", +		     have_divx_decore=no, $DIVX_LIBS) +    fi + +    if test x$have_divx_encore = xyes ; then +	AC_CHECK_LIB(divxencore, encore, +		     DIVX_LIBS="$DIVX_LIBS -ldivxencore", +		     have_divx_encore=no, $DIVX_LIBS) +    fi + +    if test x$have_divx_decore = xyes ; then +        ifelse([$1], , :, [$1]) +    else +        ifelse([$2], , :, [$2]) +    fi + +    if test x$have_divx_encore = xyes ; then +        ifelse([$3], , :, [$3]) +    else +        ifelse([$4], , :, [$4]) +    fi + +    AC_SUBST(DIVX_CFLAGS) +    AC_SUBST(DIVX_LIBS) +]) + +dnl  +dnl slightly modified  dmalloc.m4 +dnl  + +AC_DEFUN([AC_WITH_DMALLOCTH], +[ +AC_ARG_WITH(dmallocth, [  --with-dmallocth        use dmallocth. (see: http://www.dmalloc.com)], +	    [], with_dmallocth=no) +if test x$with_dmallocth = xyes ; then +    AC_MSG_RESULT([enabling dmalloc thread debugging]) +    AC_CHECK_HEADER(dmalloc.h, , AC_MSG_ERROR([header file 'dmalloc.h' is missing!])) +    AC_DEFINE(WITH_DMALLOCTH,1, [Define if using the dmallocth debugging malloc package]) +    LIBS="$LIBS -ldmallocth" +    LDFLAGS="$LDFLAGS -g" +fi +]) +# Configure paths for libfaad + +dnl AM_PATH_FAAD([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libfaad, and define FAAD_CFLAGS and FAAD_LIBS +dnl +AC_DEFUN([AM_PATH_FAAD], +[ +    AC_ARG_WITH(faad_prefix, [  --with-faad-prefix=PFX  where FAAD is installed. (optional)], +		[], with_faad_prefix="") + +    AC_ARG_ENABLE(faadtest, [  --disable-faadtest      do not try to compile and run a test FAAD program], +		  [], enable_faadtest=yes) + +    FAAD_CFLAGS="" +    FAAD_LIBS="" + +    have_faad=no +    ac_save_CPPFLAGS=$CPPFLAGS +    if test -n "$with_faad_prefix" ; then +	dnl user has specified extra path for FAAD instalation +	CPPFLAGS="-I$with_faad_prefix $CPPFLAGS" +	AC_CHECK_HEADER(faad.h, +			FAAD_CFLAGS="-I$with_faad_prefix" +			FAAD_LIBS="-L$with_faad_prefix" +			have_faad=yes) +    else +	AC_CHECK_HEADER(faad.h, have_faad=yes) +    fi +    CPPFLAGS=$ac_save_CPPFLAGS + +dnl +dnl Now check if the installed FAAD is sufficiently new. +dnl +    if test x$have_faad = xyes ; then +	FAAD_LIBS="$FAAD_LIBS -lfaad -lm" +	if test x$enable_faadtest = xyes ; then +	    AC_CACHE_CHECK([for faacDecOpen in -lfaad], +			  ac_cv_val_HAVE_FAAD, +			  [ rm -f conf.faadtest +			  ac_save_CFLAGS=$CFLAGS +			  ac_save_LIBS=$LIBS +			  CFLAGS="$CFLAGS $FAAD_CFLAGS" +			  LIBS="$LIBS $FAAD_LIBS" +			  AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <faad.h> + +int main () +{ +	faacDecHandle h = faacDecOpen(); +	system("touch conf.faadtest"); +	return 0; +}			  ], +			  [ ac_cv_val_HAVE_FAAD=yes ], +			  [ ac_cv_val_HAVE_FAAD=no ], +			  [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) +			  CFLAGS=$ac_save_CFLAGS +			  LIBS=$ac_save_LIBS]) +	    test x$ac_cv_val_HAVE_FAAD = xno && have_faad = xno +	fi +     fi + +     if test x$have_faad = xyes ; then +	 ifelse([$1], , :, [$1]) +     else +	 if test -n "$FAAD_LIBS" -a x$enable_faadtest = xyes -a ! -f conf.faadtest ; then +		    AC_MSG_WARN([Could not run FAAD test program, checking why...]) +		    CFLAGS="$CFLAGS $FAAD_CFLAGS" +		    LIBS="$LIBS $FAAD_LIBS" +		    AC_TRY_LINK([ +#include <stdio.h> +#include <faad.h> +], [ return 0 ], [ +AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means +*** that the run-time linker is not finding FAAD or finding the wrong +*** version of FAAD. If it is not finding FAAD, you'll need to set your +*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point +*** to the installed location  Also, make sure you have run ldconfig if that +*** is required on your system +*** +*** If you have an old version installed, it is best to remove it, although +*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ +AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the +*** exact error that occured. This usually means FAAD was incorrectly installed.])]) +		CFLAGS="$ac_save_CFLAGS" +		LIBS="$ac_save_LIBS" +	fi +	FAAD_CFLAGS="" +	FAAD_LIBS="" +	ifelse([$2], , :, [$2]) +    fi +    AC_SUBST(FAAD_CFLAGS) +    AC_SUBST(FAAD_LIBS) +    rm -f conf.faadtest +]) + +dnl Check for lrintf presence +dnl currently needed only by ffmpeg +AC_DEFUN([AC_FUNC_LRINTF], +[ +    AC_CACHE_CHECK([whether system declares lrintf function in math.h], +		   ac_cv_val_HAVE_LRINTF, +		   [ac_save_CFLAGS=$CFLAGS +                   CFLAGS="$CFLAGS -O2" +                   AC_TRY_RUN([ +		    #define _ISOC9X_SOURCE  1 +		    #include <math.h> +		    int main( void ) { return (lrintf(3.999f) > 0)?0:1; } ], +		   [ ac_cv_val_HAVE_LRINTF=yes ], [ ac_cv_val_HAVE_LRINTF=no ], +		   [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) +                   CFLAGS=$ac_save_CFLAGS +		   ]) +    if test x$ac_cv_val_HAVE_LRINTF = xyes; then +	AC_DEFINE(HAVE_LRINTF, 1, [Define if you have lrintf on your system.]) +    fi +]) + + +dnl Usage: +dnl AM_PATH_FFMPEG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for ffmpeg, and define FFMPEG_CFLAGS and FFMPEG_LIBS + +AC_DEFUN([AM_PATH_FFMPEG], +[ +    AC_REQUIRE([AC_FUNC_LRINTF]) + +    dnl !!! - it really sucks - Makefile.am can't be optimized even by +    dnl !!! preparing some extra variable forward +    dnl !!! FFAVFORMAT_SRC= + +    AC_REQUIRE([AC_CHECK_OSS]) +    test x$enable_oss = xyes && AC_DEFINE(CONFIG_AUDIO_OSS, 1, [Define if you want to have ffmpeg OSS audio support compiled.]) + +    AC_REQUIRE([AC_CHECK_V4L]) +    test x$enable_v4l = xyes && AC_DEFINE(CONFIG_VIDEO4LINUX, 1, [Define if you have video4linux device. (ffmpeg)]) + +    AC_REQUIRE([AC_FIND_ZLIB]) +    test x$have_zlib = xyes && AC_DEFINE(CONFIG_ZLIB, 1, [Define if you have z library (-lz) (ffmpeg)]) + +    AC_ARG_ENABLE(ffmpeg_faadbin, [  --enable-ffmpeg-faadbin build ffmpeg with FAAD binary support. (default=yes)], +	          [], enable_ffmpeg_faadbin=yes) +    test x$enable_ffmpeg_faadbin = xyes && AC_DEFINE(CONFIG_FAADBIN, 1, [Define if you want to build support for runtime linked libfaad.]) +    AC_REQUIRE([AM_PATH_FAAD]) +    test x$have_faad = xyes && AC_DEFINE(CONFIG_FAAD, 1, [Define if you want to have AAC support compiled. (ffmpeg)]) + +    AC_ARG_ENABLE(ffmpeg_risky, [  --enable-ffmpeg-risky   build ffmpeg risky code. (default=yes)], +	          [], enable_ffmpeg_risky=yes) + +    AC_ARG_ENABLE(ffmpeg_a52, [  --enable-ffmpeg-a52     build ffmpeg with A52 (AC3) support. (default=yes)], +		  [], enable_ffmpeg_a52=yes) +    if test x$enable_ffmpeg_a52 = xyes ; then +	AC_DEFINE(HAVE_FFMPEG_A52, 1, [Define if you want to use ffmpeg A52 audio decoder.]) +	AC_ARG_ENABLE(ffmpeg_a52bin, [  --enable-ffmpeg-a52bin  A52 plugin dlopens liba52.so.0 at runtime (default=no)], +		      [], enable_ffmpeg_a52bin=no) + +        if test x$enable_ffmpeg_a52bin = xyes ; then +            AC_DEFINE(CONFIG_A52BIN, 1, [Define if you want to build ffmpeg with A52 dlopened decoder.]) +        fi +    fi + +    test x$enable_ffmpeg_risky = xyes && AC_DEFINE(CONFIG_RISKY, 1, [Define if you want to compile patent encumbered codecs. (ffmpeg)]) + +    AC_DEFINE(CONFIG_ENCODERS, 1, [Define if you want to build ffmpeg encoders.]) +    AC_DEFINE(CONFIG_DECODERS, 1, [Define if you want to build ffmpeg decoders.]) +    AC_DEFINE(CONFIG_AC3, 1, [Define if you want to build ffmpeg with AC3 decoder.]) +    AC_DEFINE(SIMPLE_IDCT, 1, [Define if you want to build ffmpeg with simples idct.]) +    AC_DEFINE(CONFIG_NETWORK, 1, [Define if you want to build ffmpeg with network support.]) +    AC_DEFINE(CONFIG_MPEGAUDIO_HP, 1, [Define if you want to have highquality ffmpeg mpeg audio support compiled.]) +    AC_DEFINE(HAVE_PTHREADS, 1, [Define if you want to have ffmpeg pthread support compiled.]) + +    if test -n "$ffmpeg_profiling" ; then +	AC_DEFINE(HAVE_GPROF, 1, [Define if you want to build ffmpeg with gprof support.]) +    fi + +    test -z "$FFMPEG_CFLAGS" && FFMPEG_CFLAGS="-O4 $DEFAULT_FLAGS" +    FFMPEG_CFLAGS="$FFMPEG_CFLAGS $DEFAULT_DEFINES" + +    AC_CHECK_GNU_VECTOR(FFMPEG_SSE="-msse"; +		        AC_DEFINE(HAVE_BUILTIN_VECTOR, 1, [Define if your compiler supports vector builtins (MMX).]), []) +    AC_SUBST(FFMPEG_CFLAGS) +    AC_SUBST(FFMPEG_SSE) + +    AM_CONDITIONAL(AMM_BUILD_STRPTIME, test x$ac_cv_func_strptime != xyes ) + +dnl ffmpeg_x86opt= +dnl test x$enable_x86opt = xno && ffmpeg_x86opt="--disable-mmx" +dnl AC_MSG_RESULT([=== configuring ffmpeg ===]) +dnl    ( cd $srcdir/ffmpeg ; \ +dnl      ./configure --prefix=$prefix --cc=$CC \ +dnl		$ffmpeg_profiling $ffmpeg_cpu \ +dnl		$ffmpeg_x86opt --disable-mp3lib \ +dnl		--enable-simple_idct ) +]) +# Configure paths for FreeType2 +# Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor + +dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS +dnl +AC_DEFUN([AC_CHECK_FT2], +[dnl +dnl Get the cflags and libraries from the freetype-config script +dnl +AC_ARG_WITH(ft-prefix, +[  --with-ft-prefix=PREFIX prefix where FreeType is installed (optional)], +            ft_config_prefix="$withval", ft_config_prefix="") +AC_ARG_WITH(ft-exec-prefix, +[  --with-ft-exec-prefix=PFX exec prefix where FreeType is installed (optional)], +            ft_config_exec_prefix="$withval", ft_config_exec_prefix="") +AC_ARG_ENABLE(freetypetest, +[  --disable-freetypetest  Do not try to compile and run FT2 test program], +              [], enable_fttest=yes) + +if test x$ft_config_exec_prefix != x ; then +  ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix" +  if test x${FT2_CONFIG+set} != xset ; then +    FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config +  fi +fi +if test x$ft_config_prefix != x ; then +  ft_config_args="$ft_config_args --prefix=$ft_config_prefix" +  if test x${FT2_CONFIG+set} != xset ; then +    FT2_CONFIG=$ft_config_prefix/bin/freetype-config +  fi +fi +AC_PATH_PROG(FT2_CONFIG, freetype-config, no) + +min_ft_version=ifelse([$1], ,6.1.0,$1) +AC_MSG_CHECKING(for FreeType - version >= $min_ft_version) +no_ft="" +if test "$FT2_CONFIG" = "no" ; then +  no_ft=yes +else +  FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags` +  FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs` +  ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` +  ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` +  ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` +  ft_min_major_version=`echo $min_ft_version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` +  ft_min_minor_version=`echo $min_ft_version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` +  ft_min_micro_version=`echo $min_ft_version | \ +         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` +  if test x$enable_fttest = xyes ; then +    ft_config_is_lt="" +    if test $ft_config_major_version -lt $ft_min_major_version ; then +      ft_config_is_lt=yes +    else +      if test $ft_config_major_version -eq $ft_min_major_version ; then +        if test $ft_config_minor_version -lt $ft_min_minor_version ; then +          ft_config_is_lt=yes +        else +          if test $ft_config_minor_version -eq $ft_min_minor_version ; then +            if test $ft_config_micro_version -lt $ft_min_micro_version ; then +              ft_config_is_lt=yes +            fi +          fi +        fi +      fi +    fi +    if test x$ft_config_is_lt = xyes ; then +      no_ft=yes +    else +      ac_save_CFLAGS="$CFLAGS" +      ac_save_LIBS="$LIBS" +      CFLAGS="$CFLAGS $FT2_CFLAGS" +      LIBS="$FT2_LIBS $LIBS" +dnl +dnl Sanity checks for the results of freetype-config to some extent +dnl +      AC_TRY_RUN([ +#include <ft2build.h> +#include FT_FREETYPE_H +#include <stdio.h> +#include <stdlib.h> + +int +main() +{ +  FT_Library library; +  FT_Error error; + +  error = FT_Init_FreeType(&library); + +  if (error) +    return 1; +  else +  { +    FT_Done_FreeType(library); +    return 0; +  } +} +],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +      CFLAGS="$ac_save_CFLAGS" +      LIBS="$ac_save_LIBS" +    fi             # test $ft_config_version -lt $ft_min_version +  fi               # test x$enable_fttest = xyes +fi                 # test "$FT2_CONFIG" = "no" +if test x$no_ft = x ; then +   AC_MSG_RESULT(yes) +   ifelse([$2], , :, [$2]) +else +   AC_MSG_RESULT(no) +   if test "$FT2_CONFIG" = "no" ; then +     echo "*** The freetype-config script installed by FreeType 2 could not be found." +     echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in" +     echo "*** your path, or set the FT2_CONFIG environment variable to the" +     echo "*** full path to freetype-config." +   else +     if test x$ft_config_is_lt = xyes ; then +       echo "*** Your installed version of the FreeType 2 library is too old." +       echo "*** If you have different versions of FreeType 2, make sure that" +       echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix" +       echo "*** are used, or set the FT2_CONFIG environment variable to the" +       echo "*** full path to freetype-config." +     else +       echo "*** The FreeType test program failed to run.  If your system uses" +       echo "*** shared libraries and they are installed outside the normal" +       echo "*** system library path, make sure the variable LD_LIBRARY_PATH" +       echo "*** (or whatever is appropiate for your system) is correctly set." +     fi +   fi +   FT2_CFLAGS="" +   FT2_LIBS="" +   ifelse([$3], , :, [$3]) +fi +AC_SUBST(FT2_CFLAGS) +AC_SUBST(FT2_LIBS) +]) +# Configure paths for  iconv + +dnl Usage: +dnl AC_ICONV(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for ares, and defines +dnl - ICONV_CFLAGS (compiler flags) +dnl - ICONV_LIBS (linker flags, stripping and path) +dnl prerequisites: + +AC_DEFUN([AC_ICONV], +[ +    dnl check it it's part of the libc +    AC_CHECK_LIB(c, iconv_open, ac_cv_have_iconv=yes, ac_cv_have_iconv=no) + +    ICONV_CFLAGS= +    ICONV_LIBS= +    AC_ARG_WITH(iconv, [  --with-iconv=path       path for extra iconv library], +    [ +	if test x$ac_cv_have_iconv = xno; then +	    ac_iconv_path= +	    case "$with_iconv" in +	    'yes') ac_iconv_path="/usr" ;; +	    'no') ;; +	    *) ac_iconv_path=$with_iconv ;; +	    esac +	    if test -n "$ac_iconv_path"; then +		ac_save_ICONVLIBS=$LIBS +		LIBS="-L$ac_iconv_path/lib $LIBS" +		AC_CHECK_LIB(iconv, iconv_open, ac_cv_have_iconv=yes,) +		if test x$ac_cv_have_iconv = xyes ; then +		    ICONV_LIBS="-liconv" +		    if test "$ac_iconv_path" != "/usr"; then +			ICONV_CFLAGS="-I$ac_iconv_path/include" +			ICONV_LIBS="$ac_iconv_path/lib $ICONV_LIBS" +		    fi +		fi +		LIBS=$ac_save_ICONVLIBS +	    fi +	fi +    ]) +     +    if test x$ac_cv_have_iconv = xyes ; then +    	AC_MSG_CHECKING([for iconv declaration]) +	AC_CACHE_VAL(ac_cv_proto_iconv, [ +	AC_TRY_COMPILE([ +#include <stdlib.h> +#include <iconv.h> +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char**, size_t*, char**, size_t*); +#else +size_t iconv(); +#endif +], [], +	[ ac_cv_proto_iconv="" ], [ ac_cv_proto_iconv="const" ]) ]) +	AC_DEFINE_UNQUOTED(ICONV_CONST_CAST, $ac_cv_proto_iconv, [Use casting for iconv's inputbuffer - don't ask me.]) +	if test x$ac_cv_proto_iconv = xconst ; then +	    AC_MSG_RESULT([using const]) +	else +	    AC_MSG_RESULT([not using const]) +	fi +    	ifelse([$2], , :, [$2]) +    else +	ICONV_CFLAGS="" +	ICONV_LIBS="" +	ifelse([$3], , :, [$3]) +    fi + +    AC_SUBST(ICONV_CFLAGS) +    AC_SUBST(ICONV_LIBS) +]) +# Configure paths for libogg +# Jack Moffitt <jack@icecast.org> 10-21-2000 +# Shamelessly stolen from Owen Taylor and Manish Singh + +dnl AM_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS +dnl +AC_DEFUN([AM_PATH_OGG], +[dnl +dnl Get the cflags and libraries +dnl +AC_ARG_WITH(ogg-prefix,[  --with-ogg-prefix=PFX   prefix where libogg is installed. (optional)], ogg_prefix="$withval", ogg_prefix="") +AC_ARG_ENABLE(oggtest, [  --disable-oggtest       do not try to compile and run a test Ogg program.],, enable_oggtest=yes) + +  if test "x$ogg_prefix" != "xNONE" ; then +    ogg_args="$ogg_args --prefix=$ogg_prefix" +    OGG_CFLAGS="-I$ogg_prefix/include" +    OGG_LIBS="-L$ogg_prefix/lib" +  elif test "$prefix" != ""; then +    ogg_args="$ogg_args --prefix=$prefix" +    OGG_CFLAGS="-I$prefix/include" +    OGG_LIBS="-L$prefix/lib" +  fi + +  OGG_LIBS="$OGG_LIBS -logg" + +  AC_MSG_CHECKING(for Ogg) +  no_ogg="" + + +  if test "x$enable_oggtest" = "xyes" ; then +    ac_save_CFLAGS="$CFLAGS" +    ac_save_LIBS="$LIBS" +    CFLAGS="$CFLAGS $OGG_CFLAGS" +    LIBS="$LIBS $OGG_LIBS" +dnl +dnl Now check if the installed Ogg is sufficiently new. +dnl +      rm -f conf.oggtest +      AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ogg/ogg.h> + +int main () +{ +  system("touch conf.oggtest"); +  return 0; +} + +],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +  fi + +  if test "x$no_ogg" = "x" ; then +     AC_MSG_RESULT(yes) +     ifelse([$1], , :, [$1]) +  else +     AC_MSG_RESULT(no) +     if test -f conf.oggtest ; then +       : +     else +       echo "*** Could not run Ogg test program, checking why..." +       CFLAGS="$CFLAGS $OGG_CFLAGS" +       LIBS="$LIBS $OGG_LIBS" +       AC_TRY_LINK([ +#include <stdio.h> +#include <ogg/ogg.h> +],     [ return 0; ], +       [ echo "*** The test program compiled, but did not run. This usually means" +       echo "*** that the run-time linker is not finding Ogg or finding the wrong" +       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" +       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" +       echo "*** to the installed location  Also, make sure you have run ldconfig if that" +       echo "*** is required on your system" +       echo "***" +       echo "*** If you have an old version installed, it is best to remove it, although" +       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], +       [ echo "*** The test program failed to compile or link. See the file config.log for the" +       echo "*** exact error that occured. This usually means Ogg was incorrectly installed" +       echo "*** or that you have moved Ogg since it was installed. In the latter case, you" +       echo "*** may want to edit the ogg-config script: $OGG_CONFIG" ]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +     fi +     OGG_CFLAGS="" +     OGG_LIBS="" +     ifelse([$2], , :, [$2]) +  fi +  AC_SUBST(OGG_CFLAGS) +  AC_SUBST(OGG_LIBS) +  rm -f conf.oggtest +]) + +dnl Usage: +dnl AC_CHECK_OSS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for OSS audio interface, and defines +dnl prerequisites: + +AC_DEFUN([AC_CHECK_OSS], +[ +    AC_ARG_ENABLE(oss, [  --enable-oss            support the OSS audio API. (autodetect)], +		  [], enable_oss=yes) +    if test x$enable_oss = xyes; then +	AC_CACHE_CHECK([for OSS audio support], ac_cv_val_have_oss_audio, +	    [AC_TRY_COMPILE([ +		  #ifdef __NetBSD__ +		  #include <sys/ioccom.h> +		  #include <soundcard.h> +		  #else +		  #include <sys/soundcard.h> +		  #endif +		],[ int arg = SNDCTL_DSP_SETFRAGMENT; ], +		[ ac_cv_val_have_oss_audio=yes ], [ ac_cv_val_have_oss_audio=no ]) +	    ]) +	enable_oss=$ac_cv_val_have_oss_audio +    fi +     +    if test x$enable_oss = xyes; then +	AC_CHECK_LIB([ossaudio], [_oss_ioctl]) +        ifelse([$1], , :, [$1]) +    else +        ifelse([$2], , :, [$2]) +    fi +]) + + +dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) +dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page +dnl also defines GSTUFF_PKG_ERRORS on error +AC_DEFUN([PKG_CHECK_MODULES], [ +  succeeded=no + +  if test -z "$PKG_CONFIG"; then +    AC_PATH_PROG(PKG_CONFIG, pkg-config, no) +  fi + +  if test "$PKG_CONFIG" = "no" ; then +     echo "*** The pkg-config script could not be found. Make sure it is" +     echo "*** in your path, or set the PKG_CONFIG environment variable" +     echo "*** to the full path to pkg-config." +     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." +  else +     PKG_CONFIG_MIN_VERSION=0.9.0 +     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then +        AC_MSG_CHECKING(for $2) + +        if $PKG_CONFIG --exists "$2" ; then +            AC_MSG_RESULT(yes) +            succeeded=yes + +            AC_MSG_CHECKING($1_CFLAGS) +            $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` +            AC_MSG_RESULT($$1_CFLAGS) + +            AC_MSG_CHECKING($1_LIBS) +            $1_LIBS=`$PKG_CONFIG --libs "$2"` +            AC_MSG_RESULT($$1_LIBS) +        else +            $1_CFLAGS="" +            $1_LIBS="" +            ## If we have a custom action on failure, don't print errors, but  +            ## do set a variable so people can do so. +            $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` +            ifelse([$4], ,echo $$1_PKG_ERRORS,) +        fi + +        AC_SUBST($1_CFLAGS) +        AC_SUBST($1_LIBS) +     else +        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." +        echo "*** See http://www.freedesktop.org/software/pkgconfig" +     fi +  fi + +  if test $succeeded = yes; then +     ifelse([$3], , :, [$3]) +  else +     ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) +  fi +]) + +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor +# slightly modified for avifile + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN([AM_PATH_SDL], +[dnl  +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   prefix where SDL is installed. (optional)], +            sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX exec prefix where SDL is installed. (optional)], +            sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [  --disable-sdltest       do not try to compile and run a test SDL program.], +		    , enable_sdltest=yes) + +  if test x$sdl_exec_prefix != x ; then +     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" +     if test x${SDL_CONFIG+set} != xset ; then +        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config +     fi +  fi +  if test x$sdl_prefix != x ; then +     sdl_args="$sdl_args --prefix=$sdl_prefix" +     if test x${SDL_CONFIG+set} != xset ; then +        SDL_CONFIG=$sdl_prefix/bin/sdl-config +     fi +  fi +  if test -z "$SDL_CONFIG"; then +      AC_CHECK_PROGS(SDL_MY_CONFIG, sdl-config sdl11-config, "") +      if test -n "$SDL_MY_CONFIG"; then +	   SDL_CONFIG=`which $SDL_MY_CONFIG` +	   echo "setting SDL_CONFIG to $SDL_CONFIG" +      fi +  fi + +  AC_REQUIRE([AC_CANONICAL_TARGET]) +  PATH="$prefix/bin:$prefix/usr/bin:$PATH" +  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) +  min_sdl_version=ifelse([$1], ,0.11.0,$1) +  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) +  no_sdl="" +  if test "$SDL_CONFIG" = "no" ; then +    no_sdl=yes +  else +    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` +    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs | sed -e 's!-L/usr/lib[[^/]]!!g'` + +    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` +    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` +    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` +    if test "x$enable_sdltest" = "xyes" ; then +      ac_save_CFLAGS="$CFLAGS" +      ac_save_LIBS="$LIBS" +      CFLAGS="$CFLAGS $SDL_CFLAGS" +      LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl +      rm -f conf.sdltest +      AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "SDL.h" + +char* +my_strdup (char *str) +{ +  char *new_str; +   +  if (str) +    { +      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); +      strcpy (new_str, str); +    } +  else +    new_str = NULL; +   +  return new_str; +} + +int main (int argc, char *argv[]) +{ +  int major, minor, micro; +  char *tmp_version; + +  /* This hangs on some systems (?) +  system ("touch conf.sdltest"); +  */ +  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + +  /* HP/UX 9 (%@#!) writes to sscanf strings */ +  tmp_version = my_strdup("$min_sdl_version"); +  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { +     printf("%s, bad version string\n", "$min_sdl_version"); +     exit(1); +   } + +   if (($sdl_major_version > major) || +      (($sdl_major_version == major) && ($sdl_minor_version > minor)) || +      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) +    { +      return 0; +    } +  else +    { +      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); +      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); +      printf("*** best to upgrade to the required version.\n"); +      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); +      printf("*** to point to the correct copy of sdl-config, and remove the file\n"); +      printf("*** config.cache before re-running configure\n"); +      return 1; +    } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +     fi +  fi +  if test "x$no_sdl" = x ; then +     AC_MSG_RESULT(yes) +     ifelse([$2], , :, [$2])      +  else +     AC_MSG_RESULT(no) +     if test "$SDL_CONFIG" = "no" ; then +       echo "*** The sdl-config script installed by SDL could not be found" +       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" +       echo "*** your path, or set the SDL_CONFIG environment variable to the" +       echo "*** full path to sdl-config." +     else +       if test -f conf.sdltest ; then +        : +       else +          echo "*** Could not run SDL test program, checking why..." +          CFLAGS="$CFLAGS $SDL_CFLAGS" +          LIBS="$LIBS $SDL_LIBS" +          AC_TRY_LINK([ +#include <stdio.h> +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef  main +#define main K_and_R_C_main +],      [ return 0; ], +        [ echo "*** The test program compiled, but did not run. This usually means" +          echo "*** that the run-time linker is not finding SDL or finding the wrong" +          echo "*** version of SDL. If it is not finding SDL, you'll need to set your" +          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" +          echo "*** to the installed location  Also, make sure you have run ldconfig if that" +          echo "*** is required on your system" +	  echo "***" +          echo "*** If you have an old version installed, it is best to remove it, although" +          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], +        [ echo "*** The test program failed to compile or link. See the file config.log for the" +          echo "*** exact error that occured. This usually means SDL was incorrectly installed" +          echo "*** or that you have moved SDL since it was installed. In the latter case, you" +          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) +          CFLAGS="$ac_save_CFLAGS" +          LIBS="$ac_save_LIBS" +       fi +     fi +     SDL_CFLAGS="" +     SDL_LIBS="" +     ifelse([$3], , :, [$3]) +  fi +  AC_SUBST(SDL_CFLAGS) +  AC_SUBST(SDL_LIBS) +  rm -f conf.sdltest +]) + +AC_DEFUN([MY_TEST_SDL], +[ +AC_MSG_CHECKING([for SDL development libraries]) +cat > conftest.c <<EOF +void main() +{ +} +EOF +SDL_LIBTOOL=`$SDL_CONFIG --prefix`/lib/libSDL.la +if test -r $SDL_LIBTOOL ; then +    if libtool $CC conftest.c $SDL_LIBTOOL $LIBS $SDL_LIBS -o conftest >&5 2>&5; then +	AC_MSG_RESULT([found]) +        GOOD_SDL_INSTALLATION=yes +    else +	AC_MSG_RESULT([linking against SDL library failed. Check config.log for details.]) +        GOOD_SDL_INSTALLATION=no +    fi +else +    AC_MSG_RESULT([not found]) +    GOOD_SDL_INSTALLATION=no +fi +rm -f conftest.c conftest +]) + +dnl    -*- shell-script -*- + +dnl    This file is part of the Avifile packages +dnl    and has been heavily modified for its purposes +dnl    Copyright (C) 2002 Zdenek Kabelac (kabi@users.sourceforge.net) +dnl +dnl    Originaly this file was part of the KDE libraries/packages +dnl    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu) +dnl              (C) 1997 Stephan Kulow (coolo@kde.org) + +dnl    This file is free software; you can redistribute it and/or +dnl    modify it under the terms of the GNU Library General Public +dnl    License as published by the Free Software Foundation; either +dnl    version 2 of the License, or (at your option) any later version. + +dnl    This library is distributed in the hope that it will be useful, +dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +dnl    Library General Public License for more details. + +dnl    You should have received a copy of the GNU Library General Public License +dnl    along with this library; see the file COPYING.LIB.  If not, write to +dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +dnl    Boston, MA 02111-1307, USA. + + +dnl ------------------------------------------------------------------------ +dnl Find a file (or one of more files in a list of dirs) +dnl ------------------------------------------------------------------------ +dnl +AC_DEFUN([AC_FIND_FILE], +[ +$3=NO +for i in $2; +do +  for j in $1; +  do +    if test -r "$i/$j"; then +      $3=$i +      break 2 +    fi +  done +done +]) + +AC_DEFUN([AC_FIND_ZLIB], +[ +    AC_CACHE_CHECK([for libz], ac_cv_lib_z, +		    [ac_save_LIBS=$LIBS +		    LIBS="$LIBS -lz" +		    AC_TRY_LINK([#include<zlib.h>], +			    [return (zlibVersion() == ZLIB_VERSION); ], +			    [ ac_cv_lib_z=yes ], [ ac_cv_lib_z=no ]) +		    LIBS=$ac_save_LIBS]) +    AC_SUBST(Z_LIBS) +    if test x$ac_cv_lib_z = xyes ; then +	Z_LIBS="-lz" +	have_zlib=yes +	ifelse([$1], , :, [$1]) +    else +	Z_LIBS= +	have_zlib=no +	ifelse([$2], , :, [$2]) +    fi +]) + + +AC_DEFUN([AC_FIND_PNG], +[ +AC_REQUIRE([AC_FIND_ZLIB]) +AC_MSG_CHECKING([for libpng]) +AC_CACHE_VAL(ac_cv_lib_png, +[ac_save_LIBS="$LIBS" +LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET" +AC_TRY_LINK([#include<png.h>], +    [ +    png_structp png_ptr = png_create_read_struct(  // image ptr +		PNG_LIBPNG_VER_STRING, 0, 0, 0 ); +    return( png_ptr != 0 ); +    ], +    eval "ac_cv_lib_png='-lpng $LIBZ -lm'", +    eval "ac_cv_lib_png=no") +    LIBS=$ac_save_LIBS +]) +if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then +  AC_DEFINE_UNQUOTED(HAVE_LIBPNG) +  LIBPNG="$ac_cv_lib_png" +  AC_SUBST(LIBPNG) +  AC_MSG_RESULT($ac_cv_lib_png) +else +  AC_MSG_RESULT(no) +  LIBPNG="" +  AC_SUBST(LIBPNG) +fi +]) + + +dnl just a wrapper to clean up configure.in +AC_DEFUN([KDE_PROG_LIBTOOL], +[ +AC_REQUIRE([AM_ENABLE_SHARED]) +AC_REQUIRE([AM_ENABLE_STATIC]) +dnl libtool is only for C, so I must force him +dnl to find the correct flags for C++ +ac_save_cc=$CC +ac_save_cflags="$CFLAGS" +CC=$CXX +CFLAGS="$CXXFLAGS" +dnl AM_PROG_LIBTOOL dnl for libraries +CC=$ac_save_cc +CFLAGS="$ac_save_cflags" +]) + + +dnl Check for the type of the third argument of getsockname +AC_DEFUN([AC_CHECK_KSIZE_T], +[AC_MSG_CHECKING(for the third argument of getsockname) +AC_LANG_CPLUSPLUS +AC_CACHE_VAL(ac_cv_ksize_t, +[AC_TRY_COMPILE([ +#include <sys/types.h> +#include <sys/socket.h> +],[ +socklen_t a=0; +getsockname(0,(struct sockaddr*)0, &a); +], +ac_cv_ksize_t=socklen_t, +ac_cv_ksize_t=) +if test -z "$ac_cv_ksize_t"; then +ac_save_cxxflags="$CXXFLAGS" +if test "$GCC" = "yes"; then +  CXXFLAGS="-Werror $CXXFLAGS" +fi +AC_TRY_COMPILE([ +#include <sys/types.h> +#include <sys/socket.h> +],[ +int a=0; +getsockname(0,(struct sockaddr*)0, &a); +], +ac_cv_ksize_t=int, +ac_cv_ksize_t=size_t) +CXXFLAGS=$ac_save_cxxflags +fi +]) + +if test -z "$ac_cv_ksize_t"; then +  ac_cv_ksize_t=int +fi + +AC_MSG_RESULT($ac_cv_ksize_t) +AC_DEFINE_UNQUOTED(ksize_t, $ac_cv_ksize_t) + +]) + + + +# Search path for a program which passes the given test. +# Ulrich Drepper <drepper@cygnus.com>, 1996. + +# serial 1 +# Stephan Kulow: I appended a _KDE against name conflicts + +dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR, +dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST_KDE], +[# Extract the first word of "$2", so it can be a program name with args. +    set dummy $2; ac_word=[$]2 +    AC_MSG_CHECKING([for $ac_word]) +    AC_CACHE_VAL(ac_cv_path_$1, +        [case "[$]$1" in +          /*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. +              ;; +          *) +              IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:" +              for ac_dir in ifelse([$5], , $PATH, [$5]); do +                test -z "$ac_dir" && ac_dir=. +                if test -f $ac_dir/$ac_word; then +                  if [$3]; then +                    ac_cv_path_$1="$ac_dir/$ac_word" +                    break +                  fi +                fi +              done +              IFS="$ac_save_ifs" +              dnl If no 4th arg is given, leave the cache variable unset, +              dnl so AC_PATH_PROGS will keep looking. +              ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +                    ]) +              ;; +         esac +        ]) +    $1="$ac_cv_path_$1" +    if test -n "[$]$1"; then +      AC_MSG_RESULT([$]$1) +    else +      AC_MSG_RESULT(no) +    fi +    AC_SUBST($1)dnl +]) + + + +AC_DEFUN([AM_DISABLE_LIBRARIES], +[ +    AC_PROVIDE([AM_ENABLE_STATIC]) +    AC_PROVIDE([AM_ENABLE_SHARED]) +    enable_static=no +    enable_shared=no +]) + + + + + + +# Check whether LC_MESSAGES is available in <locale.h>. +# Ulrich Drepper <drepper@cygnus.com>, 1995. +# +# This file can be copied and used freely without restrictions.  It can +# be used in projects which are not available under the GNU General Public +# License or the GNU Library General Public License but which still want +# to provide support for the GNU gettext functionality. +# Please note that the actual code of the GNU gettext library is covered +# by the GNU Library General Public License, and the rest of the GNU +# gettext package package is covered by the GNU General Public License. +# They are *not* in the public domain. + +# serial 2 + +AC_DEFUN([AM_LC_MESSAGES], +[ +    if test $ac_cv_header_locale_h = yes; then +    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, +      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], +       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) +    if test $am_cv_val_LC_MESSAGES = yes; then +      AC_DEFINE(HAVE_LC_MESSAGES, 1, +        [Define if your <locale.h> file defines LC_MESSAGES.]) +    fi +  fi +]) + + +dnl AM_PATH_LINUX([DEFAULT PATH, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl define LINUX_PATH and LINUX_CFLAGS +AC_DEFUN([AM_PATH_LINUX], +[ +    AC_ARG_WITH(linux_prefix, [  --with-linux-prefix=PFX where are linux sources (=/usr/src/linux)], +	        [], with_linux_prefix=ifelse([$1], [], /usr/src/linux, $1)) +    if test -f $with_linux_prefix/include/linux/modversions.h ; then +	LINUX_CFLAGS="-D__KERNEL__ -DMODULE -I$with_linux_prefix/include -include $with_linux_prefix/include/linux/modversions.h" +	LINUX_PREFIX=$with_linux_prefix +    else +        LINUX_CFLAGS="" +        LINUX_PREFIX="" +    fi +    AC_SUBST(LINUX_CFLAGS) +    AC_SUBST(LINUX_PREFIX) + +    if test -n "$LINUX_PREFIX"; then +        ifelse([$2], [], [:], [$2]) +    else +        ifelse([$3], [], [:], [$3]) +    fi +]) + +# Configure paths for VIDIX + +dnl Check if vidix support should be build + +AC_DEFUN([AM_PATH_VIDIX], +[ +    AC_ARG_ENABLE(vidix, [  --enable-vidix          build vidix drivers. [default=yes]], +		  [], enable_vidix=yes) +    AC_MSG_CHECKING([for vidix]) +    if test x$enable_vidix = xyes -a x$ac_cv_prog_AWK != xno; then +      case "$target" in +        i?86-*-linux* | k?-*-linux* | athlon-*-linux*) +          enable_vidix=yes +          enable_linux=yes +          ;; +        i386-*-freebsd*) +          enable_vidix=yes +          enable_dha_kmod=no +          ;; +        *) +          enable_dha_kmod=no +          enable_vidix=no +          ;; +      esac +    fi +dnl for now without linux kernel support +    enable_linux=no  + +    AC_MSG_RESULT([$enable_vidix]) + +    if test x$enable_vidix = xyes ; then +    	AC_DEFINE(HAVE_VIDIX, 1, [Define if you want to have vidix support.]) +    fi +]) + +# Configure paths for libvorbis +# Jack Moffitt <jack@icecast.org> 10-21-2000 +# Shamelessly stolen from Owen Taylor and Manish Singh + +dnl AM_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS +dnl +AC_DEFUN([AM_PATH_VORBIS], +[dnl +dnl Get the cflags and libraries +dnl +AC_ARG_WITH(vorbis-prefix,[  --with-vorbis-prefix=PFX prefix where libvorbis is installed. (optional)], vorbis_prefix="$withval", vorbis_prefix="") +AC_ARG_ENABLE(vorbistest, [  --disable-vorbistest    do not try to compile and run a test Vorbis program.],, enable_vorbistest=yes) + +  if test "x$vorbis_prefix" != "xNONE" ; then +    vorbis_args="$vorbis_args --prefix=$vorbis_prefix" +    VORBIS_CFLAGS="-I$vorbis_prefix/include" +    VORBIS_LIBDIR="-L$vorbis_prefix/lib" +  elif test "$prefix" != ""; then +    vorbis_args="$vorbis_args --prefix=$prefix" +    VORBIS_CFLAGS="-I$prefix/include" +    VORBIS_LIBDIR="-L$prefix/lib" +  fi + +  VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm" +  VORBISFILE_LIBS="-lvorbisfile" +  VORBISENC_LIBS="-lvorbisenc" + +  AC_MSG_CHECKING(for Vorbis) +  no_vorbis="" + + +  if test "x$enable_vorbistest" = "xyes" ; then +    ac_save_CFLAGS="$CFLAGS" +    ac_save_LIBS="$LIBS" +    CFLAGS="$CFLAGS $VORBIS_CFLAGS" +    LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" +dnl +dnl Now check if the installed Vorbis is sufficiently new. +dnl +      rm -f conf.vorbistest +      AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <vorbis/codec.h> + +int main () +{ +  system("touch conf.vorbistest"); +  return 0; +} + +],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +  fi + +  if test "x$no_vorbis" = "x" ; then +     AC_MSG_RESULT(yes) +     ifelse([$1], , :, [$1]) +  else +     AC_MSG_RESULT(no) +     if test -f conf.vorbistest ; then +       : +     else +       echo "*** Could not run Vorbis test program, checking why..." +       CFLAGS="$CFLAGS $VORBIS_CFLAGS" +       LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" +       AC_TRY_LINK([ +#include <stdio.h> +#include <vorbis/codec.h> +],     [ return 0; ], +       [ echo "*** The test program compiled, but did not run. This usually means" +       echo "*** that the run-time linker is not finding Vorbis or finding the wrong" +       echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your" +       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" +       echo "*** to the installed location  Also, make sure you have run ldconfig if that" +       echo "*** is required on your system" +       echo "***" +       echo "*** If you have an old version installed, it is best to remove it, although" +       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], +       [ echo "*** The test program failed to compile or link. See the file config.log for the" +       echo "*** exact error that occured. This usually means Vorbis was incorrectly installed" +       echo "*** or that you have moved Vorbis since it was installed." ]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +     fi +     VORBIS_CFLAGS="" +     VORBIS_LIBS="" +     VORBISFILE_LIBS="" +     VORBISENC_LIBS="" +     ifelse([$2], , :, [$2]) +  fi +  AC_SUBST(VORBIS_CFLAGS) +  AC_SUBST(VORBIS_LIBS) +  AC_SUBST(VORBISFILE_LIBS) +  AC_SUBST(VORBISENC_LIBS) +  rm -f conf.vorbistest +]) + +# Configure paths for video4linux + +dnl Usage: +dnl AC_CHECK_V4L([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for video4linux interface, and defines +dnl prerequisites: + +AC_DEFUN([AC_CHECK_V4L], +[ +    AC_ARG_ENABLE(v4l, [  --enable-v4l            support v4l video interface. (autodetect)], +		  [], enable_v4l=yes) +    if test x$enable_v4l = xyes; then +	AC_CHECK_HEADER([linux/videodev.h], [], [ enable_v4l=no; ]) +    fi + +    if test x$enable_v4l = xyes; then +        ifelse([$1], , :, [$1]) +    else +        ifelse([$2], , :, [$2]) +    fi +]) + +# Configure paths for libxvidcore + +dnl AM_PATH_XVID([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libxvidcore, and define XVID_CFLAGS and XVID_LIBS +dnl +AC_DEFUN([AM_PATH_XVID], +[ +    AC_ARG_WITH(xvid_prefix, [  --with-xvid-prefix=PFX  where XviD is installed. (optional)], +		[], with_xvid_prefix="") + +    AC_ARG_ENABLE(xvidtest, [  --disable-xvidtest      do not try to compile and run a test XviD program], +		  [], enable_xvidtest=yes) + +    XVID_CFLAGS="" +    XVID_LIBS="" + +    have_xvid=no +    ac_save_CPPFLAGS=$CPPFLAGS +    if test -n "$with_xvid_prefix" ; then +	dnl user has specified extra path for XviD instalation +	CPPFLAGS="-I$with_xvid_prefix $CPPFLAGS" +	AC_CHECK_HEADER(include/xvid.h, +			XVID_CFLAGS="-I$with_xvid_prefix/include" +			XVID_LIBS="-L$with_xvid_prefix/lib" +			have_xvid=yes) +	if test x$have_xvid = xno ; then +	    AC_CHECK_HEADER(xvid.h, +			    XVID_CFLAGS="-I$with_xvid_prefix" +			    XVID_LIBS="-L$with_xvid_prefix" +			    have_xvid=yes) +	fi +    else +	AC_CHECK_HEADER(xvid.h, have_xvid=yes) +    fi +    CPPFLAGS=$ac_save_CPPFLAGS +    XVID_LIBS="$XVID_LIBS -lxvidcore" + +dnl +dnl Now check if the installed XviD is sufficiently new. +dnl +    if test x$have_xvid = xyes -a x$enable_xvidtest = xyes ; then +	AC_CACHE_CHECK([for xvid_init in -lxvidcore], +		       ac_cv_val_HAVE_XVID, +		       [ rm -f conf.xvidtest +		       ac_save_CFLAGS=$CFLAGS +		       ac_save_LIBS=$LIBS +		       CFLAGS="$CFLAGS $XVID_CFLAGS" +		       LIBS="$LIBS $XVID_LIBS" +		       AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <xvid.h> + +int main () +{ +  XVID_INIT_PARAM xinit; +  system("touch conf.xvidtest"); + +  xinit.cpu_flags = 0; +  xvid_init(NULL, 0, &xinit, NULL); + +  if (xinit.api_version == API_VERSION) { +    return 0; +  } else { +    printf("Header file and library are out of sync. Header file supports\n" +	   "version %d.%d API and shared library supports version %d.%d API.\n", +	   API_VERSION >> 16, API_VERSION & 0xFFFF, +	   xinit.api_version >> 16, xinit.api_version & 0xFFFF); +    return 1; +  } +}		        +		       ], +		       [ ac_cv_val_HAVE_XVID=yes ], +		       [ ac_cv_val_HAVE_XVID=no ], +		       [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) +		       CFLAGS=$ac_save_CFLAGS +		       LIBS=$ac_save_LIBS]) +	test x$ac_cv_val_HAVE_XVID = xno && have_xvid=no +    fi + +    if test x$have_xvid = xyes ; then +	ifelse([$1], , :, [$1]) +    else +	if test ! -f conf.xvidtest ; then +	    AC_MSG_WARN([Could not run XviD test program, checking why...]) +	    CFLAGS="$CFLAGS $XVID_CFLAGS" +	    LIBS="$LIBS $XVID_LIBS" +	    AC_TRY_LINK([ +#include <stdio.h> +#include <xvid.h> +], [ return 0 ], [  +AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means +*** that the run-time linker is not finding XviD or finding the wrong +*** version of XviD. If it is not finding XviD, you'll need to set your +*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point +*** to the installed location  Also, make sure you have run ldconfig if that +*** is required on your system +*** +*** If you have an old version installed, it is best to remove it, although +*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ +AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the +*** exact error that occured. This usually means XviD was incorrectly installed.])]) +	    CFLAGS="$ac_save_CFLAGS" +	    LIBS="$ac_save_LIBS" +	fi +	XVID_CFLAGS="" +	XVID_LIBS="" +	ifelse([$2], , :, [$2]) +    fi +    AC_SUBST(XVID_CFLAGS) +    AC_SUBST(XVID_LIBS) +    rm -f conf.xvidtest +]) + +# Configure paths for libxvidcore version 1.0 + +dnl AM_PATH_XVID([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libxvidcore, and define XVID4_CFLAGS and XVID4_LIBS +dnl +AC_DEFUN([AM_PATH_XVID4], +[ +    AC_ARG_WITH(xvid4_prefix, [  --with-xvid4-prefix=PFX where XviD4 is installed. (optional)], +		[], with_xvid4_prefix="") + +    AC_ARG_ENABLE(xvid4test, [  --disable-xvid4test     do not try to compile and run a test XviD4 program], +		  [], enable_xvid4test=yes) + +    XVID4_CFLAGS="" +    XVID4_LIBS="" + +    have_xvid4=no +    ac_save_CPPFLAGS=$CPPFLAGS +    if test -n "$with_xvid4_prefix" ; then +	dnl user has specified extra path for XviD instalation +	CPPFLAGS="-I$with_xvid4_prefix $CPPFLAGS" +	AC_CHECK_HEADER(include/xvid.h, +			XVID4_CFLAGS="-I$with_xvid4_prefix/include" +			XVID4_LIBS="-L$with_xvid4_prefix/lib" +			have_xvid4=yes) +	if test x$have_xvid4 = xno ; then +	    AC_CHECK_HEADER(xvid.h, +			    XVID4_CFLAGS="-I$with_xvid4_prefix" +			    XVID4_LIBS="-L$with_xvid4_prefix" +			    have_xvid4=yes) +	fi +    else +	AC_CHECK_HEADER(xvid.h, have_xvid4=yes) +    fi +    CPPFLAGS=$ac_save_CPPFLAGS +    XVID4_LIBS="$XVID4_LIBS -lxvidcore" + +dnl +dnl Now check if the installed XviD is sufficiently new. +dnl +    if test x$have_xvid4 = xyes -a x$enable_xvid4test = xyes ; then +	AC_CACHE_CHECK([for xvid_global in -lxvidcore (4)], +		       ac_cv_val_HAVE_XVID4, +		       [ rm -f conf.xvidtest +		       ac_save_CFLAGS=$CFLAGS +		       ac_save_LIBS=$LIBS +		       CFLAGS="$CFLAGS $XVID4_CFLAGS" +		       LIBS="$LIBS $XVID4_LIBS" +		       AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <xvid.h> + +int main () +{ +  xvid_gbl_info_t xinfo; +  system("touch conf.xvidtest"); + +  memset(&xinfo, 0, sizeof(xinfo)); +  xinfo.version = XVID_VERSION; + +  if (xvid_global(NULL, XVID_GBL_INIT, &xinfo, NULL) == XVID_ERR_FAIL) { +    printf("Header file and library are out of sync. Header file supports\n" +	   "version %d.%d API and shared library supports version %d.%d API.\n", +	   XVID_VERSION >> 16, XVID_VERSION & 0xFFFF, +	   xinfo.version >> 16, xinfo.version & 0xFFFF); +    return 1; +  } else  +    return 0; +} +		       ], +		       [ ac_cv_val_HAVE_XVID4=yes ], +		       [ ac_cv_val_HAVE_XVID4=no ], +		       [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) +		       CFLAGS=$ac_save_CFLAGS +		       LIBS=$ac_save_LIBS]) +	test x$ac_cv_val_HAVE_XVID4 = xno && have_xvid4=no +    fi + +    if test x$have_xvid4 = xyes ; then +	ifelse([$1], , :, [$1]) +    else +	if test ! -f conf.xvidtest ; then +	    AC_MSG_WARN([Could not run XviD4 test program, checking why...]) +	    CFLAGS="$CFLAGS $XVID4_CFLAGS" +	    LIBS="$LIBS $XVID4_LIBS" +	    AC_TRY_LINK([ +#include <stdio.h> +#include <xvid.h> +], [ return 0 ], [  +AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means +*** that the run-time linker is not finding XviD or finding the wrong +*** version of XviD. If it is not finding XviD, you'll need to set your +*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point +*** to the installed location  Also, make sure you have run ldconfig if that +*** is required on your system +*** +*** If you have an old version installed, it is best to remove it, although +*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ +AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the +*** exact error that occured. This usually means XviD was incorrectly installed.])]) +	    CFLAGS="$ac_save_CFLAGS" +	    LIBS="$ac_save_LIBS" +	fi +	XVID4_CFLAGS="" +	XVID4_LIBS="" +	ifelse([$2], , :, [$2]) +    fi +    AC_SUBST(XVID4_CFLAGS) +    AC_SUBST(XVID4_LIBS) +    rm -f conf.xvidtest +]) + +###############################################################################################################333 +# Check for Qt compiler flags, linker flags, and binary packages +AC_DEFUN([gw_CHECK_QT], +[ +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PATH_X]) + +AC_MSG_CHECKING([QTDIR]) +AC_ARG_WITH([qtdir], [  --with-qtdir=DIR        Qt installation directory [default=$QTDIR]], QTDIR=$withval) +# Check that QTDIR is defined or that --with-qtdir given +if test x"$QTDIR" = x ; then +    QT_SEARCH="/usr/lib/qt31 /usr/local/qt31 /usr/lib/qt3 /usr/local/qt3 /usr/lib/qt2 /usr/local/qt2 /usr/lib/qt /usr/local/qt" +    for i in $QT_SEARCH; do +        if test -f $i/include/qglobal.h -a x$QTDIR = x; then QTDIR=$i; fi +    done +fi +if test x"$QTDIR" = x ; then +    AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given]) +fi +AC_MSG_RESULT([$QTDIR]) + +# Change backslashes in QTDIR to forward slashes to prevent escaping +# problems later on in the build process, mainly for Cygwin build +# environment using MSVC as the compiler +# TODO: Use sed instead of perl +QTDIR=`echo $QTDIR | perl -p -e 's/\\\\/\\//g'` + +# Figure out which version of Qt we are using +AC_MSG_CHECKING([Qt version]) +QT_VER=`grep 'define.*QT_VERSION_STR\W' $QTDIR/include/qglobal.h | perl -p -e 's/\D//g'` +case "${QT_VER}" in +    2*) +        QT_MAJOR="2" +    ;; +    3*) +        QT_MAJOR="3" +    ;; +    *) +        AC_MSG_ERROR([*** Don't know how to handle this Qt major version]) +    ;; +esac +AC_MSG_RESULT([$QT_VER ($QT_MAJOR)]) + +# Check that moc is in path +AC_CHECK_PROG(MOC, moc, moc) +if test x$MOC = x ; then +        AC_MSG_ERROR([*** moc must be in path]) +fi + +# uic is the Qt user interface compiler +AC_CHECK_PROG(UIC, uic, uic) +if test x$UIC = x ; then +        AC_MSG_ERROR([*** uic must be in path]) +fi + +# qembed is the Qt data embedding utility. +# It is located in $QTDIR/tools/qembed, and must be compiled and installed +# manually, we'll let it slide if it isn't present +AC_CHECK_PROG(QEMBED, qembed, qembed) + + +# Calculate Qt include path +QT_CXXFLAGS="-I$QTDIR/include" + +QT_IS_EMBEDDED="no" +# On unix, figure out if we're doing a static or dynamic link +case "${host}" in +    *-cygwin) +	AC_DEFINE_UNQUOTED(WIN32, "", Defined if on Win32 platform) +        if test -f "$QTDIR/lib/qt.lib" ; then +            QT_LIB="qt.lib" +            QT_IS_STATIC="yes" +            QT_IS_MT="no" +        elif test -f "$QTDIR/lib/qt-mt.lib" ; then +            QT_LIB="qt-mt.lib"  +            QT_IS_STATIC="yes" +            QT_IS_MT="yes" +        elif test -f "$QTDIR/lib/qt$QT_VER.lib" ; then +            QT_LIB="qt$QT_VER.lib" +            QT_IS_STATIC="no" +            QT_IS_MT="no" +        elif test -f "$QTDIR/lib/qt-mt$QT_VER.lib" ; then +            QT_LIB="qt-mt$QT_VER.lib" +            QT_IS_STATIC="no" +            QT_IS_MT="yes" +        fi +        ;; + +    *) +        QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null` +        if test "x$QT_IS_STATIC" = x; then +            QT_IS_STATIC="no" +        else +            QT_IS_STATIC="yes" +        fi +        if test x$QT_IS_STATIC = xno ; then +            QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null`  +            if test "x$QT_IS_DYNAMIC" = x;  then +                AC_MSG_ERROR([*** Couldn't find any Qt libraries]) +            fi +        fi + +        if test "x`ls $QTDIR/lib/libqt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqt" +            QT_IS_MT="no" +        elif test "x`ls $QTDIR/lib/libqt-mt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqt-mt" +            QT_IS_MT="yes" +        elif test "x`ls $QTDIR/lib/libqte.* 2> /dev/null`" != x ; then +            QT_LIB="-lqte" +            QT_IS_MT="no" +            QT_IS_EMBEDDED="yes" +        elif test "x`ls $QTDIR/lib/libqte-mt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqte-mt" +            QT_IS_MT="yes" +            QT_IS_EMBEDDED="yes" +        fi +        ;; +esac +AC_MSG_CHECKING([if Qt is static]) +AC_MSG_RESULT([$QT_IS_STATIC]) +AC_MSG_CHECKING([if Qt is multithreaded]) +AC_MSG_RESULT([$QT_IS_MT]) +AC_MSG_CHECKING([if Qt is embedded]) +AC_MSG_RESULT([$QT_IS_EMBEDDED]) + +QT_GUILINK="" +QASSISTANTCLIENT_LDADD="-lqassistantclient" +case "${host}" in +    *irix*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" +        fi +        ;; + +    *linux*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg" +        fi +        ;; + + +    *osf*)  +        # Digital Unix (aka DGUX aka Tru64) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" +        fi +        ;; + +    *solaris*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl" +        fi +        ;; + + +    *win*) +        # linker flag to suppress console when linking a GUI app on Win32 +        QT_GUILINK="/subsystem:windows" + +	if test $QT_MAJOR = "3" ; then +	    if test $QT_IS_MT = yes ; then +        	QT_LIBS="/nodefaultlib:libcmt" +            else +            	QT_LIBS="/nodefaultlib:libc" +            fi +        fi + +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS $QT_LIB kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib shell32.lib imm32.lib advapi32.lib wsock32.lib winspool.lib winmm.lib netapi32.lib" +            if test $QT_MAJOR = "3" ; then +                QT_LIBS="$QT_LIBS qtmain.lib" +            fi +        else +            QT_LIBS="$QT_LIBS $QT_LIB"         +            if test $QT_MAJOR = "3" ; then +                QT_CXXFLAGS="$QT_CXXFLAGS -DQT_DLL" +                QT_LIBS="$QT_LIBS qtmain.lib qui.lib user32.lib netapi32.lib" +            fi +        fi +        QASSISTANTCLIENT_LDADD="qassistantclient.lib" +        ;; + +esac + + +if test x"$QT_IS_EMBEDDED" = "xyes" ; then +        QT_CXXFLAGS="-DQWS $QT_CXXFLAGS" +fi + +if test x"$QT_IS_MT" = "xyes" ; then +        QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_THREAD_SUPPORT" +fi + +QT_LDADD="-L$QTDIR/lib $QT_LIBS" + +if test x$QT_IS_STATIC = xyes ; then +    OLDLIBS="$LIBS" +    LIBS="$QT_LDADD" +    AC_CHECK_LIB(Xft, XftFontOpen, QT_LDADD="$QT_LDADD -lXft") +    LIBS="$LIBS" +fi + +AC_MSG_CHECKING([QT_CXXFLAGS]) +AC_MSG_RESULT([$QT_CXXFLAGS]) +AC_MSG_CHECKING([QT_LDADD]) +AC_MSG_RESULT([$QT_LDADD]) + +AC_SUBST(QT_CXXFLAGS) +AC_SUBST(QT_LDADD) +AC_SUBST(QT_GUILINK) +AC_SUBST(QASSISTANTCLIENT_LDADD) + +]) + diff --git a/acinclude.m4.mine b/acinclude.m4.mine new file mode 100644 index 0000000..0fc8b65 --- /dev/null +++ b/acinclude.m4.mine @@ -0,0 +1,475 @@ +########################################################################################################## +dnl Usage: +dnl AM_PATH_FFMPEG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for ffmpeg, and define FFMPEG_CFLAGS and FFMPEG_LIBS + +AC_DEFUN([AM_PATH_FFMPEG], +[ +    AC_REQUIRE([AC_FUNC_LRINTF]) + +    dnl !!! - it really sucks - Makefile.am can't be optimized even by +    dnl !!! preparing some extra variable forward +    dnl !!! FFAVFORMAT_SRC= + +    AC_REQUIRE([AC_CHECK_OSS]) +    test x$enable_oss = xyes && AC_DEFINE(CONFIG_AUDIO_OSS, 1, [Define if you want to have ffmpeg OSS audio support compiled.]) + +    AC_REQUIRE([AC_CHECK_V4L]) +    test x$enable_v4l = xyes && AC_DEFINE(CONFIG_VIDEO4LINUX, 1, [Define if you have video4linux device. (ffmpeg)]) + +    AC_REQUIRE([AC_FIND_ZLIB]) +    test x$have_zlib = xyes && AC_DEFINE(CONFIG_ZLIB, 1, [Define if you have z library (-lz) (ffmpeg)]) + +    AC_ARG_ENABLE(ffmpeg_faadbin, [  --enable-ffmpeg-faadbin build ffmpeg with FAAD binary support. (default=yes)], +                  [], enable_ffmpeg_faadbin=yes) +    test x$enable_ffmpeg_faadbin = xyes && AC_DEFINE(CONFIG_FAADBIN, 1, [Define if you want to build support for runtime linked libfaad.]) +    AC_REQUIRE([AM_PATH_FAAD]) +    test x$have_faad = xyes && AC_DEFINE(CONFIG_FAAD, 1, [Define if you want to have AAC support compiled. (ffmpeg)]) + +    AC_ARG_ENABLE(ffmpeg_risky, [  --enable-ffmpeg-risky   build ffmpeg risky code. (default=yes)], +                  [], enable_ffmpeg_risky=yes) + +    AC_ARG_ENABLE(ffmpeg_a52, [  --enable-ffmpeg-a52     build ffmpeg with A52 (AC3) support. (default=yes)], +                  [], enable_ffmpeg_a52=yes) +    if test x$enable_ffmpeg_a52 = xyes ; then +        AC_DEFINE(HAVE_FFMPEG_A52, 1, [Define if you want to use ffmpeg A52 audio decoder.]) +        AC_ARG_ENABLE(ffmpeg_a52bin, [  --enable-ffmpeg-a52bin  A52 plugin dlopens liba52.so.0 at runtime (default=no)], +                      [], enable_ffmpeg_a52bin=no) + +        if test x$enable_ffmpeg_a52bin = xyes ; then +            AC_DEFINE(CONFIG_A52BIN, 1, [Define if you want to build ffmpeg with A52 dlopened decoder.]) +        fi +    fi + +    test x$enable_ffmpeg_risky = xyes && AC_DEFINE(CONFIG_RISKY, 1, [Define if you want to compile patent encumbered codecs. (ffmpeg)]) + +    AC_DEFINE(CONFIG_ENCODERS, 1, [Define if you want to build ffmpeg encoders.]) +    AC_DEFINE(CONFIG_DECODERS, 1, [Define if you want to build ffmpeg decoders.]) +    AC_DEFINE(CONFIG_AC3, 1, [Define if you want to build ffmpeg with AC3 decoder.]) +    AC_DEFINE(SIMPLE_IDCT, 1, [Define if you want to build ffmpeg with simples idct.]) +    AC_DEFINE(CONFIG_NETWORK, 1, [Define if you want to build ffmpeg with network support.]) +    AC_DEFINE(CONFIG_MPEGAUDIO_HP, 1, [Define if you want to have highquality ffmpeg mpeg audio support compiled.]) +    AC_DEFINE(HAVE_PTHREADS, 1, [Define if you want to have ffmpeg pthread support compiled.]) + +    if test -n "$ffmpeg_profiling" ; then +        AC_DEFINE(HAVE_GPROF, 1, [Define if you want to build ffmpeg with gprof support.]) +    fi + +    test -z "$FFMPEG_CFLAGS" && FFMPEG_CFLAGS="-O4 $DEFAULT_FLAGS" +    FFMPEG_CFLAGS="$FFMPEG_CFLAGS $DEFAULT_DEFINES" + +    AC_CHECK_GNU_VECTOR(FFMPEG_SSE="-msse"; +                        AC_DEFINE(HAVE_BUILTIN_VECTOR, 1, [Define if your compiler supports vector builtins (MMX).]), []) +    AC_SUBST(FFMPEG_CFLAGS) +    AC_SUBST(FFMPEG_SSE) + +    AM_CONDITIONAL(AMM_BUILD_STRPTIME, test x$ac_cv_func_strptime != xyes ) + +dnl ffmpeg_x86opt= +dnl test x$enable_x86opt = xno && ffmpeg_x86opt="--disable-mmx" +dnl AC_MSG_RESULT([=== configuring ffmpeg ===]) +dnl    ( cd $srcdir/ffmpeg ; \ +dnl      ./configure --prefix=$prefix --cc=$CC \ +dnl             $ffmpeg_profiling $ffmpeg_cpu \ +dnl             $ffmpeg_x86opt --disable-mp3lib \ +dnl             --enable-simple_idct ) +]) + + +########################################################################################################## +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN([AM_PATH_SDL], +[dnl  +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)], +            sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], +            sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program], +		    , enable_sdltest=yes) + +  if test x$sdl_exec_prefix != x ; then +     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" +     if test x${SDL_CONFIG+set} != xset ; then +        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config +     fi +  fi +  if test x$sdl_prefix != x ; then +     sdl_args="$sdl_args --prefix=$sdl_prefix" +     if test x${SDL_CONFIG+set} != xset ; then +        SDL_CONFIG=$sdl_prefix/bin/sdl-config +     fi +  fi + +  AC_REQUIRE([AC_CANONICAL_TARGET]) +  PATH="$prefix/bin:$prefix/usr/bin:$PATH" +  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) +  min_sdl_version=ifelse([$1], ,0.11.0,$1) +  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) +  no_sdl="" +  if test "$SDL_CONFIG" = "no" ; then +    no_sdl=yes +  else +    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` +    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + +    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` +    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` +    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` +    if test "x$enable_sdltest" = "xyes" ; then +      ac_save_CFLAGS="$CFLAGS" +      ac_save_LIBS="$LIBS" +      CFLAGS="$CFLAGS $SDL_CFLAGS" +      LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl +      rm -f conf.sdltest +      AC_TRY_RUN([ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "SDL.h" + +char* +my_strdup (char *str) +{ +  char *new_str; +   +  if (str) +    { +      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); +      strcpy (new_str, str); +    } +  else +    new_str = NULL; +   +  return new_str; +} + +int main (int argc, char *argv[]) +{ +  int major, minor, micro; +  char *tmp_version; + +  /* This hangs on some systems (?) +  system ("touch conf.sdltest"); +  */ +  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + +  /* HP/UX 9 (%@#!) writes to sscanf strings */ +  tmp_version = my_strdup("$min_sdl_version"); +  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { +     printf("%s, bad version string\n", "$min_sdl_version"); +     exit(1); +   } + +   if (($sdl_major_version > major) || +      (($sdl_major_version == major) && ($sdl_minor_version > minor)) || +      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) +    { +      return 0; +    } +  else +    { +      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); +      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); +      printf("*** best to upgrade to the required version.\n"); +      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); +      printf("*** to point to the correct copy of sdl-config, and remove the file\n"); +      printf("*** config.cache before re-running configure\n"); +      return 1; +    } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +       CFLAGS="$ac_save_CFLAGS" +       LIBS="$ac_save_LIBS" +     fi +  fi +  if test "x$no_sdl" = x ; then +     AC_MSG_RESULT(yes) +     ifelse([$2], , :, [$2])      +  else +     AC_MSG_RESULT(no) +     if test "$SDL_CONFIG" = "no" ; then +       echo "*** The sdl-config script installed by SDL could not be found" +       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" +       echo "*** your path, or set the SDL_CONFIG environment variable to the" +       echo "*** full path to sdl-config." +     else +       if test -f conf.sdltest ; then +        : +       else +          echo "*** Could not run SDL test program, checking why..." +          CFLAGS="$CFLAGS $SDL_CFLAGS" +          LIBS="$LIBS $SDL_LIBS" +          AC_TRY_LINK([ +#include <stdio.h> +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef  main +#define main K_and_R_C_main +],      [ return 0; ], +        [ echo "*** The test program compiled, but did not run. This usually means" +          echo "*** that the run-time linker is not finding SDL or finding the wrong" +          echo "*** version of SDL. If it is not finding SDL, you'll need to set your" +          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" +          echo "*** to the installed location  Also, make sure you have run ldconfig if that" +          echo "*** is required on your system" +	  echo "***" +          echo "*** If you have an old version installed, it is best to remove it, although" +          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], +        [ echo "*** The test program failed to compile or link. See the file config.log for the" +          echo "*** exact error that occured. This usually means SDL was incorrectly installed" +          echo "*** or that you have moved SDL since it was installed. In the latter case, you" +          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) +          CFLAGS="$ac_save_CFLAGS" +          LIBS="$ac_save_LIBS" +       fi +     fi +     SDL_CFLAGS="" +     SDL_LIBS="" +     ifelse([$3], , :, [$3]) +  fi +  AC_SUBST(SDL_CFLAGS) +  AC_SUBST(SDL_LIBS) +  rm -f conf.sdltest +]) + + +###############################################################################################################333 +# Check for Qt compiler flags, linker flags, and binary packages +AC_DEFUN([gw_CHECK_QT], +[ +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PATH_X]) + +AC_MSG_CHECKING([QTDIR]) +AC_ARG_WITH([qtdir], [  --with-qtdir=DIR        Qt installation directory [default=$QTDIR]], QTDIR=$withval) +# Check that QTDIR is defined or that --with-qtdir given +if test x"$QTDIR" = x ; then +    QT_SEARCH="/usr/lib/qt31 /usr/local/qt31 /usr/lib/qt3 /usr/local/qt3 /usr/lib/qt2 /usr/local/qt2 /usr/lib/qt /usr/local/qt" +    for i in $QT_SEARCH; do +        if test -f $i/include/qglobal.h -a x$QTDIR = x; then QTDIR=$i; fi +    done +fi +if test x"$QTDIR" = x ; then +    AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given]) +fi +AC_MSG_RESULT([$QTDIR]) + +# Change backslashes in QTDIR to forward slashes to prevent escaping +# problems later on in the build process, mainly for Cygwin build +# environment using MSVC as the compiler +# TODO: Use sed instead of perl +QTDIR=`echo $QTDIR | perl -p -e 's/\\\\/\\//g'` + +# Figure out which version of Qt we are using +AC_MSG_CHECKING([Qt version]) +QT_VER=`grep 'define.*QT_VERSION_STR\W' $QTDIR/include/qglobal.h | perl -p -e 's/\D//g'` +case "${QT_VER}" in +    2*) +        QT_MAJOR="2" +    ;; +    3*) +        QT_MAJOR="3" +    ;; +    *) +        AC_MSG_ERROR([*** Don't know how to handle this Qt major version]) +    ;; +esac +AC_MSG_RESULT([$QT_VER ($QT_MAJOR)]) + +# Check that moc is in path +AC_CHECK_PROG(MOC, moc, moc) +if test x$MOC = x ; then +        AC_MSG_ERROR([*** moc must be in path]) +fi + +# uic is the Qt user interface compiler +AC_CHECK_PROG(UIC, uic, uic) +if test x$UIC = x ; then +        AC_MSG_ERROR([*** uic must be in path]) +fi + +# qembed is the Qt data embedding utility. +# It is located in $QTDIR/tools/qembed, and must be compiled and installed +# manually, we'll let it slide if it isn't present +AC_CHECK_PROG(QEMBED, qembed, qembed) + + +# Calculate Qt include path +QT_CXXFLAGS="-I$QTDIR/include" + +QT_IS_EMBEDDED="no" +# On unix, figure out if we're doing a static or dynamic link +case "${host}" in +    *-cygwin) +	AC_DEFINE_UNQUOTED(WIN32, "", Defined if on Win32 platform) +        if test -f "$QTDIR/lib/qt.lib" ; then +            QT_LIB="qt.lib" +            QT_IS_STATIC="yes" +            QT_IS_MT="no" +        elif test -f "$QTDIR/lib/qt-mt.lib" ; then +            QT_LIB="qt-mt.lib"  +            QT_IS_STATIC="yes" +            QT_IS_MT="yes" +        elif test -f "$QTDIR/lib/qt$QT_VER.lib" ; then +            QT_LIB="qt$QT_VER.lib" +            QT_IS_STATIC="no" +            QT_IS_MT="no" +        elif test -f "$QTDIR/lib/qt-mt$QT_VER.lib" ; then +            QT_LIB="qt-mt$QT_VER.lib" +            QT_IS_STATIC="no" +            QT_IS_MT="yes" +        fi +        ;; + +    *) +        QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null` +        if test "x$QT_IS_STATIC" = x; then +            QT_IS_STATIC="no" +        else +            QT_IS_STATIC="yes" +        fi +        if test x$QT_IS_STATIC = xno ; then +            QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null`  +            if test "x$QT_IS_DYNAMIC" = x;  then +                AC_MSG_ERROR([*** Couldn't find any Qt libraries]) +            fi +        fi + +        if test "x`ls $QTDIR/lib/libqt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqt" +            QT_IS_MT="no" +        elif test "x`ls $QTDIR/lib/libqt-mt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqt-mt" +            QT_IS_MT="yes" +        elif test "x`ls $QTDIR/lib/libqte.* 2> /dev/null`" != x ; then +            QT_LIB="-lqte" +            QT_IS_MT="no" +            QT_IS_EMBEDDED="yes" +        elif test "x`ls $QTDIR/lib/libqte-mt.* 2> /dev/null`" != x ; then +            QT_LIB="-lqte-mt" +            QT_IS_MT="yes" +            QT_IS_EMBEDDED="yes" +        fi +        ;; +esac +AC_MSG_CHECKING([if Qt is static]) +AC_MSG_RESULT([$QT_IS_STATIC]) +AC_MSG_CHECKING([if Qt is multithreaded]) +AC_MSG_RESULT([$QT_IS_MT]) +AC_MSG_CHECKING([if Qt is embedded]) +AC_MSG_RESULT([$QT_IS_EMBEDDED]) + +QT_GUILINK="" +QASSISTANTCLIENT_LDADD="-lqassistantclient" +case "${host}" in +    *irix*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" +        fi +        ;; + +    *linux*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg" +        fi +        ;; + + +    *osf*)  +        # Digital Unix (aka DGUX aka Tru64) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE" +        fi +        ;; + +    *solaris*) +        QT_LIBS="$QT_LIB" +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl" +        fi +        ;; + + +    *win*) +        # linker flag to suppress console when linking a GUI app on Win32 +        QT_GUILINK="/subsystem:windows" + +	if test $QT_MAJOR = "3" ; then +	    if test $QT_IS_MT = yes ; then +        	QT_LIBS="/nodefaultlib:libcmt" +            else +            	QT_LIBS="/nodefaultlib:libc" +            fi +        fi + +        if test $QT_IS_STATIC = yes ; then +            QT_LIBS="$QT_LIBS $QT_LIB kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib shell32.lib imm32.lib advapi32.lib wsock32.lib winspool.lib winmm.lib netapi32.lib" +            if test $QT_MAJOR = "3" ; then +                QT_LIBS="$QT_LIBS qtmain.lib" +            fi +        else +            QT_LIBS="$QT_LIBS $QT_LIB"         +            if test $QT_MAJOR = "3" ; then +                QT_CXXFLAGS="$QT_CXXFLAGS -DQT_DLL" +                QT_LIBS="$QT_LIBS qtmain.lib qui.lib user32.lib netapi32.lib" +            fi +        fi +        QASSISTANTCLIENT_LDADD="qassistantclient.lib" +        ;; + +esac + + +if test x"$QT_IS_EMBEDDED" = "xyes" ; then +        QT_CXXFLAGS="-DQWS $QT_CXXFLAGS" +fi + +if test x"$QT_IS_MT" = "xyes" ; then +        QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_THREAD_SUPPORT" +fi + +QT_LDADD="-L$QTDIR/lib $QT_LIBS" + +if test x$QT_IS_STATIC = xyes ; then +    OLDLIBS="$LIBS" +    LIBS="$QT_LDADD" +    AC_CHECK_LIB(Xft, XftFontOpen, QT_LDADD="$QT_LDADD -lXft") +    LIBS="$LIBS" +fi + +AC_MSG_CHECKING([QT_CXXFLAGS]) +AC_MSG_RESULT([$QT_CXXFLAGS]) +AC_MSG_CHECKING([QT_LDADD]) +AC_MSG_RESULT([$QT_LDADD]) + +AC_SUBST(QT_CXXFLAGS) +AC_SUBST(QT_LDADD) +AC_SUBST(QT_GUILINK) +AC_SUBST(QASSISTANTCLIENT_LDADD) + +]) + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..45ef969 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. +# This was lifted from the Gimp, and adapted slightly by +# Raph Levien, slightly hacked for xine by Daniel Caujolle-Bert. + +DIE=0 + +PROG=anoid + +# Check how echo works in this /bin/sh +case `echo -n` in +-n)     _echo_n=   _echo_c='\c';; +*)      _echo_n=-n _echo_c=;; +esac + + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { +        echo +        echo "You must have autoconf installed to compile $PROG." +        echo "Download the appropriate package for your distribution," +        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" +        DIE=1 +} + +(libtool --version) < /dev/null > /dev/null 2>&1 || { +        echo +        echo "You must have libtool installed to compile $PROG." +        echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.4.tar.gz" +        echo "(or a newer version if it is available)" +        DIE=1 +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { +        echo +        echo "You must have automake installed to compile $PROG." +        echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" +        echo "(or a newer version if it is available)" +        DIE=1 +} + +(aclocal --version) < /dev/null > /dev/null 2>&1 || { +	echo +	echo "**Error**: Missing aclocal. The version of automake" +	echo "installed doesn't appear recent enough." +	echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" +	echo "(or a newer version if it is available)" +	DIE=1 +} + +if [ "$DIE" -eq 1 ]; then +        exit 1 +fi + +aclocalinclude="$ACLOCAL_FLAGS"; \ +(echo $_echo_n " + Running aclocal: $_echo_c"; \ +    aclocal $aclocalinclude; \ + echo "done.") && \ +(echo $_echo_n " + Running libtoolize: $_echo_c"; \ +    libtoolize --force --copy >/dev/null 2>&1; \ + echo "done.") && \ +(echo $_echo_n " + Running autoheader: $_echo_c"; \ +    autoheader; \ + echo "done.") && \ +(echo $_echo_n " + Running automake: $_echo_c"; \ +    automake --gnu --add-missing --copy; \ + echo "done.") && \ +(echo $_echo_n " + Running autoconf: $_echo_c"; \ +    autoconf; \ + echo "done.") + +rm -f config.cache diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..1df3ba6 --- /dev/null +++ b/configure.in @@ -0,0 +1,166 @@ +# Filnavn: configure.in +AC_INIT(src/miav.cc) +AM_INIT_AUTOMAKE( miav, 0.1.1 ) + +AC_PROG_CXX + +AC_PROG_LIBTOOL +AM_PROG_LIBTOOL + +AM_CONFIG_HEADER(config.h) +AM_CXXFLAGS="-O2" +AC_STDC_HEADERS + +AC_ARG_WITH(gui,  [  --without-gui           build without GUI support]) + if test x$with_gui != xno && test -z "$GUI"; then +#dnl ==================== +#dnl Check for Qt library +#dnl ==================== +#AC_ARG_WITH(qt, [  --with-qt               build with Qt utils. (autodetected)], +#	    [], with_qt=yes) +#dnl no X means no Qt +#test x$have_x != xyes && with_qt=no +# +#if test x$with_qt = xyes ; then +#    AC_PATH_QT(200, test -z "$qt_version" && qt_version=0 +#	       AC_DEFINE_UNQUOTED(HAVE_LIBQT, $qt_version, [Define if using 'Qt' libraries.]), +#	       with_qt=no) +#else +#    AC_MSG_RESULT([compilation of Qt utils disabled]) +#fi +# +#if test x$with_qt = xyes ; then +#    AC_LANG_SAVE +#    AC_LANG_CPLUSPLUS +#    save_CXXFLAGS=$CXXFLAGS +#    save_LIBS=$LIBS +#    CXXFLAGS="$CXXFLAGS $QT_CFLAGS $X_CFLAGS" +#    LIBS="$LIBS $QT_LIBS $X_LIBS $PTHREAD_LIBS" +#    AC_CACHE_CHECK([for multithreading support in Qt], +#	ac_cv_val_with_qt_multi, +#	[ AC_TRY_LINK([ +#	    #define QT_THREAD_SUPPORT +#	    #include <qapplication.h> ], +#	    [ qApp->wakeUpGuiThread(); ], +#	    [ ac_cv_val_with_qt_multi=yes ], +#	    [ ac_cv_val_with_qt_multi=no ]) +#    ]) +#    CXXFLAGS=$save_CXXFLAGS +#    LIBS=$save_LIBS +# +#    if test x$ac_cv_val_with_qt_multi != xyes ; then +#	AC_MSG_WARN([ +#*** Your Qt installation does not support multi-threading! +#*** Avifile will be compiled - however it might crash mysteriously +#*** Instalation of threaded Qt library version (qt-mt) is recommended +#*** When rebuilding Qt use configure option '-thread'.]) +#    fi +# +#    AC_MSG_CHECKING(Qt version for Avicap) +#    if test $qt_version -ge 220 ; then +#	AC_MSG_RESULT([yes]) +#    else +#	AC_MSG_RESULT([no (needs Qt 2.2.0 or better)]) +#	build_avicap=no +#    fi +#    AC_LANG_RESTORE +#fi + + +dnl ====================== +dnl Check for Jpeg library +dnl ====================== +AC_CHECK_HEADER(jpeglib.h, have_jpeglib=yes, have_jpeglib="no ") +if test x$have_jpeglib = xyes; then +dnl default action left - saving $LIBS is necessary +    save_LIBS=$LIBS +    AC_CHECK_LIB(jpeg, jpeg_start_compress, , have_jpeglib="no ") +    LIBS=$save_LIBS +fi + +#dnl ===================== +#dnl Check for SDL library +#dnl ===================== +#AC_ARG_WITH(sdl, [  --with-sdl              build with SDL. (autodetected)], +#	    [], with_sdl=yes) +# +#if test x$with_sdl != xyes; then +#    with_sdl="no  (video rendering unavailable as requested!)" +#    AC_MSG_WARN([ +#*** there will be NO video rendering without SDL support!]) +#else +#    SDL_MIN_VERSION=1.0.0 +#    save_CFLAGS=$CFLAGS +#    save_CPPFLAGS=$CPPFLAGS +#    save_LIBS=$LD_FLAGS +#    LIBS= +#    AM_PATH_SDL($SDL_MIN_VERSION, +#		AC_DEFINE(HAVE_LIBSDL, 1, [Define if using 'SDL' library (-lsdl).]), +#		with_sdl="no  (*** no SDL => no video rendering! ***)" +#		AC_MSG_WARN([Could not find SDL >= $SDL_MIN_VERSION!]) ) +#    CFLAGS=$save_CFLAGS +#    CXXFLAGS=$save_CPPFLAGS +#    LDFLAGS="$save_LIBS +#fi + +   dnl QT lib check macro (located in acinclude.m4) +   gw_CHECK_QT + +   dnl Check for SDL +   SDL_VERSION=1.2.0 +   AM_PATH_SDL($SDL_VERSION, +   	:, +   	AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) +   	) +   CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" +   LDFLAGS="$LDFLAGS $SDL_LIBS" + +   dnl Make code aware of the gui +   AC_DEFINE([USE_GUI], [], [Is defined if te project is configured to compile with gui]) + fi  + +dnl ======================= +dnl Configure ffmpeg plugin +dnl ======================= +#AM_PATH_FFMPEG + +#LD_FLAGS=$LD_FLAGS $LIBS + +# And now for the conditionals (for ffmpeg) +#AM_CONDITIONAL(AMM_LINK_SHARED, test $lt_major_version -ge 1 -a $lt_minor_version -ge 4 -a $lt_micro_version -ge 3 ) +#AM_CONDITIONAL(AMM_FF_A52BIN, test x$enable_ffmpeg_a52bin = xyes) +#AM_CONDITIONAL(AMM_FF_FAAD, test x$have_faad = xyes ) +#AM_CONDITIONAL(AMM_FF_ALPHAOPT, test x$enable_alphaopt = xyes) +#AM_CONDITIONAL(AMM_FF_ARMOPT, test x$enable_armopt = xyes) +#AM_CONDITIONAL(AMM_FF_MIPSOPT, test x$enable_mipsopt = xyes) +#AM_CONDITIONAL(AMM_FF_MLIBOPT, test x$enable_mlibopt = xyes) +#AM_CONDITIONAL(AMM_FF_PPCOPT, test x$enable_ppcopt = xyes) +#AM_CONDITIONAL(AMM_FF_PS2OPT, test x$enable_ps2opt = xyes) +#AM_CONDITIONAL(AMM_FF_SH4OPT, test x$enable_sh4opt = xyes) +#AM_CONDITIONAL(AMM_FF_X86OPT, test x$enable_x86opt = xyes) +#AM_CONDITIONAL(AMM_USE_OSS, test x$enable_oss = xyes) +#AM_CONDITIONAL(AMM_USE_V4L, test x$enable_v4l = xyes ) + + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(CXXFLAGS) + +AC_SUBST(LDFLAGS) + +AC_OUTPUT( +	Makefile  +	src/Makefile) +#	ffmpeg/Makefile +#	ffmpeg/libavformat/Makefile +#	ffmpeg/libavcodec/Makefile +#	ffmpeg/libavcodec/alpha/Makefile +#	ffmpeg/libavcodec/armv4l/Makefile +#	ffmpeg/libavcodec/i386/Makefile +#	ffmpeg/libavcodec/liba52/Makefile +#	ffmpeg/libavcodec/libpostproc/Makefile +#	ffmpeg/libavcodec/mlib/Makefile +#	ffmpeg/libavcodec/ppc/Makefile +#	ffmpeg/libavcodec/ps2/Makefile +#	ffmpeg/libavcodec/sh4/Makefile +#	) diff --git a/pixmaps/camera.png b/pixmaps/camera.png Binary files differnew file mode 100644 index 0000000..2517ba0 --- /dev/null +++ b/pixmaps/camera.png diff --git a/pixmaps/dummy.png b/pixmaps/dummy.png Binary files differnew file mode 100644 index 0000000..da01677 --- /dev/null +++ b/pixmaps/dummy.png diff --git a/pixmaps/miav-logo-256x256.png b/pixmaps/miav-logo-256x256.png Binary files differnew file mode 100644 index 0000000..33ed3b8 --- /dev/null +++ b/pixmaps/miav-logo-256x256.png diff --git a/pixmaps/miav-logo-512x512.png b/pixmaps/miav-logo-512x512.png Binary files differnew file mode 100644 index 0000000..ead949c --- /dev/null +++ b/pixmaps/miav-logo-512x512.png diff --git a/pixmaps/miav-logo-64x64.png b/pixmaps/miav-logo-64x64.png Binary files differnew file mode 100644 index 0000000..625ec40 --- /dev/null +++ b/pixmaps/miav-logo-64x64.png diff --git a/pixmaps/record.png b/pixmaps/record.png Binary files differnew file mode 100644 index 0000000..e453246 --- /dev/null +++ b/pixmaps/record.png diff --git a/pixmaps/stop.png b/pixmaps/stop.png Binary files differnew file mode 100644 index 0000000..5eb5036 --- /dev/null +++ b/pixmaps/stop.png diff --git a/src/Makefile.am b/src/Makefile.am index 40e37ee..75e6f85 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,3 @@ -#frekin' wierd  ## TODO: Move ffmpeg, libxml and libsdl into configure.in  AM_CXXFLAGS := $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I../include $(QT_CXXFLAGS) \ diff --git a/src/aboutwindow.cc b/src/aboutwindow.cc new file mode 100644 index 0000000..6630d4c --- /dev/null +++ b/src/aboutwindow.cc @@ -0,0 +1,89 @@ +/*************************************************************************** + *            aboutwindow.cc + * + *  Sun Aug 22 21:57:49 2004 + *  Copyright  2004  deva + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI +  +#include "aboutwindow.h" + +#include <qpainter.h> +#include <qfont.h> + +#include <config.h> +//"miav-grab.h" + +AboutWindow::AboutWindow( QWidget* parent, const char* name ) +	: QDialog( parent, name ) +{ +	resize(320,460); +//	setModal(true); +	pix_logo = new QPixmap(); +	pix_logo->load("miav-logo-512x512.png"); + +	setBackgroundColor(QColor(150,150,150)); +	 +    btn_ok = new QPushButton(this); +	btn_ok->setText("OK"); +	btn_ok->move(200, 410); +    btn_ok->resize( 95, 40 ); +    btn_ok->setFont( QFont( "Arial", 12, QFont::Bold ) ); + +    QObject::connect( btn_ok, SIGNAL(clicked()), this, SLOT(close()) ); + +	show(); +} + +AboutWindow::~AboutWindow() +{ +} + +void AboutWindow::paintEvent( QPaintEvent *event ) +{ +	if(!event) return; // Just to get rid og the compile warning! +	QPainter painter; +	painter.begin(this); + +	painter.drawPixmap(-200,-50, *pix_logo); + +	painter.setBrush( Dense4Pattern );  +	painter.drawRect(25,25,270,377); +	 +	painter.setBrush( SolidPattern );     +	painter.setFont( QFont( "Arial", 18, QFont::Bold ) ); +	painter.setPen( Qt::black ); +	painter.drawText(58,58, "MIAV-Grab v" VERSION); +	painter.setPen( Qt::red ); +	painter.drawText(60,60, "MIAV-Grab v" VERSION); + +	painter.setPen( Qt::white ); +	painter.setFont( QFont( "Arial", 11, QFont::Bold ) ); +	painter.drawText(30,70, 270, 357, 0, ABOUT_INFO); + +	painter.setPen( Qt::white ); +	painter.setFont( QFont( "Arial", 8, QFont::Bold ) ); +	painter.drawText(30,165, 270, 357, 0, GPL_LICENSE); + +	painter.end(); +} + +#endif /*USE_GUI*/ diff --git a/src/aboutwindow.h b/src/aboutwindow.h new file mode 100644 index 0000000..a8437b5 --- /dev/null +++ b/src/aboutwindow.h @@ -0,0 +1,77 @@ +/*************************************************************************** + *            aboutwindow.h + * + *  Sun Aug 22 21:58:22 2004 + *  Copyright  2004  deva + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI +  +#ifndef __ABOUTWINDOW_H__ +#define __ABOUTWINDOW_H__ + +#include <qdialog.h> +//#include <qlabel.h> +#include <qpixmap.h> +//#include <qtextedit.h> +#include <qpushbutton.h> + +#define ABOUT_INFO "\ +Official homepage:\n\ +    http://www.aasimon.org/miav\n\ +Author:\n\ +    Bent Bisballe (deva@aasimon.org)\n\ +Copyright (c) 2004" + +#define GPL_LICENSE "\ +This program is free software; you can\n\ +redistribute it and/or modify it under the terms\n\ +of the GNU General Public License as published\n\ +by the Free Software Foundation; either version\n\ +2 of the License, or (at your option) any later\n\ +version.\n\ +   This program is distributed in the hope that\n\ +it will be useful, but WITHOUT ANY WARRANTY;\n\ +without even the implied warranty of\n\ +MERCHANTABILITY or FITNESS FOR A PARTI-\n\ +CULAR PURPOSE. See the GNU Library General\n\ +Public License for more details.\n\ +    You should have received a copy of the GNU\n\ +General Public License along with this program;\n\ +if not, write to the Free Software Foundation,\n\ +Inc., 59 Temple Place - Suite 330, Boston,\n\ +MA 02111-1307, USA." + +class AboutWindow : public QDialog +{ +	Q_OBJECT +public: +	AboutWindow(QWidget* parent = 0, const char* name = 0); +	~AboutWindow(); +	virtual void paintEvent( QPaintEvent *event ); + +private: +	QPushButton *btn_ok; +	QPixmap		*pix_logo; +}; + +#endif /* __ABOUTWINDOW_H__ */ + +#endif /*USE_GUI*/ diff --git a/src/camera.cc b/src/camera.cc new file mode 100644 index 0000000..574caf3 --- /dev/null +++ b/src/camera.cc @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            camera.cc + * + *  Fri Oct 29 12:46:38 CEST 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI + +#include "camera.h" + +Camera::Camera(const char *ip, const int port) +{ +  pthread_mutex_init (&mutex, NULL); +  //mutex = PTHREAD_MUTEX_INITIALIZER; +   +	AVFormatContext *ifmtctx; +	AVFormatContext *ofmtctx; + +  running = 1; + +	int channel = 0; +	char *device = "/dev/dv1394"; + +	av_register_all(); + +	encode_queue = new Queue<DVFrame>(); // infinite size +	player_queue = new Queue<FFFrame>(1); // fixed size of 1 + +	sem_init(&encode_sem, 0, 0); +	sem_init(&player_sem, 0, 0); + +	decoder = new Decoder(device,  +                        channel, +                        &encode_sem, +                        &player_sem, +                        encode_queue, +                        player_queue, +                        &mutex, +                        &running); +  //  ifmtctx = decoder->fc; +  if(!decoder->fc) return; + +	encoder = new Encoder(ip, port, +                        &encode_sem, +                        encode_queue, +                        &mutex, +                        &running); +  ofmtctx = encoder->fc; + +	player = new Player(&running, +                      &player_sem, +                      player_queue, +                      &mutex); + +  pthread_create (&decodetid, NULL, thread_run, decoder); +  pthread_create (&encodetid, NULL, thread_run, encoder); +  pthread_create (&playertid, NULL, thread_run, player); +} + +Camera::~Camera() +{ +  // Signal to the threads to stop +  running = 0; + +	pthread_join(decodetid, NULL); +	pthread_join(playertid, NULL); +  pthread_join(encodetid, NULL); + +	delete decoder; +	delete encoder; +	delete player; + +	sem_destroy(&encode_sem); +	sem_destroy(&player_sem); + +	delete player_queue; +	delete encode_queue; +} + +void Camera::setCpr(char *newcpr) +{ +  encoder->setCpr(newcpr); +} + + +void Camera::start() +{ +  encoder->stop(); +} + +void Camera::stop() +{ +  encoder->start(); +} + +void Camera::freeze() +{ +  player->stop(); +  encoder->freeze(); +} + +void Camera::unfreeze() +{ +  player->start(); +} + +void Camera::snapshot() +{ +  encoder->shoot(); +} + +#endif/* USE_GUI */ diff --git a/src/camera.h b/src/camera.h new file mode 100644 index 0000000..5190954 --- /dev/null +++ b/src/camera.h @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            camera.h + * + *  Fri Oct 29 12:46:38 CEST 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI + +#ifndef __CAMERA_H__ +#define __CAMERA_H__ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> +#include <avformat.h> + +#include "util.h" +#include <queue.h> +#include "decoder.h" +#include "encoder.h" +#include "player.h" + +#include "thread.h" +#include "ffframe.h" +#include <dvframe.h> + +#include <qwidget.h> + +class Camera { +public: +  Camera(const char *ip, +         const int port); +  ~Camera(); +  void setCpr(char *newcpr); +  void start(); +  void stop(); +  void freeze(); +  void unfreeze(); +  void snapshot(); + +private: +	pthread_t playertid; +	pthread_t decodetid; +	pthread_t encodetid; +	volatile int running; + +  Encoder *encoder; +  Decoder *decoder; +  Player *player; + +  Queue<DVFrame> *encode_queue; +  Queue<FFFrame> *player_queue; +  sem_t encode_sem; +  sem_t player_sem; +  pthread_mutex_t mutex;// = PTHREAD_MUTEX_INITIALIZER; +}; + + +#endif/*__CAMERA_H__*/ + +#endif/* USE_GUI */ diff --git a/src/cprquerydialog.cc b/src/cprquerydialog.cc new file mode 100644 index 0000000..d5d3c44 --- /dev/null +++ b/src/cprquerydialog.cc @@ -0,0 +1,376 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            cprquerydialog.cc + * + *  Sat Feb 19 17:05:43 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI + +#include <qframe.h> + +#include "messagebox.h" +#include "cprquerydialog.h" +#include "miav_config.h" + +CPRQueryDialog::CPRQueryDialog(QLabel *lcpr, +                               QLabel *lname, +                               QWidget *parent,  +                               const char *name, +                               bool modal) +	: QDialog( parent, name, modal) +{ +  MiavConfig cfg("cprquery.conf"); + +  lbl_name = lname; +  lbl_cpr = lcpr; + +  //Read configuration +  CPR_HOST = cfg.readString("cpr_host"); +  CPR_PORT = cfg.readInt("cpr_port"); + +  cpr[0] = '\0'; +  internalCpr[0] = '\0';	 + +  cprSocket = new QSocket(this); +  connect(cprSocket, SIGNAL(readyRead()), SLOT(cprSocket_readyRead())); +  connect(cprSocket, SIGNAL(connected()), SLOT(cprSocket_connected())); +  ccw = new MessageBox(this, "Confirm", "Ugyldigt CPR nummer, brug det alligevel?", TYPE_YES_NO_CANCEL); +  /*   +   +  //  connect(btn_cpr, SIGNAL(clicked()), SLOT(bcancel_clicked())); + +  //show(); +  //run(0); +  */ + +  lbl_cpr->setText("Indtast CPR"); + +  // Generate input buttons +	//digits = pos; +	 +	QFrame *topf = new QFrame(this); +	topf->setFrameStyle(QFrame::Box | QFrame::Raised); +	topf->setLineWidth(3); +	QHBoxLayout *bl = new QHBoxLayout(this); +	bl->addWidget(topf); + +	QGridLayout *gl = new QGridLayout(topf, 4, 3, 10, 2); +	QButton *b1 = createButton(topf, "1", 1); +	QButton *b2 = createButton(topf, "2", 2); +	QButton *b3 = createButton(topf, "3", 3); +	QButton *b4 = createButton(topf, "4", 4); +	QButton *b5 = createButton(topf, "5", 5); +	QButton *b6 = createButton(topf, "6", 6); +	QButton *b7 = createButton(topf, "7", 7); +	QButton *b8 = createButton(topf, "8", 8); +	QButton *b9 = createButton(topf, "9", 9); +	QButton *b0 = createButton(topf, "0", 0); +	QButton *bbs = createButton(topf, "<-", 10); +	QButton *bca = createButton(topf, "CA", 11); + +	gl->addWidget(b1, 0,0); +	gl->addWidget(b2, 0,1); +	gl->addWidget(b3, 0,2); +	gl->addWidget(b4, 1,0); +	gl->addWidget(b5, 1,1); +	gl->addWidget(b6, 1,2); +	gl->addWidget(b7, 2,0); +	gl->addWidget(b8, 2,1); +	gl->addWidget(b9, 2,2); +	gl->addWidget(b0, 3,1); +	gl->addWidget(bbs, 3,2); +	gl->addWidget(bca, 3,0); + +	/* Setup signals */ +	connect(b1, SIGNAL(clicked()), SLOT(b_1_clicked())); +	connect(b2, SIGNAL(clicked()), SLOT(b_2_clicked())); +	connect(b3, SIGNAL(clicked()), SLOT(b_3_clicked())); +	connect(b4, SIGNAL(clicked()), SLOT(b_4_clicked())); +	connect(b5, SIGNAL(clicked()), SLOT(b_5_clicked())); +	connect(b6, SIGNAL(clicked()), SLOT(b_6_clicked())); +	connect(b7, SIGNAL(clicked()), SLOT(b_7_clicked())); +	connect(b8, SIGNAL(clicked()), SLOT(b_8_clicked())); +	connect(b9, SIGNAL(clicked()), SLOT(b_9_clicked())); +	connect(b0, SIGNAL(clicked()), SLOT(b_0_clicked())); +	connect(bbs,SIGNAL(clicked()), SLOT(b_b_clicked())); +	connect(bca,SIGNAL(clicked()), SLOT(b_c_clicked())); +	 +	this->move(175,150); +  show(); +} + +CPRQueryDialog::~CPRQueryDialog() +{ +  delete ccw; +} + +QPushButton *CPRQueryDialog::createButton(QWidget *parent, const char *text, int value)  +/* A genric button-creater */ +{ +  char buf[32]; +  sprintf(buf, "%d", value); +  QPushButton *q = new QPushButton(this, buf); +   +	QFont f("Lucida", 48); +	q->setFixedSize(150, 100); +	q->setText(text); +	q->setFont(f); +	return q; +} + +/* Event function for handling buttonclicks. + * For button 0-9 the values is sent back. + * Backspace and clear are handled via special + * signals. + * When 10 digits has been input we close the form + */ +void CPRQueryDialog::b_1_clicked() { insert_digit(1); } +void CPRQueryDialog::b_2_clicked() { insert_digit(2); } +void CPRQueryDialog::b_3_clicked() { insert_digit(3); } +void CPRQueryDialog::b_4_clicked() { insert_digit(4); } +void CPRQueryDialog::b_5_clicked() { insert_digit(5); } +void CPRQueryDialog::b_6_clicked() { insert_digit(6); } +void CPRQueryDialog::b_7_clicked() { insert_digit(7); } +void CPRQueryDialog::b_8_clicked() { insert_digit(8); } +void CPRQueryDialog::b_9_clicked() { insert_digit(9); } +void CPRQueryDialog::b_0_clicked() { insert_digit(0);} +void CPRQueryDialog::b_b_clicked() { remove_digit();} +void CPRQueryDialog::b_c_clicked() { remove_all();} + +void CPRQueryDialog::b_clicked(int value)  +{ +  printf("%d\n", value); +	switch(value) { +		case 10: +			if (digits>0) digits--; +			emit bbs_clicked(); +			break; +		case 11: +			digits = 0; +			emit bca_clicked(); +			break; +		default: +			digits++; +			emit number_clicked(value); +	}		 +	if (digits == 10){ +		digits = 0; +		accept(); +	} +} + +void CPRQueryDialog::run(int pos)  +/* This is where the mgui thread starts. + * Open a inputwindow and prepare to receive a cpr + */  +{ + +  //  iw = new CPRQueryDialog(this, "Input", true, pos); +   + +  // TODO : Reconnect +  /* +  if (this->exec() == QDialog::Accepted) { +#ifdef WITH_DV +    camera->setCpr(cpr); +#endif +    verifycpr(cpr); +  } +  */ +} + +void CPRQueryDialog::remove_digit()  +/* Remove one digit from the selected cpr + * Used when the user pushes backspace in + * the inputwindow + */ +{ +  int temp; +  temp = strlen(cpr); +  if (temp == 7) /* Remove two characters due to the hyphen */ +    strcpy(cpr+temp-2, "\0"); +  else if ((temp >0) && (temp <=11)) +    strcpy(cpr+temp-1, "\0"); +  lbl_cpr->setText(cpr); +} + +void CPRQueryDialog::remove_all()  +/* Clear the selected cpr */ +{ +  strcpy(cpr, ""); +  lbl_cpr->setText(cpr); +} + +void CPRQueryDialog::insert_digit(int value) +/* Respond to what the user types in the inputWindow */ +{ +  char temp[2]; +  switch(strlen(cpr)) { +  case 5: // Automaticaly add a hyphen after the sixth digit +    sprintf(temp, "%d-", value); +    strcat(cpr, temp); +    lbl_cpr->setText(cpr); +    break; +  case 10: +    sprintf(temp, "%d", value); +    strcat(cpr, temp); +    lbl_cpr->setText(cpr); +    verifycpr(cpr); +    break; +  default: +    sprintf(temp, "%d", value); +    strcat(cpr, temp); +    lbl_cpr->setText(cpr); +    break; +  } +} + +void CPRQueryDialog::verifycpr(char *cpr)  +/* Test a cpr via test_cpr(). + * If cpr is invalid, then ask user what + * to do via confirmCprWindow + */ +{ +  strncpy(internalCpr, cpr, 6); +  strncpy(internalCpr+6, cpr+7, 4); +  internalCpr[10] = 0; +   +  if (!(test_cpr(internalCpr))) { +    switch(ccw->exec()) { +    case MSG_CANCEL: +      bedit_clicked(); +      break; +    case MSG_NO: +      bcancel_clicked(); +      break; +    case MSG_YES: +      accept(); +      break; +    } +  } else { +    cprSocket->connectToHost(CPR_HOST->c_str(), CPR_PORT); +    accept(); +  } +} + + +void CPRQueryDialog::bcancel_clicked() +/* Clears all data - alerts user if measurements are not stored */ +{ +  cpr[0]= '\0'; +  lbl_cpr->setText("Indtast CPR"); +  lbl_name->setText(""); +  run(0); +} + +void CPRQueryDialog::bedit_clicked()  +/* This is used when the user enters a cpr that is not valid and wishes to edit + * the cpr. + */ +{ +  cpr[10]= '\0'; +  lbl_cpr->setText(cpr); +  lbl_name->setText(""); +  run(9); +} + + +int CPRQueryDialog::test_cpr(const char *s) +/* Checks that a cpr i valid via a modulo11 test */ +{ +  int sum = 0; +  int ctl; +  const char *cptr; +   +  if(strlen(s) != 10) +    return 0; +   +  for(cptr = s; *cptr; cptr++) +    { +      if(!isdigit(*cptr)) +	return 0; +    } +  sum += (s[0] - '0') * 4; +  sum += (s[1] - '0') * 3; +  sum += (s[2] - '0') * 2; +  sum += (s[3] - '0') * 7; +  sum += (s[4] - '0') * 6; +  sum += (s[5] - '0') * 5; +  sum += (s[6] - '0') * 4; +  sum += (s[7] - '0') * 3; +  sum += (s[8] - '0') * 2; +  ctl = 11 - (sum % 11); +  if(ctl == 11) +    ctl = 0; +  return s[9] - '0' == ctl; +} + +void CPRQueryDialog::cprSocket_readyRead()  +/* Uses a patients cpr to look up his or hers name + * via the departments cpr-server. + * This is called by the cprSocket when the socket is ready + */ +{ +  QString name; +  QString firstname; +  QString lastname; +  int timeout = 0; +  if (!cprSocket->canReadLine()) +    return; +  while(cprSocket->canReadLine()) { +    QString s = cprSocket->readLine(); +    if (s.startsWith("0001")) { +      name.append(s.right(s.length()-4)); +      lastname.append(s.right(s.length()-4)); +      name.setLength(name.length()-1); +      if (name.length()) +	name += QString(", "); +       +    } +    if (s.startsWith("0002")) { +      name.append(s.right(s.length()-4)); +      firstname.append(s.right(s.length()-4)); +      name.setLength(name.length()-1); +      cprSocket->close(); +      lbl_name->setText(name); +      return; +    } +    if (timeout>1000) +      { +	lbl_name->setText(NAME_NOT_AVAILABLE); +	return; +      } +    timeout++; +  } +} + + +void CPRQueryDialog::cprSocket_connected()  +/* Writes the selected cpr to the cpr-server + * when the cprSocket is connected. + */ +{	 +  cprSocket->writeBlock(internalCpr, 10); +  cprSocket->writeBlock("\n", 1); +} + +#endif /* USE_GUI */ diff --git a/src/cprquerydialog.h b/src/cprquerydialog.h new file mode 100644 index 0000000..56f800c --- /dev/null +++ b/src/cprquerydialog.h @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            cprquerydialog.h + * + *  Sat Feb 19 17:05:42 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __MIAV_CPRQUERYDIALOG_H__ +#define __MIAV_CPRQUERYDIALOG_H__ + +#define CPR_EDIT        8 +#define CPR_CLEAR       9 +#define NAME_NOT_AVAILABLE      "Kunne ikke slå navn op i cpr-database" + +#include <config.h> +#ifdef USE_GUI + +#include <qdialog.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qfont.h> + +#include <qwidget.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qdialog.h> +#include <qlabel.h> + +#include <qsocket.h> +#include <qtextedit.h> +#include <qstring.h> +#include <qwidget.h> + +#include <qevent.h> + +#include <qpushbutton.h> + +#include <qwidget.h> +#include <qlayout.h> +#include <qdialog.h> + +#include <string> +using namespace std; + +#include <qdialog.h> +#include <qlabel.h> +#include <qsocket.h> + +#include "messagebox.h" + + + +class CPRQueryDialog : public QDialog { +  Q_OBJECT +public: +  CPRQueryDialog(QLabel *lcpr,  +                 QLabel *lname,  +                 QWidget * parent = 0,  +                 const char * name = 0,  +                 bool modal = FALSE); +  ~CPRQueryDialog(); +   +public slots: +  void bcancel_clicked(); +  void bedit_clicked(); +  void remove_digit(); +  void remove_all(); +  void insert_digit(int value);	 +  void cprSocket_readyRead(); +  void cprSocket_connected(); +		 +private: +  QLabel *lbl_cpr; +  QLabel *lbl_name; + +  MessageBox *ccw; +   +  QSocket *cprSocket;	 +  char cpr[12]; +  char internalCpr[11]; +   +  void verifycpr(char *cpr); +  void run(int pos); +  int test_cpr(const char *s); +   +  /*Configuration*/ +  string *CPR_HOST; +  int CPR_PORT; + +signals: +  void bbs_clicked(); +  void bca_clicked(); +  void number_clicked(int); + +public slots: +  void b_1_clicked(); +  void b_2_clicked(); +  void b_3_clicked(); +  void b_4_clicked(); +  void b_5_clicked(); +  void b_6_clicked(); +  void b_7_clicked(); +  void b_8_clicked(); +  void b_9_clicked(); +  void b_0_clicked(); +  void b_b_clicked(); +  void b_c_clicked(); + +private: +  void b_clicked(int value); +  QPushButton *createButton(QWidget *parent, const char *text, int value); +  int digits; +}; + +#endif/*__MIAV_CPRQUERYDIALOG_H__*/ + +#endif /* USE_GUI */ diff --git a/src/decoder.cc b/src/decoder.cc new file mode 100644 index 0000000..2171b1a --- /dev/null +++ b/src/decoder.cc @@ -0,0 +1,171 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * Copyright (C) 2004  Koen Otter and Glenn van der Meyden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ +#include <config.h> + +#include "decoder.h" + +Decoder::Decoder(char *device,  +                 int channel,  +                 sem_t *gencode_sem, +                 sem_t *gplayer_sem, +                 Queue<DVFrame> *gencode_queue, +                 Queue<FFFrame> *gplayer_queue, +                 pthread_mutex_t *gmutex, +                 volatile int *grunning) +{ +  encode_sem = gencode_sem; +  player_sem = gplayer_sem; +  encode_queue = gencode_queue; +  player_queue = gplayer_queue; +  mutex = gmutex; +  running = grunning; + +  AVFormatContext *ifc; +  AVFormatParameters dvpars; +  AVInputFormat *iformat; +  AVCodec *dec_codec; +   +  memset(&dvpars, 0, sizeof(dvpars)); +   +  if(!(iformat = av_find_input_format("dv1394"))) { +    fprintf(stderr, "Failed to get input format dv1394\n"); +    exit(1); +  } +   +  dvpars.device  = device;	/* "/dev/dv1394"; */ +  dvpars.channel = channel; +  dvpars.standard = "pal"; +   +  if(av_open_input_file(&ifc, "", iformat, 0, &dvpars) < 0) { +    fprintf(stderr, "Device is in use\n"); +    fc = NULL; return; +  } +  if(av_find_stream_info(ifc) < 0) { +    fprintf (stderr, "Could not find enough parameters\n"); +    fc = NULL; return; +  } + +  dump_format(ifc, 1, "", 0); +	 +  if(!(dec_codec = avcodec_find_decoder(ifc->streams[0]->codec.codec_id))) { +    printf("Unsupported codec for input stream \n"); +    fc = NULL; return; +  } + +  if(avcodec_open(&ifc->streams[0]->codec, dec_codec) < 0) { +    printf("Error while opening codec for input stream\n"); +    fc = NULL; return; +  } + +  fc = ifc; +} + +Decoder::~Decoder() +{ +  avcodec_close(&fc->streams[0]->codec); +  av_close_input_file(fc); +} + +void Decoder::decode() +{ +  if(fc == NULL) { +    printf("Decoder not initialized.\n"); +    return; +  } + +  while(*running) { +    AVPacket pkt; +    uint8_t *ptr; +    int len; +    SDL_Event user_event; +     +    av_read_packet(fc, &pkt); +    len = pkt.size; +    ptr = pkt.data; +    /* NOTE: we only decode video, we only need the data from stream_index 0 */ +    /* (stream 0: video, stream 1: audio) */ + +    while(pkt.stream_index == 0 && len > 0) { +      int ret; +      int got_picture; +      //      buf_t *buf = buf_alloc(); +      FFFrame *fff = new FFFrame(); +      DVFrame *dvf = new DVFrame(); +      dvf->type = DVF_VIDEO; +       +      memcpy(dvf->frame, ptr, len); + +      //      fprintf(stderr, "DVBufferSize: [%d]bytes\n", len); +      ret = avcodec_decode_video(&fc->streams[0]->codec,  +				 fff->frame, &got_picture, ptr, len); +       +      if(ret < 0) { +        fprintf(stderr, "Error while decoding stream\n"); +        exit(1); +      } + +      len -= ret; +      ptr += ret; +       +      pthread_mutex_lock(mutex); +      encode_queue->push(dvf); +      player_queue->push(fff); +      pthread_mutex_unlock(mutex); +       +      sem_post(encode_sem); +       +      user_event.type = SDL_USEREVENT; +      user_event.user.code = 0; +      user_event.user.data1 = NULL; +      user_event.user.data2 = NULL; +      SDL_PushEvent(&user_event); +    } + +    /* // For later use, when audio must be implemented +    while(pkt.stream_index == 1 && len > 0) { +      DVFrame *dvf = new DVFrame(); +      dvf->type = DVF_AUDIO; + +      memcpy(dvf->frame, ptr, sizeof(dvf->frame)); + +      ptr += sizeof(dvf->frame); +      len -= sizeof(dvf->frame); + +      pthread_mutex_lock(mutex); +      encode_queue->push(dvf); +      pthread_mutex_unlock(mutex); +       +      sem_post(encode_sem); +    } +    */ +    av_free_packet(&pkt); +  } + +  /* Kick the others so they wake up with empty queues */ +  sem_post(encode_sem); +  pthread_exit(NULL); +} + +void Decoder::run() { +  decode(); +} diff --git a/src/decoder.h b/src/decoder.h new file mode 100644 index 0000000..ad323b1 --- /dev/null +++ b/src/decoder.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ +#include <config.h> +#ifndef __RTVIDEOREC_DECODER_H +#define __RTVIDEOREC_DECODER_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <avformat.h> +#include <SDL/SDL.h> + +#include <queue.h> +#include "encoder.h" +#include "player.h" + +#include "thread.h" +#include "ffframe.h" +#include <dvframe.h> + +class Decoder : public Thread { + public: +  Decoder(char *device,  +          int channel, +          sem_t *gencode_sem, +          sem_t *gplayer_sem, +          Queue<DVFrame> *gencode_queue, +          Queue<FFFrame> *gplayer_queue, +          pthread_mutex_t *gmutex, +          volatile int *grunning); +  ~Decoder(); +  void run(); + +  AVFormatContext *fc; +  sem_t *encode_sem; +  sem_t *player_sem; +  Queue<DVFrame> *encode_queue; +  Queue<FFFrame> *player_queue; +  pthread_mutex_t *mutex; +  volatile int *running; + + private: +  void decode(); +}; + +#endif diff --git a/src/dvframe.cc b/src/dvframe.cc new file mode 100644 index 0000000..229332c --- /dev/null +++ b/src/dvframe.cc @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            frame.cc + * + *  Mon Nov 15 19:45:07 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> + +#include "dvframe.h" + +#include <memory.h> + +DVFrame::DVFrame() +{ +  //  frame = avcodec_alloc_frame(); +  memset(frame, 0, sizeof(frame)); +} + +DVFrame::~DVFrame() +{ +  //	av_free(frame); +} + diff --git a/src/dvframe.h b/src/dvframe.h new file mode 100644 index 0000000..a9e948c --- /dev/null +++ b/src/dvframe.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            frame.h + * + *  Mon Nov 15 19:45:07 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifndef __DVFRAME_H__ +#define __DVFRAME_H__ + +//#include <avformat.h> + +#define DVPACKAGE_SIZE 144000 + +typedef enum { +  DVF_AUDIO = 0x01, +  DVF_VIDEO = 0x02 +} DVFrameType; + + +class DVFrame { +public: +  DVFrame(); +  ~DVFrame(); +  DVFrameType type; +  char frame[DVPACKAGE_SIZE]; +}; + +#endif/*__DVFRAME_H__*/ diff --git a/src/encoder.cc b/src/encoder.cc new file mode 100644 index 0000000..3da7443 --- /dev/null +++ b/src/encoder.cc @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * Copyright (C) 2004  Koen Otter and Glenn van der Meyden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <config.h> +#include "encoder.h" + +Encoder::Encoder(const char *gip, +                 const int gport, +                 sem_t	*gsem, +                 Queue<DVFrame> *gqueue, +                 pthread_mutex_t *gmutex, +                 volatile int *grunning) +{ +  sprintf(ip, gip); +  port = gport; +  memset(cpr, 0, sizeof(cpr)); + +  printf("[ip:   %s]\n", ip); +  printf("[port: %d]\n", port); + +  sem = gsem; +  queue = gqueue; +  mutex = gmutex; +  running = grunning; + +  record = 0; + + 	sem_init(&record_sem, 0, 0); + +  s = NULL; +  n = NULL; + +  shoot_request = 0; +  shoot_value = 0; +  freeze_request = 0; +  freeze_value = 0; + +} + +Encoder::~Encoder() +{ +  if(n) delete n; +  if(s) delete s; +} + + +void Encoder::setCpr(char *newcpr) +{ +  sprintf(cpr, newcpr); +} + + +void Encoder::encode() +{  +  DVFrame *f; + +  while(*running) { +    sem_wait(sem); + +    /* +    pthread_mutex_lock(mutex); +    while((f = queue->pop())) delete f; +    pthread_mutex_unlock(mutex); + +    while(record) { +    sem_wait(sem); +    */ +       +      pthread_mutex_lock(mutex); +      f = queue->pop(); +      pthread_mutex_unlock(mutex); +       +      if((f && record) || (freeze_request != freeze_value) || (shoot_request != shoot_value)) { +        fprintf(stderr, "Rec!\n"); +        n_header h; + +        h.header_type = DATA_HEADER; +        sprintf(h.header.h_data.cpr, cpr); +        h.header.h_data.freeze = (freeze_request != freeze_value); +        h.header.h_data.snapshot = (shoot_request != shoot_value); +        h.header.h_data.record = record; + +        if(freeze_request != freeze_value) freeze_value = freeze_request; +        if(shoot_request != shoot_value) shoot_value = shoot_request; + +        n->sendPackage(&h, f->frame, sizeof(f->frame)); +      } + +      if(f) delete f; +      //} +  } +  pthread_exit(NULL); +} + +void Encoder::freeze() +{   +  if(!s) { +    s = new Socket(port); +    s->sconnect(ip); +    n = new Network(s); +  } +  freeze_request = 1 - freeze_request; +} + +void Encoder::shoot() +{ +  if(!s) { +    s = new Socket(port); +    s->sconnect(ip); +    n = new Network(s); +  } +  shoot_request = 1 - shoot_request; +} + +void Encoder::run() { +  encode(); +} + +void Encoder::start() { +  printf("GO!\n"); +  if(!s) { +    s = new Socket(port); +    s->sconnect(ip); +    n = new Network(s); +  } +  record = 1; +} + +void Encoder::stop() { +  printf("STOP!\n"); +  if(s) { +    if(n) delete n; +    delete s; +    s = NULL; +    n = NULL; +  } +  record = 0; +} diff --git a/src/encoder.h b/src/encoder.h new file mode 100644 index 0000000..d517ff5 --- /dev/null +++ b/src/encoder.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ +#include <config.h> +#ifndef __RTVIDEOREC_ENCODER_H +#define __RTVIDEOREC_ENCODER_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <avformat.h> + +#include <miav.h> + +#include "util.h" +#include <queue.h> + +#include "thread.h" +#include <dvframe.h> + +#define VIDEO_BUFFER_SIZE	(1024*1024)	/* FIXME: One size fits all... */ + + + +class Encoder : public Thread { + public: +  Encoder(const char *gip, +          const int gport, +          sem_t	*gsem, +          Queue<DVFrame> *gqueue, +          pthread_mutex_t *gmutex, +          volatile int *grunning); +  ~Encoder(); +   +  void setCpr(char *newcpr); + +  void start(); +  void stop(); + +  void freeze(); +  void shoot(); + +  void run(); + +  AVFormatContext *fc; +  sem_t	*sem; +  Queue<DVFrame> *queue; +  pthread_mutex_t *mutex; +  volatile int *running; + + private: +  int port; +  char ip[32]; +  char cpr[32]; + +  volatile int record; + +  volatile int shoot_request; +  int shoot_value; +  volatile int freeze_request; +  int freeze_value; +   +  sem_t	record_sem; +  void encode(); + +  Socket *s; +  Network *n; +}; + +#endif + diff --git a/src/ffframe.cc b/src/ffframe.cc new file mode 100644 index 0000000..cdce5ae --- /dev/null +++ b/src/ffframe.cc @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            frame.cc + * + *  Mon Nov 15 19:45:07 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "ffframe.h" + +FFFrame::FFFrame() +{ +  frame = avcodec_alloc_frame(); +} + +FFFrame::~FFFrame() +{ +	av_free(frame); +} + diff --git a/src/ffframe.h b/src/ffframe.h new file mode 100644 index 0000000..5b02780 --- /dev/null +++ b/src/ffframe.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            frame.h + * + *  Mon Nov 15 19:45:07 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifndef __FFFRAME_H__ +#define __FFFRAME_H__ + +#include <avformat.h> + +class FFFrame { +public: +  FFFrame(); +  ~FFFrame(); +  AVFrame *frame; +}; + +#endif/*__FFFRAME_H__*/ diff --git a/src/img_encoder.cc b/src/img_encoder.cc new file mode 100644 index 0000000..2f6d8b7 --- /dev/null +++ b/src/img_encoder.cc @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * Copyright (C) 2004  Koen Otter and Glenn van der Meyden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include "img_encoder.h" +#include <stdio.h> +//#include <setjmp.h> + +//av_alloc_format_context +//av_destruct_packet_nofree + +ImgEncoder::ImgEncoder() +{ +  //////////////////// GLOBAL INIT +	av_register_all(); + +  //////////////////// DECODE INIT +  AVCodec *deccodec; +   +  // find the dvvideo decoder +  deccodec = avcodec_find_decoder(CODEC_ID_DVVIDEO); +  if (!deccodec) { +    fprintf(stderr, "codec not found\n"); +    exit(1); +  } +   +  dcc= avcodec_alloc_context(); +   +  // open it +  if (avcodec_open(dcc, deccodec) < 0) { +    fprintf(stderr, "could not open codec\n"); +    exit(1); +  } +} + +ImgEncoder::~ImgEncoder() +{ +  // FIXME: free: deccodec and dcc +} + +void ImgEncoder::encode(DVFrame *dvframe,  +                        char *filename,  +                        int quality) +{  +  int ret; +  AVFrame *rawframe = avcodec_alloc_frame(); + +  ///////////////////////// DECODE +  uint8_t *ptr; +  int got_picture = 1; +  int len; + +  ptr = (uint8_t *)dvframe->frame; +  len = sizeof(dvframe->frame); + +  ret = avcodec_decode_video(dcc, rawframe, &got_picture, ptr, len); + +  if(!ret) { +    printf("Decoder fuckup!\n"); +    return; +  } +   +  // TODO: Do image convertion here! +  AVPicture pict; +  avpicture_alloc(&pict,PIX_FMT_RGB24, 720, 576); + +  img_convert(&pict, PIX_FMT_RGB24, (AVPicture *)rawframe,  +              PIX_FMT_YUV420P, 720, 576); +  printf("converted\n"); +  writeJPEGFile(filename, quality, (JSAMPLE*)(pict.data[0]), 720, 576); +  printf("written\n"); + +  avpicture_free(&pict); +  av_free(rawframe); +} +/////////////////////////////////////////////////////////////////////////////////////////// + +void ImgEncoder::writeJPEGFile(char *filename,  +                               int quality, +                               JSAMPLE * image_buffer, // Points to large array of R,G,B-order data  +                               int image_width,        // Number of columns in image  +                               int image_height        // Number of rows in image  +) +{ +  /* +  struct jpeg_compress_struct cinfo; +  struct jpeg_error_mgr jerr; + +  FILE * outfile;               // target file +  JSAMPROW row_pointer[1];      // pointer to JSAMPLE row[s]  +  int row_stride;               // physical row width in image buffer  + +  // Step 1: allocate and initialize JPEG compression object  +  cinfo.err = jpeg_std_error(&jerr); +  jpeg_create_compress(&cinfo); + +  // Step 2: specify data destination (eg, a file)  +  if ((outfile = fopen(filename, "wb")) == NULL) { +    fprintf(stderr, "can't open %s\n", filename); +    exit(1); +  } +  jpeg_stdio_dest(&cinfo, outfile); + +  // Step 3: set parameters for compression  +  cinfo.image_width = image_width;      // image width and height, in pixels  +  cinfo.image_height = image_height; +  cinfo.input_components = 3;           // # of color components per pixel  +/* +typedef enum { +        JCS_UNKNOWN,            // error/unspecified +        JCS_GRAYSCALE,          // monochrome +        JCS_RGB,                // red/green/blue +        JCS_YCbCr,              // Y/Cb/Cr (also known as YUV) +        JCS_CMYK,               // C/M/Y/K +        JCS_YCCK                // Y/Cb/Cr/K +} J_COLOR_SPACE; +* / +  cinfo.in_color_space = JCS_RGB;       // colorspace of input image  + +  jpeg_set_defaults(&cinfo); + +  jpeg_set_quality(&cinfo, quality, TRUE); // limit to baseline-JPEG values + +  // Step 4: Start compressor  +  jpeg_start_compress(&cinfo, TRUE); + +  // Step 5: while (scan lines remain to be written)  +  row_stride = image_width * 3; // JSAMPLEs per row in image_buffer  + +  while (cinfo.next_scanline < cinfo.image_height) { +    row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; +    (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); +  } + +  // Step 6: Finish compression  +  jpeg_finish_compress(&cinfo); +  fclose(outfile); + +  // Step 7: release JPEG compression object  +  jpeg_destroy_compress(&cinfo); +  */ +} diff --git a/src/img_encoder.h b/src/img_encoder.h new file mode 100644 index 0000000..7f1da7e --- /dev/null +++ b/src/img_encoder.h @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#ifndef __RTVIDEOREC_IMGENCODER_H +#define __RTVIDEOREC_IMGENCODER_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <avformat.h> +#include <jpeglib.h> + +#include <dvframe.h> + +#include "util.h" + +#define VIDEO_BUFFER_SIZE	(1024*1024)	// FIXME: One size fits all... + +class ImgEncoder { + public: +  ImgEncoder(); +  ~ImgEncoder(); +  void encode(DVFrame *frame, char* filename, int quality); +  void writeJPEGFile(char *filename,  +                     int quality, +                     JSAMPLE * image_buffer, // Points to large array of R,G,B-order data  +                     int image_width,        // Number of columns in image  +                     int image_height);      // Number of rows in image  +                      + private: +  // Decoder +  AVFormatContext *dfc; +  AVCodecContext *dcc; + +  // Encoder +  AVFormatContext *efc; +  AVCodecContext *ecc; +  AVPacket epkt; +  unsigned char *video_buffer; +  //  AVPacket pkt; +}; + +#endif + diff --git a/src/mainwindow.cc b/src/mainwindow.cc new file mode 100644 index 0000000..77b8d94 --- /dev/null +++ b/src/mainwindow.cc @@ -0,0 +1,305 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            mainwindow.cc + * + *  Sat Aug 21 19:49:34 2004 + *  Copyright  2004  deva + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI + +#include "mainwindow.h" + +#include <qpainter.h> +#include <qpicture.h> + +#include <qpushbutton.h> +#include <qfont.h> +#include <qpixmap.h> +#include <qimage.h> +#include <qlayout.h> +#include <qstatusbar.h> + +//#include "mgui_alert.h" +//#include "mgui_datasocket.h" + +#include "miav_config.h" + +#include <config.h> +//"miav-grab.h" + + +//#define WITH_DV +MainWindow::MainWindow( QWidget* parent, const char* name ) +	: QWidget( parent, name, WStyle_Customize | WStyle_NoBorder ) +{ +  //  statusBar(); +  // statusBar()->message("fisk"); +  // statusBar()->setSizeGripEnabled(false); + +  MiavConfig cfg("miav.conf"); +  /** /  +  int resolution_w = 1280; // TODO: Read actual resolution +  int resolution_h = 1024; // TODO: Read actual resolution +  /**/ +  /**/ +  int resolution_w = 1024; // TODO: Read actual resolution +  int resolution_h = 768; // TODO: Read actual resolution +  /**/ +  unit = ((float)resolution_w / (float)(cfg.readFloat("screensize") * 3.1f)); + +  move(0,0); +  resize(resolution_w, resolution_h); + +  // Load images +  pix_record = new QPixmap(); +  pix_record->load( "record.png" ); +/* +	QPainter *paint = new QPainter(); +	QPicture *pic = new QPicture(); +	pic->load(fname, "svg"); +	paint->begin(this); +	paint->setWindow(pic->boundingRect()); +	paint->drawPicture(0, 0, *pic); +	paint->end(); + */ + +  pix_stop = new QPixmap(); +  pix_stop->load( "stop.png" ); + +  pix_camera = new QPixmap(); +  pix_camera->load( "camera.png" ); + +  pix_dummy = new QPixmap(); +  pix_dummy->load( "dummy.png" ); +   +  pix_logo = new QPixmap(); +  pix_logo->load( "miav-logo-64x64.png" ); + +  createGui(); +  show(); + +  //  camera = new Camera("192.168.0.10", 30000); + +  recording = false; +  frozen = false; + +  aboutwindow = NULL; + +  //  CPRQueryDialog dlg(lbl_cpr, lbl_name, this, "CPRQueryDialog"); +  //  dlg.exec(); +  // Open the CPR Dialog +  cpr_clicked(); +} + +MainWindow::~MainWindow() +{ +  if(camera) delete camera; +  delete btn_cpr; +  if(aboutwindow) delete aboutwindow; +} + +void MainWindow::createGui() +{ +  // Layout widgets + +  /*  _________________________________________________ +   *(0) __________________________  |  ______________  | +   * | |        |        |        | | |              | | +   * |(1)       |        |        | |(2)             | | +   * | |        |        |        | | |              | | +   * | |        |        |        | | |              | | +   * | |        |        |        | | |______________| | +   * | |        |        |        | | |              | | +   * | |        |        |        | | |              | | +   * | |        |        |        | | |              | | +   * | |________|________|________| | |              | | +   * | |        |        |        | | |______________| | +   * | |________|________|________| | |              | | +   * | |        |        |        | | |              | | +   * | |________|________|________| | |              | | +   * | |        |        |        | | |              | | +   * | |________|________|________| | |______________| | +   * |______________________________|__________________| +   * |______________________________|__________________| +   */ + +	QGridLayout *g0 = new QGridLayout(this, 2, 2, 0, -1, "g0"); +	QGridLayout *g1 = new QGridLayout(3, 4, -1, "g1"); +  g0->addLayout(g1, 0, 0); +	QGridLayout *g2 = new QGridLayout(1, NUM_HISTORY, -1, "g2"); +  g0->addLayout(g2, 0, 1); + +  img_recedge = new QLabel(this); +  img_recedge->setBackgroundColor(QColor(160,160,160)); +  img_recedge->setFixedSize(740,596); +   +  img_live = new VideoWidget(img_recedge); +  //  img_live->setErasePixmap( *pix_dummy ); +  img_live->setFixedSize(720,576); +  img_live->move(10,10); +  g1->addMultiCellWidget ( img_recedge, 0, 0, 0, 2, Qt::AlignHCenter); + +  // CPR/NAME LABEL + CPR button +  lbl_cpr = createLabel("200379-1613", 18, 3); +  g1->addMultiCellWidget ( lbl_cpr, 1, 1, 0, 1); + +  btn_cpr = createButton("NYT CPR", 8, 3); +  btn_cpr->setFocus(); +  QObject::connect( btn_cpr, SIGNAL(clicked()), this, SLOT(cpr_clicked()) ); +  // Will also be connected in the MGUI code +  g1->addWidget(btn_cpr, 1, 2); + +  lbl_name = createLabel("Bent Bisballe Kjær Nyeng Jensen", 18, 2); +  g1->addMultiCellWidget ( lbl_name, 2, 2, 0, 2); + +  // Rec + Shot + Freeze buttons +  btn_rec = createButton("", 8, 3); +  btn_rec->setPixmap(*pix_record); +  QObject::connect( btn_rec, SIGNAL(clicked()), this, SLOT(rec_clicked()) ); +  g1->addWidget(btn_rec, 3, 0); +   +  btn_shoot = createButton("", 8, 3); +  btn_shoot->setPixmap(*pix_camera); +  QObject::connect( btn_shoot, SIGNAL(clicked()), this, SLOT(shoot_clicked()) ); +  g1->addWidget(btn_shoot, 3, 1); +   +  btn_freeze = createButton("FREEZE", 8, 3); +  //  btn_freeze->setPixmap(*pix_logo); +  QObject::connect( btn_freeze, SIGNAL(clicked()), this, SLOT(freeze_clicked()) ); +  g1->addWidget(btn_freeze, 3, 2); +   +  // History widgets +  for(int i = 0; i < NUM_HISTORY; i++) { +    img_history[i] = new QLabel(this); +    img_history[i]->setPixmap(*pix_dummy); +    img_history[i]->setFixedSize(240,192); +    g2->addWidget(img_history[i], i, 0, Qt::AlignHCenter); +  } + +  // Statusbar +  lbl_status = createLabel("STATUS", 18, 1); +	lbl_status->setFrameStyle(QFrame::TabWidgetPanel | QFrame::Sunken); +	lbl_status->setLineWidth(1); +  g0->addWidget(lbl_status, 4, 0); + +  lbl_version = createLabel("MIaV-Grab v" VERSION, 18, 1); +	lbl_version->setFrameStyle(QFrame::TabWidgetPanel | QFrame::Sunken); +	lbl_version->setLineWidth(1); +  lbl_version->setFixedHeight((int)unit); +  g0->addWidget(lbl_version, 4, 1); + +  /* // About icon +  btn_logo = new QPushButton("", this); +  btn_logo->setPixmap(*pix_logo); +  btn_logo->setFixedSize(74,74); +  btn_logo->move(940,10); +  btn_logo->setFlat(true); +  QObject::connect( btn_logo, SIGNAL(clicked()), this, SLOT(logo_clicked()) ); +  */ +  //lbl_version->setFont( QFont( "Arial", 8, QFont::Light ) ); +  //lbl_version->setFixedSize(90,10); +  //lbl_version->move(928,81); + +} + +QPushButton *MainWindow::createButton(char *caption, int width, int height) +{ +  QPushButton *btn = new QPushButton(caption, this); +  btn->setFont( QFont( "Arial", (int)(unit * height / 2), QFont::Bold ) ); +  btn->setFixedHeight((int)(unit * height)); +  return btn; +} + +QLabel *MainWindow::createLabel(char *caption, int width, int height) +{ +  QLabel *lbl = new QLabel(caption, this); +  lbl->setFont( QFont( "Arial", (int)(unit * height / 2), (height>1)?QFont::Bold:QFont::Normal ) ); +  lbl->setFixedHeight((int)(unit * height)); +  return lbl; +} + +void MainWindow::message(char *msg) +{ +  lbl_status->setText(msg); +} + +void MainWindow::logo_clicked() +{ +  if(aboutwindow) +    delete aboutwindow; +  aboutwindow = new AboutWindow(0, "About MIAV-Grab"); +} + +void MainWindow::cpr_clicked() +{ +  CPRQueryDialog dlg(lbl_cpr, lbl_name, this, "CPRQueryDialog"); +  printf("Cpr Dialog returned: %d\n", dlg.exec()); +} + +void MainWindow::rec_clicked() +{ +  recording = 1 - recording; +  if(recording) { +    img_recedge->setBackgroundColor(red); +    btn_rec->setPixmap(*pix_stop); +    camera->stop(); +  } else { +    img_recedge->setBackgroundColor(QColor(160,160,160)); +    btn_rec->setPixmap(*pix_record); +    camera->start(); +  } +} + +void MainWindow::shoot_clicked() +{ +  QImage image; + +  camera->snapshot(); + +  image = img_live->getScreenshot(); +  image = image.smoothScale(img_history[0]->width(), img_history[0]->height()); + +  QPixmap pixmap; +  for(int cnt = (NUM_HISTORY-1); cnt > 0; cnt--) { +    pixmap = *img_history[cnt-1]->pixmap(); +    img_history[cnt]->setPixmap(pixmap); +  } +  img_history[0]->setPixmap(image); + +  if(frozen) { +    camera->unfreeze(); +    btn_freeze->setOn(false); +    frozen = false; +  } +} + +void MainWindow::freeze_clicked() +{ +  if(frozen) { +    camera->unfreeze(); +    frozen = false; +  } else { +    camera->freeze(); +    frozen = true; +  } +} + +#endif /*USE_GUI*/ diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..51cdcca --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            mainwindow.h + * + *  Sat Aug 21 19:50:13 2004 + *  Copyright  2004  deva + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI +  +#ifndef __MAINWINDOW_H__ +#define __MAINWINDOW_H__ + +#include <string> +using namespace std; + +#include <qwidget.h> +#include <qlabel.h> +#include <qpushbutton.h> + +#include "aboutwindow.h" +#include "videowidget.h" +#include "camera.h" +#include "cprquerydialog.h" + +#define NUM_HISTORY 3 + +class MainWindow : public QWidget +{ +  Q_OBJECT +public: +  MainWindow(QWidget* parent = 0, const char* name = 0); +  ~MainWindow(); +   +  void message(char* msg); + +public slots: +  void cpr_clicked(); +  void logo_clicked(); +  void rec_clicked(); +  void shoot_clicked(); +  void freeze_clicked(); +  +private: +  void createGui(); +   +  Camera *camera; +  AboutWindow *aboutwindow; +   +  QPixmap *pix_camera; +  QPixmap *pix_record; +  QPixmap *pix_stop; +  QPixmap *pix_dummy; +  QPixmap *pix_logo; +   +  QLabel *lbl_version; +  QLabel *lbl_status; +  QLabel *lbl_cpr; +  QLabel *lbl_name; + +  QLabel *img_recedge; +  QLabel *img_history[NUM_HISTORY]; +   +  QPushButton *btn_logo; +  QPushButton *btn_cpr; +  QPushButton *btn_rec; +  QPushButton *btn_shoot; +  QPushButton *btn_freeze; +   +  VideoWidget *img_live; +   +  bool recording; +  bool frozen; + +  float unit; + +  QPushButton *createButton(char *caption, int width, int height); +  QLabel *createLabel(char *caption, int width, int height); +}; + +#endif + +#endif /*USE_GUI*/ diff --git a/src/messagebox.cc b/src/messagebox.cc new file mode 100644 index 0000000..47799b7 --- /dev/null +++ b/src/messagebox.cc @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            messagebox.cc + * + *  Fri Feb 25 20:23:19 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "messagebox.h" + +//////////////////////////////////////////////////////////////////////////////////////// +/* If the cpr input by the user is not valid, this dialog + * ask the user what to do. Edit the number, use it as it is,  + * or clear the number. + */ + +MessageBox::MessageBox(QWidget* parent, const char* name, const char* text, msg_type type) +	: QDialog(parent, name, TRUE) +{ +	QFrame *topf = new QFrame(this); +		topf->setFrameStyle(QFrame::Box | QFrame::Raised); +		topf->setLineWidth(3);	 +	QVBoxLayout *bl = new QVBoxLayout(this); +	bl->addWidget(topf); +	 +	QLabel *lbl_text = new QLabel(topf); +  //	text->setText("CPR ikke gyldigt, ønsker du at forsætte?"); +	lbl_text->setText(text); +	lbl_text->setFont(QFont("Lucida", 18)); +	QFrame *f = new QFrame(topf); + +	QVBoxLayout *blayout = new QVBoxLayout(topf, 20, 20); +	blayout->addWidget(lbl_text); +	blayout->addWidget(f); + +  switch(type) { +  case TYPE_OK: { +    QPushButton *bok = createButton(f, "Ok"); +    QGridLayout *glayout = new QGridLayout(f, 1, 1, 20, 20); +    glayout->addWidget(bok, 0, 0); +    connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));	 +    break; +  } +  case TYPE_OK_CANCEL: { +    QPushButton *bok = createButton(f, "Ok"); +    QPushButton *bcancel = createButton(f, "Cancel"); +    QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20); +    glayout->addWidget(bcancel, 0, 1); +    glayout->addWidget(bok, 0, 2); +    connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));	 +    connect(bok, SIGNAL( clicked() ), SLOT(bok_clicked()));	 +    break; +  } +  case TYPE_YES_NO: { +    QPushButton *byes = createButton(f, "Ja"); +    QPushButton *bno = createButton(f, "Nej"); +    QGridLayout *glayout = new QGridLayout(f, 1, 2, 20, 20); +    glayout->addWidget(bno, 0, 0); +    glayout->addWidget(byes, 0, 1); +    connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked())); +    connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));	 +    break; +  } +  case TYPE_YES_NO_CANCEL: { +    QPushButton *byes = createButton(f, "Ja"); +    QPushButton *bcancel = createButton(f, "Cancel"); +    QPushButton *bno = createButton(f, "Nej"); +    QGridLayout *glayout = new QGridLayout(f, 1, 3, 20, 20); +    glayout->addWidget(bno, 0, 0); +    glayout->addWidget(bcancel, 0, 1); +    glayout->addWidget(byes, 0, 2); +    connect(byes, SIGNAL( clicked() ), SLOT(byes_clicked())); +    connect(bcancel, SIGNAL( clicked() ), SLOT(bcancel_clicked()));	 +    connect(bno, SIGNAL( clicked() ), SLOT(bno_clicked()));	 +    break; +  } +  } +} + +QPushButton *MessageBox::createButton(QWidget *parent, const char *text) +{ +	QPushButton *q = new QPushButton(parent); +	q->setText(text); +	q->setFont(QFont("Lucida", 18)); +	q->setFixedSize(200, 75); +	return q; +} + +void MessageBox::bok_clicked()  +{ +	done(MSG_OK); +}	 + +void MessageBox::bcancel_clicked()  +{ +	done(MSG_CANCEL); +}	 + +void MessageBox::byes_clicked()  +{ +	done(MSG_YES); +}	 + +void MessageBox::bno_clicked()  +{ +	done(MSG_NO); +}	 + + +/* +//////////////////////////////////////////////////////////////////////////////////////// +// A generic alert dialog that can either give the user a choice +// (yes or no - returns true or false) or simply give a statement and await the users +// acknowledgement (OK - returns true) +//  + +Alert::Alert(QWidget *parent, const char *text, bool single, const char* name, bool mode)  +: QDialog(parent, name, mode)  +// Sets up the dialog. Two buttons if mode=true otherwise one button  +{ + +	QPushButton *b_true; ; +	QPushButton *b_false; + +	QFrame *topf = new QFrame(this); +	topf->setFrameStyle(QFrame::Box | QFrame::Raised); +	topf->setLineWidth(3);	 +	QVBoxLayout *bl1 = new QVBoxLayout(topf, 20, 20); + +	QLabel *l_text = new QLabel(topf); +	QFont font("Lucida", 18); +	l_text->setText(text); +	l_text->setFont(font); + +	QFrame *f = new QFrame(topf); +	QHBoxLayout *bl2 = new QHBoxLayout(f, 20, 20); + + +	QVBoxLayout *toplayout = new QVBoxLayout(this); +	toplayout->addWidget(topf); +	bl1->addWidget(l_text); +	bl1->addWidget(f); +	if(!single) +	{ +	b_true = createButton(f, M_YES); +	b_false = createButton(f, M_NO); +	bl2->addWidget(b_false); +	bl2->addWidget(b_true); +	connect(b_false, SIGNAL(clicked()), SLOT(false_clicked())); +	connect(b_true, SIGNAL(clicked()), SLOT(true_clicked())); +	} +	else +	{ +	b_true = createButton(f, M_OK); +	bl2->addWidget(b_true); +	connect(b_true, SIGNAL(clicked()), SLOT(true_clicked())); +	} + +} + +QPushButton *Alert::createButton(QWidget *parent, const char *text)  +{ +	QPushButton *q = new QPushButton(parent); +	QFont font("Lucida", 18); +	q->setFont(font); +	q->setText(text); +	q->setFixedSize(200,75); +	return q; +} + +void Alert::true_clicked()  +{ +	accept(); +} + +void Alert::false_clicked()  +{ +	reject(); +} +*/ diff --git a/src/messagebox.h b/src/messagebox.h new file mode 100644 index 0000000..11a1c05 --- /dev/null +++ b/src/messagebox.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            messagebox.h + * + *  Fri Feb 25 20:23:19 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __MIAV_MESSAGEBOX_H__ +#define __MIAV_MESSAGEBOX_H__ + +#include <qdialog.h> +#include <qwidget.h> +#include <qframe.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qlabel.h> + +typedef enum { +  MSG_YES, +  MSG_NO, +  MSG_CANCEL, +  MSG_OK +} msg_val; + +typedef enum { +  TYPE_OK, +  TYPE_OK_CANCEL, +  TYPE_YES_NO, +  TYPE_YES_NO_CANCEL, +} msg_type; + +class MessageBox : public QDialog +{ +	Q_OBJECT +public: +	MessageBox(QWidget* parent = 0, const char* name = "", const char* text = "", msg_type type = TYPE_OK); + +public slots: +  void bok_clicked(); +  void bcancel_clicked(); +  void byes_clicked(); +  void bno_clicked(); + +private: +  QPushButton *createButton(QWidget *parent, const char *text); +}; + +#endif/*__MIAV_MESSAGEBOX_H__*/ diff --git a/src/miav.cc b/src/miav.cc new file mode 100644 index 0000000..4d53bc5 --- /dev/null +++ b/src/miav.cc @@ -0,0 +1,120 @@ +/*************************************************************************** + *            miav.cc + * + *  Sat Aug 21 17:32:24 2004 + *  Copyright  2004  deva + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> + +#include "server.h" +#include "socket.h" + +#ifdef USE_GUI +#include <qapplication.h> +#include "mainwindow.h" +#include <miav.h> +#endif /* USE_GUI */ + +#include <stdio.h> + +enum { +  MODE_GRAB, +  MODE_SERVER +}; + +/**  + * This function starts the MIaV gui. + */ +int grab(int argc, char *argv[]) { +#ifdef USE_GUI +  QApplication miav_grab( argc, argv ); +  MainWindow mainwindow; +  miav_grab.setMainWidget( &mainwindow ); +  return miav_grab.exec(); +#else /* USE_GUI */ +  printf("Error: MIaV was not compiled with GUI support...\n"); +  return 0; +#endif /* USE_GUI */ +} + +/**  + * This function starts the MIaV server. + */ +int server(int argc, char *argv[]) { +  pid_t childpid; // variable to store the child's pid + +  signal(SIGCLD, SIG_IGN);  // Ved SIGCHILD til IGNORE maa wait/waitpid ikke kaldes  +                            //   (ellers kommer der kernel-brok) +   +  if(argc < 1) { +    printf("Usage: miav server [port]\n"); +    printf("[port] Is the port number the server will be listening to.\n"); +    return 1; +  } + +  printf("Listening on port %d\n",atoi(argv[0])); +  Socket *s = new Socket(atoi(argv[0])); + +  while(1) { +    Socket *sc = new Socket(s->slisten()); +    if(sc->isConnected()) { +      childpid = fork(); +       +      if(childpid == -1) { +        // fork() returns -1 on failure +        perror("fork"); +        exit(1);  +      } else if(childpid == 0) { +        // fork() returns 0 to the child process +        delete s; // Close listen socket. +        newConnection(sc); +        delete sc; // Close communication socket. +        exit(0); +      } else { +        // fork() returns new pid to the parent process +      } +    } +  } +  delete s; +  return 0; +} + +int main(int argc, char *argv[]) +{ +  int mode = MODE_GRAB; + +  if(argc < 2) { +    printf("Usage: miav [mode] [mode options]\n"); +    printf("[mode] can be one of the following: grab or server.\n"); +    return 1; +  } + +  if(!strcmp(argv[1], "grab")) mode = MODE_GRAB; +  if(!strcmp(argv[1], "server")) mode = MODE_SERVER; + +  switch(mode) { +  case MODE_GRAB: +    return grab(argc - 2, &argv[2]); +  case MODE_SERVER: +    return server(argc - 2, &argv[2]); +  } +  return 0; +} diff --git a/src/miav.h b/src/miav.h new file mode 100644 index 0000000..d6d860e --- /dev/null +++ b/src/miav.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            miav.h + * + *  Mon Nov  8 09:59:24 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __LIBMIAV_H__ +#define __LIBMIAV_H__ + +#include "util.h" + +#include "network.h" +#include "socket.h" +#include "queue.h" + +#endif/*__LIBMIAV_H__*/ diff --git a/src/miav_config.cc b/src/miav_config.cc new file mode 100644 index 0000000..2af0ef1 --- /dev/null +++ b/src/miav_config.cc @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            miav_config.cc + * + *  Sat Feb 19 14:13:19 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "miav_config.h" + +MiavConfig::MiavConfig(char *file) +{ +  configs = NULL; + +  _cfg *cfg; + +  // TODO: Read config from file. + +  // Add a config +  configs = cfg = (_cfg*) malloc(sizeof(_cfg)); +  cfg->name = new string("cpr_host"); +  cfg->stringval = new string("cpr.j.auh.dk"); +  cfg->next = (_cfg*) malloc(sizeof(_cfg)); + +  // Add another config +  cfg = cfg->next; +  cfg->name = new string("cpr_port"); +  cfg->intval = 10301; +  cfg->next = (_cfg*) malloc(sizeof(_cfg)); + +  // Add another config +  cfg = cfg->next; +  cfg->name = new string("screensize"); +  cfg->floatval = 19.0f; +  cfg->next = NULL; +} + +MiavConfig::~MiavConfig() +{ +  _cfg *die = NULL; +  _cfg *cfg = configs; + +  while(cfg) { +    if(die) free(die); +    die = cfg; +    cfg = cfg->next; +  } +  if(die) free(die); +} + +int MiavConfig::readInt(char *node) +{ +  return findNode(node)->intval; +} + +bool MiavConfig::readBool(char *node) +{ +  return findNode(node)->boolval; +} + +string *MiavConfig::readString(char *node) +{ +  return findNode(node)->stringval; +} + +float MiavConfig::readFloat(char *node) +{ +  return findNode(node)->floatval; +} + +_cfg *MiavConfig::findNode(char* node) +{ +  _cfg *cfg = configs; + +  while(cfg) { +    if(!strcmp(node, cfg->name->c_str())) return cfg; +    cfg = cfg->next; +  } +  fprintf(stderr, "ERROR: Request for nonexisting node \"%s\"!\n", node); +  exit(1); +} diff --git a/src/miav_config.h b/src/miav_config.h new file mode 100644 index 0000000..4b062e0 --- /dev/null +++ b/src/miav_config.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            miav_config.h + * + *  Sat Feb 19 14:13:19 CET 2005 + *  Copyright  2005 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __MIAV_MIAV_CONFIG_H__ +#define __MIAV_MIAV_CONFIG_H__ + +#include <string> +using namespace std; + +typedef struct __cfg { +  string *name; +  bool boolval; +  int intval; +  string *stringval; +  float floatval; +  struct __cfg* next; +} _cfg; + +class MiavConfig { +public: +  MiavConfig(char *file); +  ~MiavConfig(); + +  int readInt(char *node); +  bool readBool(char *node); +  string *readString(char *node); +  float readFloat(char *node); + +private: +  _cfg *findNode(char* node); +  _cfg *configs; +}; + +#endif/*__MIAV_MIAV_CONFIG_H__*/ diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc new file mode 100644 index 0000000..92b2657 --- /dev/null +++ b/src/mov_encoder.cc @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * Copyright (C) 2004  Koen Otter and Glenn van der Meyden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include "mov_encoder.h" + +//av_alloc_format_context +//av_destruct_packet_nofree + +MovEncoder::MovEncoder(const char *filename) +{ +  //////////////////// GLOBAL INIT +	av_register_all(); + +  //////////////////// ENCODE INIT +  AVStream *st; +  AVCodec *enc_codec; + +  if(!(efc = av_alloc_format_context())) { +    fprintf(stderr, "Could not alloc output format context\n"); +    exit(1); +  } + +  efc->oformat = guess_format("mpeg", NULL, NULL); +  //efc->oformat = guess_format(NULL, filename, NULL); + +  if(!(st = av_new_stream(efc, 0))) { +    fprintf(stderr, "Could not alloc stream\n"); +    switch((int)st) { +    case AVERROR_UNKNOWN     : printf("unknown error\n"); +      break; +    case AVERROR_IO          : printf("i/o error\n"); +      break; +    case AVERROR_NUMEXPECTED : printf("number syntax expected in filename\n"); +      break; +    case AVERROR_INVALIDDATA : printf("invalid data found\n"); +      break; +    case AVERROR_NOMEM       : printf("not enough memory\n"); +      break; +    case AVERROR_NOFMT       : printf("unknown format\n"); +      break; +    case AVERROR_NOTSUPP     : printf("operation not supported\n"); +      break; +    } +    exit(1); +  } + +  enc_codec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO); +  if(!enc_codec) { +    printf("Unsupported codec for output stream\n"); +    exit(1); +  } +  avcodec_get_context_defaults(&st->codec); +  ecc = &st->codec; +  ecc->codec_id = CODEC_ID_MPEG2VIDEO;  +  ecc->bit_rate = 8192*1000; +  ecc->bit_rate_tolerance = 8000*1000; +  ecc->frame_rate = 25;  +  ecc->frame_rate_base = 1; +   +  ecc->width = 720; +  ecc->height = 576; +  ecc->pix_fmt = PIX_FMT_YUV420P; +  ecc->gop_size = 0; +  ecc->mb_decision = FF_MB_DECISION_SIMPLE; +  ecc->qmin = 2; +  ecc->qmax = 31; +  ecc->mb_qmin = 2; +  ecc->mb_qmax = 31; +  ecc->max_qdiff = 3; +  ecc->qblur = 0.5; +  ecc->qcompress = 0.5; +  ecc->rc_eq = "tex^qComp"; +  ecc->debug= 0; +   +  ecc->rc_override_count=0; +  ecc->rc_max_rate = 0; +  ecc->rc_min_rate = 0; +  ecc->rc_buffer_size = 0; +  ecc->rc_buffer_aggressivity = 1.0; +  ecc->rc_initial_cplx= 0; +  ecc->i_quant_factor = -0.8; +  ecc->b_quant_factor = 1.25; +  ecc->i_quant_offset = 0.8; +  ecc->b_quant_offset = 1.25; +  ecc->dct_algo = 0; +  ecc->idct_algo = 0; +  ecc->strict_std_compliance = 0; +  ecc->me_method = ME_EPZS; +   +  if(avcodec_open(&st->codec, enc_codec) < 0) { +    printf("Error while opening codec for stream\n"); +    exit(1); +  } + +  if(url_fopen(&efc->pb, filename, URL_RDWR) < 0) { +    fprintf(stderr, "Could not open '%s'\n", filename); +    exit(1); +  } + +  if(av_set_parameters(efc, NULL) < 0) { +    fprintf(stderr, "%s: Invalid encoding parameters\n", filename); +    exit(1); +  } + +  dump_format(efc, 0, filename, 1); + +  if(av_write_header(efc) < 0) { +    fprintf(stderr, "Could not write header for output file \n"); +    exit(1); +  } + +  video_buffer = (unsigned char *)av_malloc(VIDEO_BUFFER_SIZE); +   +  av_init_packet(&epkt); + +  epkt.stream_index = efc->streams[0]->index; + +  //  ecc = &efc->streams[0]->codec; + +  //////////////////// DECODE INIT +  AVCodec *deccodec; +  //  AVCodecContext *dcc= NULL; +  printf("Video decoding\n"); +   +  /* find the dvvideo decoder */ +  deccodec = avcodec_find_decoder(CODEC_ID_DVVIDEO); +  if (!deccodec) { +    fprintf(stderr, "codec not found\n"); +    exit(1); +  } +   +  dcc= avcodec_alloc_context(); +   +  /* open it */ +  if (avcodec_open(dcc, deccodec) < 0) { +    fprintf(stderr, "could not open codec\n"); +    exit(1); +  } +} + +MovEncoder::~MovEncoder() +{ +  av_free(video_buffer); +  url_fclose(&efc->pb); +} + +void MovEncoder::encode(DVFrame *dvframe) +{  +  int ret; +  AVFrame *rawframe = avcodec_alloc_frame(); + +  ///////////////////////// DECODE +  uint8_t *ptr; +  int got_picture = 1; +  int len; + +  ptr = (uint8_t *)dvframe->frame; +  len = sizeof(dvframe->frame); + +  ret = avcodec_decode_video(dcc,//&dfc->streams[0]->codec,  +                             rawframe, &got_picture, ptr, len); + +  if(!ret) { +    printf("Decoder fuckup!\n"); +    return; +  } +   +  ///////////////////////// ENCODE +   +  ret = avcodec_encode_video(ecc, video_buffer, VIDEO_BUFFER_SIZE, rawframe); +   +  if(!ret) { +    printf("MovEncoder fuckup!\n"); +    return; +  } + +  epkt.data = video_buffer; +  epkt.size = ret; + +  if(ecc->coded_frame) epkt.pts = ecc->coded_frame->pts; + +  if(ecc->coded_frame && ecc->coded_frame->key_frame) epkt.flags |= PKT_FLAG_KEY; + +  av_write_frame(efc, &epkt); + +  av_free(rawframe); +} diff --git a/src/mov_encoder.h b/src/mov_encoder.h new file mode 100644 index 0000000..eb67350 --- /dev/null +++ b/src/mov_encoder.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#ifndef __RTVIDEOREC_ENCODER_H +#define __RTVIDEOREC_ENCODER_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <avformat.h> + +#include <dvframe.h> + +#include "util.h" + +#define VIDEO_BUFFER_SIZE	(1024*1024)	// FIXME: One size fits all... + +class MovEncoder { + public: +  MovEncoder(const char *filename); +  ~MovEncoder(); +  void encode(DVFrame *frame); + + private: +  // Decoder +  AVFormatContext *dfc; +  AVCodecContext *dcc; + +  // Encoder +  AVFormatContext *efc; +  AVCodecContext *ecc; +  AVPacket epkt; +  unsigned char *video_buffer; +  //  AVPacket pkt; +}; + +#endif + diff --git a/src/network.cc b/src/network.cc new file mode 100644 index 0000000..8e99855 --- /dev/null +++ b/src/network.cc @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            network.cc + * + *  Wed Nov  3 21:23:14 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include "network.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <sys/socket.h>  + +Network::Network(Socket *gs) +{ +  s = gs; +} + +Network::~Network() +{ +} + +int Network::write(void *buf, int size) +{ +  if(!s->isConnected()) { +    fprintf(stderr, "Write attempted to a socket not connected!\n"); +    return 0; +  } +  int n = send(s->ssocket, buf, size, MSG_WAITALL); + +  if(n == -1) printf("An error occurred!\n"); + +  //  printf("Sent: %s\n", buf); + +  return n; +} + +int Network::read(void *buf, int size) +{ +  if(!s->isConnected()) { +    fprintf(stderr, "Read attempted from a socket not connected!\n"); +    return 0; +  } +  int n = recv(s->ssocket, buf, size, MSG_WAITALL); + +  if(n == -1) printf("An error occurred!\n"); +   +  //  printf("Recieved: %s\n", buf); + +  return n; +} + +/* +struct  msghdr { +  void          *msg_name        // Optional address. +  socklen_t      msg_namelen     // Size of address. +  struct iovec  *msg_iov         // Scatter/gather array. +  int            msg_iovlen      // Members in msg_iov. +  void          *msg_control     // Ancillary data; see below. +  socklen_t      msg_controllen  // Ancillary data buffer len. +  int            msg_flags       // Flags on received message. +}; +*/ + +int Network::sendPackage(n_header *h, void* buf, int bufsz) +{ +  struct msghdr msg; +  struct iovec iovecs[2]; + +  memset(&msg, 0, sizeof(msg)); +   +  msg.msg_iov = iovecs; +  msg.msg_iovlen = 2; + +  msg.msg_iov[0].iov_base = h; +  msg.msg_iov[0].iov_len = sizeof(*h); + +  msg.msg_iov[1].iov_base = buf; +  msg.msg_iov[1].iov_len = bufsz; + +  int n = sendmsg(s->ssocket, &msg, 0); +  if(n < 0) { +    perror("sendmsg"); +    return -1; +  } + +  return n; +} + +int Network::recvPackage(n_header *h, void* buf, int bufsz) +{	 +  struct msghdr msg; +  struct iovec iovecs[2]; + +  memset(&msg, 0, sizeof(msg)); +   +  iovecs[0].iov_base = h; +  iovecs[0].iov_len = sizeof(*h); +   +  iovecs[1].iov_base = buf; +  iovecs[1].iov_len = bufsz; +   +  msg.msg_iov = iovecs; +  msg.msg_iovlen = 2; + +  int n = recvmsg(s->ssocket, &msg, MSG_WAITALL); + +  if(n < 0) { +    perror("recvmsg"); +    return -1; +  } + +  if(msg.msg_iovlen != 2) { +    fprintf(stderr, "Wrong package format!\n"); +    return -1; +  } +  return n; +} + diff --git a/src/network.h b/src/network.h new file mode 100644 index 0000000..72d5826 --- /dev/null +++ b/src/network.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            network.h + * + *  Wed Nov  3 21:23:14 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __MIAVLIB_NETWORK_H__ +#define __MIAVLIB_NETWORK_H__ +  +#include "socket.h" +#include "package.h" + +class Network { +public: +  Network(Socket *gs); +  ~Network(); + +  // Raw communication +  int write(void *buf, int size); +  int read(void *buf, int size); + +  // Package communication +  int sendPackage(n_header *h, void* buf, int bufsz); +  int recvPackage(n_header *h, void* buf, int bufsz); + +private: +  Socket *s; +}; + +#endif/*__NETWORK_H__*/ + + diff --git a/src/package.h b/src/package.h new file mode 100644 index 0000000..db0e5a0 --- /dev/null +++ b/src/package.h @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            package.h + * + *  Tue Nov  9 10:57:20 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __MIAVLIB_PACKAGE_H__ +#define __MIAVLIB_PACKAGE_H__ + +typedef enum { +  DATA_HEADER = 0x0001, +  INFO_HEADER = 0x0002 +} n_header_type; + +typedef struct { +  n_header_type header_type; +  union { +    struct { +      char cpr[32]; // Can hold wierd cpr numbers as well (not only danish) +      bool record; +      bool freeze; +      bool snapshot; +    } h_data; +    struct { +      int fisk;  +    } h_info; +  } header; +} n_header; + + +#endif/*__PACKAGE_H__*/ + + diff --git a/src/player.cc b/src/player.cc new file mode 100644 index 0000000..a860afa --- /dev/null +++ b/src/player.cc @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * Copyright (C) 2004  Koen Otter and Glenn van der Meyden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ +#include <config.h> +#ifdef USE_GUI + +#include "player.h" + +Player::Player(volatile int *grunning, +               sem_t	*gsem, +               Queue<FFFrame> *gqueue, +               pthread_mutex_t *gmutex) +{ +  running = grunning; +  sem = gsem; +  queue = gqueue; +  mutex = gmutex; + + 	sem_init(&play_sem, 0, 1); + +  if(SDL_Init(SDL_INIT_VIDEO) < 0) { +    fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); +    exit(1); +  } +  screen = SDL_SetVideoMode(DISPLAYWIDTH,  +			    DISPLAYHEIGHT,  +			    16,  +			    SDL_HWSURFACE|SDL_ANYFORMAT|SDL_HWACCEL); +  if(!screen) { +    fprintf(stderr, "Unable to set %dx%d video: %s\n",  +	    DISPLAYWIDTH, DISPLAYHEIGHT, SDL_GetError()); +    exit(1); +  } + +  overlay = SDL_CreateYUVOverlay(DISPLAYWIDTH, DISPLAYHEIGHT, SDL_IYUV_OVERLAY, screen); +} + +Player::~Player() +{ +  if(overlay) +    SDL_FreeYUVOverlay(overlay); +  SDL_Quit(); +} + +void Player::player() +{ +  SDL_Event event; +  SDL_Rect rect; +  FFFrame *f; +  AVPicture pict; +  int i; +  struct timespec ts; + +  //  rect.x = 20; +  //  rect.y = 182; +  rect.x = 0; +  rect.y = 0; +  rect.w = DISPLAYWIDTH; +  rect.h = DISPLAYHEIGHT; + +  //+++++Reference to the overlay pixels/pitches, only after creating a new overlay+++++ +  for(i = 0; i < 3; i++) { +    pict.data[i] = overlay->pixels[i]; +    pict.linesize[i] = overlay->pitches[i]; +  } +   +  while(*running) { +    // Wait for the semaphore to be free... then run +    sem_wait(&play_sem); +    sem_post(&play_sem); + +    if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefull exit...  + +    switch(event.type) { +    case SDL_KEYDOWN: +      switch(event.key.keysym.sym) { +      case SDLK_q: +      case SDLK_ESCAPE: +        goto quitit; +      default: +        break; +      } +      break; +       +    case SDL_USEREVENT: +      pthread_mutex_lock(mutex); +      f = queue->pop(); +      pthread_mutex_unlock(mutex); +      if(!f) break; +       +      img_convert(&pict, PIX_FMT_YUV420P, (AVPicture *)f->frame,  +                  PIX_FMT_YUV420P, DISPLAYWIDTH, DISPLAYHEIGHT); +       +      SDL_LockYUVOverlay(overlay);	 +      overlay->pixels = pict.data; +      SDL_UnlockYUVOverlay(overlay); +      SDL_DisplayYUVOverlay(overlay, &rect); +      break; +       +    case SDL_QUIT: +    quitit: +      *running = 0; +      break; + +    default: +      break; +    } +  } +  /* Remove any late buffer */ +  /* We don't care, the encoder finishes them all */ +  ts.tv_sec = 0; +  ts.tv_nsec = 100000000L;	// 100ms +  nanosleep(&ts, NULL); + +  pthread_mutex_lock(mutex); +  f = queue->pop(); +  pthread_mutex_unlock(mutex); +  if(f) delete f; +} + +void Player::run() +{ +  player(); +} + +void Player::start() +{ +  sem_post(&play_sem); +} + +void Player::stop() +{ +  sem_wait(&play_sem); +} + +#endif /* USE_GUI */ diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..e33c4e7 --- /dev/null +++ b/src/player.h @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <config.h> +#ifdef USE_GUI + +#ifndef __RTVIDEOREC_PLAYER_H +#define __RTVIDEOREC_PLAYER_H + +#include <stdio.h> +#include <stdlib.h> +#include <semaphore.h> +#include <pthread.h> +#include <time.h> +#include <SDL/SDL.h> +#include <avformat.h> + +#include "util.h" +#include <queue.h> + +#include "thread.h" +#include "ffframe.h" + +#include <qwidget.h> + +#define DISPLAYWIDTH	720	/* FIXME: These numbers suck! */ +#define DISPLAYHEIGHT	576 + +class Player : public Thread { + public: +  Player(volatile int *grunning, +         sem_t	*gsem, +         Queue<FFFrame> *gqueue, +         pthread_mutex_t *gmutex); +  ~Player(); + +  void start(); +  void stop(); + +  void run(); + + private: +  void player(); + +  volatile int *running; +  sem_t	*sem; +  Queue<FFFrame> *queue; +  pthread_mutex_t *mutex; + +  sem_t	play_sem; + +  SDL_Surface *screen; +  SDL_Overlay *overlay; +}; + +#endif + +#endif /* USE_GUI */ diff --git a/src/queue.h b/src/queue.h new file mode 100644 index 0000000..7352071 --- /dev/null +++ b/src/queue.h @@ -0,0 +1,130 @@ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  Bent Bisballe + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <config.h> +#ifndef __RTVIDEOREC_QUEUE_H +#define __RTVIDEOREC_QUEUE_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <avformat.h> +#include <avcodec.h> + +#include "util.h" + +typedef struct __buf_t { +  struct __buf_t *next; +  struct __buf_t *prev; +  void *data; +} buf_t; + + +template<typename T> +class Queue { + public: +  Queue(int glimit = 0); +  ~Queue(); + +  void push(T *t); +  T *pop(); +   + private: +  int limit; +  buf_t *head; +  buf_t *tail; +  int count; +  pthread_mutex_t mutex; +}; + +template<typename T> +Queue<T>::Queue(int glimit) +{ +  limit = glimit; +  count = 0; +  head = NULL; +  tail = NULL; +} + +template<typename T> +Queue<T>::~Queue() +{ +  if(count != 0) { +    fprintf(stderr, "Queue not empty (%d)\n", count); +    while(T *t = pop()) delete t; +  } +} + +template<typename T> +void Queue<T>::push(T *t) +{ +  buf_t *b = (buf_t*)xmalloc(sizeof(*b)); +  b->data = (void*)t; + +  assert(b != NULL); +   +  if(limit && count > 0) { +    T* tmp = (T*)pop(); +    delete tmp; +  } +   +  if(!head) { +    head = tail = b; +    b->next = b->prev = NULL; +    count = 1; +    return; +  } +   +  b->next = tail; +  b->prev = NULL; +  if(tail) +    tail->prev = b; +  tail = b; +  count++; +} + +template<typename T> +T *Queue<T>::pop() +{ +  T *d; +  buf_t *b; + +  assert(count >= 0); +   +  if(count == 0) +    return NULL; +   +  b = head; +  if(b->prev) +    b->prev->next = NULL; +  head = b->prev; +  if(b == tail) +    tail = NULL; +  count--; +   +  d = (T*)b->data; +  free(b); +  return d; +} + +#endif + diff --git a/src/server.cc b/src/server.cc new file mode 100644 index 0000000..22b691f --- /dev/null +++ b/src/server.cc @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            miav-rec.cc + * + *  Mon Nov  8 11:35:01 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "server.h" +#include "miav.h" + +#include <stdio.h> +#include <stdlib.h> + +#include "mov_encoder.h" +#include "img_encoder.h" + +void saveFrameAsImage(char* cpr, DVFrame *f) +{ +  char fname[256]; +  ImgEncoder imgenc; + +  sprintf(fname, "image-%s-%d.jpeg", cpr, rand()); + +  imgenc.encode(f, fname, 100); // Quality is between 0...100, where 100 is best. +} +/* +struct tm +{ +  int tm_sec;                   // Seconds.     [0-60] (1 leap second)  +  int tm_min;                   // Minutes.     [0-59]  +  int tm_hour;                  // Hours.       [0-23]  +  int tm_mday;                  // Day.         [1-31]  +  int tm_mon;                   // Month.       [0-11]  +  int tm_year;                  // Year - 1900.   +  int tm_wday;                  // Day of week. [0-6]  +  int tm_yday;                  // Days in year.[0-365]  +  int tm_isdst;                 // DST.         [-1/0/1] +}; +*/ + +MovEncoder *newMovEncoder(char* cpr) +{ +  MovEncoder *enc; +  struct tm *ltime; +  char fname[256]; +  time_t t = time(NULL); +  ltime = localtime(&t); +  sprintf(fname, "%.2d%.2d%.2d%.2d%.2d%.2d-%s.mpg", ltime->tm_year + 1900, ltime->tm_mon,  +          ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, cpr); +  enc = new MovEncoder(fname); +  return enc; +} + +void newConnection(Socket *s) +{   +  n_header h; +  DVFrame *f; +  DVFrame *freeze_frame = NULL; +  MovEncoder *enc = NULL; + +  f = new DVFrame(); + +  printf("New connection[pid: %d]...\n", getpid()); + +  Network n = Network(s); +  while(int ret = n.recvPackage(&h, (void*)f->frame, DVPACKAGE_SIZE)) { +    if(ret == -1) { +      fprintf(stderr, "An error occurred...!\n"); +      break; +    } +    printf("Read: %d bytes\t", ret); +    printf("\ttyp: %d\t", h.header_type); +    printf("\tcpr: %s\t", h.header.h_data.cpr); +    printf("\tfrz: %d\t", h.header.h_data.freeze); +    printf("\tsht: %d\n", h.header.h_data.snapshot); + +    if(h.header.h_data.snapshot) { +      if(freeze_frame) { +        saveFrameAsImage(h.header.h_data.cpr, freeze_frame); +        delete freeze_frame; +        freeze_frame = NULL; +      } else { +        saveFrameAsImage(h.header.h_data.cpr, f); +      } +    } + +    if(h.header.h_data.record) { +      if(!enc) enc = newMovEncoder(h.header.h_data.cpr); +      enc->encode(f); +    } + +    if(h.header.h_data.freeze) { +      if(freeze_frame) delete freeze_frame; +      freeze_frame = f; +    } else { +      delete f; +    } + +    f = new DVFrame(); +  } +  delete f; +  if(enc) delete enc; + +  printf("Connection end[pid: %d]...\n", getpid()); +   +} +/* +int main(int argc, char *argv[]) +{ +} +*/ diff --git a/src/server.h b/src/server.h new file mode 100644 index 0000000..fd28f33 --- /dev/null +++ b/src/server.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            server.h + * + *  Mon Nov  8 11:35:01 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __SERVER_H__ +#define __SERVER_H__ + +#include <unistd.h>     // Symbolic Constants +#include <sys/types.h>  // Primitive System Data Types +#include <errno.h>      // Errors +#include <stdio.h>      // Input/Output +#include <sys/wait.h>   // Wait for Process Termination +#include <stdlib.h>     // General Utilities + +#include <time.h> + +#include "dvframe.h" +#include "socket.h" + +void newConnection(Socket *s); + + +#endif/*__SERVER_H__*/ diff --git a/src/socket.cc b/src/socket.cc new file mode 100644 index 0000000..7cee58a --- /dev/null +++ b/src/socket.cc @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            socket.cc + * + *  Mon Nov  8 10:49:33 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> + +#include "socket.h" + +Socket::Socket() +{ +  connected = false; +  err = 0; +} + +Socket::Socket(u_short port) +{ +  connected = false; +  err = 0; + +  //  printf("Socket on port: %d\n", port); + +  // create socket +  ssocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); // PF_INET: ipv4, PF_INET6: ipv6 +                                                      // tcp: IPPROTO_TCP +                                                      // upd: IPPROTO_UDP +  if (ssocket < 0) { +    err = 1; +    perror("Socket: socket() failed"); +  } + +  socketaddr.sin_family = AF_INET;       // Use "internet protocol" IP +  socketaddr.sin_port = htons(port);            // connect to that port +  socketaddr.sin_addr.s_addr = INADDR_ANY;// INADDR_ANY puts your IP address automatically  + +  //  fprintf(stderr, "Socket created\n"); +} + + +Socket::~Socket() +{ +  //  if(err) perror("Socket: No socket to kill"); +  //  printf("Socket: I'm melting...[%d]\n", ssocket); +  if(ssocket >= 0) close(ssocket);  // close server socket +} + + +Socket Socket::slisten() +{ +  Socket s = Socket(); + +  if(err) { +    perror("Socket: No socket present"); +    return s; +  } +  if(!connected) { +    // bind socket to address specified by "sa" parameter +    err = bind(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr)); +     +    if (err) { +      perror("Socket: bind() failed"); +      return s; +    } +     +    // start listen for connection - kernel will accept connection requests (max 5 in queue) +    err = listen(ssocket, 5); +    if(err) { +      perror("Socket: listen() failed"); +      return s; +    } +  } + +  // accept new connection and get its connection descriptor +  int csalen = sizeof(s.socketaddr); + +  s.ssocket = accept(ssocket, (struct sockaddr*)&s.socketaddr, (socklen_t*)&csalen); +  if (s.ssocket < 0) { +    err = 1; +    perror("Socket: accept() failed"); +    return s; +  } + +  fprintf(stderr, "Socket connected\n"); +  connected = true; +  s.connected = true; +  return s; +} + + +int Socket::sconnect(char *ip) +{ +  if(err) { +    perror("Socket: No socket present"); +    return err; +  } + +  // FIXME: gethostbyname() +  socketaddr.sin_addr.s_addr = inet_addr(ip);  +  //inet_aton (ip, &socketaddr.sin_addr); +   +  err = connect(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr)); +  if (err) { +    perror("Socket: connect() failed"); +    return err; +  } +  //  fprintf(stderr, "Socket connected\n"); +  connected = true; +  return 0; +} + + +bool Socket::isConnected() +{ +  return connected; +} diff --git a/src/socket.h b/src/socket.h new file mode 100644 index 0000000..d0d85af --- /dev/null +++ b/src/socket.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            socket.h + * + *  Mon Nov  8 10:49:33 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __MIAVLIB_SOCKET_H__ +#define __MIAVLIB_SOCKET_H__ + +#include <stdio.h> +#include <string.h> + +#include <unistd.h> +#include <netinet/in.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> + +class Socket { +public: +  Socket(); +  Socket(u_short port); +  ~Socket(); +  Socket slisten(); +  int sconnect(char *ip); +  bool isConnected(); + +  struct sockaddr_in socketaddr; +  int ssocket; +  bool connected; + +private: +  int err; +}; + +#endif/*__SOCKET_H__*/ diff --git a/src/thread.cc b/src/thread.cc new file mode 100644 index 0000000..c6b4d95 --- /dev/null +++ b/src/thread.cc @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            thread.cc + * + *  Sun Oct 31 12:12:20 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> + +#include "thread.h" +#include <stdio.h> + +void* thread_run(void *data) { +  Thread *t = (Thread*)data; +  t->run(); +  return NULL; +} diff --git a/src/thread.h b/src/thread.h new file mode 100644 index 0000000..ecf0487 --- /dev/null +++ b/src/thread.h @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            thread.h + * + *  Sun Oct 31 12:12:20 CET 2004 + *  Copyright  2004 Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#ifndef __THREAD_H__ +#define __THREAD_H__ + +#include <pthread.h> +#include <semaphore.h> + +class Thread { +public: +  Thread() {} +  virtual ~Thread() {} +  virtual void run() = 0; +}; + +void* thread_run(void *data); + +#endif/*__THREAD_H__*/ diff --git a/src/util.cc b/src/util.cc new file mode 100644 index 0000000..5edf990 --- /dev/null +++ b/src/util.cc @@ -0,0 +1,56 @@ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "util.h" + +void *xmalloc(size_t s) +{ +  void *p; +  assert(s > 0); +   +  p = malloc(s); +  if(!p) { +    fprintf(stderr, "Out of memory in xmalloc\n"); +    exit(1); +  } +  memset(p, 0, s); +  return p; +} + +void *xrealloc(void *b, size_t s) +{ +  void *p; +  assert(s > 0); +   +  if(!b) return xmalloc(s); +   +  p = realloc(b, s); +  if(!p) { +    fprintf(stderr, "Out of memory in xrealloc\n"); +    exit(1); +  } +  return p; +} diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..b82b782 --- /dev/null +++ b/src/util.h @@ -0,0 +1,36 @@ +/* + * RTVideoRec Realtime video recoder and encoder for Linux + * + * Copyright (C) 2004  B. Stultiens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + +#include <config.h> +#ifndef __RTVIDEOREC_UTIL_H +#define __RTVIDEOREC_UTIL_H + +//#ifdef __cplusplus +//extern "C" { +//#endif + +void *xmalloc(size_t s); +void *xrealloc(void *b, size_t s); + +//#ifdef __cplusplus +//} +//#endif + +#endif diff --git a/src/videowidget.cc b/src/videowidget.cc new file mode 100644 index 0000000..64758bd --- /dev/null +++ b/src/videowidget.cc @@ -0,0 +1,46 @@ +/*************************************************************************** + *            videowidget.cc + * + *  Fri Sep  3 14:36:37 2004 + *  Copyright  2004  Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> + +#ifdef USE_GUI +  +#include "videowidget.h" + +VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent, "") +{ +  // A welltested hack to force SDL to draw in the QWidget +  QString ids; +  setenv("SDL_WINDOWID", ids.setNum(winId()), 1); +} + +VideoWidget::~VideoWidget() +{ +} + +QPixmap VideoWidget::getScreenshot() +{  +  return QPixmap::grabWindow (winId()); +} + +#endif /* USE_GUI */ diff --git a/src/videowidget.h b/src/videowidget.h new file mode 100644 index 0000000..52669ed --- /dev/null +++ b/src/videowidget.h @@ -0,0 +1,45 @@ +/*************************************************************************** + *            videowidget.h + * + *  Fri Sep  3 14:36:46 2004 + *  Copyright  2004  Bent Bisballe + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This program is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  This program is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Library General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include <config.h> +#ifdef USE_GUI +  +#ifndef __VIDEOWIDGET_H__ +#define __VIDEOWIDGET_H__ + +#include <qwidget.h> +#include <qpixmap.h> + +class VideoWidget : public QWidget { +Q_OBJECT + public: +  VideoWidget(QWidget *parent); +  ~VideoWidget(); +  QPixmap getScreenshot(); + + private: +}; + +#endif /* __VIDEOWIDGET_H__ */ + +#endif /* USE_GUI */ diff --git a/tools/CPUMaker b/tools/CPUMaker new file mode 100755 index 0000000..d62ff23 --- /dev/null +++ b/tools/CPUMaker @@ -0,0 +1,27 @@ +#!/bin/sh + +FLAG="${FLAG} -ansi -Wall -O2 -finline-functions" + +case "$(cat /proc/cpuinfo | egrep '^model name'|cut -d ':' -f 2|cut -c 2-)" in +	'Intel(R) Pentium(R) M processor 1300MHz') +		FLAG="${FLAG} -march=pentium3 -fomit-frame-pointer -ffast-math" +		;; +	*) +		;; +esac + +for flag in $(cat /proc/cpuinfo | egrep '^flags'|cut -d ':' -f 2|cut -c 2-); do +	case $flag in +		mmx) +			FLAG="${FLAG} -mmmx" +			;; +		sse) +			FLAG="${FLAG} -msse" +			;; +		sse2) +			FLAG="${FLAG} -msse2" +			;; +	esac +done + +echo 'GCC_FLAGS = $(QTGCC_FLAGS)' $FLAG diff --git a/tools/MIaVAdd b/tools/MIaVAdd new file mode 100755 index 0000000..8a5ca1a --- /dev/null +++ b/tools/MIaVAdd @@ -0,0 +1,64 @@ +# -*- mode: shell-script; sh-shell: bash; sh-indentation: 2 -*- + +function allfile() { +  echo "/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */" > $1; +  echo "/***************************************************************************" >> $1; +  echo " *            $1" >> $1; +  echo " *" >> $1 ; +  echo " *  `date`" >> $1; +  echo " *  Copyright  2005 Bent Bisballe" >> $1; +  echo " *  deva@aasimon.org" >> $1; +  echo " ****************************************************************************/" >> $1; +  echo "" >> $1; +  echo "/*" >> $1; +  echo " *  This program is free software; you can redistribute it and/or modify" >> $1; +  echo " *  it under the terms of the GNU General Public License as published by" >> $1; +  echo " *  the Free Software Foundation; either version 2 of the License, or" >> $1; +  echo " *  (at your option) any later version." >> $1; +  echo " *" >> $1; +  echo " *  This program is distributed in the hope that it will be useful," >> $1; +  echo " *  but WITHOUT ANY WARRANTY; without even the implied warranty of" >> $1; +  echo " *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the" >> $1; +  echo " *  GNU Library General Public License for more details." >> $1; +  echo " *" >> $1; +  echo " *  You should have received a copy of the GNU General Public License" >> $1; +  echo " *  along with this program; if not, write to the Free Software" >> $1; +  echo " *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA." >> $1; +  echo " */" >> $1; +  echo "" >> $1; +} + +function ccfile() { +  local hf=`echo -n $1 | cut -d'.' -f1`.h; +  hfile $hf; + +  allfile $1; +  echo -n '#include "' >> $1; +  echo -n $hf >> $1; +  echo '"' >> $1; +  echo '' >> $1; +} + +function hfile() { +  allfile $1; +  local hn=`echo $1 | tr 'a-z.' 'A-Z_'` +  echo -n "#ifndef __MIAV_" >> $1; +  echo -n "$hn" >> $1; +  echo "__" >> $1; +  echo -n "#define __MIAV_" >> $1; +  echo -n "$hn" >> $1; +  echo "__" >> $1; +  echo -n "#endif/*__MIAV_" >> $1; +  echo -n "$hn" >> $1; +  echo "__*/" >> $1; +} + +if [ "$#" = "1" ]; then +if [ "CC" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then +  ccfile $1; +fi; +if [ "H" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then +  hfile $1; +fi; +else echo "Usage: $0 filename"; +fi; diff --git a/tools/MocList b/tools/MocList new file mode 100755 index 0000000..b69f49f --- /dev/null +++ b/tools/MocList @@ -0,0 +1,11 @@ +# -*- mode: shell-script; sh-shell: bash; sh-indentation: 2 -*- +if grep "#define USE_GUI" ../config.h > /dev/null ; then  +    if [ "$1" = "cc" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | sed -e 's/^//g;s/\.h/\.moc.cc/g'| xargs echo; +    elif [ "$1" = "o" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | sed -e 's/^//g;s/\.h/\.moc.o/g'| xargs echo; +    elif [ "$1" = "h" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | cut -d'/' -f3 | xargs echo; +    fi +fi + diff --git a/tools/MocMaker b/tools/MocMaker new file mode 100755 index 0000000..da34900 --- /dev/null +++ b/tools/MocMaker @@ -0,0 +1,3 @@ +# -*- mode: shell-script; sh-shell: bash; sh-indentation: 2 -*- +echo -ne "\n" +for file in `grep "Q_OBJECT" *.h | cut -d: -f1 | cut -d'/' -f3 | xargs echo`; do echo -e "moc_${file%.h}.cpp: $file\n\t@\${MOC} $file -o moc_${file%.h}.cpp\n"; done  | 
