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