]> git.sesse.net Git - vlc/blob - modules/codec/dmo/dmo.h
Most compiler warning fixed
[vlc] / modules / codec / dmo / dmo.h
1 /*****************************************************************************
2  * dmo.h : DirectMedia Object codec module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002, 2003 VideoLAN
5  * $Id$
6  *
7  * Author: Gildas Bazin <gbazin@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 static const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
25 static const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
26 static const GUID IID_IWMCodecPrivateData = {0x73f0be8e, 0x57f7, 0x4f01, {0xaa, 0x66, 0x9f, 0x57, 0x34, 0xc, 0xfe, 0xe}};
27 static const GUID IID_IMediaObject = {0xd8ad0f58, 0x5494, 0x4102, {0x97, 0xc5, 0xec, 0x79, 0x8e, 0x59, 0xbc, 0xf4}};
28 static const GUID IID_IMediaBuffer = {0x59eff8b9, 0x938c, 0x4a26, {0x82, 0xf2, 0x95, 0xcb, 0x84, 0xcd, 0xc8, 0x37}};
29 static const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
30 static const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
31 static const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
32 static const GUID FORMAT_VideoInfo = {0x05589f80, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
33 static const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
34 static const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
35 static const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
36 static const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
37 static const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
38 static const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
39
40 void* CoTaskMemAlloc(unsigned long cb);
41 void CoTaskMemFree(void* cb);
42
43 #define IUnknown IUnknownHack
44 #define IClassFactory IClassFactoryHack
45 typedef struct _IUnknown IUnknown;
46 typedef struct _IClassFactory IClassFactory;
47 typedef struct _IWMCodecPrivateData IWMCodecPrivateData;
48 typedef struct _IEnumDMO IEnumDMO;
49 typedef struct _IMediaBuffer IMediaBuffer;
50 typedef struct _IMediaObject IMediaObject;
51
52 #ifndef STDCALL
53 #define STDCALL __stdcall
54 #endif
55
56 #define DMO_INPUT_DATA_BUFFERF_SYNCPOINT 1
57 #define DMO_INPUT_DATA_BUFFERF_TIME 2
58 #define DMO_INPUT_DATA_BUFFERF_TIMELENGTH 4
59 #define DMO_OUTPUT_DATA_BUFFERF_SYNCPOINT 1
60 #define DMO_OUTPUT_DATA_BUFFERF_TIME 2
61 #define DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH 4
62 #define DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER 1
63 #define DMO_E_NOTACCEPTING 0x80040204
64
65 /*
66  * DMO types definition
67  */
68 typedef struct
69 #ifdef HAVE_ATTRIBUTE_PACKED
70     __attribute__((__packed__))
71 #endif
72  _DMO_PARTIAL_MEDIATYPE
73 {
74     GUID type;
75     GUID subtype;
76
77 } DMO_PARTIAL_MEDIATYPE;
78
79 typedef struct
80 #ifdef HAVE_ATTRIBUTE_PACKED
81     __attribute__((__packed__))
82 #endif
83  _DMO_OUTPUT_DATA_BUFFER
84 {
85     IMediaBuffer *pBuffer;
86     uint32_t dwStatus;
87     REFERENCE_TIME rtTimestamp;
88     REFERENCE_TIME rtTimelength;
89
90 } DMO_OUTPUT_DATA_BUFFER;
91
92 typedef struct
93 #ifdef HAVE_ATTRIBUTE_PACKED
94     __attribute__((__packed__))
95 #endif
96  _DMOMediaType
97 {
98     GUID     majortype;
99     GUID     subtype;
100     int      bFixedSizeSamples;
101     int      bTemporalCompression;
102     uint32_t lSampleSize;
103     GUID     formattype;
104     IUnknown *pUnk;
105     uint32_t cbFormat;
106     char     *pbFormat;
107
108 } DMO_MEDIA_TYPE;
109
110 /*
111  * IUnknown interface
112  */
113 typedef struct IUnknown_vt
114 {
115     /* IUnknown methods */
116     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
117                                    void **ppvObject);
118     long (STDCALL *AddRef)(IUnknown *This);
119     long (STDCALL *Release)(IUnknown *This);
120
121 } IUnknown_vt;
122 struct _IUnknown { IUnknown_vt* vt; };
123
124 /*
125  * IClassFactory interface
126  */
127 typedef struct IClassFactory_vt
128 {
129     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
130                                    void **ppvObject);
131     long (STDCALL *AddRef)(IUnknown *This) ;
132     long (STDCALL *Release)(IUnknown *This) ;
133     long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,
134                                    const GUID* riid, void** ppvObject);
135 } IClassFactory_vt;
136
137 struct _IClassFactory { IClassFactory_vt* vt; };
138
139 /*
140  * IWMCodecPrivateData interface
141  */
142 typedef struct IWMCodecPrivateData_vt
143 {
144     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
145                                    void **ppvObject);
146     long (STDCALL *AddRef)(IUnknown *This) ;
147     long (STDCALL *Release)(IUnknown *This) ;
148
149         
150     long (STDCALL *SetPartialOutputType)(IWMCodecPrivateData * This,
151                                          DMO_MEDIA_TYPE *pmt);
152
153     long (STDCALL *GetPrivateData )(IWMCodecPrivateData * This,
154                                     uint8_t *pbData, uint32_t *pcbData);
155 } IWMCodecPrivateData_vt;
156
157 struct _IWMCodecPrivateData { IWMCodecPrivateData_vt* vt; };
158
159 /*
160  * IEnumDMO interface
161  */
162 typedef struct IEnumDMO_vt
163 {
164     /* IUnknown methods */
165     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
166                                    void **ppvObject);
167     long (STDCALL *AddRef)(IUnknown *This);
168     long (STDCALL *Release)(IUnknown *This);
169
170     /* IEnumDMO methods */
171     long (STDCALL *Next)(IEnumDMO *This, uint32_t cItemsToFetch,
172                          const GUID *pCLSID, WCHAR **Names,
173                          uint32_t *pcItemsFetched);
174     long (STDCALL *Skip)(IEnumDMO *This, uint32_t cItemsToSkip);
175     long (STDCALL *Reset)(IEnumDMO *This);
176     long (STDCALL *Clone)(IEnumDMO *This, IEnumDMO **ppEnum);
177
178 } IEnumDMO_vt;
179 struct _IEnumDMO { IEnumDMO_vt* vt; };
180
181 /*
182  * IMediaBuffer interface
183  */
184 typedef struct IMediaBuffer_vt
185 {
186     /* IUnknown methods */
187     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
188                                    void **ppvObject);
189     long (STDCALL *AddRef)(IUnknown *This);
190     long (STDCALL *Release)(IUnknown *This);
191
192     long (STDCALL *SetLength)(IMediaBuffer* This, uint32_t cbLength);
193     long (STDCALL *GetMaxLength)(IMediaBuffer* This, uint32_t *pcbMaxLength);
194     long (STDCALL *GetBufferAndLength)(IMediaBuffer* This,
195                                        char **ppBuffer, uint32_t *pcbLength);
196
197 } IMediaBuffer_vt;
198 struct _IMediaBuffer { IMediaBuffer_vt* vt; };
199
200 /*
201  * IMediaObject interface
202  */
203 typedef struct IMediaObject_vt
204 {
205     /* IUnknown methods */
206     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
207                                    void **ppvObject);
208     long (STDCALL *AddRef)(IUnknown *This);
209     long (STDCALL *Release)(IUnknown *This);
210
211     /* IEnumDMO methods */
212     long (STDCALL *GetStreamCount)(IMediaObject *This,
213                                    uint32_t *pcInputStreams,
214                                    uint32_t *pcOutputStreams);
215     long (STDCALL *GetInputStreamInfo)(IMediaObject *This,
216                                        uint32_t dwInputStreamIndex,
217                                        uint32_t *pdwFlags);
218     long (STDCALL *GetOutputStreamInfo)(IMediaObject *This,
219                                         uint32_t dwOutputStreamIndex,
220                                         uint32_t *pdwFlags);
221     long (STDCALL *GetInputType)(IMediaObject *This,
222                                  uint32_t dwInputStreamIndex,
223                                  uint32_t dwTypeIndex,
224                                  DMO_MEDIA_TYPE *pmt);
225     long (STDCALL *GetOutputType)(IMediaObject *This,
226                                   uint32_t dwOutputStreamIndex,
227                                   uint32_t dwTypeIndex,
228                                   DMO_MEDIA_TYPE *pmt);
229     long (STDCALL *SetInputType)(IMediaObject *This,
230                                  uint32_t dwInputStreamIndex,
231                                  const DMO_MEDIA_TYPE *pmt,
232                                  uint32_t dwFlags);
233     long (STDCALL *SetOutputType)(IMediaObject *This,
234                                   uint32_t dwOutputStreamIndex,
235                                   const DMO_MEDIA_TYPE *pmt,
236                                   uint32_t dwFlags);
237     long (STDCALL *GetInputCurrentType)(IMediaObject *This,
238                                         uint32_t dwInputStreamIndex,
239                                         DMO_MEDIA_TYPE *pmt);
240     long (STDCALL *GetOutputCurrentType)(IMediaObject *This,
241                                          uint32_t dwOutputStreamIndex,
242                                          DMO_MEDIA_TYPE *pmt);
243     long (STDCALL *GetInputSizeInfo)(IMediaObject *This,
244                                      uint32_t dwInputStreamIndex,
245                                      uint32_t *pcbSize,
246                                      uint32_t *pcbMaxLookahead,
247                                      uint32_t *pcbAlignment);
248     long (STDCALL *GetOutputSizeInfo)(IMediaObject *This,
249                                       uint32_t dwOutputStreamIndex,
250                                       uint32_t *pcbSize,
251                                       uint32_t *pcbAlignment);
252     long (STDCALL *GetInputMaxLatency)(IMediaObject *This,
253                                        uint32_t dwInputStreamIndex,
254                                        REFERENCE_TIME *prtMaxLatency);
255     long (STDCALL *SetInputMaxLatency)(IMediaObject *This,
256                                        uint32_t dwInputStreamIndex,
257                                        REFERENCE_TIME rtMaxLatency);
258     long (STDCALL *Flush)(IMediaObject * This);
259     long (STDCALL *Discontinuity)(IMediaObject *This,
260                                   uint32_t dwInputStreamIndex);
261     long (STDCALL *AllocateStreamingResources)(IMediaObject * This);
262     long (STDCALL *FreeStreamingResources)(IMediaObject * This);
263     long (STDCALL *GetInputStatus)(IMediaObject *This,
264                                    uint32_t dwInputStreamIndex,
265                                    uint32_t *dwFlags);
266     long (STDCALL *ProcessInput)(IMediaObject *This,
267                                  uint32_t dwInputStreamIndex,
268                                  IMediaBuffer *pBuffer,
269                                  uint32_t dwFlags,
270                                  REFERENCE_TIME rtTimestamp,
271                                  REFERENCE_TIME rtTimelength);
272     long (STDCALL *ProcessOutput)(IMediaObject *This,
273                                   uint32_t dwFlags,
274                                   uint32_t cOutputBufferCount,
275                                   DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
276                                   uint32_t *pdwStatus);
277     long (STDCALL *Lock)(IMediaObject *This, long bLock);
278
279 } IMediaObject_vt;
280 struct _IMediaObject { IMediaObject_vt* vt; };
281
282 /* Implementation of IMediaBuffer */
283 typedef struct _CMediaBuffer
284 {
285     IMediaBuffer_vt *vt;
286     int i_ref;
287     block_t *p_block;
288     int i_max_size;
289     vlc_bool_t b_own;
290
291 } CMediaBuffer;
292
293 CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );