winegstreamer: Remove FIXME / stub! from optional transform methods.
[wine.git] / dlls / winegstreamer / color_convert.c
blobf7e72e0e5141fd2236e2e9ab8e31d77125529657
1 /* Copyright 2022 RĂ©mi Bernon for CodeWeavers
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #include "gst_private.h"
20 #include "mfapi.h"
21 #include "mferror.h"
22 #include "mfobjects.h"
23 #include "mftransform.h"
24 #include "wmcodecdsp.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
29 WINE_DECLARE_DEBUG_CHANNEL(winediag);
31 static const GUID *const input_types[] =
33 &MFVideoFormat_YV12,
34 &MFVideoFormat_YUY2,
35 &MFVideoFormat_UYVY,
36 &MFVideoFormat_AYUV,
37 &MFVideoFormat_NV12,
38 &MFVideoFormat_RGB32,
39 &MFVideoFormat_RGB565,
40 &MFVideoFormat_I420,
41 &MFVideoFormat_IYUV,
42 &MFVideoFormat_YVYU,
43 &MFVideoFormat_RGB24,
44 &MFVideoFormat_RGB555,
45 &MEDIASUBTYPE_RGB8,
46 &MEDIASUBTYPE_V216,
47 &MEDIASUBTYPE_V410,
48 &MFVideoFormat_NV11,
49 &MFVideoFormat_Y41P,
50 &MFVideoFormat_Y41T,
51 &MFVideoFormat_Y42T,
52 &MFVideoFormat_YVU9,
54 static const GUID *const output_types[] =
56 &MFVideoFormat_YV12,
57 &MFVideoFormat_YUY2,
58 &MFVideoFormat_UYVY,
59 &MFVideoFormat_AYUV,
60 &MFVideoFormat_NV12,
61 &MFVideoFormat_RGB32,
62 &MFVideoFormat_RGB565,
63 &MFVideoFormat_I420,
64 &MFVideoFormat_IYUV,
65 &MFVideoFormat_YVYU,
66 &MFVideoFormat_RGB24,
67 &MFVideoFormat_RGB555,
68 &MEDIASUBTYPE_RGB8,
69 &MEDIASUBTYPE_V216,
70 &MEDIASUBTYPE_V410,
71 &MFVideoFormat_NV11,
74 struct color_convert
76 IUnknown IUnknown_inner;
77 IMFTransform IMFTransform_iface;
78 IMediaObject IMediaObject_iface;
79 IPropertyBag IPropertyBag_iface;
80 IPropertyStore IPropertyStore_iface;
81 IUnknown *outer;
82 LONG refcount;
83 IMFMediaType *input_type;
84 IMFMediaType *output_type;
86 struct wg_transform *wg_transform;
87 struct wg_sample_queue *wg_sample_queue;
90 static inline struct color_convert *impl_from_IUnknown(IUnknown *iface)
92 return CONTAINING_RECORD(iface, struct color_convert, IUnknown_inner);
95 static HRESULT try_create_wg_transform(struct color_convert *impl)
97 struct wg_format input_format, output_format;
99 if (impl->wg_transform)
100 wg_transform_destroy(impl->wg_transform);
101 impl->wg_transform = NULL;
103 mf_media_type_to_wg_format(impl->input_type, &input_format);
104 if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
105 return MF_E_INVALIDMEDIATYPE;
107 mf_media_type_to_wg_format(impl->output_type, &output_format);
108 if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
109 return MF_E_INVALIDMEDIATYPE;
111 if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format)))
112 return E_FAIL;
114 return S_OK;
117 static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out)
119 struct color_convert *impl = impl_from_IUnknown(iface);
121 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
123 if (IsEqualGUID(iid, &IID_IUnknown))
124 *out = &impl->IUnknown_inner;
125 else if (IsEqualGUID(iid, &IID_IMFTransform))
126 *out = &impl->IMFTransform_iface;
127 else if (IsEqualGUID(iid, &IID_IMediaObject))
128 *out = &impl->IMediaObject_iface;
129 else if (IsEqualIID(iid, &IID_IPropertyBag))
130 *out = &impl->IPropertyBag_iface;
131 else if (IsEqualIID(iid, &IID_IPropertyStore))
132 *out = &impl->IPropertyStore_iface;
133 else
135 *out = NULL;
136 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
137 return E_NOINTERFACE;
140 IUnknown_AddRef((IUnknown *)*out);
141 return S_OK;
144 static ULONG WINAPI unknown_AddRef(IUnknown *iface)
146 struct color_convert *impl = impl_from_IUnknown(iface);
147 ULONG refcount = InterlockedIncrement(&impl->refcount);
149 TRACE("iface %p increasing refcount to %lu.\n", iface, refcount);
151 return refcount;
154 static ULONG WINAPI unknown_Release(IUnknown *iface)
156 struct color_convert *impl = impl_from_IUnknown(iface);
157 ULONG refcount = InterlockedDecrement(&impl->refcount);
159 TRACE("iface %p decreasing refcount to %lu.\n", iface, refcount);
161 if (!refcount)
163 if (impl->wg_transform)
164 wg_transform_destroy(impl->wg_transform);
165 if (impl->input_type)
166 IMFMediaType_Release(impl->input_type);
167 if (impl->output_type)
168 IMFMediaType_Release(impl->output_type);
170 wg_sample_queue_destroy(impl->wg_sample_queue);
171 free(impl);
174 return refcount;
177 static const IUnknownVtbl unknown_vtbl =
179 unknown_QueryInterface,
180 unknown_AddRef,
181 unknown_Release,
184 static struct color_convert *impl_from_IMFTransform(IMFTransform *iface)
186 return CONTAINING_RECORD(iface, struct color_convert, IMFTransform_iface);
189 static HRESULT WINAPI transform_QueryInterface(IMFTransform *iface, REFIID iid, void **out)
191 return IUnknown_QueryInterface(impl_from_IMFTransform(iface)->outer, iid, out);
194 static ULONG WINAPI transform_AddRef(IMFTransform *iface)
196 return IUnknown_AddRef(impl_from_IMFTransform(iface)->outer);
199 static ULONG WINAPI transform_Release(IMFTransform *iface)
201 return IUnknown_Release(impl_from_IMFTransform(iface)->outer);
204 static HRESULT WINAPI transform_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum,
205 DWORD *input_maximum, DWORD *output_minimum, DWORD *output_maximum)
207 TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.\n",
208 iface, input_minimum, input_maximum, output_minimum, output_maximum);
209 *input_minimum = *input_maximum = *output_minimum = *output_maximum = 1;
210 return S_OK;
213 static HRESULT WINAPI transform_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs)
215 TRACE("iface %p, inputs %p, outputs %p.\n", iface, inputs, outputs);
216 *inputs = *outputs = 1;
217 return S_OK;
220 static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs,
221 DWORD output_size, DWORD *outputs)
223 TRACE("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p.\n", iface,
224 input_size, inputs, output_size, outputs);
225 return E_NOTIMPL;
228 static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info)
230 struct color_convert *impl = impl_from_IMFTransform(iface);
231 UINT32 sample_size;
232 UINT64 framesize;
233 GUID subtype;
234 HRESULT hr;
236 TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
238 if (!impl->input_type || !impl->output_type)
239 return MF_E_TRANSFORM_TYPE_NOT_SET;
241 if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->input_type, &MF_MT_SUBTYPE, &subtype)) &&
242 SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->input_type, &MF_MT_FRAME_SIZE, &framesize)))
243 MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
244 else
245 sample_size = 0;
247 info->dwFlags = 0;
248 info->cbSize = sample_size;
249 info->cbAlignment = 1;
250 info->hnsMaxLatency = 0;
251 info->cbMaxLookahead = 0;
253 return S_OK;
256 static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
258 struct color_convert *impl = impl_from_IMFTransform(iface);
259 UINT32 sample_size;
260 UINT64 framesize;
261 GUID subtype;
262 HRESULT hr;
264 TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
266 if (!impl->input_type || !impl->output_type)
267 return MF_E_TRANSFORM_TYPE_NOT_SET;
269 if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->output_type, &MF_MT_SUBTYPE, &subtype)) &&
270 SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->output_type, &MF_MT_FRAME_SIZE, &framesize)))
271 MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
272 else
273 sample_size = 0;
275 info->dwFlags = 0;
276 info->cbSize = sample_size;
277 info->cbAlignment = 1;
279 return S_OK;
282 static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes)
284 TRACE("iface %p, attributes %p.\n", iface, attributes);
285 return E_NOTIMPL;
288 static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes)
290 TRACE("iface %p, id %#lx, attributes %p.\n", iface, id, attributes);
291 return E_NOTIMPL;
294 static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes)
296 TRACE("iface %p, id %#lx, attributes %p.\n", iface, id, attributes);
297 return E_NOTIMPL;
300 static HRESULT WINAPI transform_DeleteInputStream(IMFTransform *iface, DWORD id)
302 TRACE("iface %p, id %#lx.\n", iface, id);
303 return E_NOTIMPL;
306 static HRESULT WINAPI transform_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids)
308 TRACE("iface %p, streams %lu, ids %p.\n", iface, streams, ids);
309 return E_NOTIMPL;
312 static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
313 IMFMediaType **type)
315 IMFMediaType *media_type;
316 const GUID *subtype;
317 HRESULT hr;
319 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type);
321 *type = NULL;
323 if (index >= ARRAY_SIZE(input_types))
324 return MF_E_NO_MORE_TYPES;
325 subtype = input_types[index];
327 if (FAILED(hr = MFCreateMediaType(&media_type)))
328 return hr;
330 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video)))
331 goto done;
332 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, subtype)))
333 goto done;
334 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1)))
335 goto done;
336 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1)))
337 goto done;
339 IMFMediaType_AddRef((*type = media_type));
341 done:
342 IMFMediaType_Release(media_type);
343 return hr;
346 static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
347 IMFMediaType **type)
349 IMFMediaType *media_type;
350 const GUID *subtype;
351 HRESULT hr;
353 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type);
355 *type = NULL;
357 if (index >= ARRAY_SIZE(output_types))
358 return MF_E_NO_MORE_TYPES;
359 subtype = output_types[index];
361 if (FAILED(hr = MFCreateMediaType(&media_type)))
362 return hr;
364 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video)))
365 goto done;
366 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, subtype)))
367 goto done;
368 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1)))
369 goto done;
370 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1)))
371 goto done;
373 IMFMediaType_AddRef((*type = media_type));
375 done:
376 IMFMediaType_Release(media_type);
377 return hr;
380 static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
382 struct color_convert *impl = impl_from_IMFTransform(iface);
383 MF_ATTRIBUTE_TYPE item_type;
384 GUID major, subtype;
385 HRESULT hr;
386 ULONG i;
388 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
390 if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) ||
391 FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
392 return MF_E_ATTRIBUTENOTFOUND;
394 if (!IsEqualGUID(&major, &MFMediaType_Video)
395 || FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
396 || item_type != MF_ATTRIBUTE_UINT64)
397 return E_INVALIDARG;
399 for (i = 0; i < ARRAY_SIZE(input_types); ++i)
400 if (IsEqualGUID(&subtype, input_types[i]))
401 break;
402 if (i == ARRAY_SIZE(input_types))
403 return MF_E_INVALIDMEDIATYPE;
404 if (flags & MFT_SET_TYPE_TEST_ONLY)
405 return S_OK;
407 if (!impl->input_type && FAILED(hr = MFCreateMediaType(&impl->input_type)))
408 return hr;
410 if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->input_type)))
412 IMFMediaType_Release(impl->input_type);
413 impl->input_type = NULL;
416 if (impl->output_type && FAILED(hr = try_create_wg_transform(impl)))
418 IMFMediaType_Release(impl->input_type);
419 impl->input_type = NULL;
422 return hr;
425 static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
427 struct color_convert *impl = impl_from_IMFTransform(iface);
428 MF_ATTRIBUTE_TYPE item_type;
429 GUID major, subtype;
430 HRESULT hr;
431 ULONG i;
433 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
435 if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) ||
436 FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
437 return MF_E_ATTRIBUTENOTFOUND;
439 if (!IsEqualGUID(&major, &MFMediaType_Video)
440 || FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
441 || item_type != MF_ATTRIBUTE_UINT64)
442 return E_INVALIDARG;
444 for (i = 0; i < ARRAY_SIZE(output_types); ++i)
445 if (IsEqualGUID(&subtype, output_types[i]))
446 break;
447 if (i == ARRAY_SIZE(output_types))
448 return MF_E_INVALIDMEDIATYPE;
449 if (flags & MFT_SET_TYPE_TEST_ONLY)
450 return S_OK;
452 if (!impl->output_type && FAILED(hr = MFCreateMediaType(&impl->output_type)))
453 return hr;
455 if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->output_type)))
457 IMFMediaType_Release(impl->output_type);
458 impl->output_type = NULL;
461 if (impl->input_type && FAILED(hr = try_create_wg_transform(impl)))
463 IMFMediaType_Release(impl->output_type);
464 impl->output_type = NULL;
467 return hr;
470 static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
472 struct color_convert *impl = impl_from_IMFTransform(iface);
473 HRESULT hr;
475 TRACE("iface %p, id %#lx, type %p.\n", iface, id, type);
477 if (id != 0)
478 return MF_E_INVALIDSTREAMNUMBER;
480 if (!impl->input_type)
481 return MF_E_TRANSFORM_TYPE_NOT_SET;
483 if (FAILED(hr = MFCreateMediaType(type)))
484 return hr;
486 if (FAILED(hr = IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type)))
487 IMFMediaType_Release(*type);
489 return hr;
492 static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
494 struct color_convert *impl = impl_from_IMFTransform(iface);
495 HRESULT hr;
497 TRACE("iface %p, id %#lx, type %p.\n", iface, id, type);
499 if (id != 0)
500 return MF_E_INVALIDSTREAMNUMBER;
502 if (!impl->output_type)
503 return MF_E_TRANSFORM_TYPE_NOT_SET;
505 if (FAILED(hr = MFCreateMediaType(type)))
506 return hr;
508 if (FAILED(hr = IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)*type)))
509 IMFMediaType_Release(*type);
511 return hr;
514 static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
516 FIXME("iface %p, id %#lx, flags %p stub!\n", iface, id, flags);
517 return E_NOTIMPL;
520 static HRESULT WINAPI transform_GetOutputStatus(IMFTransform *iface, DWORD *flags)
522 FIXME("iface %p, flags %p stub!\n", iface, flags);
523 return E_NOTIMPL;
526 static HRESULT WINAPI transform_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper)
528 TRACE("iface %p, lower %I64d, upper %I64d.\n", iface, lower, upper);
529 return E_NOTIMPL;
532 static HRESULT WINAPI transform_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event)
534 FIXME("iface %p, id %#lx, event %p stub!\n", iface, id, event);
535 return E_NOTIMPL;
538 static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param)
540 FIXME("iface %p, message %#x, param %#Ix stub!\n", iface, message, param);
541 return S_OK;
544 static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags)
546 struct color_convert *impl = impl_from_IMFTransform(iface);
548 TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface, id, sample, flags);
550 if (!impl->wg_transform)
551 return MF_E_TRANSFORM_TYPE_NOT_SET;
553 return wg_transform_push_mf(impl->wg_transform, sample, impl->wg_sample_queue);
556 static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count,
557 MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status)
559 struct color_convert *impl = impl_from_IMFTransform(iface);
560 MFT_OUTPUT_STREAM_INFO info;
561 struct wg_sample *wg_sample;
562 HRESULT hr;
564 TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
566 if (count != 1)
567 return E_INVALIDARG;
569 if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
570 return hr;
572 if (!impl->wg_transform)
573 return MF_E_TRANSFORM_TYPE_NOT_SET;
575 *status = 0;
576 samples[0].dwStatus = 0;
577 if (!samples[0].pSample) return E_INVALIDARG;
579 if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
580 return hr;
582 if (wg_sample->max_size < info.cbSize)
584 wg_sample_release(wg_sample);
585 return MF_E_BUFFERTOOSMALL;
588 if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL,
589 &samples[0].dwStatus)))
590 wg_sample_queue_flush(impl->wg_sample_queue, false);
592 wg_sample_release(wg_sample);
594 return hr;
597 static const IMFTransformVtbl transform_vtbl =
599 transform_QueryInterface,
600 transform_AddRef,
601 transform_Release,
602 transform_GetStreamLimits,
603 transform_GetStreamCount,
604 transform_GetStreamIDs,
605 transform_GetInputStreamInfo,
606 transform_GetOutputStreamInfo,
607 transform_GetAttributes,
608 transform_GetInputStreamAttributes,
609 transform_GetOutputStreamAttributes,
610 transform_DeleteInputStream,
611 transform_AddInputStreams,
612 transform_GetInputAvailableType,
613 transform_GetOutputAvailableType,
614 transform_SetInputType,
615 transform_SetOutputType,
616 transform_GetInputCurrentType,
617 transform_GetOutputCurrentType,
618 transform_GetInputStatus,
619 transform_GetOutputStatus,
620 transform_SetOutputBounds,
621 transform_ProcessEvent,
622 transform_ProcessMessage,
623 transform_ProcessInput,
624 transform_ProcessOutput,
627 static inline struct color_convert *impl_from_IMediaObject(IMediaObject *iface)
629 return CONTAINING_RECORD(iface, struct color_convert, IMediaObject_iface);
632 static HRESULT WINAPI media_object_QueryInterface(IMediaObject *iface, REFIID iid, void **obj)
634 return IUnknown_QueryInterface(impl_from_IMediaObject(iface)->outer, iid, obj);
637 static ULONG WINAPI media_object_AddRef(IMediaObject *iface)
639 return IUnknown_AddRef(impl_from_IMediaObject(iface)->outer);
642 static ULONG WINAPI media_object_Release(IMediaObject *iface)
644 return IUnknown_Release(impl_from_IMediaObject(iface)->outer);
647 static HRESULT WINAPI media_object_GetStreamCount(IMediaObject *iface, DWORD *input, DWORD *output)
649 FIXME("iface %p, input %p, output %p stub!\n", iface, input, output);
650 return E_NOTIMPL;
653 static HRESULT WINAPI media_object_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags)
655 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
656 return E_NOTIMPL;
659 static HRESULT WINAPI media_object_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags)
661 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
662 return E_NOTIMPL;
665 static HRESULT WINAPI media_object_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index,
666 DMO_MEDIA_TYPE *type)
668 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface, index, type_index, type);
669 return E_NOTIMPL;
672 static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index,
673 DMO_MEDIA_TYPE *type)
675 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface, index, type_index, type);
676 return E_NOTIMPL;
679 static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index,
680 const DMO_MEDIA_TYPE *type, DWORD flags)
682 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface, index, type, flags);
683 return E_NOTIMPL;
686 static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD index,
687 const DMO_MEDIA_TYPE *type, DWORD flags)
689 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface, index, type, flags);
690 return E_NOTIMPL;
693 static HRESULT WINAPI media_object_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type)
695 FIXME("iface %p, index %lu, type %p stub!\n", iface, index, type);
696 return E_NOTIMPL;
699 static HRESULT WINAPI media_object_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type)
701 FIXME("iface %p, index %lu, type %p stub!\n", iface, index, type);
702 return E_NOTIMPL;
705 static HRESULT WINAPI media_object_GetInputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size,
706 DWORD *lookahead, DWORD *alignment)
708 FIXME("iface %p, index %lu, size %p, lookahead %p, alignment %p stub!\n", iface, index, size,
709 lookahead, alignment);
710 return E_NOTIMPL;
713 static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment)
715 FIXME("iface %p, index %lu, size %p, alignment %p stub!\n", iface, index, size, alignment);
716 return E_NOTIMPL;
719 static HRESULT WINAPI media_object_GetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME *latency)
721 FIXME("iface %p, index %lu, latency %p stub!\n", iface, index, latency);
722 return E_NOTIMPL;
725 static HRESULT WINAPI media_object_SetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME latency)
727 FIXME("iface %p, index %lu, latency %s stub!\n", iface, index, wine_dbgstr_longlong(latency));
728 return E_NOTIMPL;
731 static HRESULT WINAPI media_object_Flush(IMediaObject *iface)
733 FIXME("iface %p stub!\n", iface);
734 return E_NOTIMPL;
737 static HRESULT WINAPI media_object_Discontinuity(IMediaObject *iface, DWORD index)
739 FIXME("iface %p, index %lu stub!\n", iface, index);
740 return E_NOTIMPL;
743 static HRESULT WINAPI media_object_AllocateStreamingResources(IMediaObject *iface)
745 FIXME("iface %p stub!\n", iface);
746 return E_NOTIMPL;
749 static HRESULT WINAPI media_object_FreeStreamingResources(IMediaObject *iface)
751 FIXME("iface %p stub!\n", iface);
752 return E_NOTIMPL;
755 static HRESULT WINAPI media_object_GetInputStatus(IMediaObject *iface, DWORD index, DWORD *flags)
757 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
758 return E_NOTIMPL;
761 static HRESULT WINAPI media_object_ProcessInput(IMediaObject *iface, DWORD index,
762 IMediaBuffer *buffer, DWORD flags, REFERENCE_TIME timestamp, REFERENCE_TIME timelength)
764 FIXME("iface %p, index %lu, buffer %p, flags %#lx, timestamp %s, timelength %s stub!\n", iface,
765 index, buffer, flags, wine_dbgstr_longlong(timestamp), wine_dbgstr_longlong(timelength));
766 return E_NOTIMPL;
769 static HRESULT WINAPI media_object_ProcessOutput(IMediaObject *iface, DWORD flags, DWORD count,
770 DMO_OUTPUT_DATA_BUFFER *buffers, DWORD *status)
772 FIXME("iface %p, flags %#lx, count %lu, buffers %p, status %p stub!\n", iface, flags, count, buffers, status);
773 return E_NOTIMPL;
776 static HRESULT WINAPI media_object_Lock(IMediaObject *iface, LONG lock)
778 FIXME("iface %p, lock %ld stub!\n", iface, lock);
779 return E_NOTIMPL;
782 static const IMediaObjectVtbl media_object_vtbl =
784 media_object_QueryInterface,
785 media_object_AddRef,
786 media_object_Release,
787 media_object_GetStreamCount,
788 media_object_GetInputStreamInfo,
789 media_object_GetOutputStreamInfo,
790 media_object_GetInputType,
791 media_object_GetOutputType,
792 media_object_SetInputType,
793 media_object_SetOutputType,
794 media_object_GetInputCurrentType,
795 media_object_GetOutputCurrentType,
796 media_object_GetInputSizeInfo,
797 media_object_GetOutputSizeInfo,
798 media_object_GetInputMaxLatency,
799 media_object_SetInputMaxLatency,
800 media_object_Flush,
801 media_object_Discontinuity,
802 media_object_AllocateStreamingResources,
803 media_object_FreeStreamingResources,
804 media_object_GetInputStatus,
805 media_object_ProcessInput,
806 media_object_ProcessOutput,
807 media_object_Lock,
810 static inline struct color_convert *impl_from_IPropertyBag(IPropertyBag *iface)
812 return CONTAINING_RECORD(iface, struct color_convert, IPropertyBag_iface);
815 static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out)
817 return IUnknown_QueryInterface(impl_from_IPropertyBag(iface)->outer, iid, out);
820 static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface)
822 return IUnknown_AddRef(impl_from_IPropertyBag(iface)->outer);
825 static ULONG WINAPI property_bag_Release(IPropertyBag *iface)
827 return IUnknown_Release(impl_from_IPropertyBag(iface)->outer);
830 static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value,
831 IErrorLog *error_log)
833 FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface, debugstr_w(prop_name), value, error_log);
834 return E_NOTIMPL;
837 static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value)
839 FIXME("iface %p, prop_name %s, value %p stub!\n", iface, debugstr_w(prop_name), value);
840 return S_OK;
843 static const IPropertyBagVtbl property_bag_vtbl =
845 property_bag_QueryInterface,
846 property_bag_AddRef,
847 property_bag_Release,
848 property_bag_Read,
849 property_bag_Write,
852 static inline struct color_convert *impl_from_IPropertyStore(IPropertyStore *iface)
854 return CONTAINING_RECORD(iface, struct color_convert, IPropertyStore_iface);
857 static HRESULT WINAPI property_store_QueryInterface(IPropertyStore *iface, REFIID iid, void **out)
859 return IUnknown_QueryInterface(impl_from_IPropertyStore(iface)->outer, iid, out);
862 static ULONG WINAPI property_store_AddRef(IPropertyStore *iface)
864 return IUnknown_AddRef(impl_from_IPropertyStore(iface)->outer);
867 static ULONG WINAPI property_store_Release(IPropertyStore *iface)
869 return IUnknown_Release(impl_from_IPropertyStore(iface)->outer);
872 static HRESULT WINAPI property_store_GetCount(IPropertyStore *iface, DWORD *count)
874 FIXME("iface %p, count %p stub!\n", iface, count);
875 return E_NOTIMPL;
878 static HRESULT WINAPI property_store_GetAt(IPropertyStore *iface, DWORD index, PROPERTYKEY *key)
880 FIXME("iface %p, index %lu, key %p stub!\n", iface, index, key);
881 return E_NOTIMPL;
884 static HRESULT WINAPI property_store_GetValue(IPropertyStore *iface, REFPROPERTYKEY key, PROPVARIANT *value)
886 FIXME("iface %p, key %p, value %p stub!\n", iface, key, value);
887 return E_NOTIMPL;
890 static HRESULT WINAPI property_store_SetValue(IPropertyStore *iface, REFPROPERTYKEY key, REFPROPVARIANT value)
892 FIXME("iface %p, key %p, value %p stub!\n", iface, key, value);
893 return E_NOTIMPL;
896 static HRESULT WINAPI property_store_Commit(IPropertyStore *iface)
898 FIXME("iface %p stub!\n", iface);
899 return E_NOTIMPL;
902 static const IPropertyStoreVtbl property_store_vtbl =
904 property_store_QueryInterface,
905 property_store_AddRef,
906 property_store_Release,
907 property_store_GetCount,
908 property_store_GetAt,
909 property_store_GetValue,
910 property_store_SetValue,
911 property_store_Commit,
914 HRESULT color_convert_create(IUnknown *outer, IUnknown **out)
916 static const struct wg_format input_format =
918 .major_type = WG_MAJOR_TYPE_VIDEO,
919 .u.video =
921 .format = WG_VIDEO_FORMAT_I420,
922 .width = 1920,
923 .height = 1080,
926 static const struct wg_format output_format =
928 .major_type = WG_MAJOR_TYPE_VIDEO,
929 .u.video =
931 .format = WG_VIDEO_FORMAT_NV12,
932 .width = 1920,
933 .height = 1080,
936 struct wg_transform *transform;
937 struct color_convert *impl;
938 HRESULT hr;
940 TRACE("outer %p, out %p.\n", outer, out);
942 if (!(transform = wg_transform_create(&input_format, &output_format)))
944 ERR_(winediag)("GStreamer doesn't support video conversion, please install appropriate plugins.\n");
945 return E_FAIL;
947 wg_transform_destroy(transform);
949 if (!(impl = calloc(1, sizeof(*impl))))
950 return E_OUTOFMEMORY;
952 if (FAILED(hr = wg_sample_queue_create(&impl->wg_sample_queue)))
954 free(impl);
955 return hr;
958 impl->IUnknown_inner.lpVtbl = &unknown_vtbl;
959 impl->IMFTransform_iface.lpVtbl = &transform_vtbl;
960 impl->IMediaObject_iface.lpVtbl = &media_object_vtbl;
961 impl->IPropertyBag_iface.lpVtbl = &property_bag_vtbl;
962 impl->IPropertyStore_iface.lpVtbl = &property_store_vtbl;
963 impl->refcount = 1;
964 impl->outer = outer ? outer : &impl->IUnknown_inner;
966 *out = &impl->IUnknown_inner;
967 TRACE("Created %p\n", *out);
968 return S_OK;