- moved the remaining of int21 calls to dlls/winedos
[wine] / programs / avitools / aviinfo.c
1 /*
2  * Copyright 1999 Marcus Meissner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include <stdio.h>
20 #include <assert.h>
21 #include <string.h>
22 #include "windef.h"
23 #include "windows.h"
24 #include "mmsystem.h"
25 #include "vfw.h"
26
27
28 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
29 {
30     int                 n;
31     HRESULT             hres;
32     HMODULE             avifil32 = LoadLibrary("avifil32.dll");
33     PAVIFILE            avif;
34     PAVISTREAM          vids,auds;
35     AVIFILEINFO         afi;
36     AVISTREAMINFO       asi;
37
38 void    (WINAPI *fnAVIFileInit)(void);
39 void    (WINAPI *fnAVIFileExit)(void);
40 ULONG   (WINAPI *fnAVIFileRelease)(PAVIFILE);
41 ULONG   (WINAPI *fnAVIStreamRelease)(PAVISTREAM);
42 HRESULT (WINAPI *fnAVIFileOpen)(PAVIFILE * ppfile,LPCTSTR szFile,UINT uMode,LPCLSID lpHandler);
43 HRESULT (WINAPI *fnAVIFileInfo)(PAVIFILE ppfile,AVIFILEINFO *afi,LONG size);
44 HRESULT (WINAPI *fnAVIFileGetStream)(PAVIFILE ppfile,PAVISTREAM *afi,DWORD fccType,LONG lParam);
45 HRESULT (WINAPI *fnAVIStreamInfo)(PAVISTREAM iface,AVISTREAMINFO *afi,LONG size);
46
47 #define XX(x) fn##x = (void*)GetProcAddress(avifil32,#x);assert(fn##x);
48 #ifdef UNICODE
49 # define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"W");assert(fn##x);
50 #else
51 # define XXT(x) fn##x = (void*)GetProcAddress(avifil32,#x"A");assert(fn##x);
52 #endif
53         /* Non character dependent routines: */
54         XX (AVIFileInit);
55         XX (AVIFileExit);
56         XX (AVIFileRelease);
57         XX (AVIStreamRelease);
58         XX (AVIFileGetStream);
59         /* A/W routines: */
60         XXT(AVIFileOpen);
61         XXT(AVIFileInfo);
62         XXT(AVIStreamInfo);
63 #undef XX
64 #undef XXT
65
66     fnAVIFileInit();
67     if (GetFileAttributes(cmdline) == INVALID_FILE_ATTRIBUTES) {
68         fprintf(stderr,"Usage: aviinfo <avifilename>\n");
69         exit(1);
70     }
71     hres = fnAVIFileOpen(&avif,cmdline,OF_READ,NULL);
72     if (hres) {
73         fprintf(stderr,"AVIFileOpen: 0x%08lx\n",hres);
74         exit(1);
75     }
76     hres = fnAVIFileInfo(avif,&afi,sizeof(afi));
77     if (hres) {
78         fprintf(stderr,"AVIFileInfo: 0x%08lx\n",hres);
79         exit(1);
80     }
81     fprintf(stderr,"AVI File Info:\n");
82     fprintf(stderr,"\tdwMaxBytesPerSec: %ld\n",afi.dwMaxBytesPerSec);
83 #define FF(x) if (afi.dwFlags & AVIFILEINFO_##x) fprintf(stderr,#x",");
84     fprintf(stderr,"\tdwFlags: 0x%lx (",afi.dwFlags);
85     FF(HASINDEX);FF(MUSTUSEINDEX);FF(ISINTERLEAVED);FF(WASCAPTUREFILE);
86     FF(COPYRIGHTED);
87     fprintf(stderr,")\n");
88 #undef FF
89 #define FF(x) if (afi.dwCaps & AVIFILECAPS_##x) fprintf(stderr,#x",");
90     fprintf(stderr,"\tdwCaps: 0x%lx (",afi.dwCaps);
91     FF(CANREAD);FF(CANWRITE);FF(ALLKEYFRAMES);FF(NOCOMPRESSION);
92     fprintf(stderr,")\n");
93 #undef FF
94     fprintf(stderr,"\tdwStreams: %ld\n",afi.dwStreams);
95     fprintf(stderr,"\tdwSuggestedBufferSize: %ld\n",afi.dwSuggestedBufferSize);
96     fprintf(stderr,"\tdwWidth: %ld\n",afi.dwWidth);
97     fprintf(stderr,"\tdwHeight: %ld\n",afi.dwHeight);
98     fprintf(stderr,"\tdwScale: %ld\n",afi.dwScale);
99     fprintf(stderr,"\tdwRate: %ld\n",afi.dwRate);
100     fprintf(stderr,"\tdwLength: %ld\n",afi.dwLength);
101     fprintf(stderr,"\tdwEditCount: %ld\n",afi.dwEditCount);
102     fprintf(stderr,"\tszFileType: %s\n",afi.szFileType);
103
104     for (n = 0;n<afi.dwStreams;n++) {
105             char buf[5];
106             PAVISTREAM  ast;
107
108             hres = fnAVIFileGetStream(avif,&ast,0,n);
109             if (hres) {
110                 fprintf(stderr,"AVIFileGetStream %d: 0x%08lx\n",n,hres);
111                 exit(1);
112             }
113             hres = fnAVIStreamInfo(ast,&asi,sizeof(asi));
114             if (hres) {
115                 fprintf(stderr,"AVIStreamInfo %d: 0x%08lx\n",n,hres);
116                 exit(1);
117             }
118             fprintf(stderr,"Stream %d:\n",n);
119             buf[4]='\0';memcpy(buf,&(asi.fccType),4);
120             fprintf(stderr,"\tfccType: %s\n",buf);
121             memcpy(buf,&(asi.fccHandler),4);
122             fprintf(stderr,"\tfccHandler: %s\n",buf);
123             fprintf(stderr,"\tdwFlags: 0x%08lx\n",asi.dwFlags);
124             fprintf(stderr,"\tdwCaps: 0x%08lx\n",asi.dwCaps);
125             fprintf(stderr,"\twPriority: %d\n",asi.wPriority);
126             fprintf(stderr,"\twLanguage: %d\n",asi.wLanguage);
127             fprintf(stderr,"\tdwScale: %ld\n",asi.dwScale);
128             fprintf(stderr,"\tdwRate: %ld\n",asi.dwRate);
129             fprintf(stderr,"\tdwStart: %ld\n",asi.dwStart);
130             fprintf(stderr,"\tdwLength: %ld\n",asi.dwLength);
131             fprintf(stderr,"\tdwInitialFrames: %ld\n",asi.dwInitialFrames);
132             fprintf(stderr,"\tdwSuggestedBufferSize: %ld\n",asi.dwSuggestedBufferSize);
133             fprintf(stderr,"\tdwQuality: %ld\n",asi.dwQuality);
134             fprintf(stderr,"\tdwSampleSize: %ld\n",asi.dwSampleSize);
135             fprintf(stderr,"\tdwEditCount: %ld\n",asi.dwEditCount);
136             fprintf(stderr,"\tdwFormatChangeCount: %ld\n",asi.dwFormatChangeCount);
137             fprintf(stderr,"\tszName: %s\n",asi.szName);
138             switch (asi.fccType) {
139             case streamtypeVIDEO:
140                 vids = ast;
141                 break;
142             case streamtypeAUDIO:
143                 auds = ast;
144                 break;
145             default:  {
146                 char type[5];
147                 type[4]='\0';memcpy(type,&(asi.fccType),4);
148
149                 fprintf(stderr,"Unhandled streamtype %s\n",type);
150                 break;
151             }
152             }
153             fnAVIStreamRelease(ast);
154     }
155     fnAVIFileRelease(avif);
156     fnAVIFileExit();
157     return 0;
158 }