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"
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
[] =
39 &MFVideoFormat_RGB565
,
44 &MFVideoFormat_RGB555
,
54 static const GUID
*const output_types
[] =
62 &MFVideoFormat_RGB565
,
67 &MFVideoFormat_RGB555
,
76 IUnknown IUnknown_inner
;
77 IMFTransform IMFTransform_iface
;
78 IMediaObject IMediaObject_iface
;
79 IPropertyBag IPropertyBag_iface
;
80 IPropertyStore IPropertyStore_iface
;
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
)))
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
;
136 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
137 return E_NOINTERFACE
;
140 IUnknown_AddRef((IUnknown
*)*out
);
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
);
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
);
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
);
177 static const IUnknownVtbl unknown_vtbl
=
179 unknown_QueryInterface
,
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;
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;
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
);
228 static HRESULT WINAPI
transform_GetInputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_INPUT_STREAM_INFO
*info
)
230 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
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
);
248 info
->cbSize
= sample_size
;
249 info
->cbAlignment
= 1;
250 info
->hnsMaxLatency
= 0;
251 info
->cbMaxLookahead
= 0;
256 static HRESULT WINAPI
transform_GetOutputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_OUTPUT_STREAM_INFO
*info
)
258 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
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
);
276 info
->cbSize
= sample_size
;
277 info
->cbAlignment
= 1;
282 static HRESULT WINAPI
transform_GetAttributes(IMFTransform
*iface
, IMFAttributes
**attributes
)
284 TRACE("iface %p, attributes %p.\n", iface
, attributes
);
288 static HRESULT WINAPI
transform_GetInputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
290 TRACE("iface %p, id %#lx, attributes %p.\n", iface
, id
, attributes
);
294 static HRESULT WINAPI
transform_GetOutputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
296 TRACE("iface %p, id %#lx, attributes %p.\n", iface
, id
, attributes
);
300 static HRESULT WINAPI
transform_DeleteInputStream(IMFTransform
*iface
, DWORD id
)
302 TRACE("iface %p, id %#lx.\n", iface
, id
);
306 static HRESULT WINAPI
transform_AddInputStreams(IMFTransform
*iface
, DWORD streams
, DWORD
*ids
)
308 TRACE("iface %p, streams %lu, ids %p.\n", iface
, streams
, ids
);
312 static HRESULT WINAPI
transform_GetInputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
315 IMFMediaType
*media_type
;
319 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface
, id
, index
, type
);
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
)))
330 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Video
)))
332 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_SUBTYPE
, subtype
)))
334 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, 1)))
336 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1)))
339 IMFMediaType_AddRef((*type
= media_type
));
342 IMFMediaType_Release(media_type
);
346 static HRESULT WINAPI
transform_GetOutputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
349 IMFMediaType
*media_type
;
353 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface
, id
, index
, type
);
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
)))
364 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Video
)))
366 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_SUBTYPE
, subtype
)))
368 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, 1)))
370 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1)))
373 IMFMediaType_AddRef((*type
= media_type
));
376 IMFMediaType_Release(media_type
);
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
;
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
)
399 for (i
= 0; i
< ARRAY_SIZE(input_types
); ++i
)
400 if (IsEqualGUID(&subtype
, input_types
[i
]))
402 if (i
== ARRAY_SIZE(input_types
))
403 return MF_E_INVALIDMEDIATYPE
;
404 if (flags
& MFT_SET_TYPE_TEST_ONLY
)
407 if (!impl
->input_type
&& FAILED(hr
= MFCreateMediaType(&impl
->input_type
)))
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
;
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
;
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
)
444 for (i
= 0; i
< ARRAY_SIZE(output_types
); ++i
)
445 if (IsEqualGUID(&subtype
, output_types
[i
]))
447 if (i
== ARRAY_SIZE(output_types
))
448 return MF_E_INVALIDMEDIATYPE
;
449 if (flags
& MFT_SET_TYPE_TEST_ONLY
)
452 if (!impl
->output_type
&& FAILED(hr
= MFCreateMediaType(&impl
->output_type
)))
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
;
470 static HRESULT WINAPI
transform_GetInputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
472 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
475 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
478 return MF_E_INVALIDSTREAMNUMBER
;
480 if (!impl
->input_type
)
481 return MF_E_TRANSFORM_TYPE_NOT_SET
;
483 if (FAILED(hr
= MFCreateMediaType(type
)))
486 if (FAILED(hr
= IMFMediaType_CopyAllItems(impl
->input_type
, (IMFAttributes
*)*type
)))
487 IMFMediaType_Release(*type
);
492 static HRESULT WINAPI
transform_GetOutputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
494 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
497 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
500 return MF_E_INVALIDSTREAMNUMBER
;
502 if (!impl
->output_type
)
503 return MF_E_TRANSFORM_TYPE_NOT_SET
;
505 if (FAILED(hr
= MFCreateMediaType(type
)))
508 if (FAILED(hr
= IMFMediaType_CopyAllItems(impl
->output_type
, (IMFAttributes
*)*type
)))
509 IMFMediaType_Release(*type
);
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
);
520 static HRESULT WINAPI
transform_GetOutputStatus(IMFTransform
*iface
, DWORD
*flags
)
522 FIXME("iface %p, flags %p stub!\n", iface
, flags
);
526 static HRESULT WINAPI
transform_SetOutputBounds(IMFTransform
*iface
, LONGLONG lower
, LONGLONG upper
)
528 TRACE("iface %p, lower %I64d, upper %I64d.\n", iface
, lower
, upper
);
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
);
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
);
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
;
564 TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface
, flags
, count
, samples
, status
);
569 if (FAILED(hr
= IMFTransform_GetOutputStreamInfo(iface
, 0, &info
)))
572 if (!impl
->wg_transform
)
573 return MF_E_TRANSFORM_TYPE_NOT_SET
;
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
)))
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
);
597 static const IMFTransformVtbl transform_vtbl
=
599 transform_QueryInterface
,
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
));
731 static HRESULT WINAPI
media_object_Flush(IMediaObject
*iface
)
733 FIXME("iface %p stub!\n", iface
);
737 static HRESULT WINAPI
media_object_Discontinuity(IMediaObject
*iface
, DWORD index
)
739 FIXME("iface %p, index %lu stub!\n", iface
, index
);
743 static HRESULT WINAPI
media_object_AllocateStreamingResources(IMediaObject
*iface
)
745 FIXME("iface %p stub!\n", iface
);
749 static HRESULT WINAPI
media_object_FreeStreamingResources(IMediaObject
*iface
)
751 FIXME("iface %p stub!\n", iface
);
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
);
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
));
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
);
776 static HRESULT WINAPI
media_object_Lock(IMediaObject
*iface
, LONG lock
)
778 FIXME("iface %p, lock %ld stub!\n", iface
, lock
);
782 static const IMediaObjectVtbl media_object_vtbl
=
784 media_object_QueryInterface
,
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
,
801 media_object_Discontinuity
,
802 media_object_AllocateStreamingResources
,
803 media_object_FreeStreamingResources
,
804 media_object_GetInputStatus
,
805 media_object_ProcessInput
,
806 media_object_ProcessOutput
,
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
);
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
);
843 static const IPropertyBagVtbl property_bag_vtbl
=
845 property_bag_QueryInterface
,
847 property_bag_Release
,
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
);
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
);
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
);
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
);
896 static HRESULT WINAPI
property_store_Commit(IPropertyStore
*iface
)
898 FIXME("iface %p stub!\n", iface
);
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
,
921 .format
= WG_VIDEO_FORMAT_I420
,
926 static const struct wg_format output_format
=
928 .major_type
= WG_MAJOR_TYPE_VIDEO
,
931 .format
= WG_VIDEO_FORMAT_NV12
,
936 struct wg_transform
*transform
;
937 struct color_convert
*impl
;
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");
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
)))
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
;
964 impl
->outer
= outer
? outer
: &impl
->IUnknown_inner
;
966 *out
= &impl
->IUnknown_inner
;
967 TRACE("Created %p\n", *out
);