]> git.sesse.net Git - vlc/blob - modules/codec/dmo/dmo.h
* modules/codec/dmo/*: added dmo encoder (can't get video encoding to work though).
[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_IMediaObject = {0xd8ad0f58, 0x5494, 0x4102, {0x97, 0xc5, 0xec, 0x79, 0x8e, 0x59, 0xbc, 0xf4}};
27 static const GUID IID_IMediaBuffer = {0x59eff8b9, 0x938c, 0x4a26, {0x82, 0xf2, 0x95, 0xcb, 0x84, 0xcd, 0xc8, 0x37}};
28 static const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
29 static const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
30 static const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
31 static const GUID FORMAT_VideoInfo = {0x05589f80, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
32 static const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
33 static const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
34 static const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
35 static const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
36 static const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
37 static const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
38
39 #define IUnknown IUnknownHack
40 #define IClassFactory IClassFactoryHack
41 typedef struct _IUnknown IUnknown;
42 typedef struct _IClassFactory IClassFactory;
43 typedef struct _IEnumDMO IEnumDMO;
44 typedef struct _IMediaBuffer IMediaBuffer;
45 typedef struct _IMediaObject IMediaObject;
46
47 #ifndef STDCALL
48 #define STDCALL __stdcall
49 #endif
50
51 #define DMO_INPUT_DATA_BUFFER_SYNCPOINT 1
52 #define DMO_INPUT_DATA_BUFFERF_TIME 2
53 #define DMO_INPUT_DATA_BUFFERF_TIMELENGTH 4
54 #define DMO_OUTPUT_DATA_BUFFER_SYNCPOINT 1
55 #define DMO_OUTPUT_DATA_BUFFERF_TIME 2
56 #define DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH 4
57 #define DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER 1
58 #define DMO_E_NOTACCEPTING 0x80040204
59
60 /*
61  * DMO types definition
62  */
63 typedef struct
64 #ifdef HAVE_ATTRIBUTE_PACKED
65     __attribute__((__packed__))
66 #endif
67  _DMO_PARTIAL_MEDIATYPE
68 {
69     GUID type;
70     GUID subtype;
71
72 } DMO_PARTIAL_MEDIATYPE;
73
74 typedef struct
75 #ifdef HAVE_ATTRIBUTE_PACKED
76     __attribute__((__packed__))
77 #endif
78  _DMO_OUTPUT_DATA_BUFFER
79 {
80     IMediaBuffer *pBuffer;
81     uint32_t dwStatus;
82     REFERENCE_TIME rtTimestamp;
83     REFERENCE_TIME rtTimelength;
84
85 } DMO_OUTPUT_DATA_BUFFER;
86
87 typedef struct
88 #ifdef HAVE_ATTRIBUTE_PACKED
89     __attribute__((__packed__))
90 #endif
91  _DMOMediaType
92 {
93     GUID     majortype;
94     GUID     subtype;
95     int      bFixedSizeSamples;
96     int      bTemporalCompression;
97     uint32_t lSampleSize;
98     GUID     formattype;
99     IUnknown *pUnk;
100     uint32_t cbFormat;
101     char     *pbFormat;
102
103 } DMO_MEDIA_TYPE;
104
105 /*
106  * IUnknown interface
107  */
108 typedef struct IUnknown_vt
109 {
110     /* IUnknown methods */
111     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
112                                    void **ppvObject);
113     long (STDCALL *AddRef)(IUnknown *This);
114     long (STDCALL *Release)(IUnknown *This);
115
116 } IUnknown_vt;
117 struct _IUnknown { IUnknown_vt* vt; };
118
119 /*
120  * IClassFactory interface
121  */
122 typedef struct IClassFactory_vt
123 {
124     long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,
125                                    void **ppvObject);
126     long (STDCALL *AddRef)(IUnknown *This) ;
127     long (STDCALL *Release)(IUnknown *This) ;
128     long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,
129                                    const GUID* riid, void** ppvObject);
130 } IClassFactory_vt;
131
132 struct _IClassFactory { IClassFactory_vt* vt; };
133
134 /*
135  * IEnumDMO interface
136  */
137 typedef struct IEnumDMO_vt
138 {
139     /* IUnknown methods */
140     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
141                                    void **ppvObject);
142     long (STDCALL *AddRef)(IUnknown *This);
143     long (STDCALL *Release)(IUnknown *This);
144
145     /* IEnumDMO methods */
146     long (STDCALL *Next)(IEnumDMO *This, uint32_t cItemsToFetch,
147                          const GUID *pCLSID, WCHAR **Names,
148                          uint32_t *pcItemsFetched);
149     long (STDCALL *Skip)(IEnumDMO *This, uint32_t cItemsToSkip);
150     long (STDCALL *Reset)(IEnumDMO *This);
151     long (STDCALL *Clone)(IEnumDMO *This, IEnumDMO **ppEnum);
152
153 } IEnumDMO_vt;
154 struct _IEnumDMO { IEnumDMO_vt* vt; };
155
156 /*
157  * IMediaBuffer interface
158  */
159 typedef struct IMediaBuffer_vt
160 {
161     /* IUnknown methods */
162     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
163                                    void **ppvObject);
164     long (STDCALL *AddRef)(IUnknown *This);
165     long (STDCALL *Release)(IUnknown *This);
166
167     long (STDCALL *SetLength)(IMediaBuffer* This, uint32_t cbLength);
168     long (STDCALL *GetMaxLength)(IMediaBuffer* This, uint32_t *pcbMaxLength);
169     long (STDCALL *GetBufferAndLength)(IMediaBuffer* This,
170                                        char** ppBuffer, uint32_t* pcbLength);
171
172 } IMediaBuffer_vt;
173 struct _IMediaBuffer { IMediaBuffer_vt* vt; };
174
175 /*
176  * IMediaObject interface
177  */
178 typedef struct IMediaObject_vt
179 {
180     /* IUnknown methods */
181     long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
182                                    void **ppvObject);
183     long (STDCALL *AddRef)(IUnknown *This);
184     long (STDCALL *Release)(IUnknown *This);
185
186     /* IEnumDMO methods */
187     long (STDCALL *GetStreamCount)(IMediaObject *This,
188                                    uint32_t *pcInputStreams,
189                                    uint32_t *pcOutputStreams);
190     long (STDCALL *GetInputStreamInfo)(IMediaObject *This,
191                                        uint32_t dwInputStreamIndex,
192                                        uint32_t *pdwFlags);
193     long (STDCALL *GetOutputStreamInfo)(IMediaObject *This,
194                                         uint32_t dwOutputStreamIndex,
195                                         uint32_t *pdwFlags);
196     long (STDCALL *GetInputType)(IMediaObject *This,
197                                  uint32_t dwInputStreamIndex,
198                                  uint32_t dwTypeIndex,
199                                  DMO_MEDIA_TYPE *pmt);
200     long (STDCALL *GetOutputType)(IMediaObject *This,
201                                   uint32_t dwOutputStreamIndex,
202                                   uint32_t dwTypeIndex,
203                                   DMO_MEDIA_TYPE *pmt);
204     long (STDCALL *SetInputType)(IMediaObject *This,
205                                  uint32_t dwInputStreamIndex,
206                                  const DMO_MEDIA_TYPE *pmt,
207                                  uint32_t dwFlags);
208     long (STDCALL *SetOutputType)(IMediaObject *This,
209                                   uint32_t dwOutputStreamIndex,
210                                   const DMO_MEDIA_TYPE *pmt,
211                                   uint32_t dwFlags);
212     long (STDCALL *GetInputCurrentType)(IMediaObject *This,
213                                         uint32_t dwInputStreamIndex,
214                                         DMO_MEDIA_TYPE *pmt);
215     long (STDCALL *GetOutputCurrentType)(IMediaObject *This,
216                                          uint32_t dwOutputStreamIndex,
217                                          DMO_MEDIA_TYPE *pmt);
218     long (STDCALL *GetInputSizeInfo)(IMediaObject *This,
219                                      uint32_t dwInputStreamIndex,
220                                      uint32_t *pcbSize,
221                                      uint32_t *pcbMaxLookahead,
222                                      uint32_t *pcbAlignment);
223     long (STDCALL *GetOutputSizeInfo)(IMediaObject *This,
224                                       uint32_t dwOutputStreamIndex,
225                                       uint32_t *pcbSize,
226                                       uint32_t *pcbAlignment);
227     long (STDCALL *GetInputMaxLatency)(IMediaObject *This,
228                                        uint32_t dwInputStreamIndex,
229                                        REFERENCE_TIME *prtMaxLatency);
230     long (STDCALL *SetInputMaxLatency)(IMediaObject *This,
231                                        uint32_t dwInputStreamIndex,
232                                        REFERENCE_TIME rtMaxLatency);
233     long (STDCALL *Flush)(IMediaObject * This);
234     long (STDCALL *Discontinuity)(IMediaObject *This,
235                                   uint32_t dwInputStreamIndex);
236     long (STDCALL *AllocateStreamingResources)(IMediaObject * This);
237     long (STDCALL *FreeStreamingResources)(IMediaObject * This);
238     long (STDCALL *GetInputStatus)(IMediaObject *This,
239                                    uint32_t dwInputStreamIndex,
240                                    uint32_t *dwFlags);
241     long (STDCALL *ProcessInput)(IMediaObject *This,
242                                  uint32_t dwInputStreamIndex,
243                                  IMediaBuffer *pBuffer,
244                                  uint32_t dwFlags,
245                                  REFERENCE_TIME rtTimestamp,
246                                  REFERENCE_TIME rtTimelength);
247     long (STDCALL *ProcessOutput)(IMediaObject *This,
248                                   uint32_t dwFlags,
249                                   uint32_t cOutputBufferCount,
250                                   DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
251                                   uint32_t *pdwStatus);
252     long (STDCALL *Lock)(IMediaObject *This, long bLock);
253
254 } IMediaObject_vt;
255 struct _IMediaObject { IMediaObject_vt* vt; };
256
257 /* Implementation of IMediaBuffer */
258 typedef struct _CMediaBuffer
259 {
260     IMediaBuffer_vt *vt;
261     int i_ref;
262     block_t *p_block;
263     int i_max_size;
264     vlc_bool_t b_own;
265
266 } CMediaBuffer;
267
268 CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );