]> git.sesse.net Git - vlc/blob - modules/codec/dmo/dmo.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / codec / dmo / dmo.h
1 /*****************************************************************************
2  * dmo.h : DirectMedia Object codec module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002, 2003 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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
41 #ifndef WIN32
42 void* CoTaskMemAlloc(unsigned long cb);
43 void CoTaskMemFree(void* cb);
44 #endif
45
46 #define IUnknown IUnknownHack
47 #define IClassFactory IClassFactoryHack
48 typedef struct _IUnknown IUnknown;
49 typedef struct _IClassFactory IClassFactory;
50 typedef struct _IWMCodecPrivateData IWMCodecPrivateData;
51 typedef struct _IEnumDMO IEnumDMO;
52 typedef struct _IMediaBuffer IMediaBuffer;
53 typedef struct _IMediaObject IMediaObject;
54
55 #ifndef STDCALL
56 #define STDCALL __stdcall
57 #endif
58
59 #define DMO_INPUT_DATA_BUFFERF_SYNCPOINT 1
60 #define DMO_INPUT_DATA_BUFFERF_TIME 2
61 #define DMO_INPUT_DATA_BUFFERF_TIMELENGTH 4
62 #define DMO_OUTPUT_DATA_BUFFERF_SYNCPOINT 1
63 #define DMO_OUTPUT_DATA_BUFFERF_TIME 2
64 #define DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH 4
65 #define DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER 1
66 #define DMO_E_NOTACCEPTING 0x80040204
67
68 /*
69  * DMO types definition
70  */
71 typedef struct
72 #ifdef HAVE_ATTRIBUTE_PACKED
73     __attribute__((__packed__))
74 #endif
75  _DMO_PARTIAL_MEDIATYPE
76 {
77     GUID type;
78     GUID subtype;
79
80 } DMO_PARTIAL_MEDIATYPE;
81
82 typedef struct
83 #ifdef HAVE_ATTRIBUTE_PACKED
84     __attribute__((__packed__))
85 #endif
86  _DMO_OUTPUT_DATA_BUFFER
87 {
88     IMediaBuffer *pBuffer;
89     uint32_t dwStatus;
90     REFERENCE_TIME rtTimestamp;
91     REFERENCE_TIME rtTimelength;
92
93 } DMO_OUTPUT_DATA_BUFFER;
94
95 typedef struct
96 #ifdef HAVE_ATTRIBUTE_PACKED
97     __attribute__((__packed__))
98 #endif
99  _DMOMediaType
100 {
101     GUID     majortype;
102     GUID     subtype;
103     int      bFixedSizeSamples;
104     int      bTemporalCompression;
105     uint32_t lSampleSize;
106     GUID     formattype;
107     IUnknown *pUnk;
108     uint32_t cbFormat;
109     char     *pbFormat;
110
111 } DMO_MEDIA_TYPE;
112
113 /*
114  * IUnknown interface
115  */
116 typedef struct IUnknown_vt
117 {
118     /* IUnknown methods */
119     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
120                                    void **ppvObject);
121     long (STDCALL *AddRef)(IUnknown *This);
122     long (STDCALL *Release)(IUnknown *This);
123
124 } IUnknown_vt;
125 struct _IUnknown { IUnknown_vt* vt; };
126
127 /*
128  * IClassFactory interface
129  */
130 typedef struct IClassFactory_vt
131 {
132     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
133                                    void **ppvObject);
134     long (STDCALL *AddRef)(IUnknown *This) ;
135     long (STDCALL *Release)(IUnknown *This) ;
136     long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,
137                                    const GUID* riid, void** ppvObject);
138 } IClassFactory_vt;
139
140 struct _IClassFactory { IClassFactory_vt* vt; };
141
142 /*
143  * IWMCodecPrivateData interface
144  */
145 typedef struct IWMCodecPrivateData_vt
146 {
147     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
148                                    void **ppvObject);
149     long (STDCALL *AddRef)(IUnknown *This) ;
150     long (STDCALL *Release)(IUnknown *This) ;
151
152  
153     long (STDCALL *SetPartialOutputType)(IWMCodecPrivateData * This,
154                                          DMO_MEDIA_TYPE *pmt);
155
156     long (STDCALL *GetPrivateData )(IWMCodecPrivateData * This,
157                                     uint8_t *pbData, uint32_t *pcbData);
158 } IWMCodecPrivateData_vt;
159
160 struct _IWMCodecPrivateData { IWMCodecPrivateData_vt* vt; };
161
162 /*
163  * IEnumDMO interface
164  */
165 typedef struct IEnumDMO_vt
166 {
167     /* IUnknown methods */
168     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
169                                    void **ppvObject);
170     long (STDCALL *AddRef)(IUnknown *This);
171     long (STDCALL *Release)(IUnknown *This);
172
173     /* IEnumDMO methods */
174     long (STDCALL *Next)(IEnumDMO *This, uint32_t cItemsToFetch,
175                          const GUID *pCLSID, WCHAR **Names,
176                          uint32_t *pcItemsFetched);
177     long (STDCALL *Skip)(IEnumDMO *This, uint32_t cItemsToSkip);
178     long (STDCALL *Reset)(IEnumDMO *This);
179     long (STDCALL *Clone)(IEnumDMO *This, IEnumDMO **ppEnum);
180
181 } IEnumDMO_vt;
182 struct _IEnumDMO { IEnumDMO_vt* vt; };
183
184 /*
185  * IMediaBuffer interface
186  */
187 typedef struct IMediaBuffer_vt
188 {
189     /* IUnknown methods */
190     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
191                                    void **ppvObject);
192     long (STDCALL *AddRef)(IUnknown *This);
193     long (STDCALL *Release)(IUnknown *This);
194
195     long (STDCALL *SetLength)(IMediaBuffer* This, uint32_t cbLength);
196     long (STDCALL *GetMaxLength)(IMediaBuffer* This, uint32_t *pcbMaxLength);
197     long (STDCALL *GetBufferAndLength)(IMediaBuffer* This,
198                                        char **ppBuffer, uint32_t *pcbLength);
199
200 } IMediaBuffer_vt;
201 struct _IMediaBuffer { IMediaBuffer_vt* vt; };
202
203 /*
204  * IMediaObject interface
205  */
206 typedef struct IMediaObject_vt
207 {
208     /* IUnknown methods */
209     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
210                                    void **ppvObject);
211     long (STDCALL *AddRef)(IUnknown *This);
212     long (STDCALL *Release)(IUnknown *This);
213
214     /* IEnumDMO methods */
215     long (STDCALL *GetStreamCount)(IMediaObject *This,
216                                    uint32_t *pcInputStreams,
217                                    uint32_t *pcOutputStreams);
218     long (STDCALL *GetInputStreamInfo)(IMediaObject *This,
219                                        uint32_t dwInputStreamIndex,
220                                        uint32_t *pdwFlags);
221     long (STDCALL *GetOutputStreamInfo)(IMediaObject *This,
222                                         uint32_t dwOutputStreamIndex,
223                                         uint32_t *pdwFlags);
224     long (STDCALL *GetInputType)(IMediaObject *This,
225                                  uint32_t dwInputStreamIndex,
226                                  uint32_t dwTypeIndex,
227                                  DMO_MEDIA_TYPE *pmt);
228     long (STDCALL *GetOutputType)(IMediaObject *This,
229                                   uint32_t dwOutputStreamIndex,
230                                   uint32_t dwTypeIndex,
231                                   DMO_MEDIA_TYPE *pmt);
232     long (STDCALL *SetInputType)(IMediaObject *This,
233                                  uint32_t dwInputStreamIndex,
234                                  const DMO_MEDIA_TYPE *pmt,
235                                  uint32_t dwFlags);
236     long (STDCALL *SetOutputType)(IMediaObject *This,
237                                   uint32_t dwOutputStreamIndex,
238                                   const DMO_MEDIA_TYPE *pmt,
239                                   uint32_t dwFlags);
240     long (STDCALL *GetInputCurrentType)(IMediaObject *This,
241                                         uint32_t dwInputStreamIndex,
242                                         DMO_MEDIA_TYPE *pmt);
243     long (STDCALL *GetOutputCurrentType)(IMediaObject *This,
244                                          uint32_t dwOutputStreamIndex,
245                                          DMO_MEDIA_TYPE *pmt);
246     long (STDCALL *GetInputSizeInfo)(IMediaObject *This,
247                                      uint32_t dwInputStreamIndex,
248                                      uint32_t *pcbSize,
249                                      uint32_t *pcbMaxLookahead,
250                                      uint32_t *pcbAlignment);
251     long (STDCALL *GetOutputSizeInfo)(IMediaObject *This,
252                                       uint32_t dwOutputStreamIndex,
253                                       uint32_t *pcbSize,
254                                       uint32_t *pcbAlignment);
255     long (STDCALL *GetInputMaxLatency)(IMediaObject *This,
256                                        uint32_t dwInputStreamIndex,
257                                        REFERENCE_TIME *prtMaxLatency);
258     long (STDCALL *SetInputMaxLatency)(IMediaObject *This,
259                                        uint32_t dwInputStreamIndex,
260                                        REFERENCE_TIME rtMaxLatency);
261     long (STDCALL *Flush)(IMediaObject * This);
262     long (STDCALL *Discontinuity)(IMediaObject *This,
263                                   uint32_t dwInputStreamIndex);
264     long (STDCALL *AllocateStreamingResources)(IMediaObject * This);
265     long (STDCALL *FreeStreamingResources)(IMediaObject * This);
266     long (STDCALL *GetInputStatus)(IMediaObject *This,
267                                    uint32_t dwInputStreamIndex,
268                                    uint32_t *dwFlags);
269     long (STDCALL *ProcessInput)(IMediaObject *This,
270                                  uint32_t dwInputStreamIndex,
271                                  IMediaBuffer *pBuffer,
272                                  uint32_t dwFlags,
273                                  REFERENCE_TIME rtTimestamp,
274                                  REFERENCE_TIME rtTimelength);
275     long (STDCALL *ProcessOutput)(IMediaObject *This,
276                                   uint32_t dwFlags,
277                                   uint32_t cOutputBufferCount,
278                                   DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
279                                   uint32_t *pdwStatus);
280     long (STDCALL *Lock)(IMediaObject *This, long bLock);
281
282 } IMediaObject_vt;
283 struct _IMediaObject { IMediaObject_vt* vt; };
284
285 /* Implementation of IMediaBuffer */
286 typedef struct _CMediaBuffer
287 {
288     IMediaBuffer_vt *vt;
289     int i_ref;
290     block_t *p_block;
291     int i_max_size;
292     vlc_bool_t b_own;
293
294 } CMediaBuffer;
295
296 CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );