2 * Copyright 2017 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "mfplat_private.h"
29 #include "wmcodecdsp.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(mfplat
);
33 DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC1
, MAKEFOURCC('I','M','C','1'));
34 DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC2
, MAKEFOURCC('I','M','C','2'));
35 DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC3
, MAKEFOURCC('I','M','C','3'));
36 DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC4
, MAKEFOURCC('I','M','C','4'));
40 struct attributes attributes
;
41 IMFMediaType IMFMediaType_iface
;
42 IMFVideoMediaType IMFVideoMediaType_iface
;
43 IMFAudioMediaType IMFAudioMediaType_iface
;
44 MFVIDEOFORMAT
*video_format
;
45 WAVEFORMATEX
*audio_format
;
50 struct attributes attributes
;
51 IMFStreamDescriptor IMFStreamDescriptor_iface
;
52 IMFMediaTypeHandler IMFMediaTypeHandler_iface
;
54 IMFMediaType
**media_types
;
55 unsigned int media_types_count
;
56 IMFMediaType
*current_type
;
59 struct presentation_desc_entry
61 IMFStreamDescriptor
*descriptor
;
65 struct presentation_desc
67 struct attributes attributes
;
68 IMFPresentationDescriptor IMFPresentationDescriptor_iface
;
69 struct presentation_desc_entry
*descriptors
;
73 static HRESULT
presentation_descriptor_init(struct presentation_desc
*object
, DWORD count
);
75 static struct media_type
*impl_from_IMFMediaType(IMFMediaType
*iface
)
77 return CONTAINING_RECORD(iface
, struct media_type
, IMFMediaType_iface
);
80 static struct media_type
*impl_from_IMFVideoMediaType(IMFVideoMediaType
*iface
)
82 return CONTAINING_RECORD(iface
, struct media_type
, IMFVideoMediaType_iface
);
85 static struct media_type
*impl_from_IMFAudioMediaType(IMFAudioMediaType
*iface
)
87 return CONTAINING_RECORD(iface
, struct media_type
, IMFAudioMediaType_iface
);
90 static inline struct stream_desc
*impl_from_IMFStreamDescriptor(IMFStreamDescriptor
*iface
)
92 return CONTAINING_RECORD(iface
, struct stream_desc
, IMFStreamDescriptor_iface
);
95 static struct stream_desc
*impl_from_IMFMediaTypeHandler(IMFMediaTypeHandler
*iface
)
97 return CONTAINING_RECORD(iface
, struct stream_desc
, IMFMediaTypeHandler_iface
);
100 static struct presentation_desc
*impl_from_IMFPresentationDescriptor(IMFPresentationDescriptor
*iface
)
102 return CONTAINING_RECORD(iface
, struct presentation_desc
, IMFPresentationDescriptor_iface
);
105 static HRESULT WINAPI
mediatype_QueryInterface(IMFMediaType
*iface
, REFIID riid
, void **out
)
107 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
110 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
112 attributes_GetGUID(&media_type
->attributes
, &MF_MT_MAJOR_TYPE
, &major
);
114 if (IsEqualGUID(&major
, &MFMediaType_Video
) && IsEqualIID(riid
, &IID_IMFVideoMediaType
))
116 *out
= &media_type
->IMFVideoMediaType_iface
;
118 else if (IsEqualGUID(&major
, &MFMediaType_Audio
) && IsEqualIID(riid
, &IID_IMFAudioMediaType
))
120 *out
= &media_type
->IMFAudioMediaType_iface
;
122 else if (IsEqualIID(riid
, &IID_IMFMediaType
) ||
123 IsEqualIID(riid
, &IID_IMFAttributes
) ||
124 IsEqualIID(riid
, &IID_IUnknown
))
126 *out
= &media_type
->IMFMediaType_iface
;
130 WARN("Unsupported %s.\n", debugstr_guid(riid
));
132 return E_NOINTERFACE
;
135 IUnknown_AddRef((IUnknown
*)*out
);
139 static ULONG WINAPI
mediatype_AddRef(IMFMediaType
*iface
)
141 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
142 ULONG refcount
= InterlockedIncrement(&media_type
->attributes
.ref
);
144 TRACE("%p, refcount %lu.\n", iface
, refcount
);
149 static ULONG WINAPI
mediatype_Release(IMFMediaType
*iface
)
151 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
152 ULONG refcount
= InterlockedDecrement(&media_type
->attributes
.ref
);
154 TRACE("%p, refcount %lu.\n", iface
, refcount
);
158 clear_attributes_object(&media_type
->attributes
);
159 CoTaskMemFree(media_type
->video_format
);
160 CoTaskMemFree(media_type
->audio_format
);
167 static HRESULT WINAPI
mediatype_GetItem(IMFMediaType
*iface
, REFGUID key
, PROPVARIANT
*value
)
169 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
171 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
173 return attributes_GetItem(&media_type
->attributes
, key
, value
);
176 static HRESULT WINAPI
mediatype_GetItemType(IMFMediaType
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
178 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
180 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), type
);
182 return attributes_GetItemType(&media_type
->attributes
, key
, type
);
185 static HRESULT WINAPI
mediatype_CompareItem(IMFMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
, BOOL
*result
)
187 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
189 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
), result
);
191 return attributes_CompareItem(&media_type
->attributes
, key
, value
, result
);
194 static HRESULT WINAPI
mediatype_Compare(IMFMediaType
*iface
, IMFAttributes
*attrs
, MF_ATTRIBUTES_MATCH_TYPE type
,
197 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
199 TRACE("%p, %p, %d, %p.\n", iface
, attrs
, type
, result
);
201 return attributes_Compare(&media_type
->attributes
, attrs
, type
, result
);
204 static HRESULT WINAPI
mediatype_GetUINT32(IMFMediaType
*iface
, REFGUID key
, UINT32
*value
)
206 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
208 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
210 return attributes_GetUINT32(&media_type
->attributes
, key
, value
);
213 static HRESULT WINAPI
mediatype_GetUINT64(IMFMediaType
*iface
, REFGUID key
, UINT64
*value
)
215 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
217 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
219 return attributes_GetUINT64(&media_type
->attributes
, key
, value
);
222 static HRESULT WINAPI
mediatype_GetDouble(IMFMediaType
*iface
, REFGUID key
, double *value
)
224 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
226 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
228 return attributes_GetDouble(&media_type
->attributes
, key
, value
);
231 static HRESULT WINAPI
mediatype_GetGUID(IMFMediaType
*iface
, REFGUID key
, GUID
*value
)
233 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
235 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
237 return attributes_GetGUID(&media_type
->attributes
, key
, value
);
240 static HRESULT WINAPI
mediatype_GetStringLength(IMFMediaType
*iface
, REFGUID key
, UINT32
*length
)
242 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
244 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), length
);
246 return attributes_GetStringLength(&media_type
->attributes
, key
, length
);
249 static HRESULT WINAPI
mediatype_GetString(IMFMediaType
*iface
, REFGUID key
, WCHAR
*value
,
250 UINT32 size
, UINT32
*length
)
252 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
254 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), value
, size
, length
);
256 return attributes_GetString(&media_type
->attributes
, key
, value
, size
, length
);
259 static HRESULT WINAPI
mediatype_GetAllocatedString(IMFMediaType
*iface
, REFGUID key
,
260 WCHAR
**value
, UINT32
*length
)
262 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
264 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), value
, length
);
266 return attributes_GetAllocatedString(&media_type
->attributes
, key
, value
, length
);
269 static HRESULT WINAPI
mediatype_GetBlobSize(IMFMediaType
*iface
, REFGUID key
, UINT32
*size
)
271 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
273 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), size
);
275 return attributes_GetBlobSize(&media_type
->attributes
, key
, size
);
278 static HRESULT WINAPI
mediatype_GetBlob(IMFMediaType
*iface
, REFGUID key
, UINT8
*buf
,
279 UINT32 bufsize
, UINT32
*blobsize
)
281 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
283 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), buf
, bufsize
, blobsize
);
285 return attributes_GetBlob(&media_type
->attributes
, key
, buf
, bufsize
, blobsize
);
288 static HRESULT WINAPI
mediatype_GetAllocatedBlob(IMFMediaType
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
290 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
292 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), buf
, size
);
294 return attributes_GetAllocatedBlob(&media_type
->attributes
, key
, buf
, size
);
297 static HRESULT WINAPI
mediatype_GetUnknown(IMFMediaType
*iface
, REFGUID key
, REFIID riid
, void **obj
)
299 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
301 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_guid(riid
), obj
);
303 return attributes_GetUnknown(&media_type
->attributes
, key
, riid
, obj
);
306 static HRESULT WINAPI
mediatype_SetItem(IMFMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
)
308 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
310 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
));
312 return attributes_SetItem(&media_type
->attributes
, key
, value
);
315 static HRESULT WINAPI
mediatype_DeleteItem(IMFMediaType
*iface
, REFGUID key
)
317 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
319 TRACE("%p, %s.\n", iface
, debugstr_attr(key
));
321 return attributes_DeleteItem(&media_type
->attributes
, key
);
324 static HRESULT WINAPI
mediatype_DeleteAllItems(IMFMediaType
*iface
)
326 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
328 TRACE("%p.\n", iface
);
330 return attributes_DeleteAllItems(&media_type
->attributes
);
333 static HRESULT WINAPI
mediatype_SetUINT32(IMFMediaType
*iface
, REFGUID key
, UINT32 value
)
335 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
337 TRACE("%p, %s, %u.\n", iface
, debugstr_attr(key
), value
);
339 return attributes_SetUINT32(&media_type
->attributes
, key
, value
);
342 static HRESULT WINAPI
mediatype_SetUINT64(IMFMediaType
*iface
, REFGUID key
, UINT64 value
)
344 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
346 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), wine_dbgstr_longlong(value
));
348 return attributes_SetUINT64(&media_type
->attributes
, key
, value
);
351 static HRESULT WINAPI
mediatype_SetDouble(IMFMediaType
*iface
, REFGUID key
, double value
)
353 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
355 TRACE("%p, %s, %f.\n", iface
, debugstr_attr(key
), value
);
357 return attributes_SetDouble(&media_type
->attributes
, key
, value
);
360 static HRESULT WINAPI
mediatype_SetGUID(IMFMediaType
*iface
, REFGUID key
, REFGUID value
)
362 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
364 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_mf_guid(value
));
366 return attributes_SetGUID(&media_type
->attributes
, key
, value
);
369 static HRESULT WINAPI
mediatype_SetString(IMFMediaType
*iface
, REFGUID key
, const WCHAR
*value
)
371 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
373 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_w(value
));
375 return attributes_SetString(&media_type
->attributes
, key
, value
);
378 static HRESULT WINAPI
mediatype_SetBlob(IMFMediaType
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
380 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
382 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_attr(key
), buf
, size
);
384 return attributes_SetBlob(&media_type
->attributes
, key
, buf
, size
);
387 static HRESULT WINAPI
mediatype_SetUnknown(IMFMediaType
*iface
, REFGUID key
, IUnknown
*unknown
)
389 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
391 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), unknown
);
393 return attributes_SetUnknown(&media_type
->attributes
, key
, unknown
);
396 static HRESULT WINAPI
mediatype_LockStore(IMFMediaType
*iface
)
398 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
400 TRACE("%p.\n", iface
);
402 return attributes_LockStore(&media_type
->attributes
);
405 static HRESULT WINAPI
mediatype_UnlockStore(IMFMediaType
*iface
)
407 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
409 TRACE("%p.\n", iface
);
411 return attributes_UnlockStore(&media_type
->attributes
);
414 static HRESULT WINAPI
mediatype_GetCount(IMFMediaType
*iface
, UINT32
*count
)
416 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
418 TRACE("%p, %p.\n", iface
, count
);
420 return attributes_GetCount(&media_type
->attributes
, count
);
423 static HRESULT WINAPI
mediatype_GetItemByIndex(IMFMediaType
*iface
, UINT32 index
, GUID
*key
, PROPVARIANT
*value
)
425 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
427 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
429 return attributes_GetItemByIndex(&media_type
->attributes
, index
, key
, value
);
432 static HRESULT WINAPI
mediatype_CopyAllItems(IMFMediaType
*iface
, IMFAttributes
*dest
)
434 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
436 TRACE("%p, %p.\n", iface
, dest
);
438 return attributes_CopyAllItems(&media_type
->attributes
, dest
);
441 static HRESULT WINAPI
mediatype_GetMajorType(IMFMediaType
*iface
, GUID
*guid
)
443 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
445 TRACE("%p, %p.\n", iface
, guid
);
447 return attributes_GetGUID(&media_type
->attributes
, &MF_MT_MAJOR_TYPE
, guid
);
450 static HRESULT
mediatype_is_compressed(struct media_type
*media_type
, BOOL
*compressed
)
454 if (FAILED(attributes_GetUINT32(&media_type
->attributes
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, &value
)))
459 *compressed
= !value
;
464 static HRESULT WINAPI
mediatype_IsCompressedFormat(IMFMediaType
*iface
, BOOL
*compressed
)
466 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
468 TRACE("%p, %p.\n", iface
, compressed
);
470 return mediatype_is_compressed(media_type
, compressed
);
473 static HRESULT
media_type_is_equal(struct media_type
*media_type
, IMFMediaType
*type
, DWORD
*flags
)
475 const DWORD full_equality_flags
= MF_MEDIATYPE_EQUAL_MAJOR_TYPES
| MF_MEDIATYPE_EQUAL_FORMAT_TYPES
|
476 MF_MEDIATYPE_EQUAL_FORMAT_DATA
| MF_MEDIATYPE_EQUAL_FORMAT_USER_DATA
;
490 left
.type
= &media_type
->attributes
.IMFAttributes_iface
;
491 right
.type
= (IMFAttributes
*)type
;
493 if (FAILED(IMFAttributes_GetGUID(left
.type
, &MF_MT_MAJOR_TYPE
, &left
.guid
)))
496 if (FAILED(IMFAttributes_GetGUID(right
.type
, &MF_MT_MAJOR_TYPE
, &right
.guid
)))
499 if (IsEqualGUID(&left
.guid
, &right
.guid
))
500 *flags
|= MF_MEDIATYPE_EQUAL_MAJOR_TYPES
;
502 /* Subtypes equal or both missing. */
503 left
.hr
= IMFAttributes_GetGUID(left
.type
, &MF_MT_SUBTYPE
, &left
.guid
);
504 right
.hr
= IMFAttributes_GetGUID(right
.type
, &MF_MT_SUBTYPE
, &right
.guid
);
506 if ((SUCCEEDED(left
.hr
) && SUCCEEDED(right
.hr
) && IsEqualGUID(&left
.guid
, &right
.guid
)) ||
507 (FAILED(left
.hr
) && FAILED(right
.hr
)))
509 *flags
|= MF_MEDIATYPE_EQUAL_FORMAT_TYPES
;
513 IMFAttributes_GetCount(left
.type
, &left
.count
);
514 IMFAttributes_GetCount(right
.type
, &right
.count
);
516 if (right
.count
< left
.count
)
523 *flags
|= MF_MEDIATYPE_EQUAL_FORMAT_DATA
;
525 for (i
= 0; i
< left
.count
; ++i
)
530 if (SUCCEEDED(IMFAttributes_GetItemByIndex(left
.type
, i
, &key
, &value
)))
532 if (IsEqualGUID(&key
, &MF_MT_USER_DATA
) ||
533 IsEqualGUID(&key
, &MF_MT_FRAME_RATE_RANGE_MIN
) ||
534 IsEqualGUID(&key
, &MF_MT_FRAME_RATE_RANGE_MAX
))
536 PropVariantClear(&value
);
541 IMFAttributes_CompareItem(right
.type
, &key
, &value
, &result
);
542 PropVariantClear(&value
);
545 *flags
&= ~MF_MEDIATYPE_EQUAL_FORMAT_DATA
;
552 PropVariantInit(&left
.value
);
553 left
.hr
= IMFAttributes_GetItem(left
.type
, &MF_MT_USER_DATA
, &left
.value
);
554 PropVariantInit(&right
.value
);
555 right
.hr
= IMFAttributes_GetItem(right
.type
, &MF_MT_USER_DATA
, &right
.value
);
557 /* Compare user data if both types have it, otherwise simply check if both don't. */
558 if (SUCCEEDED(left
.hr
) && SUCCEEDED(right
.hr
))
561 IMFAttributes_CompareItem(left
.type
, &MF_MT_USER_DATA
, &left
.value
, &result
);
564 result
= FAILED(left
.hr
) && FAILED(right
.hr
);
566 PropVariantClear(&left
.value
);
567 PropVariantClear(&right
.value
);
570 *flags
|= MF_MEDIATYPE_EQUAL_FORMAT_USER_DATA
;
572 return *flags
== full_equality_flags
? S_OK
: S_FALSE
;
575 static HRESULT WINAPI
mediatype_IsEqual(IMFMediaType
*iface
, IMFMediaType
*type
, DWORD
*flags
)
577 struct media_type
*media_type
= impl_from_IMFMediaType(iface
);
579 TRACE("%p, %p, %p.\n", iface
, type
, flags
);
581 return media_type_is_equal(media_type
, type
, flags
);
584 static HRESULT WINAPI
mediatype_GetRepresentation(IMFMediaType
*iface
, GUID guid
, void **representation
)
586 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
591 static HRESULT WINAPI
mediatype_FreeRepresentation(IMFMediaType
*iface
, GUID guid
, void *representation
)
593 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
598 static const IMFMediaTypeVtbl mediatypevtbl
=
600 mediatype_QueryInterface
,
604 mediatype_GetItemType
,
605 mediatype_CompareItem
,
611 mediatype_GetStringLength
,
613 mediatype_GetAllocatedString
,
614 mediatype_GetBlobSize
,
616 mediatype_GetAllocatedBlob
,
617 mediatype_GetUnknown
,
619 mediatype_DeleteItem
,
620 mediatype_DeleteAllItems
,
627 mediatype_SetUnknown
,
629 mediatype_UnlockStore
,
631 mediatype_GetItemByIndex
,
632 mediatype_CopyAllItems
,
633 mediatype_GetMajorType
,
634 mediatype_IsCompressedFormat
,
636 mediatype_GetRepresentation
,
637 mediatype_FreeRepresentation
640 static HRESULT WINAPI
video_mediatype_QueryInterface(IMFVideoMediaType
*iface
, REFIID riid
, void **out
)
642 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
643 return IMFMediaType_QueryInterface(&media_type
->IMFMediaType_iface
, riid
, out
);
646 static ULONG WINAPI
video_mediatype_AddRef(IMFVideoMediaType
*iface
)
648 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
649 return IMFMediaType_AddRef(&media_type
->IMFMediaType_iface
);
652 static ULONG WINAPI
video_mediatype_Release(IMFVideoMediaType
*iface
)
654 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
655 return IMFMediaType_Release(&media_type
->IMFMediaType_iface
);
658 static HRESULT WINAPI
video_mediatype_GetItem(IMFVideoMediaType
*iface
, REFGUID key
, PROPVARIANT
*value
)
660 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
662 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
664 return attributes_GetItem(&media_type
->attributes
, key
, value
);
667 static HRESULT WINAPI
video_mediatype_GetItemType(IMFVideoMediaType
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
669 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
671 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), type
);
673 return attributes_GetItemType(&media_type
->attributes
, key
, type
);
676 static HRESULT WINAPI
video_mediatype_CompareItem(IMFVideoMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
, BOOL
*result
)
678 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
680 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
), result
);
682 return attributes_CompareItem(&media_type
->attributes
, key
, value
, result
);
685 static HRESULT WINAPI
video_mediatype_Compare(IMFVideoMediaType
*iface
, IMFAttributes
*attrs
,
686 MF_ATTRIBUTES_MATCH_TYPE type
, BOOL
*result
)
688 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
690 TRACE("%p, %p, %d, %p.\n", iface
, attrs
, type
, result
);
692 return attributes_Compare(&media_type
->attributes
, attrs
, type
, result
);
695 static HRESULT WINAPI
video_mediatype_GetUINT32(IMFVideoMediaType
*iface
, REFGUID key
, UINT32
*value
)
697 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
699 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
701 return attributes_GetUINT32(&media_type
->attributes
, key
, value
);
704 static HRESULT WINAPI
video_mediatype_GetUINT64(IMFVideoMediaType
*iface
, REFGUID key
, UINT64
*value
)
706 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
708 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
710 return attributes_GetUINT64(&media_type
->attributes
, key
, value
);
713 static HRESULT WINAPI
video_mediatype_GetDouble(IMFVideoMediaType
*iface
, REFGUID key
, double *value
)
715 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
717 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
719 return attributes_GetDouble(&media_type
->attributes
, key
, value
);
722 static HRESULT WINAPI
video_mediatype_GetGUID(IMFVideoMediaType
*iface
, REFGUID key
, GUID
*value
)
724 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
726 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
728 return attributes_GetGUID(&media_type
->attributes
, key
, value
);
731 static HRESULT WINAPI
video_mediatype_GetStringLength(IMFVideoMediaType
*iface
, REFGUID key
, UINT32
*length
)
733 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
735 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), length
);
737 return attributes_GetStringLength(&media_type
->attributes
, key
, length
);
740 static HRESULT WINAPI
video_mediatype_GetString(IMFVideoMediaType
*iface
, REFGUID key
, WCHAR
*value
,
741 UINT32 size
, UINT32
*length
)
743 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
745 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), value
, size
, length
);
747 return attributes_GetString(&media_type
->attributes
, key
, value
, size
, length
);
750 static HRESULT WINAPI
video_mediatype_GetAllocatedString(IMFVideoMediaType
*iface
, REFGUID key
,
751 WCHAR
**value
, UINT32
*length
)
753 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
755 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), value
, length
);
757 return attributes_GetAllocatedString(&media_type
->attributes
, key
, value
, length
);
760 static HRESULT WINAPI
video_mediatype_GetBlobSize(IMFVideoMediaType
*iface
, REFGUID key
, UINT32
*size
)
762 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
764 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), size
);
766 return attributes_GetBlobSize(&media_type
->attributes
, key
, size
);
769 static HRESULT WINAPI
video_mediatype_GetBlob(IMFVideoMediaType
*iface
, REFGUID key
, UINT8
*buf
,
770 UINT32 bufsize
, UINT32
*blobsize
)
772 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
774 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), buf
, bufsize
, blobsize
);
776 return attributes_GetBlob(&media_type
->attributes
, key
, buf
, bufsize
, blobsize
);
779 static HRESULT WINAPI
video_mediatype_GetAllocatedBlob(IMFVideoMediaType
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
781 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
783 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), buf
, size
);
785 return attributes_GetAllocatedBlob(&media_type
->attributes
, key
, buf
, size
);
788 static HRESULT WINAPI
video_mediatype_GetUnknown(IMFVideoMediaType
*iface
, REFGUID key
, REFIID riid
, void **obj
)
790 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
792 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_guid(riid
), obj
);
794 return attributes_GetUnknown(&media_type
->attributes
, key
, riid
, obj
);
797 static HRESULT WINAPI
video_mediatype_SetItem(IMFVideoMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
)
799 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
801 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
));
803 return attributes_SetItem(&media_type
->attributes
, key
, value
);
806 static HRESULT WINAPI
video_mediatype_DeleteItem(IMFVideoMediaType
*iface
, REFGUID key
)
808 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
810 TRACE("%p, %s.\n", iface
, debugstr_attr(key
));
812 return attributes_DeleteItem(&media_type
->attributes
, key
);
815 static HRESULT WINAPI
video_mediatype_DeleteAllItems(IMFVideoMediaType
*iface
)
817 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
819 TRACE("%p.\n", iface
);
821 return attributes_DeleteAllItems(&media_type
->attributes
);
824 static HRESULT WINAPI
video_mediatype_SetUINT32(IMFVideoMediaType
*iface
, REFGUID key
, UINT32 value
)
826 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
828 TRACE("%p, %s, %u.\n", iface
, debugstr_attr(key
), value
);
830 return attributes_SetUINT32(&media_type
->attributes
, key
, value
);
833 static HRESULT WINAPI
video_mediatype_SetUINT64(IMFVideoMediaType
*iface
, REFGUID key
, UINT64 value
)
835 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
837 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), wine_dbgstr_longlong(value
));
839 return attributes_SetUINT64(&media_type
->attributes
, key
, value
);
842 static HRESULT WINAPI
video_mediatype_SetDouble(IMFVideoMediaType
*iface
, REFGUID key
, double value
)
844 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
846 TRACE("%p, %s, %f.\n", iface
, debugstr_attr(key
), value
);
848 return attributes_SetDouble(&media_type
->attributes
, key
, value
);
851 static HRESULT WINAPI
video_mediatype_SetGUID(IMFVideoMediaType
*iface
, REFGUID key
, REFGUID value
)
853 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
855 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_mf_guid(value
));
857 return attributes_SetGUID(&media_type
->attributes
, key
, value
);
860 static HRESULT WINAPI
video_mediatype_SetString(IMFVideoMediaType
*iface
, REFGUID key
, const WCHAR
*value
)
862 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
864 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_w(value
));
866 return attributes_SetString(&media_type
->attributes
, key
, value
);
869 static HRESULT WINAPI
video_mediatype_SetBlob(IMFVideoMediaType
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
871 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
873 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_attr(key
), buf
, size
);
875 return attributes_SetBlob(&media_type
->attributes
, key
, buf
, size
);
878 static HRESULT WINAPI
video_mediatype_SetUnknown(IMFVideoMediaType
*iface
, REFGUID key
, IUnknown
*unknown
)
880 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
882 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), unknown
);
884 return attributes_SetUnknown(&media_type
->attributes
, key
, unknown
);
887 static HRESULT WINAPI
video_mediatype_LockStore(IMFVideoMediaType
*iface
)
889 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
891 TRACE("%p.\n", iface
);
893 return attributes_LockStore(&media_type
->attributes
);
896 static HRESULT WINAPI
video_mediatype_UnlockStore(IMFVideoMediaType
*iface
)
898 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
900 TRACE("%p.\n", iface
);
902 return attributes_UnlockStore(&media_type
->attributes
);
905 static HRESULT WINAPI
video_mediatype_GetCount(IMFVideoMediaType
*iface
, UINT32
*count
)
907 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
909 TRACE("%p, %p.\n", iface
, count
);
911 return attributes_GetCount(&media_type
->attributes
, count
);
914 static HRESULT WINAPI
video_mediatype_GetItemByIndex(IMFVideoMediaType
*iface
, UINT32 index
, GUID
*key
, PROPVARIANT
*value
)
916 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
918 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
920 return attributes_GetItemByIndex(&media_type
->attributes
, index
, key
, value
);
923 static HRESULT WINAPI
video_mediatype_CopyAllItems(IMFVideoMediaType
*iface
, IMFAttributes
*dest
)
925 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
927 TRACE("%p, %p.\n", iface
, dest
);
929 return attributes_CopyAllItems(&media_type
->attributes
, dest
);
932 static HRESULT WINAPI
video_mediatype_GetMajorType(IMFVideoMediaType
*iface
, GUID
*guid
)
934 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
936 TRACE("%p, %p.\n", iface
, guid
);
938 return attributes_GetGUID(&media_type
->attributes
, &MF_MT_MAJOR_TYPE
, guid
);
941 static HRESULT WINAPI
video_mediatype_IsCompressedFormat(IMFVideoMediaType
*iface
, BOOL
*compressed
)
943 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
945 TRACE("%p, %p.\n", iface
, compressed
);
947 return mediatype_is_compressed(media_type
, compressed
);
950 static HRESULT WINAPI
video_mediatype_IsEqual(IMFVideoMediaType
*iface
, IMFMediaType
*type
, DWORD
*flags
)
952 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
954 TRACE("%p, %p, %p.\n", iface
, type
, flags
);
956 return media_type_is_equal(media_type
, type
, flags
);
959 static HRESULT WINAPI
video_mediatype_GetRepresentation(IMFVideoMediaType
*iface
, GUID guid
, void **representation
)
961 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
966 static HRESULT WINAPI
video_mediatype_FreeRepresentation(IMFVideoMediaType
*iface
, GUID guid
, void *representation
)
968 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
973 static const MFVIDEOFORMAT
* WINAPI
video_mediatype_GetVideoFormat(IMFVideoMediaType
*iface
)
975 struct media_type
*media_type
= impl_from_IMFVideoMediaType(iface
);
979 TRACE("%p.\n", iface
);
981 CoTaskMemFree(media_type
->video_format
);
982 media_type
->video_format
= NULL
;
983 if (FAILED(hr
= MFCreateMFVideoFormatFromMFMediaType(&media_type
->IMFMediaType_iface
, &media_type
->video_format
, &size
)))
984 WARN("Failed to create format description, hr %#lx.\n", hr
);
986 return media_type
->video_format
;
989 static HRESULT WINAPI
video_mediatype_GetVideoRepresentation(IMFVideoMediaType
*iface
, GUID representation
,
990 void **data
, LONG stride
)
992 FIXME("%p, %s, %p, %ld.\n", iface
, debugstr_guid(&representation
), data
, stride
);
997 static const IMFVideoMediaTypeVtbl videomediatypevtbl
=
999 video_mediatype_QueryInterface
,
1000 video_mediatype_AddRef
,
1001 video_mediatype_Release
,
1002 video_mediatype_GetItem
,
1003 video_mediatype_GetItemType
,
1004 video_mediatype_CompareItem
,
1005 video_mediatype_Compare
,
1006 video_mediatype_GetUINT32
,
1007 video_mediatype_GetUINT64
,
1008 video_mediatype_GetDouble
,
1009 video_mediatype_GetGUID
,
1010 video_mediatype_GetStringLength
,
1011 video_mediatype_GetString
,
1012 video_mediatype_GetAllocatedString
,
1013 video_mediatype_GetBlobSize
,
1014 video_mediatype_GetBlob
,
1015 video_mediatype_GetAllocatedBlob
,
1016 video_mediatype_GetUnknown
,
1017 video_mediatype_SetItem
,
1018 video_mediatype_DeleteItem
,
1019 video_mediatype_DeleteAllItems
,
1020 video_mediatype_SetUINT32
,
1021 video_mediatype_SetUINT64
,
1022 video_mediatype_SetDouble
,
1023 video_mediatype_SetGUID
,
1024 video_mediatype_SetString
,
1025 video_mediatype_SetBlob
,
1026 video_mediatype_SetUnknown
,
1027 video_mediatype_LockStore
,
1028 video_mediatype_UnlockStore
,
1029 video_mediatype_GetCount
,
1030 video_mediatype_GetItemByIndex
,
1031 video_mediatype_CopyAllItems
,
1032 video_mediatype_GetMajorType
,
1033 video_mediatype_IsCompressedFormat
,
1034 video_mediatype_IsEqual
,
1035 video_mediatype_GetRepresentation
,
1036 video_mediatype_FreeRepresentation
,
1037 video_mediatype_GetVideoFormat
,
1038 video_mediatype_GetVideoRepresentation
,
1041 static HRESULT WINAPI
audio_mediatype_QueryInterface(IMFAudioMediaType
*iface
, REFIID riid
, void **out
)
1043 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1044 return IMFMediaType_QueryInterface(&media_type
->IMFMediaType_iface
, riid
, out
);
1047 static ULONG WINAPI
audio_mediatype_AddRef(IMFAudioMediaType
*iface
)
1049 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1050 return IMFMediaType_AddRef(&media_type
->IMFMediaType_iface
);
1053 static ULONG WINAPI
audio_mediatype_Release(IMFAudioMediaType
*iface
)
1055 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1056 return IMFMediaType_Release(&media_type
->IMFMediaType_iface
);
1059 static HRESULT WINAPI
audio_mediatype_GetItem(IMFAudioMediaType
*iface
, REFGUID key
, PROPVARIANT
*value
)
1061 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1063 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1065 return attributes_GetItem(&media_type
->attributes
, key
, value
);
1068 static HRESULT WINAPI
audio_mediatype_GetItemType(IMFAudioMediaType
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
1070 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1072 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), type
);
1074 return attributes_GetItemType(&media_type
->attributes
, key
, type
);
1077 static HRESULT WINAPI
audio_mediatype_CompareItem(IMFAudioMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
, BOOL
*result
)
1079 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1081 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
), result
);
1083 return attributes_CompareItem(&media_type
->attributes
, key
, value
, result
);
1086 static HRESULT WINAPI
audio_mediatype_Compare(IMFAudioMediaType
*iface
, IMFAttributes
*attrs
,
1087 MF_ATTRIBUTES_MATCH_TYPE type
, BOOL
*result
)
1089 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1091 TRACE("%p, %p, %d, %p.\n", iface
, attrs
, type
, result
);
1093 return attributes_Compare(&media_type
->attributes
, attrs
, type
, result
);
1096 static HRESULT WINAPI
audio_mediatype_GetUINT32(IMFAudioMediaType
*iface
, REFGUID key
, UINT32
*value
)
1098 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1100 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1102 return attributes_GetUINT32(&media_type
->attributes
, key
, value
);
1105 static HRESULT WINAPI
audio_mediatype_GetUINT64(IMFAudioMediaType
*iface
, REFGUID key
, UINT64
*value
)
1107 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1109 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1111 return attributes_GetUINT64(&media_type
->attributes
, key
, value
);
1114 static HRESULT WINAPI
audio_mediatype_GetDouble(IMFAudioMediaType
*iface
, REFGUID key
, double *value
)
1116 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1118 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1120 return attributes_GetDouble(&media_type
->attributes
, key
, value
);
1123 static HRESULT WINAPI
audio_mediatype_GetGUID(IMFAudioMediaType
*iface
, REFGUID key
, GUID
*value
)
1125 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1127 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1129 return attributes_GetGUID(&media_type
->attributes
, key
, value
);
1132 static HRESULT WINAPI
audio_mediatype_GetStringLength(IMFAudioMediaType
*iface
, REFGUID key
, UINT32
*length
)
1134 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1136 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), length
);
1138 return attributes_GetStringLength(&media_type
->attributes
, key
, length
);
1141 static HRESULT WINAPI
audio_mediatype_GetString(IMFAudioMediaType
*iface
, REFGUID key
, WCHAR
*value
,
1142 UINT32 size
, UINT32
*length
)
1144 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1146 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), value
, size
, length
);
1148 return attributes_GetString(&media_type
->attributes
, key
, value
, size
, length
);
1151 static HRESULT WINAPI
audio_mediatype_GetAllocatedString(IMFAudioMediaType
*iface
, REFGUID key
,
1152 WCHAR
**value
, UINT32
*length
)
1154 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1156 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), value
, length
);
1158 return attributes_GetAllocatedString(&media_type
->attributes
, key
, value
, length
);
1161 static HRESULT WINAPI
audio_mediatype_GetBlobSize(IMFAudioMediaType
*iface
, REFGUID key
, UINT32
*size
)
1163 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1165 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), size
);
1167 return attributes_GetBlobSize(&media_type
->attributes
, key
, size
);
1170 static HRESULT WINAPI
audio_mediatype_GetBlob(IMFAudioMediaType
*iface
, REFGUID key
, UINT8
*buf
,
1171 UINT32 bufsize
, UINT32
*blobsize
)
1173 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1175 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), buf
, bufsize
, blobsize
);
1177 return attributes_GetBlob(&media_type
->attributes
, key
, buf
, bufsize
, blobsize
);
1180 static HRESULT WINAPI
audio_mediatype_GetAllocatedBlob(IMFAudioMediaType
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
1182 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1184 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), buf
, size
);
1186 return attributes_GetAllocatedBlob(&media_type
->attributes
, key
, buf
, size
);
1189 static HRESULT WINAPI
audio_mediatype_GetUnknown(IMFAudioMediaType
*iface
, REFGUID key
, REFIID riid
, void **obj
)
1191 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1193 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_guid(riid
), obj
);
1195 return attributes_GetUnknown(&media_type
->attributes
, key
, riid
, obj
);
1198 static HRESULT WINAPI
audio_mediatype_SetItem(IMFAudioMediaType
*iface
, REFGUID key
, REFPROPVARIANT value
)
1200 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1202 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
));
1204 return attributes_SetItem(&media_type
->attributes
, key
, value
);
1207 static HRESULT WINAPI
audio_mediatype_DeleteItem(IMFAudioMediaType
*iface
, REFGUID key
)
1209 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1211 TRACE("%p, %s.\n", iface
, debugstr_attr(key
));
1213 return attributes_DeleteItem(&media_type
->attributes
, key
);
1216 static HRESULT WINAPI
audio_mediatype_DeleteAllItems(IMFAudioMediaType
*iface
)
1218 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1220 TRACE("%p.\n", iface
);
1222 return attributes_DeleteAllItems(&media_type
->attributes
);
1225 static HRESULT WINAPI
audio_mediatype_SetUINT32(IMFAudioMediaType
*iface
, REFGUID key
, UINT32 value
)
1227 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1229 TRACE("%p, %s, %u.\n", iface
, debugstr_attr(key
), value
);
1231 return attributes_SetUINT32(&media_type
->attributes
, key
, value
);
1234 static HRESULT WINAPI
audio_mediatype_SetUINT64(IMFAudioMediaType
*iface
, REFGUID key
, UINT64 value
)
1236 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1238 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), wine_dbgstr_longlong(value
));
1240 return attributes_SetUINT64(&media_type
->attributes
, key
, value
);
1243 static HRESULT WINAPI
audio_mediatype_SetDouble(IMFAudioMediaType
*iface
, REFGUID key
, double value
)
1245 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1247 TRACE("%p, %s, %f.\n", iface
, debugstr_attr(key
), value
);
1249 return attributes_SetDouble(&media_type
->attributes
, key
, value
);
1252 static HRESULT WINAPI
audio_mediatype_SetGUID(IMFAudioMediaType
*iface
, REFGUID key
, REFGUID value
)
1254 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1256 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_mf_guid(value
));
1258 return attributes_SetGUID(&media_type
->attributes
, key
, value
);
1261 static HRESULT WINAPI
audio_mediatype_SetString(IMFAudioMediaType
*iface
, REFGUID key
, const WCHAR
*value
)
1263 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1265 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_w(value
));
1267 return attributes_SetString(&media_type
->attributes
, key
, value
);
1270 static HRESULT WINAPI
audio_mediatype_SetBlob(IMFAudioMediaType
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
1272 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1274 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_attr(key
), buf
, size
);
1276 return attributes_SetBlob(&media_type
->attributes
, key
, buf
, size
);
1279 static HRESULT WINAPI
audio_mediatype_SetUnknown(IMFAudioMediaType
*iface
, REFGUID key
, IUnknown
*unknown
)
1281 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1283 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), unknown
);
1285 return attributes_SetUnknown(&media_type
->attributes
, key
, unknown
);
1288 static HRESULT WINAPI
audio_mediatype_LockStore(IMFAudioMediaType
*iface
)
1290 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1292 TRACE("%p.\n", iface
);
1294 return attributes_LockStore(&media_type
->attributes
);
1297 static HRESULT WINAPI
audio_mediatype_UnlockStore(IMFAudioMediaType
*iface
)
1299 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1301 TRACE("%p.\n", iface
);
1303 return attributes_UnlockStore(&media_type
->attributes
);
1306 static HRESULT WINAPI
audio_mediatype_GetCount(IMFAudioMediaType
*iface
, UINT32
*count
)
1308 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1310 TRACE("%p, %p.\n", iface
, count
);
1312 return attributes_GetCount(&media_type
->attributes
, count
);
1315 static HRESULT WINAPI
audio_mediatype_GetItemByIndex(IMFAudioMediaType
*iface
, UINT32 index
, GUID
*key
, PROPVARIANT
*value
)
1317 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1319 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
1321 return attributes_GetItemByIndex(&media_type
->attributes
, index
, key
, value
);
1324 static HRESULT WINAPI
audio_mediatype_CopyAllItems(IMFAudioMediaType
*iface
, IMFAttributes
*dest
)
1326 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1328 TRACE("%p, %p.\n", iface
, dest
);
1330 return attributes_CopyAllItems(&media_type
->attributes
, dest
);
1333 static HRESULT WINAPI
audio_mediatype_GetMajorType(IMFAudioMediaType
*iface
, GUID
*guid
)
1335 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1337 TRACE("%p, %p.\n", iface
, guid
);
1339 return attributes_GetGUID(&media_type
->attributes
, &MF_MT_MAJOR_TYPE
, guid
);
1342 static HRESULT WINAPI
audio_mediatype_IsCompressedFormat(IMFAudioMediaType
*iface
, BOOL
*compressed
)
1344 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1346 TRACE("%p, %p.\n", iface
, compressed
);
1348 return mediatype_is_compressed(media_type
, compressed
);
1351 static HRESULT WINAPI
audio_mediatype_IsEqual(IMFAudioMediaType
*iface
, IMFMediaType
*type
, DWORD
*flags
)
1353 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1355 TRACE("%p, %p, %p.\n", iface
, type
, flags
);
1357 return media_type_is_equal(media_type
, type
, flags
);
1360 static HRESULT WINAPI
audio_mediatype_GetRepresentation(IMFAudioMediaType
*iface
, GUID guid
, void **representation
)
1362 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
1367 static HRESULT WINAPI
audio_mediatype_FreeRepresentation(IMFAudioMediaType
*iface
, GUID guid
, void *representation
)
1369 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(&guid
), representation
);
1374 static const WAVEFORMATEX
* WINAPI
audio_mediatype_GetAudioFormat(IMFAudioMediaType
*iface
)
1376 struct media_type
*media_type
= impl_from_IMFAudioMediaType(iface
);
1380 TRACE("%p.\n", iface
);
1382 CoTaskMemFree(media_type
->audio_format
);
1383 media_type
->audio_format
= NULL
;
1384 if (FAILED(hr
= MFCreateWaveFormatExFromMFMediaType(&media_type
->IMFMediaType_iface
, &media_type
->audio_format
,
1385 &size
, MFWaveFormatExConvertFlag_Normal
)))
1387 WARN("Failed to create wave format description, hr %#lx.\n", hr
);
1390 return media_type
->audio_format
;
1393 static const IMFAudioMediaTypeVtbl audiomediatypevtbl
=
1395 audio_mediatype_QueryInterface
,
1396 audio_mediatype_AddRef
,
1397 audio_mediatype_Release
,
1398 audio_mediatype_GetItem
,
1399 audio_mediatype_GetItemType
,
1400 audio_mediatype_CompareItem
,
1401 audio_mediatype_Compare
,
1402 audio_mediatype_GetUINT32
,
1403 audio_mediatype_GetUINT64
,
1404 audio_mediatype_GetDouble
,
1405 audio_mediatype_GetGUID
,
1406 audio_mediatype_GetStringLength
,
1407 audio_mediatype_GetString
,
1408 audio_mediatype_GetAllocatedString
,
1409 audio_mediatype_GetBlobSize
,
1410 audio_mediatype_GetBlob
,
1411 audio_mediatype_GetAllocatedBlob
,
1412 audio_mediatype_GetUnknown
,
1413 audio_mediatype_SetItem
,
1414 audio_mediatype_DeleteItem
,
1415 audio_mediatype_DeleteAllItems
,
1416 audio_mediatype_SetUINT32
,
1417 audio_mediatype_SetUINT64
,
1418 audio_mediatype_SetDouble
,
1419 audio_mediatype_SetGUID
,
1420 audio_mediatype_SetString
,
1421 audio_mediatype_SetBlob
,
1422 audio_mediatype_SetUnknown
,
1423 audio_mediatype_LockStore
,
1424 audio_mediatype_UnlockStore
,
1425 audio_mediatype_GetCount
,
1426 audio_mediatype_GetItemByIndex
,
1427 audio_mediatype_CopyAllItems
,
1428 audio_mediatype_GetMajorType
,
1429 audio_mediatype_IsCompressedFormat
,
1430 audio_mediatype_IsEqual
,
1431 audio_mediatype_GetRepresentation
,
1432 audio_mediatype_FreeRepresentation
,
1433 audio_mediatype_GetAudioFormat
,
1436 static HRESULT
create_media_type(struct media_type
**ret
)
1438 struct media_type
*object
;
1441 if (!(object
= calloc(1, sizeof(*object
))))
1442 return E_OUTOFMEMORY
;
1444 if (FAILED(hr
= init_attributes_object(&object
->attributes
, 0)))
1449 object
->IMFMediaType_iface
.lpVtbl
= &mediatypevtbl
;
1450 object
->IMFVideoMediaType_iface
.lpVtbl
= &videomediatypevtbl
;
1451 object
->IMFAudioMediaType_iface
.lpVtbl
= &audiomediatypevtbl
;
1458 /***********************************************************************
1459 * MFCreateMediaType (mfplat.@)
1461 HRESULT WINAPI
MFCreateMediaType(IMFMediaType
**media_type
)
1463 struct media_type
*object
;
1466 TRACE("%p.\n", media_type
);
1469 return E_INVALIDARG
;
1471 if (FAILED(hr
= create_media_type(&object
)))
1474 *media_type
= &object
->IMFMediaType_iface
;
1476 TRACE("Created media type %p.\n", *media_type
);
1481 static HRESULT WINAPI
stream_descriptor_QueryInterface(IMFStreamDescriptor
*iface
, REFIID riid
, void **out
)
1483 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
1485 if (IsEqualIID(riid
, &IID_IMFStreamDescriptor
) ||
1486 IsEqualIID(riid
, &IID_IMFAttributes
) ||
1487 IsEqualIID(riid
, &IID_IUnknown
))
1490 IMFStreamDescriptor_AddRef(iface
);
1494 WARN("Unsupported %s.\n", debugstr_guid(riid
));
1496 return E_NOINTERFACE
;
1499 static ULONG WINAPI
stream_descriptor_AddRef(IMFStreamDescriptor
*iface
)
1501 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1502 ULONG refcount
= InterlockedIncrement(&stream_desc
->attributes
.ref
);
1504 TRACE("%p, refcount %lu.\n", iface
, refcount
);
1509 static ULONG WINAPI
stream_descriptor_Release(IMFStreamDescriptor
*iface
)
1511 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1512 ULONG refcount
= InterlockedDecrement(&stream_desc
->attributes
.ref
);
1515 TRACE("%p, refcount %lu.\n", iface
, refcount
);
1519 for (i
= 0; i
< stream_desc
->media_types_count
; ++i
)
1521 if (stream_desc
->media_types
[i
])
1522 IMFMediaType_Release(stream_desc
->media_types
[i
]);
1524 free(stream_desc
->media_types
);
1525 if (stream_desc
->current_type
)
1526 IMFMediaType_Release(stream_desc
->current_type
);
1527 clear_attributes_object(&stream_desc
->attributes
);
1534 static HRESULT WINAPI
stream_descriptor_GetItem(IMFStreamDescriptor
*iface
, REFGUID key
, PROPVARIANT
*value
)
1536 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1538 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1540 return attributes_GetItem(&stream_desc
->attributes
, key
, value
);
1543 static HRESULT WINAPI
stream_descriptor_GetItemType(IMFStreamDescriptor
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
1545 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1547 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), type
);
1549 return attributes_GetItemType(&stream_desc
->attributes
, key
, type
);
1552 static HRESULT WINAPI
stream_descriptor_CompareItem(IMFStreamDescriptor
*iface
, REFGUID key
, REFPROPVARIANT value
,
1555 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1557 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
), result
);
1559 return attributes_CompareItem(&stream_desc
->attributes
, key
, value
, result
);
1562 static HRESULT WINAPI
stream_descriptor_Compare(IMFStreamDescriptor
*iface
, IMFAttributes
*theirs
,
1563 MF_ATTRIBUTES_MATCH_TYPE type
, BOOL
*result
)
1565 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1567 TRACE("%p, %p, %d, %p.\n", iface
, theirs
, type
, result
);
1569 return attributes_Compare(&stream_desc
->attributes
, theirs
, type
, result
);
1572 static HRESULT WINAPI
stream_descriptor_GetUINT32(IMFStreamDescriptor
*iface
, REFGUID key
, UINT32
*value
)
1574 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1576 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1578 return attributes_GetUINT32(&stream_desc
->attributes
, key
, value
);
1581 static HRESULT WINAPI
stream_descriptor_GetUINT64(IMFStreamDescriptor
*iface
, REFGUID key
, UINT64
*value
)
1583 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1585 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1587 return attributes_GetUINT64(&stream_desc
->attributes
, key
, value
);
1590 static HRESULT WINAPI
stream_descriptor_GetDouble(IMFStreamDescriptor
*iface
, REFGUID key
, double *value
)
1592 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1594 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1596 return attributes_GetDouble(&stream_desc
->attributes
, key
, value
);
1599 static HRESULT WINAPI
stream_descriptor_GetGUID(IMFStreamDescriptor
*iface
, REFGUID key
, GUID
*value
)
1601 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1603 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
1605 return attributes_GetGUID(&stream_desc
->attributes
, key
, value
);
1608 static HRESULT WINAPI
stream_descriptor_GetStringLength(IMFStreamDescriptor
*iface
, REFGUID key
, UINT32
*length
)
1610 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1612 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), length
);
1614 return attributes_GetStringLength(&stream_desc
->attributes
, key
, length
);
1617 static HRESULT WINAPI
stream_descriptor_GetString(IMFStreamDescriptor
*iface
, REFGUID key
, WCHAR
*value
,
1618 UINT32 size
, UINT32
*length
)
1620 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1622 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), value
, size
, length
);
1624 return attributes_GetString(&stream_desc
->attributes
, key
, value
, size
, length
);
1627 static HRESULT WINAPI
stream_descriptor_GetAllocatedString(IMFStreamDescriptor
*iface
, REFGUID key
,
1628 WCHAR
**value
, UINT32
*length
)
1630 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1632 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), value
, length
);
1634 return attributes_GetAllocatedString(&stream_desc
->attributes
, key
, value
, length
);
1637 static HRESULT WINAPI
stream_descriptor_GetBlobSize(IMFStreamDescriptor
*iface
, REFGUID key
, UINT32
*size
)
1639 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1641 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), size
);
1643 return attributes_GetBlobSize(&stream_desc
->attributes
, key
, size
);
1646 static HRESULT WINAPI
stream_descriptor_GetBlob(IMFStreamDescriptor
*iface
, REFGUID key
, UINT8
*buf
,
1647 UINT32 bufsize
, UINT32
*blobsize
)
1649 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1651 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), buf
, bufsize
, blobsize
);
1653 return attributes_GetBlob(&stream_desc
->attributes
, key
, buf
, bufsize
, blobsize
);
1656 static HRESULT WINAPI
stream_descriptor_GetAllocatedBlob(IMFStreamDescriptor
*iface
, REFGUID key
, UINT8
**buf
,
1659 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1661 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), buf
, size
);
1663 return attributes_GetAllocatedBlob(&stream_desc
->attributes
, key
, buf
, size
);
1666 static HRESULT WINAPI
stream_descriptor_GetUnknown(IMFStreamDescriptor
*iface
, REFGUID key
, REFIID riid
, void **out
)
1668 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1670 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_guid(riid
), out
);
1672 return attributes_GetUnknown(&stream_desc
->attributes
, key
, riid
, out
);
1675 static HRESULT WINAPI
stream_descriptor_SetItem(IMFStreamDescriptor
*iface
, REFGUID key
, REFPROPVARIANT value
)
1677 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1679 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
));
1681 return attributes_SetItem(&stream_desc
->attributes
, key
, value
);
1684 static HRESULT WINAPI
stream_descriptor_DeleteItem(IMFStreamDescriptor
*iface
, REFGUID key
)
1686 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1688 TRACE("%p, %s.\n", iface
, debugstr_attr(key
));
1690 return attributes_DeleteItem(&stream_desc
->attributes
, key
);
1693 static HRESULT WINAPI
stream_descriptor_DeleteAllItems(IMFStreamDescriptor
*iface
)
1695 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1697 TRACE("%p.\n", iface
);
1699 return attributes_DeleteAllItems(&stream_desc
->attributes
);
1702 static HRESULT WINAPI
stream_descriptor_SetUINT32(IMFStreamDescriptor
*iface
, REFGUID key
, UINT32 value
)
1704 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1706 TRACE("%p, %s, %u.\n", iface
, debugstr_attr(key
), value
);
1708 return attributes_SetUINT32(&stream_desc
->attributes
, key
, value
);
1711 static HRESULT WINAPI
stream_descriptor_SetUINT64(IMFStreamDescriptor
*iface
, REFGUID key
, UINT64 value
)
1713 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1715 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), wine_dbgstr_longlong(value
));
1717 return attributes_SetUINT64(&stream_desc
->attributes
, key
, value
);
1720 static HRESULT WINAPI
stream_descriptor_SetDouble(IMFStreamDescriptor
*iface
, REFGUID key
, double value
)
1722 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1724 TRACE("%p, %s, %f.\n", iface
, debugstr_attr(key
), value
);
1726 return attributes_SetDouble(&stream_desc
->attributes
, key
, value
);
1729 static HRESULT WINAPI
stream_descriptor_SetGUID(IMFStreamDescriptor
*iface
, REFGUID key
, REFGUID value
)
1731 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1733 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_mf_guid(value
));
1735 return attributes_SetGUID(&stream_desc
->attributes
, key
, value
);
1738 static HRESULT WINAPI
stream_descriptor_SetString(IMFStreamDescriptor
*iface
, REFGUID key
, const WCHAR
*value
)
1740 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1742 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_w(value
));
1744 return attributes_SetString(&stream_desc
->attributes
, key
, value
);
1747 static HRESULT WINAPI
stream_descriptor_SetBlob(IMFStreamDescriptor
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
1749 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1751 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_attr(key
), buf
, size
);
1753 return attributes_SetBlob(&stream_desc
->attributes
, key
, buf
, size
);
1756 static HRESULT WINAPI
stream_descriptor_SetUnknown(IMFStreamDescriptor
*iface
, REFGUID key
, IUnknown
*unknown
)
1758 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1760 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), unknown
);
1762 return attributes_SetUnknown(&stream_desc
->attributes
, key
, unknown
);
1765 static HRESULT WINAPI
stream_descriptor_LockStore(IMFStreamDescriptor
*iface
)
1767 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1769 TRACE("%p.\n", iface
);
1771 return attributes_LockStore(&stream_desc
->attributes
);
1774 static HRESULT WINAPI
stream_descriptor_UnlockStore(IMFStreamDescriptor
*iface
)
1776 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1778 TRACE("%p.\n", iface
);
1780 return attributes_UnlockStore(&stream_desc
->attributes
);
1783 static HRESULT WINAPI
stream_descriptor_GetCount(IMFStreamDescriptor
*iface
, UINT32
*count
)
1785 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1787 TRACE("%p, %p.\n", iface
, count
);
1789 return attributes_GetCount(&stream_desc
->attributes
, count
);
1792 static HRESULT WINAPI
stream_descriptor_GetItemByIndex(IMFStreamDescriptor
*iface
, UINT32 index
, GUID
*key
,
1795 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1797 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
1799 return attributes_GetItemByIndex(&stream_desc
->attributes
, index
, key
, value
);
1802 static HRESULT WINAPI
stream_descriptor_CopyAllItems(IMFStreamDescriptor
*iface
, IMFAttributes
*dest
)
1804 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1806 TRACE("%p, %p.\n", iface
, dest
);
1808 return attributes_CopyAllItems(&stream_desc
->attributes
, dest
);
1811 static HRESULT WINAPI
stream_descriptor_GetStreamIdentifier(IMFStreamDescriptor
*iface
, DWORD
*identifier
)
1813 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1815 TRACE("%p, %p.\n", iface
, identifier
);
1817 *identifier
= stream_desc
->identifier
;
1822 static HRESULT WINAPI
stream_descriptor_GetMediaTypeHandler(IMFStreamDescriptor
*iface
, IMFMediaTypeHandler
**handler
)
1824 struct stream_desc
*stream_desc
= impl_from_IMFStreamDescriptor(iface
);
1826 TRACE("%p, %p.\n", iface
, handler
);
1828 *handler
= &stream_desc
->IMFMediaTypeHandler_iface
;
1829 IMFMediaTypeHandler_AddRef(*handler
);
1834 static const IMFStreamDescriptorVtbl streamdescriptorvtbl
=
1836 stream_descriptor_QueryInterface
,
1837 stream_descriptor_AddRef
,
1838 stream_descriptor_Release
,
1839 stream_descriptor_GetItem
,
1840 stream_descriptor_GetItemType
,
1841 stream_descriptor_CompareItem
,
1842 stream_descriptor_Compare
,
1843 stream_descriptor_GetUINT32
,
1844 stream_descriptor_GetUINT64
,
1845 stream_descriptor_GetDouble
,
1846 stream_descriptor_GetGUID
,
1847 stream_descriptor_GetStringLength
,
1848 stream_descriptor_GetString
,
1849 stream_descriptor_GetAllocatedString
,
1850 stream_descriptor_GetBlobSize
,
1851 stream_descriptor_GetBlob
,
1852 stream_descriptor_GetAllocatedBlob
,
1853 stream_descriptor_GetUnknown
,
1854 stream_descriptor_SetItem
,
1855 stream_descriptor_DeleteItem
,
1856 stream_descriptor_DeleteAllItems
,
1857 stream_descriptor_SetUINT32
,
1858 stream_descriptor_SetUINT64
,
1859 stream_descriptor_SetDouble
,
1860 stream_descriptor_SetGUID
,
1861 stream_descriptor_SetString
,
1862 stream_descriptor_SetBlob
,
1863 stream_descriptor_SetUnknown
,
1864 stream_descriptor_LockStore
,
1865 stream_descriptor_UnlockStore
,
1866 stream_descriptor_GetCount
,
1867 stream_descriptor_GetItemByIndex
,
1868 stream_descriptor_CopyAllItems
,
1869 stream_descriptor_GetStreamIdentifier
,
1870 stream_descriptor_GetMediaTypeHandler
1873 static HRESULT WINAPI
mediatype_handler_QueryInterface(IMFMediaTypeHandler
*iface
, REFIID riid
, void **obj
)
1875 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
1877 if (IsEqualIID(riid
, &IID_IMFMediaTypeHandler
) ||
1878 IsEqualIID(riid
, &IID_IUnknown
))
1881 IMFMediaTypeHandler_AddRef(iface
);
1885 WARN("Unsupported %s.\n", debugstr_guid(riid
));
1887 return E_NOINTERFACE
;
1890 static ULONG WINAPI
mediatype_handler_AddRef(IMFMediaTypeHandler
*iface
)
1892 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1893 return IMFStreamDescriptor_AddRef(&stream_desc
->IMFStreamDescriptor_iface
);
1896 static ULONG WINAPI
mediatype_handler_Release(IMFMediaTypeHandler
*iface
)
1898 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1899 return IMFStreamDescriptor_Release(&stream_desc
->IMFStreamDescriptor_iface
);
1902 static BOOL
stream_descriptor_is_mediatype_supported(IMFMediaType
*media_type
, IMFMediaType
*candidate
)
1906 if (FAILED(IMFMediaType_IsEqual(media_type
, candidate
, &flags
)))
1909 return (flags
& (MF_MEDIATYPE_EQUAL_MAJOR_TYPES
| MF_MEDIATYPE_EQUAL_FORMAT_TYPES
)) ==
1910 (MF_MEDIATYPE_EQUAL_MAJOR_TYPES
| MF_MEDIATYPE_EQUAL_FORMAT_TYPES
);
1913 static HRESULT WINAPI
mediatype_handler_IsMediaTypeSupported(IMFMediaTypeHandler
*iface
, IMFMediaType
*in_type
,
1914 IMFMediaType
**out_type
)
1916 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1917 BOOL supported
= FALSE
;
1920 TRACE("%p, %p, %p.\n", iface
, in_type
, out_type
);
1928 EnterCriticalSection(&stream_desc
->attributes
.cs
);
1930 supported
= stream_desc
->current_type
&& stream_descriptor_is_mediatype_supported(stream_desc
->current_type
, in_type
);
1933 for (i
= 0; i
< stream_desc
->media_types_count
; ++i
)
1935 if ((supported
= stream_descriptor_is_mediatype_supported(stream_desc
->media_types
[i
], in_type
)))
1940 LeaveCriticalSection(&stream_desc
->attributes
.cs
);
1942 return supported
? S_OK
: MF_E_INVALIDMEDIATYPE
;
1945 static HRESULT WINAPI
mediatype_handler_GetMediaTypeCount(IMFMediaTypeHandler
*iface
, DWORD
*count
)
1947 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1949 TRACE("%p, %p.\n", iface
, count
);
1951 *count
= stream_desc
->media_types_count
;
1956 static HRESULT WINAPI
mediatype_handler_GetMediaTypeByIndex(IMFMediaTypeHandler
*iface
, DWORD index
,
1957 IMFMediaType
**type
)
1959 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1961 TRACE("%p, %lu, %p.\n", iface
, index
, type
);
1963 if (index
>= stream_desc
->media_types_count
)
1964 return MF_E_NO_MORE_TYPES
;
1966 if (stream_desc
->media_types
[index
])
1968 *type
= stream_desc
->media_types
[index
];
1969 IMFMediaType_AddRef(*type
);
1972 return stream_desc
->media_types
[index
] ? S_OK
: E_FAIL
;
1975 static HRESULT WINAPI
mediatype_handler_SetCurrentMediaType(IMFMediaTypeHandler
*iface
, IMFMediaType
*type
)
1977 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1979 TRACE("%p, %p.\n", iface
, type
);
1984 EnterCriticalSection(&stream_desc
->attributes
.cs
);
1985 if (stream_desc
->current_type
)
1986 IMFMediaType_Release(stream_desc
->current_type
);
1987 stream_desc
->current_type
= type
;
1988 IMFMediaType_AddRef(stream_desc
->current_type
);
1989 LeaveCriticalSection(&stream_desc
->attributes
.cs
);
1994 static HRESULT WINAPI
mediatype_handler_GetCurrentMediaType(IMFMediaTypeHandler
*iface
, IMFMediaType
**type
)
1996 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
1999 TRACE("%p, %p.\n", iface
, type
);
2001 EnterCriticalSection(&stream_desc
->attributes
.cs
);
2002 if (stream_desc
->current_type
)
2004 *type
= stream_desc
->current_type
;
2005 IMFMediaType_AddRef(*type
);
2008 hr
= MF_E_NOT_INITIALIZED
;
2009 LeaveCriticalSection(&stream_desc
->attributes
.cs
);
2014 static HRESULT WINAPI
mediatype_handler_GetMajorType(IMFMediaTypeHandler
*iface
, GUID
*type
)
2016 struct stream_desc
*stream_desc
= impl_from_IMFMediaTypeHandler(iface
);
2019 TRACE("%p, %p.\n", iface
, type
);
2021 EnterCriticalSection(&stream_desc
->attributes
.cs
);
2022 hr
= IMFMediaType_GetGUID(stream_desc
->current_type
? stream_desc
->current_type
:
2023 stream_desc
->media_types
[0], &MF_MT_MAJOR_TYPE
, type
);
2024 LeaveCriticalSection(&stream_desc
->attributes
.cs
);
2029 static const IMFMediaTypeHandlerVtbl mediatypehandlervtbl
=
2031 mediatype_handler_QueryInterface
,
2032 mediatype_handler_AddRef
,
2033 mediatype_handler_Release
,
2034 mediatype_handler_IsMediaTypeSupported
,
2035 mediatype_handler_GetMediaTypeCount
,
2036 mediatype_handler_GetMediaTypeByIndex
,
2037 mediatype_handler_SetCurrentMediaType
,
2038 mediatype_handler_GetCurrentMediaType
,
2039 mediatype_handler_GetMajorType
,
2042 /***********************************************************************
2043 * MFCreateStreamDescriptor (mfplat.@)
2045 HRESULT WINAPI
MFCreateStreamDescriptor(DWORD identifier
, DWORD count
,
2046 IMFMediaType
**types
, IMFStreamDescriptor
**descriptor
)
2048 struct stream_desc
*object
;
2052 TRACE("%ld, %ld, %p, %p.\n", identifier
, count
, types
, descriptor
);
2055 return E_INVALIDARG
;
2057 if (!(object
= calloc(1, sizeof(*object
))))
2058 return E_OUTOFMEMORY
;
2060 if (FAILED(hr
= init_attributes_object(&object
->attributes
, 0)))
2065 object
->IMFStreamDescriptor_iface
.lpVtbl
= &streamdescriptorvtbl
;
2066 object
->IMFMediaTypeHandler_iface
.lpVtbl
= &mediatypehandlervtbl
;
2067 object
->identifier
= identifier
;
2068 object
->media_types
= calloc(count
, sizeof(*object
->media_types
));
2069 if (!object
->media_types
)
2071 IMFStreamDescriptor_Release(&object
->IMFStreamDescriptor_iface
);
2072 return E_OUTOFMEMORY
;
2074 for (i
= 0; i
< count
; ++i
)
2076 object
->media_types
[i
] = types
[i
];
2077 if (object
->media_types
[i
])
2078 IMFMediaType_AddRef(object
->media_types
[i
]);
2080 object
->media_types_count
= count
;
2082 *descriptor
= &object
->IMFStreamDescriptor_iface
;
2087 static HRESULT WINAPI
presentation_descriptor_QueryInterface(IMFPresentationDescriptor
*iface
, REFIID riid
, void **out
)
2089 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
2091 if (IsEqualIID(riid
, &IID_IMFPresentationDescriptor
) ||
2092 IsEqualIID(riid
, &IID_IMFAttributes
) ||
2093 IsEqualIID(riid
, &IID_IUnknown
))
2096 IMFPresentationDescriptor_AddRef(iface
);
2100 WARN("Unsupported %s.\n", debugstr_guid(riid
));
2102 return E_NOINTERFACE
;
2105 static ULONG WINAPI
presentation_descriptor_AddRef(IMFPresentationDescriptor
*iface
)
2107 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2108 ULONG refcount
= InterlockedIncrement(&presentation_desc
->attributes
.ref
);
2110 TRACE("%p, refcount %lu.\n", iface
, refcount
);
2115 static ULONG WINAPI
presentation_descriptor_Release(IMFPresentationDescriptor
*iface
)
2117 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2118 ULONG refcount
= InterlockedDecrement(&presentation_desc
->attributes
.ref
);
2121 TRACE("%p, refcount %lu.\n", iface
, refcount
);
2125 for (i
= 0; i
< presentation_desc
->count
; ++i
)
2127 if (presentation_desc
->descriptors
[i
].descriptor
)
2128 IMFStreamDescriptor_Release(presentation_desc
->descriptors
[i
].descriptor
);
2130 clear_attributes_object(&presentation_desc
->attributes
);
2131 free(presentation_desc
->descriptors
);
2132 free(presentation_desc
);
2138 static HRESULT WINAPI
presentation_descriptor_GetItem(IMFPresentationDescriptor
*iface
, REFGUID key
,
2141 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2143 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
2145 return attributes_GetItem(&presentation_desc
->attributes
, key
, value
);
2148 static HRESULT WINAPI
presentation_descriptor_GetItemType(IMFPresentationDescriptor
*iface
, REFGUID key
,
2149 MF_ATTRIBUTE_TYPE
*type
)
2151 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2153 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), type
);
2155 return attributes_GetItemType(&presentation_desc
->attributes
, key
, type
);
2158 static HRESULT WINAPI
presentation_descriptor_CompareItem(IMFPresentationDescriptor
*iface
, REFGUID key
,
2159 REFPROPVARIANT value
, BOOL
*result
)
2161 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2163 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
), result
);
2165 return attributes_CompareItem(&presentation_desc
->attributes
, key
, value
, result
);
2168 static HRESULT WINAPI
presentation_descriptor_Compare(IMFPresentationDescriptor
*iface
, IMFAttributes
*attrs
,
2169 MF_ATTRIBUTES_MATCH_TYPE type
, BOOL
*result
)
2171 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2173 TRACE("%p, %p, %d, %p.\n", iface
, attrs
, type
, result
);
2175 return attributes_Compare(&presentation_desc
->attributes
, attrs
, type
, result
);
2178 static HRESULT WINAPI
presentation_descriptor_GetUINT32(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT32
*value
)
2180 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2182 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
2184 return attributes_GetUINT32(&presentation_desc
->attributes
, key
, value
);
2187 static HRESULT WINAPI
presentation_descriptor_GetUINT64(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT64
*value
)
2189 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2191 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
2193 return attributes_GetUINT64(&presentation_desc
->attributes
, key
, value
);
2196 static HRESULT WINAPI
presentation_descriptor_GetDouble(IMFPresentationDescriptor
*iface
, REFGUID key
, double *value
)
2198 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2200 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
2202 return attributes_GetDouble(&presentation_desc
->attributes
, key
, value
);
2205 static HRESULT WINAPI
presentation_descriptor_GetGUID(IMFPresentationDescriptor
*iface
, REFGUID key
, GUID
*value
)
2207 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2209 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), value
);
2211 return attributes_GetGUID(&presentation_desc
->attributes
, key
, value
);
2214 static HRESULT WINAPI
presentation_descriptor_GetStringLength(IMFPresentationDescriptor
*iface
, REFGUID key
,
2217 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2219 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), length
);
2221 return attributes_GetStringLength(&presentation_desc
->attributes
, key
, length
);
2224 static HRESULT WINAPI
presentation_descriptor_GetString(IMFPresentationDescriptor
*iface
, REFGUID key
, WCHAR
*value
,
2225 UINT32 size
, UINT32
*length
)
2227 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2229 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), value
, size
, length
);
2231 return attributes_GetString(&presentation_desc
->attributes
, key
, value
, size
, length
);
2234 static HRESULT WINAPI
presentation_descriptor_GetAllocatedString(IMFPresentationDescriptor
*iface
, REFGUID key
,
2235 WCHAR
**value
, UINT32
*length
)
2237 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2239 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), value
, length
);
2241 return attributes_GetAllocatedString(&presentation_desc
->attributes
, key
, value
, length
);
2244 static HRESULT WINAPI
presentation_descriptor_GetBlobSize(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT32
*size
)
2246 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2248 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), size
);
2250 return attributes_GetBlobSize(&presentation_desc
->attributes
, key
, size
);
2253 static HRESULT WINAPI
presentation_descriptor_GetBlob(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT8
*buf
,
2254 UINT32 bufsize
, UINT32
*blobsize
)
2256 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2258 TRACE("%p, %s, %p, %u, %p.\n", iface
, debugstr_attr(key
), buf
, bufsize
, blobsize
);
2260 return attributes_GetBlob(&presentation_desc
->attributes
, key
, buf
, bufsize
, blobsize
);
2263 static HRESULT WINAPI
presentation_descriptor_GetAllocatedBlob(IMFPresentationDescriptor
*iface
, REFGUID key
,
2264 UINT8
**buf
, UINT32
*size
)
2266 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2268 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_attr(key
), buf
, size
);
2270 return attributes_GetAllocatedBlob(&presentation_desc
->attributes
, key
, buf
, size
);
2273 static HRESULT WINAPI
presentation_descriptor_GetUnknown(IMFPresentationDescriptor
*iface
, REFGUID key
,
2274 REFIID riid
, void **out
)
2276 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2278 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_attr(key
), debugstr_guid(riid
), out
);
2280 return attributes_GetUnknown(&presentation_desc
->attributes
, key
, riid
, out
);
2283 static HRESULT WINAPI
presentation_descriptor_SetItem(IMFPresentationDescriptor
*iface
, REFGUID key
,
2284 REFPROPVARIANT value
)
2286 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2288 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_propvar(value
));
2290 return attributes_SetItem(&presentation_desc
->attributes
, key
, value
);
2293 static HRESULT WINAPI
presentation_descriptor_DeleteItem(IMFPresentationDescriptor
*iface
, REFGUID key
)
2295 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2297 TRACE("%p, %s.\n", iface
, debugstr_attr(key
));
2299 return attributes_DeleteItem(&presentation_desc
->attributes
, key
);
2302 static HRESULT WINAPI
presentation_descriptor_DeleteAllItems(IMFPresentationDescriptor
*iface
)
2304 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2306 TRACE("%p.\n", iface
);
2308 return attributes_DeleteAllItems(&presentation_desc
->attributes
);
2311 static HRESULT WINAPI
presentation_descriptor_SetUINT32(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT32 value
)
2313 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2315 TRACE("%p, %s, %u.\n", iface
, debugstr_attr(key
), value
);
2317 return attributes_SetUINT32(&presentation_desc
->attributes
, key
, value
);
2320 static HRESULT WINAPI
presentation_descriptor_SetUINT64(IMFPresentationDescriptor
*iface
, REFGUID key
, UINT64 value
)
2322 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2324 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), wine_dbgstr_longlong(value
));
2326 return attributes_SetUINT64(&presentation_desc
->attributes
, key
, value
);
2329 static HRESULT WINAPI
presentation_descriptor_SetDouble(IMFPresentationDescriptor
*iface
, REFGUID key
, double value
)
2331 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2333 TRACE("%p, %s, %f.\n", iface
, debugstr_attr(key
), value
);
2335 return attributes_SetDouble(&presentation_desc
->attributes
, key
, value
);
2338 static HRESULT WINAPI
presentation_descriptor_SetGUID(IMFPresentationDescriptor
*iface
, REFGUID key
, REFGUID value
)
2340 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2342 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_mf_guid(value
));
2344 return attributes_SetGUID(&presentation_desc
->attributes
, key
, value
);
2347 static HRESULT WINAPI
presentation_descriptor_SetString(IMFPresentationDescriptor
*iface
, REFGUID key
,
2350 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2352 TRACE("%p, %s, %s.\n", iface
, debugstr_attr(key
), debugstr_w(value
));
2354 return attributes_SetString(&presentation_desc
->attributes
, key
, value
);
2357 static HRESULT WINAPI
presentation_descriptor_SetBlob(IMFPresentationDescriptor
*iface
, REFGUID key
, const UINT8
*buf
,
2360 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2362 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_attr(key
), buf
, size
);
2364 return attributes_SetBlob(&presentation_desc
->attributes
, key
, buf
, size
);
2367 static HRESULT WINAPI
presentation_descriptor_SetUnknown(IMFPresentationDescriptor
*iface
, REFGUID key
,
2370 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2372 TRACE("%p, %s, %p.\n", iface
, debugstr_attr(key
), unknown
);
2374 return attributes_SetUnknown(&presentation_desc
->attributes
, key
, unknown
);
2377 static HRESULT WINAPI
presentation_descriptor_LockStore(IMFPresentationDescriptor
*iface
)
2379 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2381 TRACE("%p.\n", iface
);
2383 return attributes_LockStore(&presentation_desc
->attributes
);
2386 static HRESULT WINAPI
presentation_descriptor_UnlockStore(IMFPresentationDescriptor
*iface
)
2388 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2390 TRACE("%p.\n", iface
);
2392 return attributes_UnlockStore(&presentation_desc
->attributes
);
2395 static HRESULT WINAPI
presentation_descriptor_GetCount(IMFPresentationDescriptor
*iface
, UINT32
*count
)
2397 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2399 TRACE("%p, %p.\n", iface
, count
);
2401 return attributes_GetCount(&presentation_desc
->attributes
, count
);
2404 static HRESULT WINAPI
presentation_descriptor_GetItemByIndex(IMFPresentationDescriptor
*iface
, UINT32 index
, GUID
*key
,
2407 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2409 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
2411 return attributes_GetItemByIndex(&presentation_desc
->attributes
, index
, key
, value
);
2414 static HRESULT WINAPI
presentation_descriptor_CopyAllItems(IMFPresentationDescriptor
*iface
, IMFAttributes
*dest
)
2416 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2418 TRACE("%p, %p.\n", iface
, dest
);
2420 return attributes_CopyAllItems(&presentation_desc
->attributes
, dest
);
2423 static HRESULT WINAPI
presentation_descriptor_GetStreamDescriptorCount(IMFPresentationDescriptor
*iface
, DWORD
*count
)
2425 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2427 TRACE("%p, %p.\n", iface
, count
);
2429 *count
= presentation_desc
->count
;
2434 static HRESULT WINAPI
presentation_descriptor_GetStreamDescriptorByIndex(IMFPresentationDescriptor
*iface
, DWORD index
,
2435 BOOL
*selected
, IMFStreamDescriptor
**descriptor
)
2437 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2439 TRACE("%p, %lu, %p, %p.\n", iface
, index
, selected
, descriptor
);
2441 if (index
>= presentation_desc
->count
)
2442 return E_INVALIDARG
;
2444 EnterCriticalSection(&presentation_desc
->attributes
.cs
);
2445 *selected
= presentation_desc
->descriptors
[index
].selected
;
2446 LeaveCriticalSection(&presentation_desc
->attributes
.cs
);
2448 *descriptor
= presentation_desc
->descriptors
[index
].descriptor
;
2449 IMFStreamDescriptor_AddRef(*descriptor
);
2454 static HRESULT WINAPI
presentation_descriptor_SelectStream(IMFPresentationDescriptor
*iface
, DWORD index
)
2456 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2458 TRACE("%p, %lu.\n", iface
, index
);
2460 if (index
>= presentation_desc
->count
)
2461 return E_INVALIDARG
;
2463 EnterCriticalSection(&presentation_desc
->attributes
.cs
);
2464 presentation_desc
->descriptors
[index
].selected
= TRUE
;
2465 LeaveCriticalSection(&presentation_desc
->attributes
.cs
);
2470 static HRESULT WINAPI
presentation_descriptor_DeselectStream(IMFPresentationDescriptor
*iface
, DWORD index
)
2472 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2474 TRACE("%p, %lu.\n", iface
, index
);
2476 if (index
>= presentation_desc
->count
)
2477 return E_INVALIDARG
;
2479 EnterCriticalSection(&presentation_desc
->attributes
.cs
);
2480 presentation_desc
->descriptors
[index
].selected
= FALSE
;
2481 LeaveCriticalSection(&presentation_desc
->attributes
.cs
);
2486 static HRESULT WINAPI
presentation_descriptor_Clone(IMFPresentationDescriptor
*iface
,
2487 IMFPresentationDescriptor
**descriptor
)
2489 struct presentation_desc
*presentation_desc
= impl_from_IMFPresentationDescriptor(iface
);
2490 struct presentation_desc
*object
;
2493 TRACE("%p, %p.\n", iface
, descriptor
);
2495 if (!(object
= calloc(1, sizeof(*object
))))
2496 return E_OUTOFMEMORY
;
2498 presentation_descriptor_init(object
, presentation_desc
->count
);
2500 EnterCriticalSection(&presentation_desc
->attributes
.cs
);
2502 for (i
= 0; i
< presentation_desc
->count
; ++i
)
2504 object
->descriptors
[i
] = presentation_desc
->descriptors
[i
];
2505 IMFStreamDescriptor_AddRef(object
->descriptors
[i
].descriptor
);
2508 attributes_CopyAllItems(&presentation_desc
->attributes
, (IMFAttributes
*)&object
->IMFPresentationDescriptor_iface
);
2510 LeaveCriticalSection(&presentation_desc
->attributes
.cs
);
2512 *descriptor
= &object
->IMFPresentationDescriptor_iface
;
2517 static const IMFPresentationDescriptorVtbl presentationdescriptorvtbl
=
2519 presentation_descriptor_QueryInterface
,
2520 presentation_descriptor_AddRef
,
2521 presentation_descriptor_Release
,
2522 presentation_descriptor_GetItem
,
2523 presentation_descriptor_GetItemType
,
2524 presentation_descriptor_CompareItem
,
2525 presentation_descriptor_Compare
,
2526 presentation_descriptor_GetUINT32
,
2527 presentation_descriptor_GetUINT64
,
2528 presentation_descriptor_GetDouble
,
2529 presentation_descriptor_GetGUID
,
2530 presentation_descriptor_GetStringLength
,
2531 presentation_descriptor_GetString
,
2532 presentation_descriptor_GetAllocatedString
,
2533 presentation_descriptor_GetBlobSize
,
2534 presentation_descriptor_GetBlob
,
2535 presentation_descriptor_GetAllocatedBlob
,
2536 presentation_descriptor_GetUnknown
,
2537 presentation_descriptor_SetItem
,
2538 presentation_descriptor_DeleteItem
,
2539 presentation_descriptor_DeleteAllItems
,
2540 presentation_descriptor_SetUINT32
,
2541 presentation_descriptor_SetUINT64
,
2542 presentation_descriptor_SetDouble
,
2543 presentation_descriptor_SetGUID
,
2544 presentation_descriptor_SetString
,
2545 presentation_descriptor_SetBlob
,
2546 presentation_descriptor_SetUnknown
,
2547 presentation_descriptor_LockStore
,
2548 presentation_descriptor_UnlockStore
,
2549 presentation_descriptor_GetCount
,
2550 presentation_descriptor_GetItemByIndex
,
2551 presentation_descriptor_CopyAllItems
,
2552 presentation_descriptor_GetStreamDescriptorCount
,
2553 presentation_descriptor_GetStreamDescriptorByIndex
,
2554 presentation_descriptor_SelectStream
,
2555 presentation_descriptor_DeselectStream
,
2556 presentation_descriptor_Clone
,
2559 static HRESULT
presentation_descriptor_init(struct presentation_desc
*object
, DWORD count
)
2563 if (FAILED(hr
= init_attributes_object(&object
->attributes
, 0)))
2565 object
->IMFPresentationDescriptor_iface
.lpVtbl
= &presentationdescriptorvtbl
;
2566 if (!(object
->descriptors
= calloc(count
, sizeof(*object
->descriptors
))))
2568 IMFPresentationDescriptor_Release(&object
->IMFPresentationDescriptor_iface
);
2569 return E_OUTOFMEMORY
;
2571 object
->count
= count
;
2576 /***********************************************************************
2577 * MFCreatePresentationDescriptor (mfplat.@)
2579 HRESULT WINAPI
MFCreatePresentationDescriptor(DWORD count
, IMFStreamDescriptor
**descriptors
,
2580 IMFPresentationDescriptor
**out
)
2582 struct presentation_desc
*object
;
2586 TRACE("%lu, %p, %p.\n", count
, descriptors
, out
);
2589 return E_INVALIDARG
;
2591 for (i
= 0; i
< count
; ++i
)
2593 if (!descriptors
[i
])
2594 return E_INVALIDARG
;
2597 if (!(object
= calloc(1, sizeof(*object
))))
2598 return E_OUTOFMEMORY
;
2600 if (FAILED(hr
= presentation_descriptor_init(object
, count
)))
2606 for (i
= 0; i
< count
; ++i
)
2608 object
->descriptors
[i
].descriptor
= descriptors
[i
];
2609 IMFStreamDescriptor_AddRef(object
->descriptors
[i
].descriptor
);
2612 *out
= &object
->IMFPresentationDescriptor_iface
;
2617 struct uncompressed_video_format
2619 const GUID
*subtype
;
2620 unsigned char bytes_per_pixel
;
2621 unsigned char alignment
;
2622 unsigned char bottom_up
;
2626 static int __cdecl
uncompressed_video_format_compare(const void *a
, const void *b
)
2628 const GUID
*guid
= a
;
2629 const struct uncompressed_video_format
*format
= b
;
2630 return memcmp(guid
, format
->subtype
, sizeof(*guid
));
2633 static const struct uncompressed_video_format video_formats
[] =
2635 { &MFVideoFormat_RGB24
, 3, 3, 1, 0 },
2636 { &MFVideoFormat_ARGB32
, 4, 3, 1, 0 },
2637 { &MFVideoFormat_RGB32
, 4, 3, 1, 0 },
2638 { &MFVideoFormat_RGB565
, 2, 3, 1, 0 },
2639 { &MFVideoFormat_RGB555
, 2, 3, 1, 0 },
2640 { &MFVideoFormat_A2R10G10B10
, 4, 3, 1, 0 },
2641 { &MFVideoFormat_RGB8
, 1, 3, 1, 0 },
2642 { &MFVideoFormat_L8
, 1, 3, 1, 0 },
2643 { &MFVideoFormat_AYUV
, 4, 3, 0, 1 },
2644 { &MFVideoFormat_I420
, 1, 0, 0, 1 },
2645 { &MFVideoFormat_IMC1
, 2, 3, 0, 1 },
2646 { &MFVideoFormat_IMC2
, 1, 0, 0, 1 },
2647 { &MFVideoFormat_IMC3
, 2, 3, 0, 1 },
2648 { &MFVideoFormat_IMC4
, 1, 0, 0, 1 },
2649 { &MFVideoFormat_IYUV
, 1, 0, 0, 1 },
2650 { &MFVideoFormat_NV11
, 1, 0, 0, 1 },
2651 { &MFVideoFormat_NV12
, 1, 0, 0, 1 },
2652 { &MFVideoFormat_D16
, 2, 3, 0, 0 },
2653 { &MFVideoFormat_L16
, 2, 3, 0, 0 },
2654 { &MFVideoFormat_UYVY
, 2, 0, 0, 1 },
2655 { &MFVideoFormat_YUY2
, 2, 0, 0, 1 },
2656 { &MFVideoFormat_YV12
, 1, 0, 0, 1 },
2657 { &MFVideoFormat_YVYU
, 2, 0, 0, 1 },
2658 { &MFVideoFormat_A16B16G16R16F
, 8, 3, 1, 0 },
2659 { &MEDIASUBTYPE_RGB8
, 1, 3, 1, 0 },
2660 { &MEDIASUBTYPE_RGB565
, 2, 3, 1, 0 },
2661 { &MEDIASUBTYPE_RGB555
, 2, 3, 1, 0 },
2662 { &MEDIASUBTYPE_RGB24
, 3, 3, 1, 0 },
2663 { &MEDIASUBTYPE_RGB32
, 4, 3, 1, 0 },
2666 static struct uncompressed_video_format
*mf_get_video_format(const GUID
*subtype
)
2668 return bsearch(subtype
, video_formats
, ARRAY_SIZE(video_formats
), sizeof(*video_formats
),
2669 uncompressed_video_format_compare
);
2672 static unsigned int mf_get_stride_for_format(const struct uncompressed_video_format
*format
, unsigned int width
)
2674 return (width
* format
->bytes_per_pixel
+ format
->alignment
) & ~format
->alignment
;
2677 unsigned int mf_format_get_stride(const GUID
*subtype
, unsigned int width
, BOOL
*is_yuv
)
2679 struct uncompressed_video_format
*format
= mf_get_video_format(subtype
);
2683 *is_yuv
= format
->yuv
;
2684 return mf_get_stride_for_format(format
, width
);
2690 /***********************************************************************
2691 * MFGetStrideForBitmapInfoHeader (mfplat.@)
2693 HRESULT WINAPI
MFGetStrideForBitmapInfoHeader(DWORD fourcc
, DWORD width
, LONG
*stride
)
2695 struct uncompressed_video_format
*format
;
2698 TRACE("%s, %lu, %p.\n", debugstr_fourcc(fourcc
), width
, stride
);
2700 memcpy(&subtype
, &MFVideoFormat_Base
, sizeof(subtype
));
2701 subtype
.Data1
= fourcc
;
2703 if (!(format
= mf_get_video_format(&subtype
)))
2706 return MF_E_INVALIDMEDIATYPE
;
2709 *stride
= mf_get_stride_for_format(format
, width
);
2710 if (format
->bottom_up
)
2716 /***********************************************************************
2717 * MFCalculateImageSize (mfplat.@)
2719 HRESULT WINAPI
MFCalculateImageSize(REFGUID subtype
, UINT32 width
, UINT32 height
, UINT32
*size
)
2721 struct uncompressed_video_format
*format
;
2722 unsigned int stride
;
2724 TRACE("%s, %u, %u, %p.\n", debugstr_mf_guid(subtype
), width
, height
, size
);
2726 if (!(format
= mf_get_video_format(subtype
)))
2729 return E_INVALIDARG
;
2732 switch (subtype
->Data1
)
2734 case MAKEFOURCC('I','M','C','2'):
2735 case MAKEFOURCC('I','M','C','4'):
2736 case MAKEFOURCC('N','V','1','2'):
2737 case MAKEFOURCC('Y','V','1','2'):
2738 case MAKEFOURCC('I','4','2','0'):
2739 case MAKEFOURCC('I','Y','U','V'):
2740 /* 2 x 2 block, interleaving UV for half the height */
2741 *size
= ((width
+ 1) & ~1) * height
* 3 / 2;
2743 case MAKEFOURCC('N','V','1','1'):
2744 *size
= ((width
+ 3) & ~3) * height
* 3 / 2;
2749 *size
= width
* format
->bytes_per_pixel
* height
;
2752 stride
= mf_get_stride_for_format(format
, width
);
2753 *size
= stride
* height
;
2759 /***********************************************************************
2760 * MFGetPlaneSize (mfplat.@)
2762 HRESULT WINAPI
MFGetPlaneSize(DWORD fourcc
, DWORD width
, DWORD height
, DWORD
*size
)
2764 struct uncompressed_video_format
*format
;
2765 unsigned int stride
;
2768 TRACE("%s, %lu, %lu, %p.\n", debugstr_fourcc(fourcc
), width
, height
, size
);
2770 memcpy(&subtype
, &MFVideoFormat_Base
, sizeof(subtype
));
2771 subtype
.Data1
= fourcc
;
2773 if ((format
= mf_get_video_format(&subtype
)))
2774 stride
= mf_get_stride_for_format(format
, width
);
2780 case MAKEFOURCC('I','M','C','2'):
2781 case MAKEFOURCC('I','M','C','4'):
2782 case MAKEFOURCC('N','V','1','2'):
2783 case MAKEFOURCC('Y','V','1','2'):
2784 case MAKEFOURCC('I','4','2','0'):
2785 case MAKEFOURCC('I','Y','U','V'):
2786 case MAKEFOURCC('N','V','1','1'):
2787 *size
= stride
* height
* 3 / 2;
2790 *size
= stride
* height
;
2796 /***********************************************************************
2797 * MFCompareFullToPartialMediaType (mfplat.@)
2799 BOOL WINAPI
MFCompareFullToPartialMediaType(IMFMediaType
*full_type
, IMFMediaType
*partial_type
)
2804 TRACE("%p, %p.\n", full_type
, partial_type
);
2806 if (FAILED(IMFMediaType_GetMajorType(partial_type
, &major
)))
2809 if (FAILED(IMFMediaType_Compare(partial_type
, (IMFAttributes
*)full_type
, MF_ATTRIBUTES_MATCH_OUR_ITEMS
, &result
)))
2815 /***********************************************************************
2816 * MFWrapMediaType (mfplat.@)
2818 HRESULT WINAPI
MFWrapMediaType(IMFMediaType
*original
, REFGUID major
, REFGUID subtype
, IMFMediaType
**ret
)
2820 IMFMediaType
*mediatype
;
2825 TRACE("%p, %s, %s, %p.\n", original
, debugstr_guid(major
), debugstr_guid(subtype
), ret
);
2827 if (FAILED(hr
= MFGetAttributesAsBlobSize((IMFAttributes
*)original
, &size
)))
2830 if (!(buffer
= malloc(size
)))
2831 return E_OUTOFMEMORY
;
2833 if (FAILED(hr
= MFGetAttributesAsBlob((IMFAttributes
*)original
, buffer
, size
)))
2836 if (FAILED(hr
= MFCreateMediaType(&mediatype
)))
2839 if (FAILED(hr
= IMFMediaType_SetGUID(mediatype
, &MF_MT_MAJOR_TYPE
, major
)))
2842 if (FAILED(hr
= IMFMediaType_SetGUID(mediatype
, &MF_MT_SUBTYPE
, subtype
)))
2845 if (FAILED(hr
= IMFMediaType_SetBlob(mediatype
, &MF_MT_WRAPPED_TYPE
, buffer
, size
)))
2856 /***********************************************************************
2857 * MFUnwrapMediaType (mfplat.@)
2859 HRESULT WINAPI
MFUnwrapMediaType(IMFMediaType
*wrapper
, IMFMediaType
**ret
)
2861 IMFMediaType
*mediatype
;
2866 TRACE("%p, %p.\n", wrapper
, ret
);
2868 if (FAILED(hr
= MFCreateMediaType(&mediatype
)))
2871 if (FAILED(hr
= IMFMediaType_GetAllocatedBlob(wrapper
, &MF_MT_WRAPPED_TYPE
, &buffer
, &size
)))
2873 IMFMediaType_Release(mediatype
);
2877 hr
= MFInitAttributesFromBlob((IMFAttributes
*)mediatype
, buffer
, size
);
2878 CoTaskMemFree(buffer
);
2887 /***********************************************************************
2888 * MFCreateWaveFormatExFromMFMediaType (mfplat.@)
2890 HRESULT WINAPI
MFCreateWaveFormatExFromMFMediaType(IMFMediaType
*mediatype
, WAVEFORMATEX
**ret_format
,
2891 UINT32
*size
, UINT32 flags
)
2893 WAVEFORMATEXTENSIBLE
*format_ext
= NULL
;
2894 WAVEFORMATEX
*format
;
2895 GUID major
, subtype
;
2899 TRACE("%p, %p, %p, %#x.\n", mediatype
, ret_format
, size
, flags
);
2901 if (FAILED(hr
= IMFMediaType_GetGUID(mediatype
, &MF_MT_MAJOR_TYPE
, &major
)))
2904 if (FAILED(hr
= IMFMediaType_GetGUID(mediatype
, &MF_MT_SUBTYPE
, &subtype
)))
2907 if (!IsEqualGUID(&major
, &MFMediaType_Audio
))
2908 return E_INVALIDARG
;
2910 if (!IsEqualGUID(&subtype
, &MFAudioFormat_PCM
) && !IsEqualGUID(&subtype
, &MFAudioFormat_Float
))
2912 FIXME("Unsupported audio format %s.\n", debugstr_guid(&subtype
));
2916 /* FIXME: probably WAVE_FORMAT_MPEG/WAVE_FORMAT_MPEGLAYER3 should be handled separately. */
2917 if (flags
== MFWaveFormatExConvertFlag_ForceExtensible
)
2919 format_ext
= CoTaskMemAlloc(sizeof(*format_ext
));
2920 *size
= sizeof(*format_ext
);
2921 format
= (WAVEFORMATEX
*)format_ext
;
2925 format
= CoTaskMemAlloc(sizeof(*format
));
2926 *size
= sizeof(*format
);
2930 return E_OUTOFMEMORY
;
2932 memset(format
, 0, *size
);
2935 format
->wFormatTag
= WAVE_FORMAT_EXTENSIBLE
;
2936 else if (IsEqualGUID(&subtype
, &MFAudioFormat_Float
))
2937 format
->wFormatTag
= WAVE_FORMAT_IEEE_FLOAT
;
2939 format
->wFormatTag
= WAVE_FORMAT_PCM
;
2941 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_NUM_CHANNELS
, &value
)))
2942 format
->nChannels
= value
;
2943 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_SAMPLES_PER_SECOND
, &value
)))
2944 format
->nSamplesPerSec
= value
;
2945 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND
, &value
)))
2946 format
->nAvgBytesPerSec
= value
;
2947 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_BLOCK_ALIGNMENT
, &value
)))
2948 format
->nBlockAlign
= value
;
2949 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_BITS_PER_SAMPLE
, &value
)))
2950 format
->wBitsPerSample
= value
;
2953 format
->cbSize
= sizeof(*format_ext
) - sizeof(*format
);
2955 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE
, &value
)))
2956 format_ext
->Samples
.wSamplesPerBlock
= value
;
2958 if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype
, &MF_MT_AUDIO_CHANNEL_MASK
, &value
)))
2959 format_ext
->dwChannelMask
= value
;
2960 memcpy(&format_ext
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
, sizeof(format_ext
->SubFormat
));
2963 *ret_format
= format
;
2968 static void mediatype_set_uint32(IMFMediaType
*mediatype
, const GUID
*attr
, unsigned int value
, HRESULT
*hr
)
2971 *hr
= IMFMediaType_SetUINT32(mediatype
, attr
, value
);
2974 static void mediatype_set_uint64(IMFMediaType
*mediatype
, const GUID
*attr
, unsigned int high
, unsigned int low
, HRESULT
*hr
)
2977 *hr
= IMFMediaType_SetUINT64(mediatype
, attr
, (UINT64
)high
<< 32 | low
);
2980 static void mediatype_set_guid(IMFMediaType
*mediatype
, const GUID
*attr
, const GUID
*value
, HRESULT
*hr
)
2983 *hr
= IMFMediaType_SetGUID(mediatype
, attr
, value
);
2986 static void mediatype_set_blob(IMFMediaType
*mediatype
, const GUID
*attr
, const UINT8
*data
,
2987 unsigned int size
, HRESULT
*hr
)
2990 *hr
= IMFMediaType_SetBlob(mediatype
, attr
, data
, size
);
2993 /***********************************************************************
2994 * MFInitMediaTypeFromWaveFormatEx (mfplat.@)
2996 HRESULT WINAPI
MFInitMediaTypeFromWaveFormatEx(IMFMediaType
*mediatype
, const WAVEFORMATEX
*format
, UINT32 size
)
2998 const WAVEFORMATEXTENSIBLE
*wfex
= (const WAVEFORMATEXTENSIBLE
*)format
;
3002 TRACE("%p, %p, %u.\n", mediatype
, format
, size
);
3004 if (!mediatype
|| !format
)
3007 if (format
->cbSize
+ sizeof(*format
) > size
)
3008 return E_INVALIDARG
;
3010 hr
= IMFMediaType_DeleteAllItems(mediatype
);
3012 mediatype_set_guid(mediatype
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Audio
, &hr
);
3014 if (format
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
)
3016 memcpy(&subtype
, &wfex
->SubFormat
, sizeof(subtype
));
3018 if (wfex
->dwChannelMask
)
3019 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_CHANNEL_MASK
, wfex
->dwChannelMask
, &hr
);
3021 if (format
->wBitsPerSample
&& wfex
->Samples
.wValidBitsPerSample
)
3022 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE
, wfex
->Samples
.wValidBitsPerSample
, &hr
);
3026 memcpy(&subtype
, &MFAudioFormat_Base
, sizeof(subtype
));
3027 subtype
.Data1
= format
->wFormatTag
;
3029 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_PREFER_WAVEFORMATEX
, 1, &hr
);
3031 mediatype_set_guid(mediatype
, &MF_MT_SUBTYPE
, &subtype
, &hr
);
3033 if (format
->nChannels
)
3034 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_NUM_CHANNELS
, format
->nChannels
, &hr
);
3036 if (format
->nSamplesPerSec
)
3037 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_SAMPLES_PER_SECOND
, format
->nSamplesPerSec
, &hr
);
3039 if (format
->nAvgBytesPerSec
)
3040 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND
, format
->nAvgBytesPerSec
, &hr
);
3042 if (format
->nBlockAlign
)
3043 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_BLOCK_ALIGNMENT
, format
->nBlockAlign
, &hr
);
3045 if (format
->wBitsPerSample
)
3046 mediatype_set_uint32(mediatype
, &MF_MT_AUDIO_BITS_PER_SAMPLE
, format
->wBitsPerSample
, &hr
);
3048 if (IsEqualGUID(&subtype
, &MFAudioFormat_PCM
) ||
3049 IsEqualGUID(&subtype
, &MFAudioFormat_Float
))
3051 mediatype_set_uint32(mediatype
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1, &hr
);
3054 if (format
->cbSize
&& format
->wFormatTag
!= WAVE_FORMAT_EXTENSIBLE
)
3055 mediatype_set_blob(mediatype
, &MF_MT_USER_DATA
, (const UINT8
*)(format
+ 1), format
->cbSize
, &hr
);
3060 /***********************************************************************
3061 * MFCreateVideoMediaTypeFromSubtype (mfplat.@)
3063 HRESULT WINAPI
MFCreateVideoMediaTypeFromSubtype(const GUID
*subtype
, IMFVideoMediaType
**media_type
)
3065 struct media_type
*object
;
3068 TRACE("%s, %p.\n", debugstr_guid(subtype
), media_type
);
3071 return E_INVALIDARG
;
3073 if (FAILED(hr
= create_media_type(&object
)))
3076 IMFMediaType_SetGUID(&object
->IMFMediaType_iface
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Video
);
3077 IMFMediaType_SetGUID(&object
->IMFMediaType_iface
, &MF_MT_SUBTYPE
, subtype
);
3079 *media_type
= &object
->IMFVideoMediaType_iface
;
3084 /***********************************************************************
3085 * MFCreateAudioMediaType (mfplat.@)
3087 HRESULT WINAPI
MFCreateAudioMediaType(const WAVEFORMATEX
*format
, IMFAudioMediaType
**media_type
)
3089 struct media_type
*object
;
3092 TRACE("%p, %p.\n", format
, media_type
);
3095 return E_INVALIDARG
;
3097 if (FAILED(hr
= create_media_type(&object
)))
3100 if (FAILED(hr
= MFInitMediaTypeFromWaveFormatEx(&object
->IMFMediaType_iface
, format
, sizeof(*format
) + format
->cbSize
)))
3102 IMFMediaType_Release(&object
->IMFMediaType_iface
);
3106 *media_type
= &object
->IMFAudioMediaType_iface
;
3111 static void media_type_get_ratio(IMFMediaType
*media_type
, const GUID
*attr
, DWORD
*numerator
,
3116 if (SUCCEEDED(IMFMediaType_GetUINT64(media_type
, attr
, &value
)))
3118 *numerator
= value
>> 32;
3119 *denominator
= value
;
3123 /***********************************************************************
3124 * MFCreateMFVideoFormatFromMFMediaType (mfplat.@)
3126 HRESULT WINAPI
MFCreateMFVideoFormatFromMFMediaType(IMFMediaType
*media_type
, MFVIDEOFORMAT
**video_format
, UINT32
*size
)
3128 UINT32 flags
, palette_size
= 0, value
;
3129 MFVIDEOFORMAT
*format
;
3133 TRACE("%p, %p, %p.\n", media_type
, video_format
, size
);
3135 *size
= sizeof(*format
);
3137 if (SUCCEEDED(IMFMediaType_GetBlobSize(media_type
, &MF_MT_PALETTE
, &palette_size
)))
3138 *size
+= palette_size
;
3140 if (!(format
= CoTaskMemAlloc(*size
)))
3141 return E_OUTOFMEMORY
;
3143 *video_format
= format
;
3145 memset(format
, 0, sizeof(*format
));
3146 format
->dwSize
= *size
;
3148 if (SUCCEEDED(IMFMediaType_GetGUID(media_type
, &MF_MT_SUBTYPE
, &guid
)))
3150 memcpy(&format
->guidFormat
, &guid
, sizeof(guid
));
3151 format
->surfaceInfo
.Format
= guid
.Data1
;
3154 media_type_get_ratio(media_type
, &MF_MT_FRAME_SIZE
, &format
->videoInfo
.dwWidth
, &format
->videoInfo
.dwHeight
);
3155 media_type_get_ratio(media_type
, &MF_MT_PIXEL_ASPECT_RATIO
, &format
->videoInfo
.PixelAspectRatio
.Numerator
,
3156 &format
->videoInfo
.PixelAspectRatio
.Denominator
);
3157 media_type_get_ratio(media_type
, &MF_MT_FRAME_RATE
, &format
->videoInfo
.FramesPerSecond
.Numerator
,
3158 &format
->videoInfo
.FramesPerSecond
.Denominator
);
3160 IMFMediaType_GetUINT32(media_type
, &MF_MT_VIDEO_CHROMA_SITING
, &format
->videoInfo
.SourceChromaSubsampling
);
3161 IMFMediaType_GetUINT32(media_type
, &MF_MT_INTERLACE_MODE
, &format
->videoInfo
.InterlaceMode
);
3162 IMFMediaType_GetUINT32(media_type
, &MF_MT_TRANSFER_FUNCTION
, &format
->videoInfo
.TransferFunction
);
3163 IMFMediaType_GetUINT32(media_type
, &MF_MT_VIDEO_PRIMARIES
, &format
->videoInfo
.ColorPrimaries
);
3164 IMFMediaType_GetUINT32(media_type
, &MF_MT_YUV_MATRIX
, &format
->videoInfo
.TransferMatrix
);
3165 IMFMediaType_GetUINT32(media_type
, &MF_MT_VIDEO_LIGHTING
, &format
->videoInfo
.SourceLighting
);
3166 IMFMediaType_GetUINT32(media_type
, &MF_MT_VIDEO_NOMINAL_RANGE
, &format
->videoInfo
.NominalRange
);
3167 IMFMediaType_GetBlob(media_type
, &MF_MT_GEOMETRIC_APERTURE
, (UINT8
*)&format
->videoInfo
.GeometricAperture
,
3168 sizeof(format
->videoInfo
.GeometricAperture
), NULL
);
3169 IMFMediaType_GetBlob(media_type
, &MF_MT_MINIMUM_DISPLAY_APERTURE
, (UINT8
*)&format
->videoInfo
.MinimumDisplayAperture
,
3170 sizeof(format
->videoInfo
.MinimumDisplayAperture
), NULL
);
3173 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_PAD_CONTROL_FLAGS
, &flags
)))
3174 format
->videoInfo
.VideoFlags
|= flags
;
3175 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_SOURCE_CONTENT_HINT
, &flags
)))
3176 format
->videoInfo
.VideoFlags
|= flags
;
3177 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_DRM_FLAGS
, &flags
)))
3178 format
->videoInfo
.VideoFlags
|= flags
;
3179 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_PAN_SCAN_ENABLED
, &flags
)) && !!flags
)
3181 format
->videoInfo
.VideoFlags
|= MFVideoFlag_PanScanEnabled
;
3182 IMFMediaType_GetBlob(media_type
, &MF_MT_PAN_SCAN_APERTURE
, (UINT8
*)&format
->videoInfo
.PanScanAperture
,
3183 sizeof(format
->videoInfo
.PanScanAperture
), NULL
);
3185 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_DEFAULT_STRIDE
, (UINT32
*)&stride
)) && stride
< 0)
3186 format
->videoInfo
.VideoFlags
|= MFVideoFlag_BottomUpLinearRep
;
3188 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_AVG_BITRATE
, &value
)))
3189 format
->compressedInfo
.AvgBitrate
= value
;
3190 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_AVG_BIT_ERROR_RATE
, &value
)))
3191 format
->compressedInfo
.AvgBitErrorRate
= value
;
3192 if (SUCCEEDED(IMFMediaType_GetUINT32(media_type
, &MF_MT_MAX_KEYFRAME_SPACING
, &value
)))
3193 format
->compressedInfo
.MaxKeyFrameSpacing
= value
;
3198 format
->surfaceInfo
.PaletteEntries
= palette_size
/ sizeof(*format
->surfaceInfo
.Palette
);
3199 IMFMediaType_GetBlob(media_type
, &MF_MT_PALETTE
, (UINT8
*)format
->surfaceInfo
.Palette
, palette_size
, NULL
);
3205 /***********************************************************************
3206 * MFConvertColorInfoToDXVA (mfplat.@)
3208 HRESULT WINAPI
MFConvertColorInfoToDXVA(DWORD
*dxva_info
, const MFVIDEOFORMAT
*format
)
3212 UINT SampleFormat
: 8;
3213 UINT VideoChromaSubsampling
: 4;
3214 UINT NominalRange
: 3;
3215 UINT VideoTransferMatrix
: 3;
3216 UINT VideoLighting
: 4;
3217 UINT VideoPrimaries
: 5;
3218 UINT VideoTransferFunction
: 5;
3219 } *dxva_format
= (void *)dxva_info
;
3221 TRACE("%p, %p.\n", dxva_info
, format
);
3223 if (format
->videoInfo
.InterlaceMode
== MFVideoInterlace_MixedInterlaceOrProgressive
)
3224 dxva_format
->SampleFormat
= DXVA2_SampleFieldInterleavedEvenFirst
;
3226 dxva_format
->SampleFormat
= format
->videoInfo
.InterlaceMode
;
3228 dxva_format
->VideoChromaSubsampling
= format
->videoInfo
.SourceChromaSubsampling
;
3229 dxva_format
->NominalRange
= format
->videoInfo
.NominalRange
;
3230 dxva_format
->VideoTransferMatrix
= format
->videoInfo
.TransferMatrix
;
3231 dxva_format
->VideoLighting
= format
->videoInfo
.SourceLighting
;
3232 dxva_format
->VideoPrimaries
= format
->videoInfo
.ColorPrimaries
;
3233 dxva_format
->VideoTransferFunction
= format
->videoInfo
.TransferFunction
;
3244 static int __cdecl
frame_rate_compare(const void *a
, const void *b
)
3246 const UINT64
*key
= a
;
3247 const struct frame_rate
*known_rate
= b
;
3248 return *key
== known_rate
->key
? 0 : ( *key
< known_rate
->key
? 1 : -1 );
3251 /***********************************************************************
3252 * MFFrameRateToAverageTimePerFrame (mfplat.@)
3254 HRESULT WINAPI
MFFrameRateToAverageTimePerFrame(UINT32 numerator
, UINT32 denominator
, UINT64
*avgframetime
)
3256 static const struct frame_rate known_rates
[] =
3258 #define KNOWN_RATE(n,d,ft) { ((UINT64)n << 32) | d, ft }
3259 KNOWN_RATE(60000, 1001, 166833),
3260 KNOWN_RATE(30000, 1001, 333667),
3261 KNOWN_RATE(24000, 1001, 417188),
3262 KNOWN_RATE(60, 1, 166667),
3263 KNOWN_RATE(50, 1, 200000),
3264 KNOWN_RATE(30, 1, 333333),
3265 KNOWN_RATE(25, 1, 400000),
3266 KNOWN_RATE(24, 1, 416667),
3269 UINT64 rate
= ((UINT64
)numerator
<< 32) | denominator
;
3270 const struct frame_rate
*entry
;
3272 TRACE("%u, %u, %p.\n", numerator
, denominator
, avgframetime
);
3274 if ((entry
= bsearch(&rate
, known_rates
, ARRAY_SIZE(known_rates
), sizeof(*known_rates
),
3275 frame_rate_compare
)))
3277 *avgframetime
= entry
->value
;
3280 *avgframetime
= numerator
? denominator
* (UINT64
)10000000 / numerator
: 0;
3285 static unsigned int get_gcd(unsigned int a
, unsigned int b
)
3299 /***********************************************************************
3300 * MFAverageTimePerFrameToFrameRate (mfplat.@)
3302 HRESULT WINAPI
MFAverageTimePerFrameToFrameRate(UINT64 avgtime
, UINT32
*numerator
, UINT32
*denominator
)
3304 static const struct frame_rate known_rates
[] =
3306 #define KNOWN_RATE(ft,n,d) { ft, ((UINT64)n << 32) | d }
3307 KNOWN_RATE(417188, 24000, 1001),
3308 KNOWN_RATE(416667, 24, 1),
3309 KNOWN_RATE(400000, 25, 1),
3310 KNOWN_RATE(333667, 30000, 1001),
3311 KNOWN_RATE(333333, 30, 1),
3312 KNOWN_RATE(200000, 50, 1),
3313 KNOWN_RATE(166833, 60000, 1001),
3314 KNOWN_RATE(166667, 60, 1),
3317 const struct frame_rate
*entry
;
3320 TRACE("%s, %p, %p.\n", wine_dbgstr_longlong(avgtime
), numerator
, denominator
);
3322 if ((entry
= bsearch(&avgtime
, known_rates
, ARRAY_SIZE(known_rates
), sizeof(*known_rates
),
3323 frame_rate_compare
)))
3325 *numerator
= entry
->value
>> 32;
3326 *denominator
= entry
->value
;
3330 if (avgtime
> 100000000) avgtime
= 100000000;
3331 gcd
= get_gcd(10000000, avgtime
);
3332 *numerator
= 10000000 / gcd
;
3333 *denominator
= avgtime
/ gcd
;
3337 *numerator
= *denominator
= 0;
3343 /***********************************************************************
3344 * MFMapDXGIFormatToDX9Format (mfplat.@)
3346 DWORD WINAPI
MFMapDXGIFormatToDX9Format(DXGI_FORMAT dxgi_format
)
3348 switch (dxgi_format
)
3350 case DXGI_FORMAT_R32G32B32A32_FLOAT
:
3351 return D3DFMT_A32B32G32R32F
;
3352 case DXGI_FORMAT_R16G16B16A16_FLOAT
:
3353 return D3DFMT_A16B16G16R16F
;
3354 case DXGI_FORMAT_R16G16B16A16_UNORM
:
3355 return D3DFMT_A16B16G16R16
;
3356 case DXGI_FORMAT_R16G16B16A16_SNORM
:
3357 return D3DFMT_Q16W16V16U16
;
3358 case DXGI_FORMAT_R32G32_FLOAT
:
3359 return D3DFMT_G32R32F
;
3360 case DXGI_FORMAT_R10G10B10A2_UNORM
:
3361 return D3DFMT_A2B10G10R10
;
3362 case DXGI_FORMAT_R8G8B8A8_SNORM
:
3363 return D3DFMT_Q8W8V8U8
;
3364 case DXGI_FORMAT_R16G16_FLOAT
:
3365 return D3DFMT_G16R16F
;
3366 case DXGI_FORMAT_R16G16_UNORM
:
3367 return D3DFMT_G16R16
;
3368 case DXGI_FORMAT_R16G16_SNORM
:
3369 return D3DFMT_V16U16
;
3370 case DXGI_FORMAT_D32_FLOAT
:
3371 return D3DFMT_D32F_LOCKABLE
;
3372 case DXGI_FORMAT_R32_FLOAT
:
3374 case DXGI_FORMAT_D24_UNORM_S8_UINT
:
3375 return D3DFMT_D24S8
;
3376 case DXGI_FORMAT_R8G8_SNORM
:
3378 case DXGI_FORMAT_R16_FLOAT
:
3380 case DXGI_FORMAT_D16_UNORM
:
3381 return D3DFMT_D16_LOCKABLE
;
3382 case DXGI_FORMAT_R16_UNORM
:
3384 case DXGI_FORMAT_R8_UNORM
:
3386 case DXGI_FORMAT_A8_UNORM
:
3388 case DXGI_FORMAT_BC1_UNORM
:
3389 case DXGI_FORMAT_BC1_UNORM_SRGB
:
3391 case DXGI_FORMAT_BC2_UNORM
:
3392 case DXGI_FORMAT_BC2_UNORM_SRGB
:
3394 case DXGI_FORMAT_BC3_UNORM
:
3395 case DXGI_FORMAT_BC3_UNORM_SRGB
:
3397 case DXGI_FORMAT_R8G8B8A8_UNORM
:
3398 return D3DFMT_A8B8G8R8
;
3399 case DXGI_FORMAT_B8G8R8A8_UNORM
:
3400 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
:
3401 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
:
3402 return D3DFMT_A8R8G8B8
;
3403 case DXGI_FORMAT_B8G8R8X8_UNORM
:
3404 case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
:
3405 return D3DFMT_X8R8G8B8
;
3406 case DXGI_FORMAT_AYUV
:
3407 return MAKEFOURCC('A','Y','U','V');
3408 case DXGI_FORMAT_Y410
:
3409 return MAKEFOURCC('Y','4','1','0');
3410 case DXGI_FORMAT_Y416
:
3411 return MAKEFOURCC('Y','4','1','6');
3412 case DXGI_FORMAT_NV12
:
3413 return MAKEFOURCC('N','V','1','2');
3414 case DXGI_FORMAT_P010
:
3415 return MAKEFOURCC('P','0','1','0');
3416 case DXGI_FORMAT_P016
:
3417 return MAKEFOURCC('P','0','1','6');
3418 case DXGI_FORMAT_420_OPAQUE
:
3419 return MAKEFOURCC('4','2','0','O');
3420 case DXGI_FORMAT_YUY2
:
3422 case DXGI_FORMAT_Y210
:
3423 return MAKEFOURCC('Y','2','1','0');
3424 case DXGI_FORMAT_Y216
:
3425 return MAKEFOURCC('Y','2','1','6');
3426 case DXGI_FORMAT_NV11
:
3427 return MAKEFOURCC('N','V','1','1');
3428 case DXGI_FORMAT_AI44
:
3429 return MAKEFOURCC('A','I','4','4');
3430 case DXGI_FORMAT_IA44
:
3431 return MAKEFOURCC('I','A','4','4');
3432 case DXGI_FORMAT_P8
:
3434 case DXGI_FORMAT_A8P8
:
3441 /***********************************************************************
3442 * MFMapDX9FormatToDXGIFormat (mfplat.@)
3444 DXGI_FORMAT WINAPI
MFMapDX9FormatToDXGIFormat(DWORD format
)
3448 case D3DFMT_A32B32G32R32F
:
3449 return DXGI_FORMAT_R32G32B32A32_FLOAT
;
3450 case D3DFMT_A16B16G16R16F
:
3451 return DXGI_FORMAT_R16G16B16A16_FLOAT
;
3452 case D3DFMT_A16B16G16R16
:
3453 return DXGI_FORMAT_R16G16B16A16_UNORM
;
3454 case D3DFMT_Q16W16V16U16
:
3455 return DXGI_FORMAT_R16G16B16A16_SNORM
;
3456 case D3DFMT_G32R32F
:
3457 return DXGI_FORMAT_R32G32_FLOAT
;
3458 case D3DFMT_A2B10G10R10
:
3459 return DXGI_FORMAT_R10G10B10A2_UNORM
;
3460 case D3DFMT_Q8W8V8U8
:
3461 return DXGI_FORMAT_R8G8B8A8_SNORM
;
3462 case D3DFMT_G16R16F
:
3463 return DXGI_FORMAT_R16G16_FLOAT
;
3465 return DXGI_FORMAT_R16G16_UNORM
;
3467 return DXGI_FORMAT_R16G16_SNORM
;
3468 case D3DFMT_D32F_LOCKABLE
:
3469 return DXGI_FORMAT_D32_FLOAT
;
3471 return DXGI_FORMAT_R32_FLOAT
;
3473 return DXGI_FORMAT_D24_UNORM_S8_UINT
;
3475 return DXGI_FORMAT_R8G8_SNORM
;
3477 return DXGI_FORMAT_R16_FLOAT
;
3479 return DXGI_FORMAT_R16_UNORM
;
3481 return DXGI_FORMAT_R8_UNORM
;
3483 return DXGI_FORMAT_A8_UNORM
;
3485 return DXGI_FORMAT_BC1_UNORM
;
3487 return DXGI_FORMAT_BC2_UNORM
;
3489 return DXGI_FORMAT_BC3_UNORM
;
3490 case D3DFMT_A8R8G8B8
:
3491 return DXGI_FORMAT_B8G8R8A8_UNORM
;
3492 case D3DFMT_X8R8G8B8
:
3493 return DXGI_FORMAT_B8G8R8X8_UNORM
;
3494 case MAKEFOURCC('A','Y','U','V'):
3495 return DXGI_FORMAT_AYUV
;
3496 case MAKEFOURCC('Y','4','1','0'):
3497 return DXGI_FORMAT_Y410
;
3498 case MAKEFOURCC('Y','4','1','6'):
3499 return DXGI_FORMAT_Y416
;
3500 case MAKEFOURCC('N','V','1','2'):
3501 return DXGI_FORMAT_NV12
;
3502 case MAKEFOURCC('P','0','1','0'):
3503 return DXGI_FORMAT_P010
;
3504 case MAKEFOURCC('P','0','1','6'):
3505 return DXGI_FORMAT_P016
;
3506 case MAKEFOURCC('4','2','0','O'):
3507 return DXGI_FORMAT_420_OPAQUE
;
3509 return DXGI_FORMAT_YUY2
;
3510 case MAKEFOURCC('Y','2','1','0'):
3511 return DXGI_FORMAT_Y210
;
3512 case MAKEFOURCC('Y','2','1','6'):
3513 return DXGI_FORMAT_Y216
;
3514 case MAKEFOURCC('N','V','1','1'):
3515 return DXGI_FORMAT_NV11
;
3516 case MAKEFOURCC('A','I','4','4'):
3517 return DXGI_FORMAT_AI44
;
3518 case MAKEFOURCC('I','A','4','4'):
3519 return DXGI_FORMAT_IA44
;
3521 return DXGI_FORMAT_P8
;
3523 return DXGI_FORMAT_A8P8
;
3525 return DXGI_FORMAT_UNKNOWN
;
3529 /***********************************************************************
3530 * MFInitVideoFormat_RGB (mfplat.@)
3532 HRESULT WINAPI
MFInitVideoFormat_RGB(MFVIDEOFORMAT
*format
, DWORD width
, DWORD height
, DWORD d3dformat
)
3534 unsigned int transfer_function
;
3536 TRACE("%p, %lu, %lu, %#lx.\n", format
, width
, height
, d3dformat
);
3539 return E_INVALIDARG
;
3541 if (!d3dformat
) d3dformat
= D3DFMT_X8R8G8B8
;
3545 case D3DFMT_X8R8G8B8
:
3547 case D3DFMT_A8R8G8B8
:
3549 case D3DFMT_X1R5G5B5
:
3550 case D3DFMT_A2B10G10R10
:
3552 transfer_function
= MFVideoTransFunc_sRGB
;
3555 transfer_function
= MFVideoTransFunc_10
;
3558 memset(format
, 0, sizeof(*format
));
3559 format
->dwSize
= sizeof(*format
);
3560 format
->videoInfo
.dwWidth
= width
;
3561 format
->videoInfo
.dwHeight
= height
;
3562 format
->videoInfo
.PixelAspectRatio
.Numerator
= 1;
3563 format
->videoInfo
.PixelAspectRatio
.Denominator
= 1;
3564 format
->videoInfo
.InterlaceMode
= MFVideoInterlace_Progressive
;
3565 format
->videoInfo
.TransferFunction
= transfer_function
;
3566 format
->videoInfo
.ColorPrimaries
= MFVideoPrimaries_BT709
;
3567 format
->videoInfo
.SourceLighting
= MFVideoLighting_office
;
3568 format
->videoInfo
.FramesPerSecond
.Numerator
= 60;
3569 format
->videoInfo
.FramesPerSecond
.Denominator
= 1;
3570 format
->videoInfo
.NominalRange
= MFNominalRange_Normal
;
3571 format
->videoInfo
.GeometricAperture
.Area
.cx
= width
;
3572 format
->videoInfo
.GeometricAperture
.Area
.cy
= height
;
3573 format
->videoInfo
.MinimumDisplayAperture
= format
->videoInfo
.GeometricAperture
;
3574 memcpy(&format
->guidFormat
, &MFVideoFormat_Base
, sizeof(format
->guidFormat
));
3575 format
->guidFormat
.Data1
= d3dformat
;
3576 format
->surfaceInfo
.Format
= d3dformat
;
3581 static HRESULT
mf_get_stride_for_bitmap_info_header(DWORD fourcc
, const BITMAPINFOHEADER
*bih
, LONG
*stride
)
3585 if (FAILED(hr
= MFGetStrideForBitmapInfoHeader(fourcc
, bih
->biWidth
, stride
))) return hr
;
3586 if (bih
->biHeight
< 0) *stride
*= -1;
3591 static const GUID
* get_mf_subtype_for_am_subtype(const GUID
*subtype
)
3593 static const GUID null
;
3595 if (IsEqualGUID(subtype
, &MEDIASUBTYPE_RGB32
))
3596 return &MFVideoFormat_RGB32
;
3597 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_ARGB32
))
3598 return &MFVideoFormat_ARGB32
;
3599 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_I420
))
3600 return &MFVideoFormat_I420
;
3601 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_AYUV
))
3602 return &MFVideoFormat_AYUV
;
3603 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_YV12
))
3604 return &MFVideoFormat_YV12
;
3605 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_YUY2
))
3606 return &MFVideoFormat_YUY2
;
3607 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_UYVY
))
3608 return &MFVideoFormat_UYVY
;
3609 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_YVYU
))
3610 return &MFVideoFormat_YVYU
;
3611 else if (IsEqualGUID(subtype
, &MEDIASUBTYPE_NV12
))
3612 return &MFVideoFormat_NV12
;
3615 FIXME("Unknown subtype %s.\n", debugstr_guid(subtype
));
3620 /***********************************************************************
3621 * MFCreateVideoMediaTypeFromVideoInfoHeader (mfplat.@)
3623 HRESULT WINAPI
MFCreateVideoMediaTypeFromVideoInfoHeader(const KS_VIDEOINFOHEADER
*vih
, DWORD size
, DWORD pixel_aspect_ratio_x
,
3624 DWORD pixel_aspect_ratio_y
, MFVideoInterlaceMode interlace_mode
, QWORD video_flags
, const GUID
*subtype
,
3625 IMFVideoMediaType
**ret
)
3627 FIXME("%p, %lu, %lu, %lu, %d, %I64x, %s, %p.\n", vih
, size
, pixel_aspect_ratio_x
, pixel_aspect_ratio_y
, interlace_mode
,
3628 video_flags
, debugstr_guid(subtype
), ret
);
3633 /***********************************************************************
3634 * MFInitMediaTypeFromVideoInfoHeader (mfplat.@)
3636 HRESULT WINAPI
MFInitMediaTypeFromVideoInfoHeader(IMFMediaType
*media_type
, const VIDEOINFOHEADER
*vih
, UINT32 size
,
3637 const GUID
*subtype
)
3643 FIXME("%p, %p, %u, %s.\n", media_type
, vih
, size
, debugstr_guid(subtype
));
3645 IMFMediaType_DeleteAllItems(media_type
);
3649 FIXME("Implicit subtype is not supported.\n");
3653 height
= abs(vih
->bmiHeader
.biHeight
);
3655 mediatype_set_guid(media_type
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Video
, &hr
);
3656 mediatype_set_guid(media_type
, &MF_MT_SUBTYPE
, subtype
, &hr
);
3657 mediatype_set_uint64(media_type
, &MF_MT_PIXEL_ASPECT_RATIO
, 1, 1, &hr
);
3658 mediatype_set_uint32(media_type
, &MF_MT_INTERLACE_MODE
, MFVideoInterlace_Progressive
, &hr
);
3659 mediatype_set_uint64(media_type
, &MF_MT_FRAME_SIZE
, vih
->bmiHeader
.biWidth
, height
, &hr
);
3661 if (SUCCEEDED(mf_get_stride_for_bitmap_info_header(subtype
->Data1
, &vih
->bmiHeader
, &stride
)))
3663 mediatype_set_uint32(media_type
, &MF_MT_DEFAULT_STRIDE
, stride
, &hr
);
3664 mediatype_set_uint32(media_type
, &MF_MT_SAMPLE_SIZE
, abs(stride
) * height
, &hr
);
3665 mediatype_set_uint32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, 1, &hr
);
3666 mediatype_set_uint32(media_type
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1, &hr
);
3672 /***********************************************************************
3673 * MFInitMediaTypeFromAMMediaType (mfplat.@)
3675 HRESULT WINAPI
MFInitMediaTypeFromAMMediaType(IMFMediaType
*media_type
, const AM_MEDIA_TYPE
*am_type
)
3679 TRACE("%p, %p.\n", media_type
, am_type
);
3681 IMFMediaType_DeleteAllItems(media_type
);
3683 if (IsEqualGUID(&am_type
->majortype
, &MEDIATYPE_Video
))
3685 if (IsEqualGUID(&am_type
->formattype
, &FORMAT_VideoInfo
))
3687 const VIDEOINFOHEADER
*vih
= (const VIDEOINFOHEADER
*)am_type
->pbFormat
;
3688 const GUID
*subtype
;
3692 subtype
= get_mf_subtype_for_am_subtype(&am_type
->subtype
);
3693 height
= abs(vih
->bmiHeader
.biHeight
);
3695 mediatype_set_guid(media_type
, &MF_MT_MAJOR_TYPE
, &MFMediaType_Video
, &hr
);
3696 mediatype_set_guid(media_type
, &MF_MT_SUBTYPE
, subtype
, &hr
);
3697 mediatype_set_uint64(media_type
, &MF_MT_PIXEL_ASPECT_RATIO
, 1, 1, &hr
);
3698 mediatype_set_uint32(media_type
, &MF_MT_INTERLACE_MODE
, MFVideoInterlace_Progressive
, &hr
);
3699 mediatype_set_uint64(media_type
, &MF_MT_FRAME_SIZE
, vih
->bmiHeader
.biWidth
, height
, &hr
);
3700 mediatype_set_uint32(media_type
, &MF_MT_ALL_SAMPLES_INDEPENDENT
, 1, &hr
);
3702 if (SUCCEEDED(mf_get_stride_for_bitmap_info_header(subtype
->Data1
, &vih
->bmiHeader
, &stride
)))
3704 mediatype_set_uint32(media_type
, &MF_MT_DEFAULT_STRIDE
, stride
, &hr
);
3705 mediatype_set_uint32(media_type
, &MF_MT_SAMPLE_SIZE
, abs(stride
) * height
, &hr
);
3706 mediatype_set_uint32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, 1, &hr
);
3710 if (am_type
->bFixedSizeSamples
)
3711 mediatype_set_uint32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, 1, &hr
);
3712 if (am_type
->lSampleSize
)
3713 mediatype_set_uint32(media_type
, &MF_MT_SAMPLE_SIZE
, am_type
->lSampleSize
, &hr
);
3720 FIXME("Unsupported format type %s.\n", debugstr_guid(&am_type
->formattype
));
3724 FIXME("Unsupported major type %s.\n", debugstr_guid(&am_type
->majortype
));