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
*audio_formats
[] =
39 IUnknown IUnknown_inner
;
40 IMFTransform IMFTransform_iface
;
41 IMediaObject IMediaObject_iface
;
42 IPropertyBag IPropertyBag_iface
;
43 IPropertyStore IPropertyStore_iface
;
47 IMFMediaType
*input_type
;
48 MFT_INPUT_STREAM_INFO input_info
;
49 IMFMediaType
*output_type
;
50 MFT_OUTPUT_STREAM_INFO output_info
;
52 struct wg_transform
*wg_transform
;
53 struct wg_sample_queue
*wg_sample_queue
;
56 static HRESULT
try_create_wg_transform(struct resampler
*impl
)
58 struct wg_format input_format
, output_format
;
60 if (impl
->wg_transform
)
61 wg_transform_destroy(impl
->wg_transform
);
62 impl
->wg_transform
= NULL
;
64 mf_media_type_to_wg_format(impl
->input_type
, &input_format
);
65 if (input_format
.major_type
== WG_MAJOR_TYPE_UNKNOWN
)
66 return MF_E_INVALIDMEDIATYPE
;
68 mf_media_type_to_wg_format(impl
->output_type
, &output_format
);
69 if (output_format
.major_type
== WG_MAJOR_TYPE_UNKNOWN
)
70 return MF_E_INVALIDMEDIATYPE
;
72 if (!(impl
->wg_transform
= wg_transform_create(&input_format
, &output_format
)))
78 static inline struct resampler
*impl_from_IUnknown(IUnknown
*iface
)
80 return CONTAINING_RECORD(iface
, struct resampler
, IUnknown_inner
);
83 static HRESULT WINAPI
unknown_QueryInterface(IUnknown
*iface
, REFIID iid
, void **out
)
85 struct resampler
*impl
= impl_from_IUnknown(iface
);
87 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
89 if (IsEqualGUID(iid
, &IID_IUnknown
))
90 *out
= &impl
->IUnknown_inner
;
91 else if (IsEqualGUID(iid
, &IID_IMFTransform
))
92 *out
= &impl
->IMFTransform_iface
;
93 else if (IsEqualGUID(iid
, &IID_IMediaObject
))
94 *out
= &impl
->IMediaObject_iface
;
95 else if (IsEqualIID(iid
, &IID_IPropertyBag
))
96 *out
= &impl
->IPropertyBag_iface
;
97 else if (IsEqualIID(iid
, &IID_IPropertyStore
))
98 *out
= &impl
->IPropertyStore_iface
;
102 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
103 return E_NOINTERFACE
;
106 IUnknown_AddRef((IUnknown
*)*out
);
110 static ULONG WINAPI
unknown_AddRef(IUnknown
*iface
)
112 struct resampler
*impl
= impl_from_IUnknown(iface
);
113 ULONG refcount
= InterlockedIncrement(&impl
->refcount
);
115 TRACE("iface %p increasing refcount to %lu.\n", iface
, refcount
);
120 static ULONG WINAPI
unknown_Release(IUnknown
*iface
)
122 struct resampler
*impl
= impl_from_IUnknown(iface
);
123 ULONG refcount
= InterlockedDecrement(&impl
->refcount
);
125 TRACE("iface %p decreasing refcount to %lu.\n", iface
, refcount
);
129 if (impl
->wg_transform
)
130 wg_transform_destroy(impl
->wg_transform
);
131 if (impl
->input_type
)
132 IMFMediaType_Release(impl
->input_type
);
133 if (impl
->output_type
)
134 IMFMediaType_Release(impl
->output_type
);
136 wg_sample_queue_destroy(impl
->wg_sample_queue
);
143 static const IUnknownVtbl unknown_vtbl
=
145 unknown_QueryInterface
,
150 static struct resampler
*impl_from_IMFTransform(IMFTransform
*iface
)
152 return CONTAINING_RECORD(iface
, struct resampler
, IMFTransform_iface
);
155 static HRESULT WINAPI
transform_QueryInterface(IMFTransform
*iface
, REFIID iid
, void **out
)
157 return IUnknown_QueryInterface(impl_from_IMFTransform(iface
)->outer
, iid
, out
);
160 static ULONG WINAPI
transform_AddRef(IMFTransform
*iface
)
162 return IUnknown_AddRef(impl_from_IMFTransform(iface
)->outer
);
165 static ULONG WINAPI
transform_Release(IMFTransform
*iface
)
167 return IUnknown_Release(impl_from_IMFTransform(iface
)->outer
);
170 static HRESULT WINAPI
transform_GetStreamLimits(IMFTransform
*iface
, DWORD
*input_minimum
,
171 DWORD
*input_maximum
, DWORD
*output_minimum
, DWORD
*output_maximum
)
173 TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.\n",
174 iface
, input_minimum
, input_maximum
, output_minimum
, output_maximum
);
175 *input_minimum
= *input_maximum
= *output_minimum
= *output_maximum
= 1;
179 static HRESULT WINAPI
transform_GetStreamCount(IMFTransform
*iface
, DWORD
*inputs
, DWORD
*outputs
)
181 TRACE("iface %p, inputs %p, outputs %p.\n", iface
, inputs
, outputs
);
182 *inputs
= *outputs
= 1;
186 static HRESULT WINAPI
transform_GetStreamIDs(IMFTransform
*iface
, DWORD input_size
, DWORD
*inputs
,
187 DWORD output_size
, DWORD
*outputs
)
189 TRACE("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p.\n", iface
,
190 input_size
, inputs
, output_size
, outputs
);
194 static HRESULT WINAPI
transform_GetInputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_INPUT_STREAM_INFO
*info
)
196 struct resampler
*impl
= impl_from_IMFTransform(iface
);
198 TRACE("iface %p, id %#lx, info %p.\n", iface
, id
, info
);
200 if (!impl
->input_type
|| !impl
->output_type
)
202 memset(info
, 0, sizeof(*info
));
203 return MF_E_TRANSFORM_TYPE_NOT_SET
;
206 *info
= impl
->input_info
;
210 static HRESULT WINAPI
transform_GetOutputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_OUTPUT_STREAM_INFO
*info
)
212 struct resampler
*impl
= impl_from_IMFTransform(iface
);
214 TRACE("iface %p, id %#lx, info %p.\n", iface
, id
, info
);
216 if (!impl
->input_type
|| !impl
->output_type
)
218 memset(info
, 0, sizeof(*info
));
219 return MF_E_TRANSFORM_TYPE_NOT_SET
;
222 *info
= impl
->output_info
;
226 static HRESULT WINAPI
transform_GetAttributes(IMFTransform
*iface
, IMFAttributes
**attributes
)
228 TRACE("iface %p, attributes %p.\n", iface
, attributes
);
232 static HRESULT WINAPI
transform_GetInputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
234 TRACE("iface %p, id %#lx, attributes %p.\n", iface
, id
, attributes
);
238 static HRESULT WINAPI
transform_GetOutputStreamAttributes(IMFTransform
*iface
, DWORD id
, IMFAttributes
**attributes
)
240 TRACE("iface %p, id %#lx, attributes %p.\n", iface
, id
, attributes
);
244 static HRESULT WINAPI
transform_DeleteInputStream(IMFTransform
*iface
, DWORD id
)
246 TRACE("iface %p, id %#lx.\n", iface
, id
);
250 static HRESULT WINAPI
transform_AddInputStreams(IMFTransform
*iface
, DWORD streams
, DWORD
*ids
)
252 TRACE("iface %p, streams %lu, ids %p.\n", iface
, streams
, ids
);
256 static HRESULT
get_available_media_type(DWORD index
, IMFMediaType
**type
, BOOL output
)
258 UINT32 sample_size
, sample_rate
= 48000, block_alignment
, channel_count
= 2;
259 IMFMediaType
*media_type
;
265 if (index
>= (output
? 2 : 1) * ARRAY_SIZE(audio_formats
))
266 return MF_E_NO_MORE_TYPES
;
267 subtype
= audio_formats
[index
% ARRAY_SIZE(audio_formats
)];
269 if (FAILED(hr
= MFCreateMediaType(&media_type
)))
272 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Audio
)))
274 if (FAILED(hr
= IMFMediaType_SetGUID(media_type
, &MF_MT_SUBTYPE
, subtype
)))
276 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1)))
278 if (index
< ARRAY_SIZE(audio_formats
))
281 if (IsEqualGUID(subtype
, &MFAudioFormat_Float
))
283 else if (IsEqualGUID(subtype
, &MFAudioFormat_PCM
))
287 FIXME("Subtype %s not implemented!\n", debugstr_guid(subtype
));
292 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_BITS_PER_SAMPLE
, sample_size
)))
294 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_NUM_CHANNELS
, channel_count
)))
296 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_SAMPLES_PER_SECOND
, sample_rate
)))
299 block_alignment
= sample_size
* channel_count
/ 8;
300 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_BLOCK_ALIGNMENT
, block_alignment
)))
302 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND
, sample_rate
* block_alignment
)))
304 if (FAILED(hr
= IMFMediaType_SetUINT32(media_type
, &MF_MT_AUDIO_PREFER_WAVEFORMATEX
, 1)))
309 IMFMediaType_AddRef((*type
= media_type
));
311 IMFMediaType_Release(media_type
);
315 static HRESULT WINAPI
transform_GetInputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
318 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface
, id
, index
, type
);
319 return get_available_media_type(index
, type
, FALSE
);
322 static HRESULT WINAPI
transform_GetOutputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
325 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface
, id
, index
, type
);
326 return get_available_media_type(index
, type
, TRUE
);
329 static HRESULT
check_media_type(IMFMediaType
*type
)
331 MF_ATTRIBUTE_TYPE item_type
;
336 if (FAILED(hr
= IMFMediaType_GetGUID(type
, &MF_MT_MAJOR_TYPE
, &major
)) ||
337 FAILED(hr
= IMFMediaType_GetGUID(type
, &MF_MT_SUBTYPE
, &subtype
)))
338 return MF_E_ATTRIBUTENOTFOUND
;
340 if (!IsEqualGUID(&major
, &MFMediaType_Audio
))
341 return MF_E_INVALIDMEDIATYPE
;
343 for (i
= 0; i
< ARRAY_SIZE(audio_formats
); ++i
)
344 if (IsEqualGUID(&subtype
, audio_formats
[i
]))
346 if (i
== ARRAY_SIZE(audio_formats
))
347 return MF_E_INVALIDMEDIATYPE
;
349 if (FAILED(IMFMediaType_GetItemType(type
, &MF_MT_AUDIO_BITS_PER_SAMPLE
, &item_type
)) ||
350 item_type
!= MF_ATTRIBUTE_UINT32
)
351 return MF_E_INVALIDMEDIATYPE
;
352 if (FAILED(IMFMediaType_GetItemType(type
, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND
, &item_type
)) ||
353 item_type
!= MF_ATTRIBUTE_UINT32
)
354 return MF_E_INVALIDMEDIATYPE
;
355 if (FAILED(IMFMediaType_GetItemType(type
, &MF_MT_AUDIO_NUM_CHANNELS
, &item_type
)) ||
356 item_type
!= MF_ATTRIBUTE_UINT32
)
357 return MF_E_INVALIDMEDIATYPE
;
358 if (FAILED(IMFMediaType_GetItemType(type
, &MF_MT_AUDIO_SAMPLES_PER_SECOND
, &item_type
)) ||
359 item_type
!= MF_ATTRIBUTE_UINT32
)
360 return MF_E_INVALIDMEDIATYPE
;
365 static HRESULT WINAPI
transform_SetInputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*type
, DWORD flags
)
367 struct resampler
*impl
= impl_from_IMFTransform(iface
);
368 UINT32 block_alignment
;
371 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface
, id
, type
, flags
);
373 if (FAILED(hr
= check_media_type(type
)))
375 if (FAILED(hr
= IMFMediaType_GetUINT32(type
, &MF_MT_AUDIO_BLOCK_ALIGNMENT
, &block_alignment
)))
376 return MF_E_INVALIDMEDIATYPE
;
377 if (flags
& MFT_SET_TYPE_TEST_ONLY
)
380 if (!impl
->input_type
&& FAILED(hr
= MFCreateMediaType(&impl
->input_type
)))
383 if (impl
->output_type
)
385 IMFMediaType_Release(impl
->output_type
);
386 impl
->output_type
= NULL
;
389 if (SUCCEEDED(hr
= IMFMediaType_CopyAllItems(type
, (IMFAttributes
*)impl
->input_type
)))
390 impl
->input_info
.cbSize
= block_alignment
;
393 IMFMediaType_Release(impl
->input_type
);
394 impl
->input_info
.cbSize
= 0;
395 impl
->input_type
= NULL
;
401 static HRESULT WINAPI
transform_SetOutputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*type
, DWORD flags
)
403 struct resampler
*impl
= impl_from_IMFTransform(iface
);
404 UINT32 block_alignment
;
407 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface
, id
, type
, flags
);
409 if (!impl
->input_type
)
410 return MF_E_TRANSFORM_TYPE_NOT_SET
;
412 if (FAILED(hr
= check_media_type(type
)))
414 if (FAILED(hr
= IMFMediaType_GetUINT32(type
, &MF_MT_AUDIO_BLOCK_ALIGNMENT
, &block_alignment
)))
415 return MF_E_INVALIDMEDIATYPE
;
416 if (flags
& MFT_SET_TYPE_TEST_ONLY
)
419 if (!impl
->output_type
&& FAILED(hr
= MFCreateMediaType(&impl
->output_type
)))
422 if (FAILED(hr
= IMFMediaType_CopyAllItems(type
, (IMFAttributes
*)impl
->output_type
)))
425 if (FAILED(hr
= try_create_wg_transform(impl
)))
428 impl
->output_info
.cbSize
= block_alignment
;
432 IMFMediaType_Release(impl
->output_type
);
433 impl
->output_info
.cbSize
= 0;
434 impl
->output_type
= NULL
;
438 static HRESULT WINAPI
transform_GetInputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
440 struct resampler
*impl
= impl_from_IMFTransform(iface
);
443 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
446 return MF_E_INVALIDSTREAMNUMBER
;
448 if (!impl
->input_type
)
449 return MF_E_TRANSFORM_TYPE_NOT_SET
;
451 if (FAILED(hr
= MFCreateMediaType(type
)))
454 if (FAILED(hr
= IMFMediaType_CopyAllItems(impl
->input_type
, (IMFAttributes
*)*type
)))
455 IMFMediaType_Release(*type
);
460 static HRESULT WINAPI
transform_GetOutputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
462 struct resampler
*impl
= impl_from_IMFTransform(iface
);
465 TRACE("iface %p, id %#lx, type %p.\n", iface
, id
, type
);
468 return MF_E_INVALIDSTREAMNUMBER
;
470 if (!impl
->output_type
)
471 return MF_E_TRANSFORM_TYPE_NOT_SET
;
473 if (FAILED(hr
= MFCreateMediaType(type
)))
476 if (FAILED(hr
= IMFMediaType_CopyAllItems(impl
->output_type
, (IMFAttributes
*)*type
)))
477 IMFMediaType_Release(*type
);
482 static HRESULT WINAPI
transform_GetInputStatus(IMFTransform
*iface
, DWORD id
, DWORD
*flags
)
484 FIXME("iface %p, id %#lx, flags %p stub!\n", iface
, id
, flags
);
488 static HRESULT WINAPI
transform_GetOutputStatus(IMFTransform
*iface
, DWORD
*flags
)
490 FIXME("iface %p, flags %p stub!\n", iface
, flags
);
494 static HRESULT WINAPI
transform_SetOutputBounds(IMFTransform
*iface
, LONGLONG lower
, LONGLONG upper
)
496 TRACE("iface %p, lower %I64d, upper %I64d.\n", iface
, lower
, upper
);
500 static HRESULT WINAPI
transform_ProcessEvent(IMFTransform
*iface
, DWORD id
, IMFMediaEvent
*event
)
502 FIXME("iface %p, id %#lx, event %p stub!\n", iface
, id
, event
);
506 static HRESULT WINAPI
transform_ProcessMessage(IMFTransform
*iface
, MFT_MESSAGE_TYPE message
, ULONG_PTR param
)
508 FIXME("iface %p, message %#x, param %p stub!\n", iface
, message
, (void *)param
);
512 static HRESULT WINAPI
transform_ProcessInput(IMFTransform
*iface
, DWORD id
, IMFSample
*sample
, DWORD flags
)
514 struct resampler
*impl
= impl_from_IMFTransform(iface
);
516 TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface
, id
, sample
, flags
);
518 if (!impl
->wg_transform
)
519 return MF_E_TRANSFORM_TYPE_NOT_SET
;
521 return wg_transform_push_mf(impl
->wg_transform
, sample
, impl
->wg_sample_queue
);
524 static HRESULT WINAPI
transform_ProcessOutput(IMFTransform
*iface
, DWORD flags
, DWORD count
,
525 MFT_OUTPUT_DATA_BUFFER
*samples
, DWORD
*status
)
527 struct resampler
*impl
= impl_from_IMFTransform(iface
);
528 MFT_OUTPUT_STREAM_INFO info
;
531 TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface
, flags
, count
, samples
, status
);
536 if (!impl
->wg_transform
)
537 return MF_E_TRANSFORM_TYPE_NOT_SET
;
539 *status
= samples
->dwStatus
= 0;
540 if (!samples
->pSample
)
542 samples
->dwStatus
= MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE
;
543 return MF_E_TRANSFORM_NEED_MORE_INPUT
;
546 if (FAILED(hr
= IMFTransform_GetOutputStreamInfo(iface
, 0, &info
)))
549 if (SUCCEEDED(hr
= wg_transform_read_mf(impl
->wg_transform
, samples
->pSample
,
550 info
.cbSize
, NULL
, &samples
->dwStatus
)))
551 wg_sample_queue_flush(impl
->wg_sample_queue
, false);
556 static const IMFTransformVtbl transform_vtbl
=
558 transform_QueryInterface
,
561 transform_GetStreamLimits
,
562 transform_GetStreamCount
,
563 transform_GetStreamIDs
,
564 transform_GetInputStreamInfo
,
565 transform_GetOutputStreamInfo
,
566 transform_GetAttributes
,
567 transform_GetInputStreamAttributes
,
568 transform_GetOutputStreamAttributes
,
569 transform_DeleteInputStream
,
570 transform_AddInputStreams
,
571 transform_GetInputAvailableType
,
572 transform_GetOutputAvailableType
,
573 transform_SetInputType
,
574 transform_SetOutputType
,
575 transform_GetInputCurrentType
,
576 transform_GetOutputCurrentType
,
577 transform_GetInputStatus
,
578 transform_GetOutputStatus
,
579 transform_SetOutputBounds
,
580 transform_ProcessEvent
,
581 transform_ProcessMessage
,
582 transform_ProcessInput
,
583 transform_ProcessOutput
,
586 static inline struct resampler
*impl_from_IMediaObject(IMediaObject
*iface
)
588 return CONTAINING_RECORD(iface
, struct resampler
, IMediaObject_iface
);
591 static HRESULT WINAPI
media_object_QueryInterface(IMediaObject
*iface
, REFIID iid
, void **obj
)
593 return IUnknown_QueryInterface(impl_from_IMediaObject(iface
)->outer
, iid
, obj
);
596 static ULONG WINAPI
media_object_AddRef(IMediaObject
*iface
)
598 return IUnknown_AddRef(impl_from_IMediaObject(iface
)->outer
);
601 static ULONG WINAPI
media_object_Release(IMediaObject
*iface
)
603 return IUnknown_Release(impl_from_IMediaObject(iface
)->outer
);
606 static HRESULT WINAPI
media_object_GetStreamCount(IMediaObject
*iface
, DWORD
*input
, DWORD
*output
)
608 FIXME("iface %p, input %p, output %p semi-stub!\n", iface
, input
, output
);
609 *input
= *output
= 1;
613 static HRESULT WINAPI
media_object_GetInputStreamInfo(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
615 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
619 static HRESULT WINAPI
media_object_GetOutputStreamInfo(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
621 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
625 static HRESULT WINAPI
media_object_GetInputType(IMediaObject
*iface
, DWORD index
, DWORD type_index
,
626 DMO_MEDIA_TYPE
*type
)
628 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface
, index
, type_index
, type
);
632 static HRESULT WINAPI
media_object_GetOutputType(IMediaObject
*iface
, DWORD index
, DWORD type_index
,
633 DMO_MEDIA_TYPE
*type
)
635 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface
, index
, type_index
, type
);
639 static HRESULT WINAPI
media_object_SetInputType(IMediaObject
*iface
, DWORD index
,
640 const DMO_MEDIA_TYPE
*type
, DWORD flags
)
642 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface
, index
, type
, flags
);
646 static HRESULT WINAPI
media_object_SetOutputType(IMediaObject
*iface
, DWORD index
,
647 const DMO_MEDIA_TYPE
*type
, DWORD flags
)
649 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface
, index
, type
, flags
);
653 static HRESULT WINAPI
media_object_GetInputCurrentType(IMediaObject
*iface
, DWORD index
, DMO_MEDIA_TYPE
*type
)
655 FIXME("iface %p, index %lu, type %p stub!\n", iface
, index
, type
);
659 static HRESULT WINAPI
media_object_GetOutputCurrentType(IMediaObject
*iface
, DWORD index
, DMO_MEDIA_TYPE
*type
)
661 FIXME("iface %p, index %lu, type %p stub!\n", iface
, index
, type
);
665 static HRESULT WINAPI
media_object_GetInputSizeInfo(IMediaObject
*iface
, DWORD index
, DWORD
*size
,
666 DWORD
*lookahead
, DWORD
*alignment
)
668 FIXME("iface %p, index %lu, size %p, lookahead %p, alignment %p stub!\n", iface
, index
, size
,
669 lookahead
, alignment
);
673 static HRESULT WINAPI
media_object_GetOutputSizeInfo(IMediaObject
*iface
, DWORD index
, DWORD
*size
, DWORD
*alignment
)
675 FIXME("iface %p, index %lu, size %p, alignment %p stub!\n", iface
, index
, size
, alignment
);
679 static HRESULT WINAPI
media_object_GetInputMaxLatency(IMediaObject
*iface
, DWORD index
, REFERENCE_TIME
*latency
)
681 FIXME("iface %p, index %lu, latency %p stub!\n", iface
, index
, latency
);
685 static HRESULT WINAPI
media_object_SetInputMaxLatency(IMediaObject
*iface
, DWORD index
, REFERENCE_TIME latency
)
687 FIXME("iface %p, index %lu, latency %s stub!\n", iface
, index
, wine_dbgstr_longlong(latency
));
691 static HRESULT WINAPI
media_object_Flush(IMediaObject
*iface
)
693 FIXME("iface %p stub!\n", iface
);
697 static HRESULT WINAPI
media_object_Discontinuity(IMediaObject
*iface
, DWORD index
)
699 FIXME("iface %p, index %lu stub!\n", iface
, index
);
703 static HRESULT WINAPI
media_object_AllocateStreamingResources(IMediaObject
*iface
)
705 FIXME("iface %p stub!\n", iface
);
709 static HRESULT WINAPI
media_object_FreeStreamingResources(IMediaObject
*iface
)
711 FIXME("iface %p stub!\n", iface
);
715 static HRESULT WINAPI
media_object_GetInputStatus(IMediaObject
*iface
, DWORD index
, DWORD
*flags
)
717 FIXME("iface %p, index %lu, flags %p stub!\n", iface
, index
, flags
);
721 static HRESULT WINAPI
media_object_ProcessInput(IMediaObject
*iface
, DWORD index
,
722 IMediaBuffer
*buffer
, DWORD flags
, REFERENCE_TIME timestamp
, REFERENCE_TIME timelength
)
724 FIXME("iface %p, index %lu, buffer %p, flags %#lx, timestamp %s, timelength %s stub!\n", iface
,
725 index
, buffer
, flags
, wine_dbgstr_longlong(timestamp
), wine_dbgstr_longlong(timelength
));
729 static HRESULT WINAPI
media_object_ProcessOutput(IMediaObject
*iface
, DWORD flags
, DWORD count
,
730 DMO_OUTPUT_DATA_BUFFER
*buffers
, DWORD
*status
)
732 FIXME("iface %p, flags %#lx, count %lu, buffers %p, status %p stub!\n", iface
, flags
, count
, buffers
, status
);
736 static HRESULT WINAPI
media_object_Lock(IMediaObject
*iface
, LONG lock
)
738 FIXME("iface %p, lock %ld stub!\n", iface
, lock
);
742 static const IMediaObjectVtbl media_object_vtbl
=
744 media_object_QueryInterface
,
746 media_object_Release
,
747 media_object_GetStreamCount
,
748 media_object_GetInputStreamInfo
,
749 media_object_GetOutputStreamInfo
,
750 media_object_GetInputType
,
751 media_object_GetOutputType
,
752 media_object_SetInputType
,
753 media_object_SetOutputType
,
754 media_object_GetInputCurrentType
,
755 media_object_GetOutputCurrentType
,
756 media_object_GetInputSizeInfo
,
757 media_object_GetOutputSizeInfo
,
758 media_object_GetInputMaxLatency
,
759 media_object_SetInputMaxLatency
,
761 media_object_Discontinuity
,
762 media_object_AllocateStreamingResources
,
763 media_object_FreeStreamingResources
,
764 media_object_GetInputStatus
,
765 media_object_ProcessInput
,
766 media_object_ProcessOutput
,
770 static inline struct resampler
*impl_from_IPropertyBag(IPropertyBag
*iface
)
772 return CONTAINING_RECORD(iface
, struct resampler
, IPropertyBag_iface
);
775 static HRESULT WINAPI
property_bag_QueryInterface(IPropertyBag
*iface
, REFIID iid
, void **out
)
777 return IUnknown_QueryInterface(impl_from_IPropertyBag(iface
)->outer
, iid
, out
);
780 static ULONG WINAPI
property_bag_AddRef(IPropertyBag
*iface
)
782 return IUnknown_AddRef(impl_from_IPropertyBag(iface
)->outer
);
785 static ULONG WINAPI
property_bag_Release(IPropertyBag
*iface
)
787 return IUnknown_Release(impl_from_IPropertyBag(iface
)->outer
);
790 static HRESULT WINAPI
property_bag_Read(IPropertyBag
*iface
, const WCHAR
*prop_name
, VARIANT
*value
,
791 IErrorLog
*error_log
)
793 FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface
, debugstr_w(prop_name
), value
, error_log
);
797 static HRESULT WINAPI
property_bag_Write(IPropertyBag
*iface
, const WCHAR
*prop_name
, VARIANT
*value
)
799 FIXME("iface %p, prop_name %s, value %p stub!\n", iface
, debugstr_w(prop_name
), value
);
803 static const IPropertyBagVtbl property_bag_vtbl
=
805 property_bag_QueryInterface
,
807 property_bag_Release
,
812 static inline struct resampler
*impl_from_IPropertyStore(IPropertyStore
*iface
)
814 return CONTAINING_RECORD(iface
, struct resampler
, IPropertyStore_iface
);
817 static HRESULT WINAPI
property_store_QueryInterface(IPropertyStore
*iface
, REFIID iid
, void **out
)
819 return IUnknown_QueryInterface(impl_from_IPropertyStore(iface
)->outer
, iid
, out
);
822 static ULONG WINAPI
property_store_AddRef(IPropertyStore
*iface
)
824 return IUnknown_AddRef(impl_from_IPropertyStore(iface
)->outer
);
827 static ULONG WINAPI
property_store_Release(IPropertyStore
*iface
)
829 return IUnknown_Release(impl_from_IPropertyStore(iface
)->outer
);
832 static HRESULT WINAPI
property_store_GetCount(IPropertyStore
*iface
, DWORD
*count
)
834 FIXME("iface %p, count %p stub!\n", iface
, count
);
838 static HRESULT WINAPI
property_store_GetAt(IPropertyStore
*iface
, DWORD index
, PROPERTYKEY
*key
)
840 FIXME("iface %p, index %lu, key %p stub!\n", iface
, index
, key
);
844 static HRESULT WINAPI
property_store_GetValue(IPropertyStore
*iface
, REFPROPERTYKEY key
, PROPVARIANT
*value
)
846 FIXME("iface %p, key %p, value %p stub!\n", iface
, key
, value
);
850 static HRESULT WINAPI
property_store_SetValue(IPropertyStore
*iface
, REFPROPERTYKEY key
, REFPROPVARIANT value
)
852 FIXME("iface %p, key %p, value %p stub!\n", iface
, key
, value
);
856 static HRESULT WINAPI
property_store_Commit(IPropertyStore
*iface
)
858 FIXME("iface %p stub!\n", iface
);
862 static const IPropertyStoreVtbl property_store_vtbl
=
864 property_store_QueryInterface
,
865 property_store_AddRef
,
866 property_store_Release
,
867 property_store_GetCount
,
868 property_store_GetAt
,
869 property_store_GetValue
,
870 property_store_SetValue
,
871 property_store_Commit
,
874 HRESULT
resampler_create(IUnknown
*outer
, IUnknown
**out
)
876 static const struct wg_format input_format
=
878 .major_type
= WG_MAJOR_TYPE_AUDIO
,
881 .format
= WG_AUDIO_FORMAT_S16LE
,
887 static const struct wg_format output_format
=
889 .major_type
= WG_MAJOR_TYPE_AUDIO
,
892 .format
= WG_AUDIO_FORMAT_F32LE
,
898 struct wg_transform
*transform
;
899 struct resampler
*impl
;
902 TRACE("outer %p, out %p.\n", outer
, out
);
904 if (!(transform
= wg_transform_create(&input_format
, &output_format
)))
906 ERR_(winediag
)("GStreamer doesn't support audio resampling, please install appropriate plugins.\n");
909 wg_transform_destroy(transform
);
911 if (!(impl
= calloc(1, sizeof(*impl
))))
912 return E_OUTOFMEMORY
;
914 if (FAILED(hr
= wg_sample_queue_create(&impl
->wg_sample_queue
)))
920 impl
->IUnknown_inner
.lpVtbl
= &unknown_vtbl
;
921 impl
->IMFTransform_iface
.lpVtbl
= &transform_vtbl
;
922 impl
->IMediaObject_iface
.lpVtbl
= &media_object_vtbl
;
923 impl
->IPropertyBag_iface
.lpVtbl
= &property_bag_vtbl
;
924 impl
->IPropertyStore_iface
.lpVtbl
= &property_store_vtbl
;
926 impl
->outer
= outer
? outer
: &impl
->IUnknown_inner
;
928 impl
->input_info
.cbAlignment
= 1;
929 impl
->output_info
.cbAlignment
= 1;
931 *out
= &impl
->IUnknown_inner
;
932 TRACE("Created %p\n", *out
);