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