bugfixes
[swftools.git] / m4 / avi2swf.m4
1 AC_DEFUN(RFX_CHECK_AVI2SWF,
2 [
3
4 AC_CHECK_PROGS(AVIFILE_CONFIG, avifile-config)
5
6 if test "x$AVIFILE_CONFIG" '!=' "x";then
7     OLDCPPFLAGS="$CPPFLAGS"
8     # temporarily add avifile paths to CPPFLAGS...
9     CPPFLAGS="$CPPFLAGS $CXXFLAGS "`$AVIFILE_CONFIG --cflags`
10     AC_CHECK_HEADERS(avifile/version.h version.h)
11     # ... and reset
12     CPPFLAGS="$OLDCPPFLAGS"
13 fi
14
15 AC_MSG_CHECKING([whether we can compile the avifile test program])
16
17 if test "x${ac_cv_header_version_h}" '=' "xyes";then
18     HAVE_VERSION_H_DEFINE='#define HAVE_VERSION_H'
19 fi
20 if test "x${ac_cv_header_avifile_version_h}" '=' "xyes";then
21     HAVE_AVIFILE_VERSION_H_DEFINE='#define HAVE_AVIFILE_VERSION_H'
22 fi
23
24 cat > conftest.cpp << EOF
25
26 // hack- we can't yet access the variables in config.h (because it hasn't been generated yet),
27 // so we have to introduce them this way
28 $HAVE_VERSION_H_DEFINE
29 $HAVE_AVIFILE_VERSION_H_DEFINE
30
31 #ifdef HAVE_VERSION_H
32   #include <version.h>
33 #endif
34 #ifdef HAVE_AVIFILE_VERSION_H
35   #include <avifile/version.h>
36 #endif
37
38 #if (AVIFILE_MAJOR_VERSION == 0) && (AVIFILE_MINOR_VERSION>=6) 
39    #include <avifile.h>
40    #include <aviplay.h>
41    #include <avm_fourcc.h>
42    #include <avm_creators.h>
43    #include <StreamInfo.h>
44    #define VERSION6
45 #else
46    #include <avifile.h>
47    #include <aviplay.h>
48    #include <aviutil.h>
49    #define Width width
50    #define Height height
51    #define Data data
52    #define Bpp bpp
53 #endif
54
55 void test()
56 {
57   IAviReadFile* player;
58   IAviReadStream* astream;
59   IAviReadStream* vstream;
60   player = CreateIAviReadFile(0);
61   astream = player->GetStream(0, AviStream::Audio);
62   vstream = player->GetStream(0, AviStream::Video);
63   vstream -> StartStreaming();
64   astream -> StartStreaming();
65 #ifndef VERSION6
66   MainAVIHeader head;
67   player->GetFileHeader(&head);
68   head.dwMicroSecPerFrame;
69   head.dwTotalFrames;
70   head.dwStreams;
71   head.dwWidth;
72   head.dwHeight;
73   head.dwMicroSecPerFrame;
74   astream->GetEndPos(),
75   astream->GetEndTime());
76   player->StreamCount();
77 #else
78   StreamInfo*audioinfo;
79   StreamInfo*videoinfo;
80   audioinfo = astream->GetStreamInfo();
81   videoinfo = vstream->GetStreamInfo();
82   videoinfo->GetVideoWidth();
83   videoinfo->GetVideoHeight();
84   audioinfo->GetAudioSamplesPerSec();
85   videoinfo->GetFps();
86 #endif
87   CImage*img = vstream->GetFrame();
88   img->ToRGB();
89   img->Data();
90   img->Bpp();
91   img->Width();
92   img->Height();
93   WAVEFORMATEX wave;
94   astream->GetAudioFormatInfo(&wave,0);
95   uint_t a,b;
96   astream->ReadFrames(0,0,0,a,b);
97 }
98 int main (int argc, char*argv[])
99 {
100     return 0;
101 }
102 EOF
103
104 if test "x$AVIFILE_CONFIG" '!=' "x";then
105     AVIFILE_LIBS=`$AVIFILE_CONFIG --libs`
106     AVIFILE_CFLAGS=`$AVIFILE_CONFIG --cflags`
107     avifile_link='$CXX $CPPFLAGS $CXXFLAGS $AVIFILE_CFLAGS conftest.cpp $AVIFILE_LIBS -o conftest${ac_exeext}'
108     if { (eval echo avi2swf.m4:71: \"$avifile_link\") 1>&5; (eval $avifile_link) 2>&5; } && test -s conftest${ac_exeext} && ./conftest${ac_exeext}; then
109       AC_MSG_RESULT(yes)
110       AVIFILE=true
111       export AVIFILE
112       AC_DEFINE_UNQUOTED(AVIFILE, true)
113     else
114       echo "configure: failed program was:" >&5
115       cat conftest.cpp >&5
116       AC_MSG_RESULT(no)
117     fi
118 else
119     AC_MSG_RESULT(no)
120 fi
121 rm -f conftest*
122 ])
123
124