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 FIXME("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p stub!\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 FIXME("iface %p, attributes %p stub!\n", iface
, attributes
);
288 static HRESULT WINAPI
transform_GetInputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
290 FIXME("iface %p, id %#lx, attributes %p stub!\n", iface
, id
, attributes
);
291 return MFCreateAttributes(attributes
, 0);
294 static HRESULT WINAPI
transform_GetOutputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
296 FIXME("iface %p, id %#lx, attributes %p stub!\n", iface
, id
, attributes
);
300 static HRESULT WINAPI
transform_DeleteInputStream(IMFTransform
*iface
, DWORD id
)
302 FIXME("iface %p, id %#lx stub!\n", iface
, id
);
306 static HRESULT WINAPI
transform_AddInputStreams(IMFTransform
*iface
, DWORD streams
, DWORD
*ids
)
308 FIXME("iface %p, streams %lu, ids %p stub!\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
;
405 if (!impl
->input_type
&& FAILED(hr
= MFCreateMediaType(&impl
->input_type
)))
408 if (FAILED(hr
= IMFMediaType_CopyAllItems(type
, (IMFAttributes
*)impl
->input_type
)))
410 IMFMediaType_Release(impl
->input_type
);
411 impl
->input_type
= NULL
;
414 if (impl
->output_type
&& FAILED(hr
= try_create_wg_transform(impl
)))
416 IMFMediaType_Release(impl
->input_type
);
417 impl
->input_type
= NULL
;
423 static HRESULT WINAPI
transform_SetOutputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*type
, DWORD flags
)
425 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
426 MF_ATTRIBUTE_TYPE item_type
;
431 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface
, id
, type
, flags
);
433 if (FAILED(hr
= IMFMediaType_GetGUID(type
, &MF_MT_MAJOR_TYPE
, &major
)) ||
434 FAILED(hr
= IMFMediaType_GetGUID(type
, &MF_MT_SUBTYPE
, &subtype
)))
435 return MF_E_ATTRIBUTENOTFOUND
;
437 if (!IsEqualGUID(&major
, &MFMediaType_Video
)
438 || FAILED(IMFMediaType_GetItemType(type
, &MF_MT_FRAME_SIZE
, &item_type
))
439 || item_type
!= MF_ATTRIBUTE_UINT64
)
442 for (i
= 0; i
< ARRAY_SIZE(output_types
); ++i
)
443 if (IsEqualGUID(&subtype
, output_types
[i
]))
445 if (i
== ARRAY_SIZE(output_types
))
446 return MF_E_INVALIDMEDIATYPE
;
448 if (!impl
->output_type
&& FAILED(hr
= MFCreateMediaType(&impl
->output_type
)))
451 if (FAILED(hr
= IMFMediaType_CopyAllItems(type
, (IMFAttributes
*)impl
->output_type
)))
453 IMFMediaType_Release(impl
->output_type
);
454 impl
->output_type
= NULL
;
457 if (impl
->input_type
&& FAILED(hr
= try_create_wg_transform(impl
)))
459 IMFMediaType_Release(impl
->output_type
);
460 impl
->output_type
= NULL
;
466 static HRESULT WINAPI
transform_GetInputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
468 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
472 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
475 return MF_E_INVALIDSTREAMNUMBER
;
477 if (!impl
->input_type
)
478 return MF_E_TRANSFORM_TYPE_NOT_SET
;
480 if (FAILED(hr
= MFCreateMediaType(&ret
)))
483 return IMFMediaType_CopyAllItems(impl
->input_type
, (IMFAttributes
*)ret
);
486 static HRESULT WINAPI
transform_GetOutputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
488 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
492 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
495 return MF_E_INVALIDSTREAMNUMBER
;
497 if (!impl
->output_type
)
498 return MF_E_TRANSFORM_TYPE_NOT_SET
;
500 if (FAILED(hr
= MFCreateMediaType(&ret
)))
503 return IMFMediaType_CopyAllItems(impl
->output_type
, (IMFAttributes
*)ret
);
506 static HRESULT WINAPI
transform_GetInputStatus(IMFTransform
*iface
, DWORD id
, DWORD
*flags
)
508 FIXME("iface %p, id %#lx, flags %p stub!\n", iface
, id
, flags
);
512 static HRESULT WINAPI
transform_GetOutputStatus(IMFTransform
*iface
, DWORD
*flags
)
514 FIXME("iface %p, flags %p stub!\n", iface
, flags
);
518 static HRESULT WINAPI
transform_SetOutputBounds(IMFTransform
*iface
, LONGLONG lower
, LONGLONG upper
)
520 FIXME("iface %p, lower %I64d, upper %I64d stub!\n", iface
, lower
, upper
);
524 static HRESULT WINAPI
transform_ProcessEvent(IMFTransform
*iface
, DWORD id
, IMFMediaEvent
*event
)
526 FIXME("iface %p, id %#lx, event %p stub!\n", iface
, id
, event
);
530 static HRESULT WINAPI
transform_ProcessMessage(IMFTransform
*iface
, MFT_MESSAGE_TYPE message
, ULONG_PTR param
)
532 FIXME("iface %p, message %#x, param %#Ix stub!\n", iface
, message
, param
);
536 static HRESULT WINAPI
transform_ProcessInput(IMFTransform
*iface
, DWORD id
, IMFSample
*sample
, DWORD flags
)
538 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
539 struct wg_sample
*wg_sample
;
540 MFT_INPUT_STREAM_INFO info
;
543 TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface
, id
, sample
, flags
);
545 if (FAILED(hr
= IMFTransform_GetInputStreamInfo(iface
, 0, &info
)))
548 if (!impl
->wg_transform
)
549 return MF_E_TRANSFORM_TYPE_NOT_SET
;
551 if (FAILED(hr
= wg_sample_create_mf(sample
, &wg_sample
)))
554 return wg_transform_push_mf(impl
->wg_transform
, wg_sample
,
555 impl
->wg_sample_queue
);
558 static HRESULT WINAPI
transform_ProcessOutput(IMFTransform
*iface
, DWORD flags
, DWORD count
,
559 MFT_OUTPUT_DATA_BUFFER
*samples
, DWORD
*status
)
561 struct color_convert
*impl
= impl_from_IMFTransform(iface
);
562 MFT_OUTPUT_STREAM_INFO info
;
563 struct wg_sample
*wg_sample
;
566 TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface
, flags
, count
, samples
, status
);
571 if (FAILED(hr
= IMFTransform_GetOutputStreamInfo(iface
, 0, &info
)))
574 if (!impl
->wg_transform
)
575 return MF_E_TRANSFORM_TYPE_NOT_SET
;
578 samples
[0].dwStatus
= 0;
579 if (!samples
[0].pSample
) return E_INVALIDARG
;
581 if (FAILED(hr
= wg_sample_create_mf(samples
[0].pSample
, &wg_sample
)))
584 if (wg_sample
->max_size
< info
.cbSize
)
586 wg_sample_release(wg_sample
);
587 return MF_E_BUFFERTOOSMALL
;
590 if (SUCCEEDED(hr
= wg_transform_read_mf(impl
->wg_transform
, wg_sample
, NULL
)))
591 wg_sample_queue_flush(impl
->wg_sample_queue
, false);
592 wg_sample_release(wg_sample
);
594 if (hr
== MF_E_TRANSFORM_STREAM_CHANGE
)
596 FIXME("Unexpected stream format change!\n");
597 samples
[0].dwStatus
|= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE
;
598 *status
|= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE
;
604 static const IMFTransformVtbl transform_vtbl
=
606 transform_QueryInterface
,
609 transform_GetStreamLimits
,
610 transform_GetStreamCount
,
611 transform_GetStreamIDs
,
612 transform_GetInputStreamInfo
,
613 transform_GetOutputStreamInfo
,
614 transform_GetAttributes
,
615 transform_GetInputStreamAttributes
,
616 transform_GetOutputStreamAttributes
,
617 transform_DeleteInputStream
,
618 transform_AddInputStreams
,
619 transform_GetInputAvailableType
,
620 transform_GetOutputAvailableType
,
621 transform_SetInputType
,
622 transform_SetOutputType
,
623 transform_GetInputCurrentType
,
624 transform_GetOutputCurrentType
,
625 transform_GetInputStatus
,
626 transform_GetOutputStatus
,
627 transform_SetOutputBounds
,
628 transform_ProcessEvent
,
629 transform_ProcessMessage
,
630 transform_ProcessInput
,
631 transform_ProcessOutput
,
634 static inline struct color_convert
*impl_from_IMediaObject(IMediaObject
*iface
)
636 return CONTAINING_RECORD(iface
, struct color_convert
, IMediaObject_iface
);
639 static HRESULT WINAPI
media_object_QueryInterface(IMediaObject
*iface
, REFIID iid
, void **obj
)
641 return IUnknown_QueryInterface(impl_from_IMediaObject(iface
)->outer
, iid
, obj
);
644 static ULONG WINAPI
media_object_AddRef(IMediaObject
*iface
)
646 return IUnknown_AddRef(impl_from_IMediaObject(iface
)->outer
);
649 static ULONG WINAPI
media_object_Release(IMediaObject
*iface
)
651 return IUnknown_Release(impl_from_IMediaObject(iface
)->outer
);
654 static HRESULT WINAPI
media_object_GetStreamCount(IMediaObject
*iface
, DWORD
*input
, DWORD
*output
)
656 FIXME("iface %p, input %p, output %p stub!\n", iface
, input
, output
);
660 static HRESULT WINAPI
media_object_GetInputStreamInfo(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
662 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
666 static HRESULT WINAPI
media_object_GetOutputStreamInfo(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
668 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
672 static HRESULT WINAPI
media_object_GetInputType(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_GetOutputType(IMediaObject
*iface
, DWORD index
, DWORD type_index
,
680 DMO_MEDIA_TYPE
*type
)
682 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface
, index
, type_index
, type
);
686 static HRESULT WINAPI
media_object_SetInputType(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_SetOutputType(IMediaObject
*iface
, DWORD index
,
694 const DMO_MEDIA_TYPE
*type
, DWORD flags
)
696 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface
, index
, type
, flags
);
700 static HRESULT WINAPI
media_object_GetInputCurrentType(IMediaObject
*iface
, DWORD index
, DMO_MEDIA_TYPE
*type
)
702 FIXME("iface %p, index %lu, type %p stub!\n", iface
, index
, type
);
706 static HRESULT WINAPI
media_object_GetOutputCurrentType(IMediaObject
*iface
, DWORD index
, DMO_MEDIA_TYPE
*type
)
708 FIXME("iface %p, index %lu, type %p stub!\n", iface
, index
, type
);
712 static HRESULT WINAPI
media_object_GetInputSizeInfo(IMediaObject
*iface
, DWORD index
, DWORD
*size
,
713 DWORD
*lookahead
, DWORD
*alignment
)
715 FIXME("iface %p, index %lu, size %p, lookahead %p, alignment %p stub!\n", iface
, index
, size
,
716 lookahead
, alignment
);
720 static HRESULT WINAPI
media_object_GetOutputSizeInfo(IMediaObject
*iface
, DWORD index
, DWORD
*size
, DWORD
*alignment
)
722 FIXME("iface %p, index %lu, size %p, alignment %p stub!\n", iface
, index
, size
, alignment
);
726 static HRESULT WINAPI
media_object_GetInputMaxLatency(IMediaObject
*iface
, DWORD index
, REFERENCE_TIME
*latency
)
728 FIXME("iface %p, index %lu, latency %p stub!\n", iface
, index
, latency
);
732 static HRESULT WINAPI
media_object_SetInputMaxLatency(IMediaObject
*iface
, DWORD index
, REFERENCE_TIME latency
)
734 FIXME("iface %p, index %lu, latency %s stub!\n", iface
, index
, wine_dbgstr_longlong(latency
));
738 static HRESULT WINAPI
media_object_Flush(IMediaObject
*iface
)
740 FIXME("iface %p stub!\n", iface
);
744 static HRESULT WINAPI
media_object_Discontinuity(IMediaObject
*iface
, DWORD index
)
746 FIXME("iface %p, index %lu stub!\n", iface
, index
);
750 static HRESULT WINAPI
media_object_AllocateStreamingResources(IMediaObject
*iface
)
752 FIXME("iface %p stub!\n", iface
);
756 static HRESULT WINAPI
media_object_FreeStreamingResources(IMediaObject
*iface
)
758 FIXME("iface %p stub!\n", iface
);
762 static HRESULT WINAPI
media_object_GetInputStatus(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
764 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
768 static HRESULT WINAPI
media_object_ProcessInput(IMediaObject
*iface
, DWORD index
,
769 IMediaBuffer
*buffer
, DWORD flags
, REFERENCE_TIME timestamp
, REFERENCE_TIME timelength
)
771 FIXME("iface %p, index %lu, buffer %p, flags %#lx, timestamp %s, timelength %s stub!\n", iface
,
772 index
, buffer
, flags
, wine_dbgstr_longlong(timestamp
), wine_dbgstr_longlong(timelength
));
776 static HRESULT WINAPI
media_object_ProcessOutput(IMediaObject
*iface
, DWORD flags
, DWORD count
,
777 DMO_OUTPUT_DATA_BUFFER
*buffers
, DWORD
*status
)
779 FIXME("iface %p, flags %#lx, count %lu, buffers %p, status %p stub!\n", iface
, flags
, count
, buffers
, status
);
783 static HRESULT WINAPI
media_object_Lock(IMediaObject
*iface
, LONG lock
)
785 FIXME("iface %p, lock %ld stub!\n", iface
, lock
);
789 static const IMediaObjectVtbl media_object_vtbl
=
791 media_object_QueryInterface
,
793 media_object_Release
,
794 media_object_GetStreamCount
,
795 media_object_GetInputStreamInfo
,
796 media_object_GetOutputStreamInfo
,
797 media_object_GetInputType
,
798 media_object_GetOutputType
,
799 media_object_SetInputType
,
800 media_object_SetOutputType
,
801 media_object_GetInputCurrentType
,
802 media_object_GetOutputCurrentType
,
803 media_object_GetInputSizeInfo
,
804 media_object_GetOutputSizeInfo
,
805 media_object_GetInputMaxLatency
,
806 media_object_SetInputMaxLatency
,
808 media_object_Discontinuity
,
809 media_object_AllocateStreamingResources
,
810 media_object_FreeStreamingResources
,
811 media_object_GetInputStatus
,
812 media_object_ProcessInput
,
813 media_object_ProcessOutput
,
817 static inline struct color_convert
*impl_from_IPropertyBag(IPropertyBag
*iface
)
819 return CONTAINING_RECORD(iface
, struct color_convert
, IPropertyBag_iface
);
822 static HRESULT WINAPI
property_bag_QueryInterface(IPropertyBag
*iface
, REFIID iid
, void **out
)
824 return IUnknown_QueryInterface(impl_from_IPropertyBag(iface
)->outer
, iid
, out
);
827 static ULONG WINAPI
property_bag_AddRef(IPropertyBag
*iface
)
829 return IUnknown_AddRef(impl_from_IPropertyBag(iface
)->outer
);
832 static ULONG WINAPI
property_bag_Release(IPropertyBag
*iface
)
834 return IUnknown_Release(impl_from_IPropertyBag(iface
)->outer
);
837 static HRESULT WINAPI
property_bag_Read(IPropertyBag
*iface
, const WCHAR
*prop_name
, VARIANT
*value
,
838 IErrorLog
*error_log
)
840 FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface
, debugstr_w(prop_name
), value
, error_log
);
844 static HRESULT WINAPI
property_bag_Write(IPropertyBag
*iface
, const WCHAR
*prop_name
, VARIANT
*value
)
846 FIXME("iface %p, prop_name %s, value %p stub!\n", iface
, debugstr_w(prop_name
), value
);
850 static const IPropertyBagVtbl property_bag_vtbl
=
852 property_bag_QueryInterface
,
854 property_bag_Release
,
859 static inline struct color_convert
*impl_from_IPropertyStore(IPropertyStore
*iface
)
861 return CONTAINING_RECORD(iface
, struct color_convert
, IPropertyStore_iface
);
864 static HRESULT WINAPI
property_store_QueryInterface(IPropertyStore
*iface
, REFIID iid
, void **out
)
866 return IUnknown_QueryInterface(impl_from_IPropertyStore(iface
)->outer
, iid
, out
);
869 static ULONG WINAPI
property_store_AddRef(IPropertyStore
*iface
)
871 return IUnknown_AddRef(impl_from_IPropertyStore(iface
)->outer
);
874 static ULONG WINAPI
property_store_Release(IPropertyStore
*iface
)
876 return IUnknown_Release(impl_from_IPropertyStore(iface
)->outer
);
879 static HRESULT WINAPI
property_store_GetCount(IPropertyStore
*iface
, DWORD
*count
)
881 FIXME("iface %p, count %p stub!\n", iface
, count
);
885 static HRESULT WINAPI
property_store_GetAt(IPropertyStore
*iface
, DWORD index
, PROPERTYKEY
*key
)
887 FIXME("iface %p, index %lu, key %p stub!\n", iface
, index
, key
);
891 static HRESULT WINAPI
property_store_GetValue(IPropertyStore
*iface
, REFPROPERTYKEY key
, PROPVARIANT
*value
)
893 FIXME("iface %p, key %p, value %p stub!\n", iface
, key
, value
);
897 static HRESULT WINAPI
property_store_SetValue(IPropertyStore
*iface
, REFPROPERTYKEY key
, REFPROPVARIANT value
)
899 FIXME("iface %p, key %p, value %p stub!\n", iface
, key
, value
);
903 static HRESULT WINAPI
property_store_Commit(IPropertyStore
*iface
)
905 FIXME("iface %p stub!\n", iface
);
909 static const IPropertyStoreVtbl property_store_vtbl
=
911 property_store_QueryInterface
,
912 property_store_AddRef
,
913 property_store_Release
,
914 property_store_GetCount
,
915 property_store_GetAt
,
916 property_store_GetValue
,
917 property_store_SetValue
,
918 property_store_Commit
,
921 HRESULT
color_convert_create(IUnknown
*outer
, IUnknown
**out
)
923 static const struct wg_format input_format
=
925 .major_type
= WG_MAJOR_TYPE_VIDEO
,
928 .format
= WG_VIDEO_FORMAT_I420
,
933 static const struct wg_format output_format
=
935 .major_type
= WG_MAJOR_TYPE_VIDEO
,
938 .format
= WG_VIDEO_FORMAT_NV12
,
943 struct wg_transform
*transform
;
944 struct color_convert
*impl
;
947 TRACE("outer %p, out %p.\n", outer
, out
);
949 if (!(transform
= wg_transform_create(&input_format
, &output_format
)))
951 ERR_(winediag
)("GStreamer doesn't support video conversion, please install appropriate plugins.\n");
954 wg_transform_destroy(transform
);
956 if (!(impl
= calloc(1, sizeof(*impl
))))
957 return E_OUTOFMEMORY
;
959 if (FAILED(hr
= wg_sample_queue_create(&impl
->wg_sample_queue
)))
965 impl
->IUnknown_inner
.lpVtbl
= &unknown_vtbl
;
966 impl
->IMFTransform_iface
.lpVtbl
= &transform_vtbl
;
967 impl
->IMediaObject_iface
.lpVtbl
= &media_object_vtbl
;
968 impl
->IPropertyBag_iface
.lpVtbl
= &property_bag_vtbl
;
969 impl
->IPropertyStore_iface
.lpVtbl
= &property_store_vtbl
;
971 impl
->outer
= outer
? outer
: &impl
->IUnknown_inner
;
973 *out
= &impl
->IUnknown_inner
;
974 TRACE("Created %p\n", *out
);