xref: /reactos/dll/win32/wmvcore/writer.c (revision c2c66aff)
1 /*
2  * Copyright 2015 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "wmvcore.h"
20 #include "wmsdkidl.h"
21 
22 #include "wine/debug.h"
23 
24 WINE_DEFAULT_DEBUG_CHANNEL(wmvcore);
25 
26 typedef struct {
27     IWMWriter IWMWriter_iface;
28     IWMWriterAdvanced3 IWMWriterAdvanced3_iface;
29     LONG ref;
30 } WMWriter;
31 
32 static inline WMWriter *impl_from_IWMWriter(IWMWriter *iface)
33 {
34     return CONTAINING_RECORD(iface, WMWriter, IWMWriter_iface);
35 }
36 
37 static HRESULT WINAPI WMWriter_QueryInterface(IWMWriter *iface, REFIID riid, void **ppv)
38 {
39     WMWriter *This = impl_from_IWMWriter(iface);
40 
41     if(IsEqualGUID(&IID_IUnknown, riid)) {
42         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
43         *ppv = &This->IWMWriter_iface;
44     }else if(IsEqualGUID(&IID_IWMWriter, riid)) {
45         TRACE("(%p)->(IID_IWMWriter %p)\n", This, ppv);
46         *ppv = &This->IWMWriter_iface;
47     }else if(IsEqualGUID(&IID_IWMWriterAdvanced, riid)) {
48         TRACE("(%p)->(IID_IWMWriterAdvanced %p)\n", This, ppv);
49         *ppv = &This->IWMWriterAdvanced3_iface;
50     }else if(IsEqualGUID(&IID_IWMWriterAdvanced2, riid)) {
51         TRACE("(%p)->(IID_IWMWriterAdvanced2 %p)\n", This, ppv);
52         *ppv = &This->IWMWriterAdvanced3_iface;
53     }else if(IsEqualGUID(&IID_IWMWriterAdvanced3, riid)) {
54         TRACE("(%p)->(IID_IWMWriterAdvanced3 %p)\n", This, ppv);
55         *ppv = &This->IWMWriterAdvanced3_iface;
56     }else {
57         FIXME("Unsupported iface %s\n", debugstr_guid(riid));
58         *ppv = NULL;
59         return E_NOINTERFACE;
60     }
61 
62     IUnknown_AddRef((IUnknown*)*ppv);
63     return S_OK;
64 }
65 
66 static ULONG WINAPI WMWriter_AddRef(IWMWriter *iface)
67 {
68     WMWriter *This = impl_from_IWMWriter(iface);
69     LONG ref = InterlockedIncrement(&This->ref);
70 
71     TRACE("(%p) ref=%d\n", This, ref);
72 
73     return ref;
74 }
75 
76 static ULONG WINAPI WMWriter_Release(IWMWriter *iface)
77 {
78     WMWriter *This = impl_from_IWMWriter(iface);
79     LONG ref = InterlockedDecrement(&This->ref);
80 
81     TRACE("(%p) ref=%d\n", This, ref);
82 
83     if(!ref)
84         heap_free(This);
85 
86     return ref;
87 }
88 
89 static HRESULT WINAPI WMWriter_SetProfileByID(IWMWriter *iface, REFGUID guidProfile)
90 {
91     WMWriter *This = impl_from_IWMWriter(iface);
92     FIXME("(%p)->(%s)\n", This, debugstr_guid(guidProfile));
93     return E_NOTIMPL;
94 }
95 
96 static HRESULT WINAPI WMWriter_SetProfile(IWMWriter *iface, IWMProfile *profile)
97 {
98     WMWriter *This = impl_from_IWMWriter(iface);
99     FIXME("(%p)->(%p)\n", This, profile);
100     return E_NOTIMPL;
101 }
102 
103 static HRESULT WINAPI WMWriter_SetOutputFilename(IWMWriter *iface, const WCHAR *filename)
104 {
105     WMWriter *This = impl_from_IWMWriter(iface);
106     FIXME("(%p)->(%s)\n", This, debugstr_w(filename));
107     return E_NOTIMPL;
108 }
109 
110 static HRESULT WINAPI WMWriter_GetInputCount(IWMWriter *iface, DWORD *pcInputs)
111 {
112     WMWriter *This = impl_from_IWMWriter(iface);
113     FIXME("(%p)->(%p)\n", This, pcInputs);
114     return E_NOTIMPL;
115 }
116 
117 static HRESULT WINAPI WMWriter_GetInputProps(IWMWriter *iface, DWORD dwInputNum, IWMInputMediaProps **input)
118 {
119     WMWriter *This = impl_from_IWMWriter(iface);
120     FIXME("(%p)->(%d %p)\n", This, dwInputNum, input);
121     return E_NOTIMPL;
122 }
123 
124 static HRESULT WINAPI WMWriter_SetInputProps(IWMWriter *iface, DWORD dwInputNum, IWMInputMediaProps *input)
125 {
126     WMWriter *This = impl_from_IWMWriter(iface);
127     FIXME("(%p)->(%d %p)\n", This, dwInputNum, input);
128     return E_NOTIMPL;
129 }
130 
131 static HRESULT WINAPI WMWriter_GetInputFormatCount(IWMWriter *iface, DWORD dwInputNumber, DWORD *pcFormat)
132 {
133     WMWriter *This = impl_from_IWMWriter(iface);
134     FIXME("(%p)->(%d %p)\n", This, dwInputNumber, pcFormat);
135     return E_NOTIMPL;
136 }
137 
138 static HRESULT WINAPI WMWriter_GetInputFormat(IWMWriter *iface, DWORD dwInputNumber, DWORD dwFormatNumber,
139         IWMInputMediaProps **props)
140 {
141     WMWriter *This = impl_from_IWMWriter(iface);
142     FIXME("(%p)->(%d %d %p)\n", This, dwInputNumber, dwFormatNumber, props);
143     return E_NOTIMPL;
144 }
145 
146 static HRESULT WINAPI WMWriter_BeginWriting(IWMWriter *iface)
147 {
148     WMWriter *This = impl_from_IWMWriter(iface);
149     FIXME("(%p)\n", This);
150     return E_NOTIMPL;
151 }
152 
153 static HRESULT WINAPI WMWriter_EndWriting(IWMWriter *iface)
154 {
155     WMWriter *This = impl_from_IWMWriter(iface);
156     FIXME("(%p)\n", This);
157     return E_NOTIMPL;
158 }
159 
160 static HRESULT WINAPI WMWriter_AllocateSample(IWMWriter *iface, DWORD size, INSSBuffer **sample)
161 {
162     WMWriter *This = impl_from_IWMWriter(iface);
163     FIXME("(%p)->(%d %p)\n", This, size, sample);
164     return E_NOTIMPL;
165 }
166 
167 static HRESULT WINAPI WMWriter_WriteSample(IWMWriter *iface, DWORD dwInputNum, QWORD cnsSampleTime,
168         DWORD flags, INSSBuffer *sample)
169 {
170     WMWriter *This = impl_from_IWMWriter(iface);
171     FIXME("(%p)->(%d %s %x %p)\n", This, dwInputNum, wine_dbgstr_longlong(cnsSampleTime), flags, sample);
172     return E_NOTIMPL;
173 }
174 
175 static HRESULT WINAPI WMWriter_Flush(IWMWriter *iface)
176 {
177     WMWriter *This = impl_from_IWMWriter(iface);
178     FIXME("(%p)\n", This);
179     return E_NOTIMPL;
180 }
181 
182 static const IWMWriterVtbl WMWriterVtbl = {
183     WMWriter_QueryInterface,
184     WMWriter_AddRef,
185     WMWriter_Release,
186     WMWriter_SetProfileByID,
187     WMWriter_SetProfile,
188     WMWriter_SetOutputFilename,
189     WMWriter_GetInputCount,
190     WMWriter_GetInputProps,
191     WMWriter_SetInputProps,
192     WMWriter_GetInputFormatCount,
193     WMWriter_GetInputFormat,
194     WMWriter_BeginWriting,
195     WMWriter_EndWriting,
196     WMWriter_AllocateSample,
197     WMWriter_WriteSample,
198     WMWriter_Flush
199 };
200 
201 static inline WMWriter *impl_from_IWMWriterAdvanced3(IWMWriterAdvanced3 *iface)
202 {
203     return CONTAINING_RECORD(iface, WMWriter, IWMWriterAdvanced3_iface);
204 }
205 
206 static HRESULT WINAPI WMWriterAdvanced_QueryInterface(IWMWriterAdvanced3 *iface, REFIID riid, void **ppv)
207 {
208     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
209     return IWMWriter_QueryInterface(&This->IWMWriter_iface, riid, ppv);
210 }
211 
212 static ULONG WINAPI WMWriterAdvanced_AddRef(IWMWriterAdvanced3 *iface)
213 {
214     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
215     return IWMWriter_AddRef(&This->IWMWriter_iface);
216 }
217 
218 static ULONG WINAPI WMWriterAdvanced_Release(IWMWriterAdvanced3 *iface)
219 {
220     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
221     return IWMWriter_Release(&This->IWMWriter_iface);
222 }
223 
224 static HRESULT WINAPI WMWriterAdvanced_GetSinkCount(IWMWriterAdvanced3 *iface, DWORD *sinks)
225 {
226     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
227     FIXME("(%p)->(%p)\n", This, sinks);
228     return E_NOTIMPL;
229 }
230 
231 static HRESULT WINAPI WMWriterAdvanced_GetSink(IWMWriterAdvanced3 *iface, DWORD sink_num, IWMWriterSink **sink)
232 {
233     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
234     FIXME("(%p)->(%u %p)\n", This, sink_num, sink);
235     return E_NOTIMPL;
236 }
237 
238 static HRESULT WINAPI WMWriterAdvanced_AddSink(IWMWriterAdvanced3 *iface, IWMWriterSink *sink)
239 {
240     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
241     FIXME("(%p)->(%p)\n", This, sink);
242     return E_NOTIMPL;
243 }
244 
245 static HRESULT WINAPI WMWriterAdvanced_RemoveSink(IWMWriterAdvanced3 *iface, IWMWriterSink *sink)
246 {
247     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
248     FIXME("(%p)->(%p)\n", This, sink);
249     return E_NOTIMPL;
250 }
251 
252 static HRESULT WINAPI WMWriterAdvanced_WriteStreamSample(IWMWriterAdvanced3 *iface, WORD stream_num,
253         QWORD sample_time, DWORD sample_send_time, QWORD sample_duration, DWORD flags, INSSBuffer *sample)
254 {
255     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
256     FIXME("(%p)->(%u %s %u %s %x %p)\n", This, stream_num, wine_dbgstr_longlong(sample_time),
257           sample_send_time, wine_dbgstr_longlong(sample_duration), flags, sample);
258     return E_NOTIMPL;
259 }
260 
261 static HRESULT WINAPI WMWriterAdvanced_SetLiveSource(IWMWriterAdvanced3 *iface, BOOL is_live_source)
262 {
263     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
264     FIXME("(%p)->(%x)\n", This, is_live_source);
265     return E_NOTIMPL;
266 }
267 
268 static HRESULT WINAPI WMWriterAdvanced_IsRealTime(IWMWriterAdvanced3 *iface, BOOL *real_time)
269 {
270     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
271     FIXME("(%p)->(%p)\n", This, real_time);
272     return E_NOTIMPL;
273 }
274 
275 static HRESULT WINAPI WMWriterAdvanced_GetWriterTime(IWMWriterAdvanced3 *iface, QWORD *current_time)
276 {
277     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
278     FIXME("(%p)->(%p)\n", This, current_time);
279     return E_NOTIMPL;
280 }
281 
282 static HRESULT WINAPI WMWriterAdvanced_GetStatistics(IWMWriterAdvanced3 *iface, WORD stream_num, WM_WRITER_STATISTICS *stats)
283 {
284     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
285     FIXME("(%p)->(%u %p)\n", This, stream_num, stats);
286     return E_NOTIMPL;
287 }
288 
289 static HRESULT WINAPI WMWriterAdvanced_SetSyncTolerance(IWMWriterAdvanced3 *iface, DWORD window)
290 {
291     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
292     FIXME("(%p)->(%u)\n", This, window);
293     return E_NOTIMPL;
294 }
295 
296 static HRESULT WINAPI WMWriterAdvanced_GetSyncTolerance(IWMWriterAdvanced3 *iface, DWORD *window)
297 {
298     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
299     FIXME("(%p)->(%p)\n", This, window);
300     return E_NOTIMPL;
301 }
302 
303 static HRESULT WINAPI WMWriterAdvanced2_GetInputSetting(IWMWriterAdvanced3 *iface, DWORD input_num,
304         const WCHAR *name, WMT_ATTR_DATATYPE *time, BYTE *value, WORD *length)
305 {
306     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
307     FIXME("(%p)->(%u %s %p %p %p)\n", This, input_num, debugstr_w(name), time, value, length);
308     return E_NOTIMPL;
309 }
310 
311 static HRESULT WINAPI WMWriterAdvanced2_SetInputSetting(IWMWriterAdvanced3 *iface, DWORD input_num,
312         const WCHAR *name, WMT_ATTR_DATATYPE type, const BYTE *value, WORD length)
313 {
314     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
315     FIXME("(%p)->(%u %s %d %p %u)\n", This, input_num, debugstr_w(name), type, value, length);
316     return E_NOTIMPL;
317 }
318 
319 static HRESULT WINAPI WMWriterAdvanced3_GetStatisticsEx(IWMWriterAdvanced3 *iface, WORD stream_num,
320         WM_WRITER_STATISTICS_EX *stats)
321 {
322     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
323     FIXME("(%p)->(%u %p)\n", This, stream_num, stats);
324     return E_NOTIMPL;
325 }
326 
327 static HRESULT WINAPI WMWriterAdvanced3_SetNonBlocking(IWMWriterAdvanced3 *iface)
328 {
329     WMWriter *This = impl_from_IWMWriterAdvanced3(iface);
330     FIXME("(%p)\n", This);
331     return E_NOTIMPL;
332 }
333 
334 static const IWMWriterAdvanced3Vtbl WMWriterAdvanced3Vtbl = {
335     WMWriterAdvanced_QueryInterface,
336     WMWriterAdvanced_AddRef,
337     WMWriterAdvanced_Release,
338     WMWriterAdvanced_GetSinkCount,
339     WMWriterAdvanced_GetSink,
340     WMWriterAdvanced_AddSink,
341     WMWriterAdvanced_RemoveSink,
342     WMWriterAdvanced_WriteStreamSample,
343     WMWriterAdvanced_SetLiveSource,
344     WMWriterAdvanced_IsRealTime,
345     WMWriterAdvanced_GetWriterTime,
346     WMWriterAdvanced_GetStatistics,
347     WMWriterAdvanced_SetSyncTolerance,
348     WMWriterAdvanced_GetSyncTolerance,
349     WMWriterAdvanced2_GetInputSetting,
350     WMWriterAdvanced2_SetInputSetting,
351     WMWriterAdvanced3_GetStatisticsEx,
352     WMWriterAdvanced3_SetNonBlocking
353 };
354 
355 HRESULT WINAPI WMCreateWriter(IUnknown *reserved, IWMWriter **writer)
356 {
357     WMWriter *ret;
358 
359     TRACE("(%p %p)\n", reserved, writer);
360 
361     ret = heap_alloc(sizeof(*ret));
362     if(!ret)
363         return E_OUTOFMEMORY;
364 
365     ret->IWMWriter_iface.lpVtbl = &WMWriterVtbl;
366     ret->IWMWriterAdvanced3_iface.lpVtbl = &WMWriterAdvanced3Vtbl;
367     ret->ref = 1;
368 
369     *writer = &ret->IWMWriter_iface;
370     return S_OK;
371 }
372