rpcrt4: Write the function header into the procedure format string.
[wine.git] / dlls / mfplat / main.c
blob33080d0b27899874dadc85ea1a745f7f8eaa8963
1 /*
3 * Copyright 2014 Austin English
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include <string.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
30 #include "initguid.h"
31 #include "mfapi.h"
32 #include "mfidl.h"
33 #include "mferror.h"
35 #include "wine/heap.h"
36 #include "wine/debug.h"
37 #include "wine/unicode.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
41 static const WCHAR transform_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
42 'T','r','a','n','s','f','o','r','m','s',0};
43 static const WCHAR categories_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
44 'T','r','a','n','s','f','o','r','m','s','\\',
45 'C','a','t','e','g','o','r','i','e','s',0};
46 static const WCHAR inputtypesW[] = {'I','n','p','u','t','T','y','p','e','s',0};
47 static const WCHAR outputtypesW[] = {'O','u','t','p','u','t','T','y','p','e','s',0};
48 static const WCHAR szGUIDFmt[] =
50 '%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0',
51 '2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2',
52 'x','%','0','2','x','%','0','2','x','%','0','2','x',0
55 static const BYTE guid_conv_table[256] =
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
59 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
60 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
61 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
62 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
63 0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf /* 0x60 */
66 static WCHAR* GUIDToString(WCHAR *str, REFGUID guid)
68 sprintfW(str, szGUIDFmt, guid->Data1, guid->Data2,
69 guid->Data3, guid->Data4[0], guid->Data4[1],
70 guid->Data4[2], guid->Data4[3], guid->Data4[4],
71 guid->Data4[5], guid->Data4[6], guid->Data4[7]);
73 return str;
76 static inline BOOL is_valid_hex(WCHAR c)
78 if (!(((c >= '0') && (c <= '9')) ||
79 ((c >= 'a') && (c <= 'f')) ||
80 ((c >= 'A') && (c <= 'F'))))
81 return FALSE;
82 return TRUE;
85 static BOOL GUIDFromString(LPCWSTR s, GUID *id)
87 int i;
89 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
91 id->Data1 = 0;
92 for (i = 0; i < 8; i++)
94 if (!is_valid_hex(s[i])) return FALSE;
95 id->Data1 = (id->Data1 << 4) | guid_conv_table[s[i]];
97 if (s[8]!='-') return FALSE;
99 id->Data2 = 0;
100 for (i = 9; i < 13; i++)
102 if (!is_valid_hex(s[i])) return FALSE;
103 id->Data2 = (id->Data2 << 4) | guid_conv_table[s[i]];
105 if (s[13]!='-') return FALSE;
107 id->Data3 = 0;
108 for (i = 14; i < 18; i++)
110 if (!is_valid_hex(s[i])) return FALSE;
111 id->Data3 = (id->Data3 << 4) | guid_conv_table[s[i]];
113 if (s[18]!='-') return FALSE;
115 for (i = 19; i < 36; i+=2)
117 if (i == 23)
119 if (s[i]!='-') return FALSE;
120 i++;
122 if (!is_valid_hex(s[i]) || !is_valid_hex(s[i+1])) return FALSE;
123 id->Data4[(i-19)/2] = guid_conv_table[s[i]] << 4 | guid_conv_table[s[i+1]];
126 if (!s[37]) return TRUE;
127 return FALSE;
130 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
132 switch (reason)
134 case DLL_WINE_PREATTACH:
135 return FALSE; /* prefer native version */
136 case DLL_PROCESS_ATTACH:
137 DisableThreadLibraryCalls(instance);
138 break;
141 return TRUE;
144 static HRESULT register_transform(CLSID *clsid, WCHAR *name,
145 UINT32 cinput, MFT_REGISTER_TYPE_INFO *input_types,
146 UINT32 coutput, MFT_REGISTER_TYPE_INFO *output_types)
148 static const WCHAR reg_format[] = {'%','s','\\','%','s',0};
149 HKEY hclsid = 0;
150 WCHAR buffer[64];
151 DWORD size;
152 WCHAR str[250];
154 GUIDToString(buffer, clsid);
155 sprintfW(str, reg_format, transform_keyW, buffer);
157 if (RegCreateKeyW(HKEY_CLASSES_ROOT, str, &hclsid))
158 return E_FAIL;
160 size = (strlenW(name) + 1) * sizeof(WCHAR);
161 if (RegSetValueExW(hclsid, NULL, 0, REG_SZ, (BYTE *)name, size))
162 goto err;
164 if (cinput && input_types)
166 size = cinput * sizeof(MFT_REGISTER_TYPE_INFO);
167 if (RegSetValueExW(hclsid, inputtypesW, 0, REG_BINARY, (BYTE *)input_types, size))
168 goto err;
171 if (coutput && output_types)
173 size = coutput * sizeof(MFT_REGISTER_TYPE_INFO);
174 if (RegSetValueExW(hclsid, outputtypesW, 0, REG_BINARY, (BYTE *)output_types, size))
175 goto err;
178 RegCloseKey(hclsid);
179 return S_OK;
181 err:
182 RegCloseKey(hclsid);
183 return E_FAIL;
186 static HRESULT register_category(CLSID *clsid, GUID *category)
188 static const WCHAR reg_format[] = {'%','s','\\','%','s','\\','%','s',0};
189 HKEY htmp1;
190 WCHAR guid1[64], guid2[64];
191 WCHAR str[350];
193 GUIDToString(guid1, category);
194 GUIDToString(guid2, clsid);
196 sprintfW(str, reg_format, categories_keyW, guid1, guid2);
198 if (RegCreateKeyW(HKEY_CLASSES_ROOT, str, &htmp1))
199 return E_FAIL;
201 RegCloseKey(htmp1);
202 return S_OK;
205 /***********************************************************************
206 * MFTRegister (mfplat.@)
208 HRESULT WINAPI MFTRegister(CLSID clsid, GUID category, LPWSTR name, UINT32 flags, UINT32 cinput,
209 MFT_REGISTER_TYPE_INFO *input_types, UINT32 coutput,
210 MFT_REGISTER_TYPE_INFO *output_types, IMFAttributes *attributes)
212 HRESULT hr;
214 TRACE("(%s, %s, %s, %x, %u, %p, %u, %p, %p)\n", debugstr_guid(&clsid), debugstr_guid(&category),
215 debugstr_w(name), flags, cinput, input_types,
216 coutput, output_types, attributes);
218 if (attributes)
219 FIXME("attributes not yet supported.\n");
221 if (flags)
222 FIXME("flags not yet supported.\n");
224 hr = register_transform(&clsid, name, cinput, input_types, coutput, output_types);
225 if(FAILED(hr))
226 ERR("Failed to write register transform\n");
228 if (SUCCEEDED(hr))
229 hr = register_category(&clsid, &category);
231 return hr;
234 HRESULT WINAPI MFTRegisterLocal(IClassFactory *factory, REFGUID category, LPCWSTR name,
235 UINT32 flags, UINT32 cinput, const MFT_REGISTER_TYPE_INFO *input_types,
236 UINT32 coutput, const MFT_REGISTER_TYPE_INFO* output_types)
238 FIXME("(%p, %s, %s, %x, %u, %p, %u, %p)\n", factory, debugstr_guid(category), debugstr_w(name),
239 flags, cinput, input_types, coutput, output_types);
241 return S_OK;
244 HRESULT WINAPI MFTUnregisterLocal(IClassFactory *factory)
246 FIXME("(%p)\n", factory);
248 return S_OK;
251 static BOOL match_type(const WCHAR *clsid_str, const WCHAR *type_str, MFT_REGISTER_TYPE_INFO *type)
253 HKEY htransform, hfilter;
254 DWORD reg_type, size;
255 LONG ret = FALSE;
256 MFT_REGISTER_TYPE_INFO *info = NULL;
257 int i;
259 if (RegOpenKeyW(HKEY_CLASSES_ROOT, transform_keyW, &htransform))
260 return FALSE;
262 if (RegOpenKeyW(htransform, clsid_str, &hfilter))
264 RegCloseKey(htransform);
265 return FALSE;
268 if (RegQueryValueExW(hfilter, type_str, NULL, &reg_type, NULL, &size) != ERROR_SUCCESS)
269 goto out;
271 if (reg_type != REG_BINARY)
272 goto out;
274 if (!size || size % (sizeof(MFT_REGISTER_TYPE_INFO)) != 0)
275 goto out;
277 info = HeapAlloc(GetProcessHeap(), 0, size);
278 if (!info)
279 goto out;
281 if (RegQueryValueExW(hfilter, type_str, NULL, &reg_type, (LPBYTE)info, &size) != ERROR_SUCCESS)
282 goto out;
284 for (i = 0; i < size / sizeof(MFT_REGISTER_TYPE_INFO); i++)
286 if (IsEqualGUID(&info[i].guidMajorType, &type->guidMajorType) &&
287 IsEqualGUID(&info[i].guidSubtype, &type->guidSubtype))
289 ret = TRUE;
290 break;
294 out:
295 HeapFree(GetProcessHeap(), 0, info);
296 RegCloseKey(hfilter);
297 RegCloseKey(htransform);
298 return ret;
301 /***********************************************************************
302 * MFTEnum (mfplat.@)
304 HRESULT WINAPI MFTEnum(GUID category, UINT32 flags, MFT_REGISTER_TYPE_INFO *input_type,
305 MFT_REGISTER_TYPE_INFO *output_type, IMFAttributes *attributes,
306 CLSID **pclsids, UINT32 *pcount)
308 WCHAR buffer[64], clsid_str[MAX_PATH] = {0};
309 HKEY hcategory, hlist;
310 DWORD index = 0;
311 DWORD size = MAX_PATH;
312 CLSID *clsids = NULL;
313 UINT32 count = 0;
314 LONG ret;
316 TRACE("(%s, %x, %p, %p, %p, %p, %p)\n", debugstr_guid(&category), flags, input_type,
317 output_type, attributes, pclsids, pcount);
319 if (!pclsids || !pcount)
320 return E_INVALIDARG;
322 if (RegOpenKeyW(HKEY_CLASSES_ROOT, categories_keyW, &hcategory))
323 return E_FAIL;
325 GUIDToString(buffer, &category);
327 ret = RegOpenKeyW(hcategory, buffer, &hlist);
328 RegCloseKey(hcategory);
329 if (ret) return E_FAIL;
331 while (RegEnumKeyExW(hlist, index, clsid_str, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
333 GUID clsid;
334 void *tmp;
336 if (!GUIDFromString(clsid_str, &clsid))
337 goto next;
339 if (output_type && !match_type(clsid_str, outputtypesW, output_type))
340 goto next;
342 if (input_type && !match_type(clsid_str, inputtypesW, input_type))
343 goto next;
345 tmp = CoTaskMemRealloc(clsids, (count + 1) * sizeof(GUID));
346 if (!tmp)
348 CoTaskMemFree(clsids);
349 RegCloseKey(hlist);
350 return E_OUTOFMEMORY;
353 clsids = tmp;
354 clsids[count++] = clsid;
356 next:
357 size = MAX_PATH;
358 index++;
361 *pclsids = clsids;
362 *pcount = count;
364 RegCloseKey(hlist);
365 return S_OK;
368 /***********************************************************************
369 * MFTEnumEx (mfplat.@)
371 HRESULT WINAPI MFTEnumEx(GUID category, UINT32 flags, const MFT_REGISTER_TYPE_INFO *input_type,
372 const MFT_REGISTER_TYPE_INFO *output_type, IMFActivate ***activate,
373 UINT32 *pcount)
375 FIXME("(%s, %x, %p, %p, %p, %p): stub\n", debugstr_guid(&category), flags, input_type,
376 output_type, activate, pcount);
378 *pcount = 0;
379 return S_OK;
382 /***********************************************************************
383 * MFTUnregister (mfplat.@)
385 HRESULT WINAPI MFTUnregister(CLSID clsid)
387 WCHAR buffer[64], category[MAX_PATH];
388 HKEY htransform, hcategory, htmp;
389 DWORD size = MAX_PATH;
390 DWORD index = 0;
392 TRACE("(%s)\n", debugstr_guid(&clsid));
394 GUIDToString(buffer, &clsid);
396 if (!RegOpenKeyW(HKEY_CLASSES_ROOT, transform_keyW, &htransform))
398 RegDeleteKeyW(htransform, buffer);
399 RegCloseKey(htransform);
402 if (!RegOpenKeyW(HKEY_CLASSES_ROOT, categories_keyW, &hcategory))
404 while (RegEnumKeyExW(hcategory, index, category, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
406 if (!RegOpenKeyW(hcategory, category, &htmp))
408 RegDeleteKeyW(htmp, buffer);
409 RegCloseKey(htmp);
411 size = MAX_PATH;
412 index++;
414 RegCloseKey(hcategory);
417 return S_OK;
420 /***********************************************************************
421 * MFStartup (mfplat.@)
423 HRESULT WINAPI MFStartup(ULONG version, DWORD flags)
425 #define MF_VERSION_XP MAKELONG( MF_API_VERSION, 1 )
426 #define MF_VERSION_WIN7 MAKELONG( MF_API_VERSION, 2 )
428 FIXME("(%u, %u): stub\n", version, flags);
430 if(version != MF_VERSION_XP && version != MF_VERSION_WIN7)
431 return MF_E_BAD_STARTUP_VERSION;
433 return S_OK;
436 /***********************************************************************
437 * MFShutdown (mfplat.@)
439 HRESULT WINAPI MFShutdown(void)
441 FIXME("(): stub\n");
442 return S_OK;
445 HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG srcstride, DWORD width, DWORD lines)
447 FIXME("(%p, %d, %p, %d, %d, %d) stub\n", dest, deststride, src, srcstride, width, lines);
448 return E_NOTIMPL;
451 typedef struct _mfattributes
453 IMFAttributes IMFAttributes_iface;
454 LONG ref;
455 } mfattributes;
457 static inline mfattributes *impl_from_IMFAttributes(IMFAttributes *iface)
459 return CONTAINING_RECORD(iface, mfattributes, IMFAttributes_iface);
462 static HRESULT WINAPI mfattributes_QueryInterface(IMFAttributes *iface, REFIID riid, void **out)
464 mfattributes *This = impl_from_IMFAttributes(iface);
466 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
468 if(IsEqualGUID(riid, &IID_IUnknown) ||
469 IsEqualGUID(riid, &IID_IMFAttributes))
471 *out = &This->IMFAttributes_iface;
473 else
475 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
476 *out = NULL;
477 return E_NOINTERFACE;
480 IUnknown_AddRef((IUnknown*)*out);
481 return S_OK;
484 static ULONG WINAPI mfattributes_AddRef(IMFAttributes *iface)
486 mfattributes *This = impl_from_IMFAttributes(iface);
487 ULONG ref = InterlockedIncrement(&This->ref);
489 TRACE("(%p) ref=%u\n", This, ref);
491 return ref;
494 static ULONG WINAPI mfattributes_Release(IMFAttributes *iface)
496 mfattributes *This = impl_from_IMFAttributes(iface);
497 ULONG ref = InterlockedDecrement(&This->ref);
499 TRACE("(%p) ref=%u\n", This, ref);
501 if (!ref)
503 HeapFree(GetProcessHeap(), 0, This);
506 return ref;
509 static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value)
511 mfattributes *This = impl_from_IMFAttributes(iface);
513 FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
515 return E_NOTIMPL;
518 static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
520 mfattributes *This = impl_from_IMFAttributes(iface);
522 FIXME("%p, %s, %p\n", This, debugstr_guid(key), type);
524 return E_NOTIMPL;
527 static HRESULT WINAPI mfattributes_CompareItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
529 mfattributes *This = impl_from_IMFAttributes(iface);
531 FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), value, result);
533 return E_NOTIMPL;
536 static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
537 BOOL *result)
539 mfattributes *This = impl_from_IMFAttributes(iface);
541 FIXME("%p, %p, %d, %p\n", This, theirs, type, result);
543 return E_NOTIMPL;
546 static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value)
548 mfattributes *This = impl_from_IMFAttributes(iface);
550 FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
552 return E_NOTIMPL;
555 static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value)
557 mfattributes *This = impl_from_IMFAttributes(iface);
559 FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
561 return E_NOTIMPL;
564 static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value)
566 mfattributes *This = impl_from_IMFAttributes(iface);
568 FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
570 return E_NOTIMPL;
573 static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GUID *value)
575 mfattributes *This = impl_from_IMFAttributes(iface);
577 FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
579 return E_NOTIMPL;
582 static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID key, UINT32 *length)
584 mfattributes *This = impl_from_IMFAttributes(iface);
586 FIXME("%p, %s, %p\n", This, debugstr_guid(key), length);
588 return E_NOTIMPL;
591 static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, WCHAR *value,
592 UINT32 size, UINT32 *length)
594 mfattributes *This = impl_from_IMFAttributes(iface);
596 FIXME("%p, %s, %p, %d, %p\n", This, debugstr_guid(key), value, size, length);
598 return E_NOTIMPL;
601 static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key,
602 WCHAR **value, UINT32 *length)
604 mfattributes *This = impl_from_IMFAttributes(iface);
606 FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), value, length);
608 return E_NOTIMPL;
611 static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key, UINT32 *size)
613 mfattributes *This = impl_from_IMFAttributes(iface);
615 FIXME("%p, %s, %p\n", This, debugstr_guid(key), size);
617 return E_NOTIMPL;
620 static HRESULT WINAPI mfattributes_GetBlob(IMFAttributes *iface, REFGUID key, UINT8 *buf,
621 UINT32 bufsize, UINT32 *blobsize)
623 mfattributes *This = impl_from_IMFAttributes(iface);
625 FIXME("%p, %s, %p, %d, %p\n", This, debugstr_guid(key), buf, bufsize, blobsize);
627 return E_NOTIMPL;
630 static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUID key, UINT8 **buf, UINT32 *size)
632 mfattributes *This = impl_from_IMFAttributes(iface);
634 FIXME("%p, %s, %p, %p\n", This, debugstr_guid(key), buf, size);
636 return E_NOTIMPL;
639 static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv)
641 mfattributes *This = impl_from_IMFAttributes(iface);
643 FIXME("%p, %s, %s, %p\n", This, debugstr_guid(key), debugstr_guid(riid), ppv);
645 return E_NOTIMPL;
648 static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT Value)
650 mfattributes *This = impl_from_IMFAttributes(iface);
652 FIXME("%p, %s, %p\n", This, debugstr_guid(key), Value);
654 return E_NOTIMPL;
657 static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key)
659 mfattributes *This = impl_from_IMFAttributes(iface);
661 FIXME("%p, %s\n", This, debugstr_guid(key));
663 return E_NOTIMPL;
666 static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
668 mfattributes *This = impl_from_IMFAttributes(iface);
670 FIXME("%p\n", This);
672 return E_NOTIMPL;
675 static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value)
677 mfattributes *This = impl_from_IMFAttributes(iface);
679 FIXME("%p, %s, %d\n", This, debugstr_guid(key), value);
681 return E_NOTIMPL;
684 static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value)
686 mfattributes *This = impl_from_IMFAttributes(iface);
688 FIXME("%p, %s, %s\n", This, debugstr_guid(key), wine_dbgstr_longlong(value));
690 return E_NOTIMPL;
693 static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value)
695 mfattributes *This = impl_from_IMFAttributes(iface);
697 FIXME("%p, %s, %f\n", This, debugstr_guid(key), value);
699 return E_NOTIMPL;
702 static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, REFGUID value)
704 mfattributes *This = impl_from_IMFAttributes(iface);
706 FIXME("%p, %s, %s\n", This, debugstr_guid(key), debugstr_guid(value));
708 return E_NOTIMPL;
711 static HRESULT WINAPI mfattributes_SetString(IMFAttributes *iface, REFGUID key, const WCHAR *value)
713 mfattributes *This = impl_from_IMFAttributes(iface);
715 FIXME("%p, %s, %s\n", This, debugstr_guid(key), debugstr_w(value));
717 return E_NOTIMPL;
720 static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size)
722 mfattributes *This = impl_from_IMFAttributes(iface);
724 FIXME("%p, %s, %p, %d\n", This, debugstr_guid(key), buf, size);
726 return E_NOTIMPL;
729 static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown)
731 mfattributes *This = impl_from_IMFAttributes(iface);
733 FIXME("%p, %s, %p\n", This, debugstr_guid(key), unknown);
735 return E_NOTIMPL;
738 static HRESULT WINAPI mfattributes_LockStore(IMFAttributes *iface)
740 mfattributes *This = impl_from_IMFAttributes(iface);
742 FIXME("%p\n", This);
744 return E_NOTIMPL;
747 static HRESULT WINAPI mfattributes_UnlockStore(IMFAttributes *iface)
749 mfattributes *This = impl_from_IMFAttributes(iface);
751 FIXME("%p\n", This);
753 return E_NOTIMPL;
756 static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items)
758 mfattributes *This = impl_from_IMFAttributes(iface);
760 FIXME("%p, %p\n", This, items);
762 if(items)
763 *items = 0;
765 return E_NOTIMPL;
768 static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value)
770 mfattributes *This = impl_from_IMFAttributes(iface);
772 FIXME("%p, %d, %p, %p\n", This, index, key, value);
774 return E_NOTIMPL;
777 static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest)
779 mfattributes *This = impl_from_IMFAttributes(iface);
781 FIXME("%p, %p\n", This, dest);
783 return E_NOTIMPL;
786 static const IMFAttributesVtbl mfattributes_vtbl =
788 mfattributes_QueryInterface,
789 mfattributes_AddRef,
790 mfattributes_Release,
791 mfattributes_GetItem,
792 mfattributes_GetItemType,
793 mfattributes_CompareItem,
794 mfattributes_Compare,
795 mfattributes_GetUINT32,
796 mfattributes_GetUINT64,
797 mfattributes_GetDouble,
798 mfattributes_GetGUID,
799 mfattributes_GetStringLength,
800 mfattributes_GetString,
801 mfattributes_GetAllocatedString,
802 mfattributes_GetBlobSize,
803 mfattributes_GetBlob,
804 mfattributes_GetAllocatedBlob,
805 mfattributes_GetUnknown,
806 mfattributes_SetItem,
807 mfattributes_DeleteItem,
808 mfattributes_DeleteAllItems,
809 mfattributes_SetUINT32,
810 mfattributes_SetUINT64,
811 mfattributes_SetDouble,
812 mfattributes_SetGUID,
813 mfattributes_SetString,
814 mfattributes_SetBlob,
815 mfattributes_SetUnknown,
816 mfattributes_LockStore,
817 mfattributes_UnlockStore,
818 mfattributes_GetCount,
819 mfattributes_GetItemByIndex,
820 mfattributes_CopyAllItems
823 static void init_attribute_object(mfattributes *object, UINT32 size)
825 object->ref = 1;
826 object->IMFAttributes_iface.lpVtbl = &mfattributes_vtbl;
829 /***********************************************************************
830 * MFCreateAttributes (mfplat.@)
832 HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size)
834 mfattributes *object;
836 TRACE("%p, %d\n", attributes, size);
838 object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) );
839 if(!object)
840 return E_OUTOFMEMORY;
842 init_attribute_object(object, size);
843 *attributes = &object->IMFAttributes_iface;
845 return S_OK;
848 typedef struct _mfbytestream
850 mfattributes attributes;
851 IMFByteStream IMFByteStream_iface;
852 } mfbytestream;
854 static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface)
856 return CONTAINING_RECORD(iface, mfbytestream, IMFByteStream_iface);
859 static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID riid, void **out)
861 mfbytestream *This = impl_from_IMFByteStream(iface);
863 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
865 if(IsEqualGUID(riid, &IID_IUnknown) ||
866 IsEqualGUID(riid, &IID_IMFByteStream))
868 *out = &This->IMFByteStream_iface;
870 else if(IsEqualGUID(riid, &IID_IMFAttributes))
872 *out = &This->attributes.IMFAttributes_iface;
874 else
876 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
877 *out = NULL;
878 return E_NOINTERFACE;
881 IUnknown_AddRef((IUnknown*)*out);
882 return S_OK;
885 static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface)
887 mfbytestream *This = impl_from_IMFByteStream(iface);
888 ULONG ref = InterlockedIncrement(&This->attributes.ref);
890 TRACE("(%p) ref=%u\n", This, ref);
892 return ref;
895 static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface)
897 mfbytestream *This = impl_from_IMFByteStream(iface);
898 ULONG ref = InterlockedDecrement(&This->attributes.ref);
900 TRACE("(%p) ref=%u\n", This, ref);
902 if (!ref)
904 HeapFree(GetProcessHeap(), 0, This);
907 return ref;
910 static HRESULT WINAPI mfbytestream_GetCapabilities(IMFByteStream *iface, DWORD *capabilities)
912 mfbytestream *This = impl_from_IMFByteStream(iface);
914 FIXME("%p, %p\n", This, capabilities);
916 return E_NOTIMPL;
919 static HRESULT WINAPI mfbytestream_GetLength(IMFByteStream *iface, QWORD *length)
921 mfbytestream *This = impl_from_IMFByteStream(iface);
923 FIXME("%p, %p\n", This, length);
925 return E_NOTIMPL;
928 static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length)
930 mfbytestream *This = impl_from_IMFByteStream(iface);
932 FIXME("%p, %s\n", This, wine_dbgstr_longlong(length));
934 return E_NOTIMPL;
937 static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position)
939 mfbytestream *This = impl_from_IMFByteStream(iface);
941 FIXME("%p, %p\n", This, position);
943 return E_NOTIMPL;
946 static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position)
948 mfbytestream *This = impl_from_IMFByteStream(iface);
950 FIXME("%p, %s\n", This, wine_dbgstr_longlong(position));
952 return E_NOTIMPL;
955 static HRESULT WINAPI mfbytestream_IsEndOfStream(IMFByteStream *iface, BOOL *endstream)
957 mfbytestream *This = impl_from_IMFByteStream(iface);
959 FIXME("%p, %p\n", This, endstream);
961 if(endstream)
962 *endstream = TRUE;
964 return S_OK;
967 static HRESULT WINAPI mfbytestream_Read(IMFByteStream *iface, BYTE *data, ULONG count, ULONG *byte_read)
969 mfbytestream *This = impl_from_IMFByteStream(iface);
971 FIXME("%p, %p, %u, %p\n", This, data, count, byte_read);
973 return E_NOTIMPL;
976 static HRESULT WINAPI mfbytestream_BeginRead(IMFByteStream *iface, BYTE *data, ULONG count,
977 IMFAsyncCallback *callback, IUnknown *state)
979 mfbytestream *This = impl_from_IMFByteStream(iface);
981 FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state);
983 return E_NOTIMPL;
986 static HRESULT WINAPI mfbytestream_EndRead(IMFByteStream *iface, IMFAsyncResult *result, ULONG *byte_read)
988 mfbytestream *This = impl_from_IMFByteStream(iface);
990 FIXME("%p, %p, %p\n", This, result, byte_read);
992 return E_NOTIMPL;
995 static HRESULT WINAPI mfbytestream_Write(IMFByteStream *iface, const BYTE *data, ULONG count, ULONG *written)
997 mfbytestream *This = impl_from_IMFByteStream(iface);
999 FIXME("%p, %p, %u, %p\n", This, data, count, written);
1001 return E_NOTIMPL;
1004 static HRESULT WINAPI mfbytestream_BeginWrite(IMFByteStream *iface, const BYTE *data, ULONG count,
1005 IMFAsyncCallback *callback, IUnknown *state)
1007 mfbytestream *This = impl_from_IMFByteStream(iface);
1009 FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state);
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI mfbytestream_EndWrite(IMFByteStream *iface, IMFAsyncResult *result, ULONG *written)
1016 mfbytestream *This = impl_from_IMFByteStream(iface);
1018 FIXME("%p, %p, %p\n", This, result, written);
1020 return E_NOTIMPL;
1023 static HRESULT WINAPI mfbytestream_Seek(IMFByteStream *iface, MFBYTESTREAM_SEEK_ORIGIN seek, LONGLONG offset,
1024 DWORD flags, QWORD *current)
1026 mfbytestream *This = impl_from_IMFByteStream(iface);
1028 FIXME("%p, %u, %s, 0x%08x, %p\n", This, seek, wine_dbgstr_longlong(offset), flags, current);
1030 return E_NOTIMPL;
1033 static HRESULT WINAPI mfbytestream_Flush(IMFByteStream *iface)
1035 mfbytestream *This = impl_from_IMFByteStream(iface);
1037 FIXME("%p\n", This);
1039 return E_NOTIMPL;
1042 static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface)
1044 mfbytestream *This = impl_from_IMFByteStream(iface);
1046 FIXME("%p\n", This);
1048 return E_NOTIMPL;
1051 static const IMFByteStreamVtbl mfbytestream_vtbl =
1053 mfbytestream_QueryInterface,
1054 mfbytestream_AddRef,
1055 mfbytestream_Release,
1056 mfbytestream_GetCapabilities,
1057 mfbytestream_GetLength,
1058 mfbytestream_SetLength,
1059 mfbytestream_GetCurrentPosition,
1060 mfbytestream_SetCurrentPosition,
1061 mfbytestream_IsEndOfStream,
1062 mfbytestream_Read,
1063 mfbytestream_BeginRead,
1064 mfbytestream_EndRead,
1065 mfbytestream_Write,
1066 mfbytestream_BeginWrite,
1067 mfbytestream_EndWrite,
1068 mfbytestream_Seek,
1069 mfbytestream_Flush,
1070 mfbytestream_Close
1073 static inline mfbytestream *impl_from_IMFByteStream_IMFAttributes(IMFAttributes *iface)
1075 return CONTAINING_RECORD(iface, mfbytestream, attributes.IMFAttributes_iface);
1078 static HRESULT WINAPI mfbytestream_attributes_QueryInterface(
1079 IMFAttributes *iface, REFIID riid, void **out)
1081 mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
1082 return IMFByteStream_QueryInterface(&This->IMFByteStream_iface, riid, out);
1085 static ULONG WINAPI mfbytestream_attributes_AddRef(IMFAttributes *iface)
1087 mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
1088 return IMFByteStream_AddRef(&This->IMFByteStream_iface);
1091 static ULONG WINAPI mfbytestream_attributes_Release(IMFAttributes *iface)
1093 mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
1094 return IMFByteStream_Release(&This->IMFByteStream_iface);
1097 static const IMFAttributesVtbl mfbytestream_attributes_vtbl =
1099 mfbytestream_attributes_QueryInterface,
1100 mfbytestream_attributes_AddRef,
1101 mfbytestream_attributes_Release,
1102 mfattributes_GetItem,
1103 mfattributes_GetItemType,
1104 mfattributes_CompareItem,
1105 mfattributes_Compare,
1106 mfattributes_GetUINT32,
1107 mfattributes_GetUINT64,
1108 mfattributes_GetDouble,
1109 mfattributes_GetGUID,
1110 mfattributes_GetStringLength,
1111 mfattributes_GetString,
1112 mfattributes_GetAllocatedString,
1113 mfattributes_GetBlobSize,
1114 mfattributes_GetBlob,
1115 mfattributes_GetAllocatedBlob,
1116 mfattributes_GetUnknown,
1117 mfattributes_SetItem,
1118 mfattributes_DeleteItem,
1119 mfattributes_DeleteAllItems,
1120 mfattributes_SetUINT32,
1121 mfattributes_SetUINT64,
1122 mfattributes_SetDouble,
1123 mfattributes_SetGUID,
1124 mfattributes_SetString,
1125 mfattributes_SetBlob,
1126 mfattributes_SetUnknown,
1127 mfattributes_LockStore,
1128 mfattributes_UnlockStore,
1129 mfattributes_GetCount,
1130 mfattributes_GetItemByIndex,
1131 mfattributes_CopyAllItems
1134 HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream)
1136 mfbytestream *object;
1138 TRACE("(%p, %p): stub\n", stream, bytestream);
1140 object = heap_alloc( sizeof(*object) );
1141 if(!object)
1142 return E_OUTOFMEMORY;
1144 init_attribute_object(&object->attributes, 0);
1145 object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl;
1146 object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
1148 *bytestream = &object->IMFByteStream_iface;
1150 return S_OK;
1153 HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags,
1154 LPCWSTR url, IMFByteStream **bytestream)
1156 mfbytestream *object;
1157 DWORD fileaccessmode = 0;
1158 DWORD filesharemode = FILE_SHARE_READ;
1159 DWORD filecreation_disposition = 0;
1160 DWORD fileattributes = 0;
1161 HANDLE file;
1163 FIXME("(%d, %d, %d, %s, %p): stub\n", accessmode, openmode, flags, debugstr_w(url), bytestream);
1165 switch (accessmode)
1167 case MF_ACCESSMODE_READ:
1168 fileaccessmode = GENERIC_READ;
1169 break;
1170 case MF_ACCESSMODE_WRITE:
1171 fileaccessmode = GENERIC_WRITE;
1172 break;
1173 case MF_ACCESSMODE_READWRITE:
1174 fileaccessmode = GENERIC_READ | GENERIC_WRITE;
1175 break;
1178 switch (openmode)
1180 case MF_OPENMODE_FAIL_IF_NOT_EXIST:
1181 filecreation_disposition = OPEN_EXISTING;
1182 break;
1183 case MF_OPENMODE_FAIL_IF_EXIST:
1184 filecreation_disposition = CREATE_NEW;
1185 break;
1186 case MF_OPENMODE_RESET_IF_EXIST:
1187 filecreation_disposition = TRUNCATE_EXISTING;
1188 break;
1189 case MF_OPENMODE_APPEND_IF_EXIST:
1190 filecreation_disposition = OPEN_ALWAYS;
1191 fileaccessmode |= FILE_APPEND_DATA;
1192 break;
1193 case MF_OPENMODE_DELETE_IF_EXIST:
1194 filecreation_disposition = CREATE_ALWAYS;
1195 break;
1198 if (flags & MF_FILEFLAGS_NOBUFFERING)
1199 fileattributes |= FILE_FLAG_NO_BUFFERING;
1201 /* Open HANDLE to file */
1202 file = CreateFileW(url, fileaccessmode, filesharemode, NULL,
1203 filecreation_disposition, fileattributes, 0);
1205 if(file == INVALID_HANDLE_VALUE)
1206 return HRESULT_FROM_WIN32(GetLastError());
1208 /* Close the file again, since we don't do anything with it yet */
1209 CloseHandle(file);
1211 object = heap_alloc( sizeof(*object) );
1212 if(!object)
1213 return E_OUTOFMEMORY;
1215 init_attribute_object(&object->attributes, 0);
1216 object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl;
1217 object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
1219 *bytestream = &object->IMFByteStream_iface;
1221 return S_OK;
1224 static HRESULT WINAPI MFPluginControl_QueryInterface(IMFPluginControl *iface, REFIID riid, void **ppv)
1226 if(IsEqualGUID(riid, &IID_IUnknown)) {
1227 TRACE("(IID_IUnknown %p)\n", ppv);
1228 *ppv = iface;
1229 }else if(IsEqualGUID(riid, &IID_IMFPluginControl)) {
1230 TRACE("(IID_IMFPluginControl %p)\n", ppv);
1231 *ppv = iface;
1232 }else {
1233 FIXME("(%s %p)\n", debugstr_guid(riid), ppv);
1234 *ppv = NULL;
1235 return E_NOINTERFACE;
1238 IUnknown_AddRef((IUnknown*)*ppv);
1239 return S_OK;
1242 static ULONG WINAPI MFPluginControl_AddRef(IMFPluginControl *iface)
1244 TRACE("\n");
1245 return 2;
1248 static ULONG WINAPI MFPluginControl_Release(IMFPluginControl *iface)
1250 TRACE("\n");
1251 return 1;
1254 static HRESULT WINAPI MFPluginControl_GetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type,
1255 const WCHAR *selector, CLSID *clsid)
1257 FIXME("(%d %s %p)\n", plugin_type, debugstr_w(selector), clsid);
1258 return E_NOTIMPL;
1261 static HRESULT WINAPI MFPluginControl_GetPreferredClsidByIndex(IMFPluginControl *iface, DWORD plugin_type,
1262 DWORD index, WCHAR **selector, CLSID *clsid)
1264 FIXME("(%d %d %p %p)\n", plugin_type, index, selector, clsid);
1265 return E_NOTIMPL;
1268 static HRESULT WINAPI MFPluginControl_SetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type,
1269 const WCHAR *selector, const CLSID *clsid)
1271 FIXME("(%d %s %s)\n", plugin_type, debugstr_w(selector), debugstr_guid(clsid));
1272 return E_NOTIMPL;
1275 static HRESULT WINAPI MFPluginControl_IsDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid)
1277 FIXME("(%d %s)\n", plugin_type, debugstr_guid(clsid));
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI MFPluginControl_GetDisabledByIndex(IMFPluginControl *iface, DWORD plugin_type, DWORD index, CLSID *clsid)
1283 FIXME("(%d %d %p)\n", plugin_type, index, clsid);
1284 return E_NOTIMPL;
1287 static HRESULT WINAPI MFPluginControl_SetDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid, BOOL disabled)
1289 FIXME("(%d %s %x)\n", plugin_type, debugstr_guid(clsid), disabled);
1290 return E_NOTIMPL;
1293 static const IMFPluginControlVtbl MFPluginControlVtbl = {
1294 MFPluginControl_QueryInterface,
1295 MFPluginControl_AddRef,
1296 MFPluginControl_Release,
1297 MFPluginControl_GetPreferredClsid,
1298 MFPluginControl_GetPreferredClsidByIndex,
1299 MFPluginControl_SetPreferredClsid,
1300 MFPluginControl_IsDisabled,
1301 MFPluginControl_GetDisabledByIndex,
1302 MFPluginControl_SetDisabled
1305 static IMFPluginControl plugin_control = { &MFPluginControlVtbl };
1307 /***********************************************************************
1308 * MFGetPluginControl (mfplat.@)
1310 HRESULT WINAPI MFGetPluginControl(IMFPluginControl **ret)
1312 TRACE("(%p)\n", ret);
1314 *ret = &plugin_control;
1315 return S_OK;
1318 typedef struct _mfsourceresolver
1320 IMFSourceResolver IMFSourceResolver_iface;
1321 LONG ref;
1322 } mfsourceresolver;
1324 static inline mfsourceresolver *impl_from_IMFSourceResolver(IMFSourceResolver *iface)
1326 return CONTAINING_RECORD(iface, mfsourceresolver, IMFSourceResolver_iface);
1329 static HRESULT WINAPI mfsourceresolver_QueryInterface(IMFSourceResolver *iface, REFIID riid, void **obj)
1331 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1333 TRACE("(%p->(%s, %p)\n", This, debugstr_guid(riid), obj);
1335 if (IsEqualIID(riid, &IID_IMFSourceResolver) ||
1336 IsEqualIID(riid, &IID_IUnknown))
1338 *obj = &This->IMFSourceResolver_iface;
1340 else
1342 *obj = NULL;
1343 FIXME("unsupported interface %s\n", debugstr_guid(riid));
1344 return E_NOINTERFACE;
1347 IUnknown_AddRef((IUnknown *)*obj);
1348 return S_OK;
1351 static ULONG WINAPI mfsourceresolver_AddRef(IMFSourceResolver *iface)
1353 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1354 ULONG ref = InterlockedIncrement(&This->ref);
1356 TRACE("(%p)->(%u)\n", This, ref);
1358 return ref;
1361 static ULONG WINAPI mfsourceresolver_Release(IMFSourceResolver *iface)
1363 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1364 ULONG ref = InterlockedDecrement(&This->ref);
1366 TRACE("(%p)->(%u)\n", This, ref);
1368 if (!ref)
1369 HeapFree(GetProcessHeap(), 0, This);
1371 return ref;
1374 static HRESULT WINAPI mfsourceresolver_CreateObjectFromURL(IMFSourceResolver *iface, const WCHAR *url,
1375 DWORD flags, IPropertyStore *props, MF_OBJECT_TYPE *obj_type, IUnknown **object)
1377 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1379 FIXME("(%p)->(%s, %#x, %p, %p, %p): stub\n", This, debugstr_w(url), flags, props, obj_type, object);
1381 return E_NOTIMPL;
1384 static HRESULT WINAPI mfsourceresolver_CreateObjectFromByteStream(IMFSourceResolver *iface, IMFByteStream *stream,
1385 const WCHAR *url, DWORD flags, IPropertyStore *props, MF_OBJECT_TYPE *obj_type, IUnknown **object)
1387 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1389 FIXME("(%p)->(%p, %s, %#x, %p, %p, %p): stub\n", This, stream, debugstr_w(url), flags, props, obj_type, object);
1391 return E_NOTIMPL;
1394 static HRESULT WINAPI mfsourceresolver_BeginCreateObjectFromURL(IMFSourceResolver *iface, const WCHAR *url,
1395 DWORD flags, IPropertyStore *props, IUnknown **cancel_cookie, IMFAsyncCallback *callback, IUnknown *unk_state)
1397 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1399 FIXME("(%p)->(%s, %#x, %p, %p, %p, %p): stub\n", This, debugstr_w(url), flags, props, cancel_cookie,
1400 callback, unk_state);
1402 return E_NOTIMPL;
1405 static HRESULT WINAPI mfsourceresolver_EndCreateObjectFromURL(IMFSourceResolver *iface, IMFAsyncResult *result,
1406 MF_OBJECT_TYPE *obj_type, IUnknown **object)
1408 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1410 FIXME("(%p)->(%p, %p, %p): stub\n", This, result, obj_type, object);
1412 return E_NOTIMPL;
1415 static HRESULT WINAPI mfsourceresolver_BeginCreateObjectFromByteStream(IMFSourceResolver *iface, IMFByteStream *stream,
1416 const WCHAR *url, DWORD flags, IPropertyStore *props, IUnknown **cancel_cookie, IMFAsyncCallback *callback,
1417 IUnknown *unk_state)
1419 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1421 FIXME("(%p)->(%p, %s, %#x, %p, %p, %p, %p): stub\n", This, stream, debugstr_w(url), flags, props, cancel_cookie,
1422 callback, unk_state);
1424 return E_NOTIMPL;
1427 static HRESULT WINAPI mfsourceresolver_EndCreateObjectFromByteStream(IMFSourceResolver *iface, IMFAsyncResult *result,
1428 MF_OBJECT_TYPE *obj_type, IUnknown **object)
1430 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1432 FIXME("(%p)->(%p, %p, %p): stub\n", This, result, obj_type, object);
1434 return E_NOTIMPL;
1437 static HRESULT WINAPI mfsourceresolver_CancelObjectCreation(IMFSourceResolver *iface, IUnknown *cancel_cookie)
1439 mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
1441 FIXME("(%p)->(%p): stub\n", This, cancel_cookie);
1443 return E_NOTIMPL;
1446 static const IMFSourceResolverVtbl mfsourceresolvervtbl =
1448 mfsourceresolver_QueryInterface,
1449 mfsourceresolver_AddRef,
1450 mfsourceresolver_Release,
1451 mfsourceresolver_CreateObjectFromURL,
1452 mfsourceresolver_CreateObjectFromByteStream,
1453 mfsourceresolver_BeginCreateObjectFromURL,
1454 mfsourceresolver_EndCreateObjectFromURL,
1455 mfsourceresolver_BeginCreateObjectFromByteStream,
1456 mfsourceresolver_EndCreateObjectFromByteStream,
1457 mfsourceresolver_CancelObjectCreation,
1460 /***********************************************************************
1461 * MFCreateSourceResolver (mfplat.@)
1463 HRESULT WINAPI MFCreateSourceResolver(IMFSourceResolver **resolver)
1465 mfsourceresolver *object;
1467 TRACE("%p\n", resolver);
1469 if (!resolver)
1470 return E_POINTER;
1472 object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) );
1473 if (!object)
1474 return E_OUTOFMEMORY;
1476 object->IMFSourceResolver_iface.lpVtbl = &mfsourceresolvervtbl;
1477 object->ref = 1;
1479 *resolver = &object->IMFSourceResolver_iface;
1480 return S_OK;
1483 typedef struct _mfmediatype
1485 mfattributes attributes;
1486 IMFMediaType IMFMediaType_iface;
1487 } mfmediatype;
1489 static inline mfmediatype *impl_from_IMFMediaType(IMFMediaType *iface)
1491 return CONTAINING_RECORD(iface, mfmediatype, IMFMediaType_iface);
1494 static HRESULT WINAPI mediatype_QueryInterface(IMFMediaType *iface, REFIID riid, void **object)
1496 mfmediatype *This = impl_from_IMFMediaType(iface);
1498 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), object);
1500 if(IsEqualGUID(riid, &IID_IUnknown) ||
1501 IsEqualGUID(riid, &IID_IMFAttributes) ||
1502 IsEqualGUID(riid, &IID_IMFMediaType))
1504 *object = &This->IMFMediaType_iface;
1506 else
1508 FIXME("(%s, %p)\n", debugstr_guid(riid), object);
1509 *object = NULL;
1510 return E_NOINTERFACE;
1513 IUnknown_AddRef((IUnknown*)*object);
1514 return S_OK;
1517 static ULONG WINAPI mediatype_AddRef(IMFMediaType *iface)
1519 mfmediatype *This = impl_from_IMFMediaType(iface);
1520 ULONG ref = InterlockedIncrement(&This->attributes.ref);
1522 TRACE("(%p) ref=%u\n", This, ref);
1524 return ref;
1527 static ULONG WINAPI mediatype_Release(IMFMediaType *iface)
1529 mfmediatype *This = impl_from_IMFMediaType(iface);
1530 ULONG ref = InterlockedDecrement(&This->attributes.ref);
1532 TRACE("(%p) ref=%u\n", This, ref);
1534 if (!ref)
1536 HeapFree(GetProcessHeap(), 0, This);
1539 return ref;
1542 static HRESULT WINAPI mediatype_GetItem(IMFMediaType *iface, REFGUID key, PROPVARIANT *value)
1544 mfmediatype *This = impl_from_IMFMediaType(iface);
1545 return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value);
1548 static HRESULT WINAPI mediatype_GetItemType(IMFMediaType *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
1550 mfmediatype *This = impl_from_IMFMediaType(iface);
1551 return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type);
1554 static HRESULT WINAPI mediatype_CompareItem(IMFMediaType *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
1556 mfmediatype *This = impl_from_IMFMediaType(iface);
1557 return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result);
1560 static HRESULT WINAPI mediatype_Compare(IMFMediaType *iface, IMFAttributes *attrs, MF_ATTRIBUTES_MATCH_TYPE type,
1561 BOOL *result)
1563 mfmediatype *This = impl_from_IMFMediaType(iface);
1564 return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, attrs, type, result);
1567 static HRESULT WINAPI mediatype_GetUINT32(IMFMediaType *iface, REFGUID key, UINT32 *value)
1569 mfmediatype *This = impl_from_IMFMediaType(iface);
1570 return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value);
1573 static HRESULT WINAPI mediatype_GetUINT64(IMFMediaType *iface, REFGUID key, UINT64 *value)
1575 mfmediatype *This = impl_from_IMFMediaType(iface);
1576 return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value);
1579 static HRESULT WINAPI mediatype_GetDouble(IMFMediaType *iface, REFGUID key, double *value)
1581 mfmediatype *This = impl_from_IMFMediaType(iface);
1582 return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value);
1585 static HRESULT WINAPI mediatype_GetGUID(IMFMediaType *iface, REFGUID key, GUID *value)
1587 mfmediatype *This = impl_from_IMFMediaType(iface);
1588 return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value);
1591 static HRESULT WINAPI mediatype_GetStringLength(IMFMediaType *iface, REFGUID key, UINT32 *length)
1593 mfmediatype *This = impl_from_IMFMediaType(iface);
1594 return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length);
1597 static HRESULT WINAPI mediatype_GetString(IMFMediaType *iface, REFGUID key, WCHAR *value,
1598 UINT32 size, UINT32 *length)
1600 mfmediatype *This = impl_from_IMFMediaType(iface);
1601 return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length);
1604 static HRESULT WINAPI mediatype_GetAllocatedString(IMFMediaType *iface, REFGUID key,
1605 WCHAR **value, UINT32 *length)
1607 mfmediatype *This = impl_from_IMFMediaType(iface);
1608 return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length);
1611 static HRESULT WINAPI mediatype_GetBlobSize(IMFMediaType *iface, REFGUID key, UINT32 *size)
1613 mfmediatype *This = impl_from_IMFMediaType(iface);
1614 return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size);
1617 static HRESULT WINAPI mediatype_GetBlob(IMFMediaType *iface, REFGUID key, UINT8 *buf,
1618 UINT32 bufsize, UINT32 *blobsize)
1620 mfmediatype *This = impl_from_IMFMediaType(iface);
1621 return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize);
1624 static HRESULT WINAPI mediatype_GetAllocatedBlob(IMFMediaType *iface, REFGUID key, UINT8 **buf, UINT32 *size)
1626 mfmediatype *This = impl_from_IMFMediaType(iface);
1627 return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
1630 static HRESULT WINAPI mediatype_GetUnknown(IMFMediaType *iface, REFGUID key, REFIID riid, void **ppv)
1632 mfmediatype *This = impl_from_IMFMediaType(iface);
1633 return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv);
1636 static HRESULT WINAPI mediatype_SetItem(IMFMediaType *iface, REFGUID key, REFPROPVARIANT value)
1638 mfmediatype *This = impl_from_IMFMediaType(iface);
1639 return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value);
1642 static HRESULT WINAPI mediatype_DeleteItem(IMFMediaType *iface, REFGUID key)
1644 mfmediatype *This = impl_from_IMFMediaType(iface);
1645 return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key);
1648 static HRESULT WINAPI mediatype_DeleteAllItems(IMFMediaType *iface)
1650 mfmediatype *This = impl_from_IMFMediaType(iface);
1651 return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface);
1654 static HRESULT WINAPI mediatype_SetUINT32(IMFMediaType *iface, REFGUID key, UINT32 value)
1656 mfmediatype *This = impl_from_IMFMediaType(iface);
1657 return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value);
1660 static HRESULT WINAPI mediatype_SetUINT64(IMFMediaType *iface, REFGUID key, UINT64 value)
1662 mfmediatype *This = impl_from_IMFMediaType(iface);
1663 return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value);
1666 static HRESULT WINAPI mediatype_SetDouble(IMFMediaType *iface, REFGUID key, double value)
1668 mfmediatype *This = impl_from_IMFMediaType(iface);
1669 return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value);
1672 static HRESULT WINAPI mediatype_SetGUID(IMFMediaType *iface, REFGUID key, REFGUID value)
1674 mfmediatype *This = impl_from_IMFMediaType(iface);
1675 return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value);
1678 static HRESULT WINAPI mediatype_SetString(IMFMediaType *iface, REFGUID key, const WCHAR *value)
1680 mfmediatype *This = impl_from_IMFMediaType(iface);
1681 return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value);
1684 static HRESULT WINAPI mediatype_SetBlob(IMFMediaType *iface, REFGUID key, const UINT8 *buf, UINT32 size)
1686 mfmediatype *This = impl_from_IMFMediaType(iface);
1687 return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
1690 static HRESULT WINAPI mediatype_SetUnknown(IMFMediaType *iface, REFGUID key, IUnknown *unknown)
1692 mfmediatype *This = impl_from_IMFMediaType(iface);
1693 return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown);
1696 static HRESULT WINAPI mediatype_LockStore(IMFMediaType *iface)
1698 mfmediatype *This = impl_from_IMFMediaType(iface);
1699 return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface);
1702 static HRESULT WINAPI mediatype_UnlockStore(IMFMediaType *iface)
1704 mfmediatype *This = impl_from_IMFMediaType(iface);
1705 return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface);
1708 static HRESULT WINAPI mediatype_GetCount(IMFMediaType *iface, UINT32 *items)
1710 mfmediatype *This = impl_from_IMFMediaType(iface);
1711 return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items);
1714 static HRESULT WINAPI mediatype_GetItemByIndex(IMFMediaType *iface, UINT32 index, GUID *key, PROPVARIANT *value)
1716 mfmediatype *This = impl_from_IMFMediaType(iface);
1717 return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value);
1720 static HRESULT WINAPI mediatype_CopyAllItems(IMFMediaType *iface, IMFAttributes *dest)
1722 mfmediatype *This = impl_from_IMFMediaType(iface);
1724 FIXME("%p, %p\n", This, dest);
1726 return E_NOTIMPL;
1729 static HRESULT WINAPI mediatype_GetMajorType(IMFMediaType *iface, GUID *guid)
1731 mfmediatype *This = impl_from_IMFMediaType(iface);
1733 FIXME("%p, %p\n", This, guid);
1735 return E_NOTIMPL;
1738 static HRESULT WINAPI mediatype_IsCompressedFormat(IMFMediaType *iface, BOOL *compressed)
1740 mfmediatype *This = impl_from_IMFMediaType(iface);
1742 FIXME("%p, %p\n", This, compressed);
1744 return E_NOTIMPL;
1747 static HRESULT WINAPI mediatype_IsEqual(IMFMediaType *iface, IMFMediaType *type, DWORD *flags)
1749 mfmediatype *This = impl_from_IMFMediaType(iface);
1751 FIXME("%p, %p, %p\n", This, type, flags);
1753 return E_NOTIMPL;
1756 static HRESULT WINAPI mediatype_GetRepresentation(IMFMediaType *iface, GUID guid, void **representation)
1758 mfmediatype *This = impl_from_IMFMediaType(iface);
1760 FIXME("%p, %s, %p\n", This, debugstr_guid(&guid), representation);
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI mediatype_FreeRepresentation(IMFMediaType *iface, GUID guid, void *representation)
1767 mfmediatype *This = impl_from_IMFMediaType(iface);
1769 FIXME("%p, %s, %p\n", This, debugstr_guid(&guid), representation);
1771 return E_NOTIMPL;
1774 static const IMFMediaTypeVtbl mediatype_vtbl =
1776 mediatype_QueryInterface,
1777 mediatype_AddRef,
1778 mediatype_Release,
1779 mediatype_GetItem,
1780 mediatype_GetItemType,
1781 mediatype_CompareItem,
1782 mediatype_Compare,
1783 mediatype_GetUINT32,
1784 mediatype_GetUINT64,
1785 mediatype_GetDouble,
1786 mediatype_GetGUID,
1787 mediatype_GetStringLength,
1788 mediatype_GetString,
1789 mediatype_GetAllocatedString,
1790 mediatype_GetBlobSize,
1791 mediatype_GetBlob,
1792 mediatype_GetAllocatedBlob,
1793 mediatype_GetUnknown,
1794 mediatype_SetItem,
1795 mediatype_DeleteItem,
1796 mediatype_DeleteAllItems,
1797 mediatype_SetUINT32,
1798 mediatype_SetUINT64,
1799 mediatype_SetDouble,
1800 mediatype_SetGUID,
1801 mediatype_SetString,
1802 mediatype_SetBlob,
1803 mediatype_SetUnknown,
1804 mediatype_LockStore,
1805 mediatype_UnlockStore,
1806 mediatype_GetCount,
1807 mediatype_GetItemByIndex,
1808 mediatype_CopyAllItems,
1809 mediatype_GetMajorType,
1810 mediatype_IsCompressedFormat,
1811 mediatype_IsEqual,
1812 mediatype_GetRepresentation,
1813 mediatype_FreeRepresentation
1816 /***********************************************************************
1817 * MFCreateMediaType (mfplat.@)
1819 HRESULT WINAPI MFCreateMediaType(IMFMediaType **type)
1821 mfmediatype *object;
1823 TRACE("%p\n", type);
1825 if(!type)
1826 return E_INVALIDARG;
1828 object = heap_alloc( sizeof(*object) );
1829 if(!object)
1830 return E_OUTOFMEMORY;
1832 init_attribute_object(&object->attributes, 0);
1833 object->IMFMediaType_iface.lpVtbl = &mediatype_vtbl;
1835 *type = &object->IMFMediaType_iface;
1837 return S_OK;
1840 typedef struct _mfeventqueue
1842 IMFMediaEventQueue IMFMediaEventQueue_iface;
1843 LONG ref;
1844 } mfeventqueue;
1846 static inline mfeventqueue *impl_from_IMFMediaEventQueue(IMFMediaEventQueue *iface)
1848 return CONTAINING_RECORD(iface, mfeventqueue, IMFMediaEventQueue_iface);
1851 static HRESULT WINAPI mfeventqueue_QueryInterface(IMFMediaEventQueue *iface, REFIID riid, void **out)
1853 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1855 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
1857 if(IsEqualGUID(riid, &IID_IUnknown) ||
1858 IsEqualGUID(riid, &IID_IMFMediaEventQueue))
1860 *out = &This->IMFMediaEventQueue_iface;
1862 else
1864 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
1865 *out = NULL;
1866 return E_NOINTERFACE;
1869 IUnknown_AddRef((IUnknown*)*out);
1870 return S_OK;
1873 static ULONG WINAPI mfeventqueue_AddRef(IMFMediaEventQueue *iface)
1875 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1876 ULONG ref = InterlockedIncrement(&This->ref);
1878 TRACE("(%p) ref=%u\n", This, ref);
1880 return ref;
1883 static ULONG WINAPI mfeventqueue_Release(IMFMediaEventQueue *iface)
1885 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1886 ULONG ref = InterlockedDecrement(&This->ref);
1888 TRACE("(%p) ref=%u\n", This, ref);
1890 if (!ref)
1892 HeapFree(GetProcessHeap(), 0, This);
1895 return ref;
1898 static HRESULT WINAPI mfeventqueue_GetEvent(IMFMediaEventQueue *iface, DWORD flags, IMFMediaEvent **event)
1900 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1902 FIXME("%p, %p\n", This, event);
1904 return E_NOTIMPL;
1907 static HRESULT WINAPI mfeventqueue_BeginGetEvent(IMFMediaEventQueue *iface, IMFAsyncCallback *callback, IUnknown *state)
1909 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1911 FIXME("%p, %p, %p\n", This, callback, state);
1913 return E_NOTIMPL;
1916 static HRESULT WINAPI mfeventqueue_EndGetEvent(IMFMediaEventQueue *iface, IMFAsyncResult *result, IMFMediaEvent **event)
1918 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1920 FIXME("%p, %p, %p\n", This, result, event);
1922 return E_NOTIMPL;
1925 static HRESULT WINAPI mfeventqueue_QueueEvent(IMFMediaEventQueue *iface, IMFMediaEvent *event)
1927 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1929 FIXME("%p, %p\n", This, event);
1931 return E_NOTIMPL;
1934 static HRESULT WINAPI mfeventqueue_QueueEventParamVar(IMFMediaEventQueue *iface, MediaEventType met,
1935 REFGUID type, HRESULT status, const PROPVARIANT *value)
1937 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1939 FIXME("%p, %d, %s, 0x%08x, %p\n", This, met, debugstr_guid(type), status, value);
1941 return E_NOTIMPL;
1944 static HRESULT WINAPI mfeventqueue_QueueEventParamUnk(IMFMediaEventQueue *iface, MediaEventType met, REFGUID type,
1945 HRESULT status, IUnknown *unk)
1947 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1949 FIXME("%p, %d, %s, 0x%08x, %p\n", This, met, debugstr_guid(type), status, unk);
1951 return E_NOTIMPL;
1954 static HRESULT WINAPI mfeventqueue_Shutdown(IMFMediaEventQueue *iface)
1956 mfeventqueue *This = impl_from_IMFMediaEventQueue(iface);
1958 FIXME("%p\n", This);
1960 return E_NOTIMPL;
1963 static const IMFMediaEventQueueVtbl mfeventqueue_vtbl =
1965 mfeventqueue_QueryInterface,
1966 mfeventqueue_AddRef,
1967 mfeventqueue_Release,
1968 mfeventqueue_GetEvent,
1969 mfeventqueue_BeginGetEvent,
1970 mfeventqueue_EndGetEvent,
1971 mfeventqueue_QueueEvent,
1972 mfeventqueue_QueueEventParamVar,
1973 mfeventqueue_QueueEventParamUnk,
1974 mfeventqueue_Shutdown
1977 /***********************************************************************
1978 * MFCreateEventQueue (mfplat.@)
1980 HRESULT WINAPI MFCreateEventQueue(IMFMediaEventQueue **queue)
1982 mfeventqueue *object;
1984 TRACE("%p\n", queue);
1986 object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) );
1987 if(!object)
1988 return E_OUTOFMEMORY;
1990 object->ref = 1;
1991 object->IMFMediaEventQueue_iface.lpVtbl = &mfeventqueue_vtbl;
1993 *queue = &object->IMFMediaEventQueue_iface;
1995 return S_OK;
1998 typedef struct _mfdescriptor
2000 mfattributes attributes;
2001 IMFStreamDescriptor IMFStreamDescriptor_iface;
2002 } mfdescriptor;
2004 static inline mfdescriptor *impl_from_IMFStreamDescriptor(IMFStreamDescriptor *iface)
2006 return CONTAINING_RECORD(iface, mfdescriptor, IMFStreamDescriptor_iface);
2009 static HRESULT WINAPI mfdescriptor_QueryInterface(IMFStreamDescriptor *iface, REFIID riid, void **out)
2011 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2013 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
2015 if(IsEqualGUID(riid, &IID_IUnknown) ||
2016 IsEqualGUID(riid, &IID_IMFAttributes) ||
2017 IsEqualGUID(riid, &IID_IMFStreamDescriptor))
2019 *out = &This->IMFStreamDescriptor_iface;
2021 else
2023 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
2024 *out = NULL;
2025 return E_NOINTERFACE;
2028 IUnknown_AddRef((IUnknown*)*out);
2029 return S_OK;
2032 static ULONG WINAPI mfdescriptor_AddRef(IMFStreamDescriptor *iface)
2034 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2035 ULONG ref = InterlockedIncrement(&This->attributes.ref);
2037 TRACE("(%p) ref=%u\n", This, ref);
2039 return ref;
2042 static ULONG WINAPI mfdescriptor_Release(IMFStreamDescriptor *iface)
2044 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2045 ULONG ref = InterlockedDecrement(&This->attributes.ref);
2047 TRACE("(%p) ref=%u\n", This, ref);
2049 if (!ref)
2051 heap_free(This);
2054 return ref;
2057 static HRESULT WINAPI mfdescriptor_GetItem(IMFStreamDescriptor *iface, REFGUID key, PROPVARIANT *value)
2059 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2060 return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value);
2063 static HRESULT WINAPI mfdescriptor_GetItemType(IMFStreamDescriptor *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
2065 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2066 return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type);
2069 static HRESULT WINAPI mfdescriptor_CompareItem(IMFStreamDescriptor *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
2071 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2072 return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result);
2075 static HRESULT WINAPI mfdescriptor_Compare(IMFStreamDescriptor *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
2076 BOOL *result)
2078 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2079 return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, theirs, type, result);
2082 static HRESULT WINAPI mfdescriptor_GetUINT32(IMFStreamDescriptor *iface, REFGUID key, UINT32 *value)
2084 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2085 return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value);
2088 static HRESULT WINAPI mfdescriptor_GetUINT64(IMFStreamDescriptor *iface, REFGUID key, UINT64 *value)
2090 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2091 return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value);
2094 static HRESULT WINAPI mfdescriptor_GetDouble(IMFStreamDescriptor *iface, REFGUID key, double *value)
2096 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2097 return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value);
2100 static HRESULT WINAPI mfdescriptor_GetGUID(IMFStreamDescriptor *iface, REFGUID key, GUID *value)
2102 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2103 return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value);
2106 static HRESULT WINAPI mfdescriptor_GetStringLength(IMFStreamDescriptor *iface, REFGUID key, UINT32 *length)
2108 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2109 return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length);
2112 static HRESULT WINAPI mfdescriptor_GetString(IMFStreamDescriptor *iface, REFGUID key, WCHAR *value,
2113 UINT32 size, UINT32 *length)
2115 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2116 return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length);
2119 static HRESULT WINAPI mfdescriptor_GetAllocatedString(IMFStreamDescriptor *iface, REFGUID key,
2120 WCHAR **value, UINT32 *length)
2122 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2123 return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length);
2126 static HRESULT WINAPI mfdescriptor_GetBlobSize(IMFStreamDescriptor *iface, REFGUID key, UINT32 *size)
2128 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2129 return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size);
2132 static HRESULT WINAPI mfdescriptor_GetBlob(IMFStreamDescriptor *iface, REFGUID key, UINT8 *buf,
2133 UINT32 bufsize, UINT32 *blobsize)
2135 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2136 return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize);
2139 static HRESULT WINAPI mfdescriptor_GetAllocatedBlob(IMFStreamDescriptor *iface, REFGUID key, UINT8 **buf, UINT32 *size)
2141 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2142 return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
2145 static HRESULT WINAPI mfdescriptor_GetUnknown(IMFStreamDescriptor *iface, REFGUID key, REFIID riid, void **ppv)
2147 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2148 return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv);
2151 static HRESULT WINAPI mfdescriptor_SetItem(IMFStreamDescriptor *iface, REFGUID key, REFPROPVARIANT value)
2153 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2154 return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value);
2157 static HRESULT WINAPI mfdescriptor_DeleteItem(IMFStreamDescriptor *iface, REFGUID key)
2159 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2160 return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key);
2163 static HRESULT WINAPI mfdescriptor_DeleteAllItems(IMFStreamDescriptor *iface)
2165 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2166 return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface);
2169 static HRESULT WINAPI mfdescriptor_SetUINT32(IMFStreamDescriptor *iface, REFGUID key, UINT32 value)
2171 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2172 return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value);
2175 static HRESULT WINAPI mfdescriptor_SetUINT64(IMFStreamDescriptor *iface, REFGUID key, UINT64 value)
2177 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2178 return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value);
2181 static HRESULT WINAPI mfdescriptor_SetDouble(IMFStreamDescriptor *iface, REFGUID key, double value)
2183 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2184 return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value);
2187 static HRESULT WINAPI mfdescriptor_SetGUID(IMFStreamDescriptor *iface, REFGUID key, REFGUID value)
2189 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2190 return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value);
2193 static HRESULT WINAPI mfdescriptor_SetString(IMFStreamDescriptor *iface, REFGUID key, const WCHAR *value)
2195 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2196 return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value);
2199 static HRESULT WINAPI mfdescriptor_SetBlob(IMFStreamDescriptor *iface, REFGUID key, const UINT8 *buf, UINT32 size)
2201 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2202 return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
2205 static HRESULT WINAPI mfdescriptor_SetUnknown(IMFStreamDescriptor *iface, REFGUID key, IUnknown *unknown)
2207 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2208 return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown);
2211 static HRESULT WINAPI mfdescriptor_LockStore(IMFStreamDescriptor *iface)
2213 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2214 return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface);
2217 static HRESULT WINAPI mfdescriptor_UnlockStore(IMFStreamDescriptor *iface)
2219 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2220 return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface);
2223 static HRESULT WINAPI mfdescriptor_GetCount(IMFStreamDescriptor *iface, UINT32 *items)
2225 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2226 return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items);
2229 static HRESULT WINAPI mfdescriptor_GetItemByIndex(IMFStreamDescriptor *iface, UINT32 index, GUID *key, PROPVARIANT *value)
2231 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2232 return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value);
2235 static HRESULT WINAPI mfdescriptor_CopyAllItems(IMFStreamDescriptor *iface, IMFAttributes *dest)
2237 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2239 FIXME("%p, %p\n", This, dest);
2241 return E_NOTIMPL;
2244 static HRESULT WINAPI mfdescriptor_GetStreamIdentifier(IMFStreamDescriptor *iface, DWORD *identifier)
2246 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2248 FIXME("%p, %p\n", This, identifier);
2250 return E_NOTIMPL;
2253 static HRESULT WINAPI mfdescriptor_GetMediaTypeHandler(IMFStreamDescriptor *iface, IMFMediaTypeHandler **handler)
2255 mfdescriptor *This = impl_from_IMFStreamDescriptor(iface);
2257 FIXME("%p, %p\n", This, handler);
2259 return E_NOTIMPL;
2262 static const IMFStreamDescriptorVtbl mfdescriptor_vtbl =
2264 mfdescriptor_QueryInterface,
2265 mfdescriptor_AddRef,
2266 mfdescriptor_Release,
2267 mfdescriptor_GetItem,
2268 mfdescriptor_GetItemType,
2269 mfdescriptor_CompareItem,
2270 mfdescriptor_Compare,
2271 mfdescriptor_GetUINT32,
2272 mfdescriptor_GetUINT64,
2273 mfdescriptor_GetDouble,
2274 mfdescriptor_GetGUID,
2275 mfdescriptor_GetStringLength,
2276 mfdescriptor_GetString,
2277 mfdescriptor_GetAllocatedString,
2278 mfdescriptor_GetBlobSize,
2279 mfdescriptor_GetBlob,
2280 mfdescriptor_GetAllocatedBlob,
2281 mfdescriptor_GetUnknown,
2282 mfdescriptor_SetItem,
2283 mfdescriptor_DeleteItem,
2284 mfdescriptor_DeleteAllItems,
2285 mfdescriptor_SetUINT32,
2286 mfdescriptor_SetUINT64,
2287 mfdescriptor_SetDouble,
2288 mfdescriptor_SetGUID,
2289 mfdescriptor_SetString,
2290 mfdescriptor_SetBlob,
2291 mfdescriptor_SetUnknown,
2292 mfdescriptor_LockStore,
2293 mfdescriptor_UnlockStore,
2294 mfdescriptor_GetCount,
2295 mfdescriptor_GetItemByIndex,
2296 mfdescriptor_CopyAllItems,
2297 mfdescriptor_GetStreamIdentifier,
2298 mfdescriptor_GetMediaTypeHandler
2301 HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD count,
2302 IMFMediaType **types, IMFStreamDescriptor **descriptor)
2304 mfdescriptor *object;
2306 TRACE("%d, %d, %p, %p\n", identifier, count, types, descriptor);
2308 object = heap_alloc(sizeof(*object));
2309 if(!object)
2310 return E_OUTOFMEMORY;
2312 init_attribute_object(&object->attributes, 0);
2313 object->IMFStreamDescriptor_iface.lpVtbl = &mfdescriptor_vtbl;
2314 *descriptor = &object->IMFStreamDescriptor_iface;
2316 return S_OK;
2320 typedef struct _mfbuffer
2322 IMFMediaBuffer IMFMediaBuffer_iface;
2323 LONG ref;
2325 BYTE *buffer;
2326 DWORD max_length;
2327 DWORD current;
2328 } mfbuffer;
2330 static inline mfbuffer *impl_from_IMFMediaBuffer(IMFMediaBuffer *iface)
2332 return CONTAINING_RECORD(iface, mfbuffer, IMFMediaBuffer_iface);
2335 static HRESULT WINAPI mfbuffer_QueryInterface(IMFMediaBuffer *iface, REFIID riid, void **out)
2337 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2339 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
2341 if(IsEqualGUID(riid, &IID_IUnknown) ||
2342 IsEqualGUID(riid, &IID_IMFMediaBuffer))
2344 *out = &This->IMFMediaBuffer_iface;
2346 else
2348 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
2349 *out = NULL;
2350 return E_NOINTERFACE;
2353 IUnknown_AddRef((IUnknown*)*out);
2354 return S_OK;
2357 static ULONG WINAPI mfbuffer_AddRef(IMFMediaBuffer *iface)
2359 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2360 ULONG ref = InterlockedIncrement(&This->ref);
2362 TRACE("(%p) ref=%u\n", This, ref);
2364 return ref;
2367 static ULONG WINAPI mfbuffer_Release(IMFMediaBuffer *iface)
2369 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2370 ULONG ref = InterlockedDecrement(&This->ref);
2372 TRACE("(%p) ref=%u\n", This, ref);
2374 if (!ref)
2376 heap_free(This->buffer);
2377 heap_free(This);
2380 return ref;
2383 static HRESULT WINAPI mfbuffer_Lock(IMFMediaBuffer *iface, BYTE **buffer, DWORD *max, DWORD *current)
2385 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2387 TRACE("%p, %p %p, %p\n", This, buffer, max, current);
2389 if(!buffer)
2390 return E_INVALIDARG;
2392 *buffer = This->buffer;
2393 if(max)
2394 *max = This->max_length;
2395 if(current)
2396 *current = This->current;
2398 return S_OK;
2401 static HRESULT WINAPI mfbuffer_Unlock(IMFMediaBuffer *iface)
2403 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2405 TRACE("%p\n", This);
2407 return S_OK;
2410 static HRESULT WINAPI mfbuffer_GetCurrentLength(IMFMediaBuffer *iface, DWORD *current)
2412 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2414 TRACE("%p\n", This);
2416 if(!current)
2417 return E_INVALIDARG;
2419 *current = This->current;
2421 return S_OK;
2424 static HRESULT WINAPI mfbuffer_SetCurrentLength(IMFMediaBuffer *iface, DWORD current)
2426 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2428 TRACE("%p, %u\n", This, current);
2430 if(current > This->max_length)
2431 return E_INVALIDARG;
2433 This->current = current;
2435 return S_OK;
2438 static HRESULT WINAPI mfbuffer_GetMaxLength(IMFMediaBuffer *iface, DWORD *max)
2440 mfbuffer *This = impl_from_IMFMediaBuffer(iface);
2442 TRACE("%p, %p\n", This, max);
2444 if(!max)
2445 return E_INVALIDARG;
2447 *max = This->max_length;
2449 return S_OK;
2452 static const IMFMediaBufferVtbl mfbuffer_vtbl =
2454 mfbuffer_QueryInterface,
2455 mfbuffer_AddRef,
2456 mfbuffer_Release,
2457 mfbuffer_Lock,
2458 mfbuffer_Unlock,
2459 mfbuffer_GetCurrentLength,
2460 mfbuffer_SetCurrentLength,
2461 mfbuffer_GetMaxLength
2464 HRESULT WINAPI MFCreateMemoryBuffer(DWORD max_length, IMFMediaBuffer **buffer)
2466 mfbuffer *object;
2467 BYTE *bytes;
2469 TRACE("%u, %p\n", max_length, buffer);
2471 if(!buffer)
2472 return E_INVALIDARG;
2474 object = heap_alloc( sizeof(*object) );
2475 if(!object)
2476 return E_OUTOFMEMORY;
2478 bytes = heap_alloc( max_length );
2479 if(!bytes)
2481 heap_free(object);
2482 return E_OUTOFMEMORY;
2485 object->ref = 1;
2486 object->max_length = max_length;
2487 object->current = 0;
2488 object->buffer = bytes;
2489 object->IMFMediaBuffer_iface.lpVtbl = &mfbuffer_vtbl;
2490 *buffer = &object->IMFMediaBuffer_iface;
2492 return S_OK;
2495 typedef struct _mfsample
2497 mfattributes attributes;
2498 IMFSample IMFSample_iface;
2499 } mfsample;
2501 static inline mfsample *impl_from_IMFSample(IMFSample *iface)
2503 return CONTAINING_RECORD(iface, mfsample, IMFSample_iface);
2506 static HRESULT WINAPI mfsample_QueryInterface(IMFSample *iface, REFIID riid, void **out)
2508 mfsample *This = impl_from_IMFSample(iface);
2510 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
2512 if(IsEqualGUID(riid, &IID_IUnknown) ||
2513 IsEqualGUID(riid, &IID_IMFAttributes) ||
2514 IsEqualGUID(riid, &IID_IMFSample))
2516 *out = &This->IMFSample_iface;
2518 else
2520 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
2521 *out = NULL;
2522 return E_NOINTERFACE;
2525 IUnknown_AddRef((IUnknown*)*out);
2526 return S_OK;
2529 static ULONG WINAPI mfsample_AddRef(IMFSample *iface)
2531 mfsample *This = impl_from_IMFSample(iface);
2532 ULONG ref = InterlockedIncrement(&This->attributes.ref);
2534 TRACE("(%p) ref=%u\n", This, ref);
2536 return ref;
2539 static ULONG WINAPI mfsample_Release(IMFSample *iface)
2541 mfsample *This = impl_from_IMFSample(iface);
2542 ULONG ref = InterlockedDecrement(&This->attributes.ref);
2544 TRACE("(%p) ref=%u\n", This, ref);
2546 if (!ref)
2548 heap_free(This);
2551 return ref;
2554 static HRESULT WINAPI mfsample_GetItem(IMFSample *iface, REFGUID key, PROPVARIANT *value)
2556 mfsample *This = impl_from_IMFSample(iface);
2557 return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value);
2560 static HRESULT WINAPI mfsample_GetItemType(IMFSample *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
2562 mfsample *This = impl_from_IMFSample(iface);
2563 return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type);
2566 static HRESULT WINAPI mfsample_CompareItem(IMFSample *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
2568 mfsample *This = impl_from_IMFSample(iface);
2569 return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result);
2572 static HRESULT WINAPI mfsample_Compare(IMFSample *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
2573 BOOL *result)
2575 mfsample *This = impl_from_IMFSample(iface);
2576 return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, theirs, type, result);
2579 static HRESULT WINAPI mfsample_GetUINT32(IMFSample *iface, REFGUID key, UINT32 *value)
2581 mfsample *This = impl_from_IMFSample(iface);
2582 return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value);
2585 static HRESULT WINAPI mfsample_GetUINT64(IMFSample *iface, REFGUID key, UINT64 *value)
2587 mfsample *This = impl_from_IMFSample(iface);
2588 return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value);
2591 static HRESULT WINAPI mfsample_GetDouble(IMFSample *iface, REFGUID key, double *value)
2593 mfsample *This = impl_from_IMFSample(iface);
2594 return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value);
2597 static HRESULT WINAPI mfsample_GetGUID(IMFSample *iface, REFGUID key, GUID *value)
2599 mfsample *This = impl_from_IMFSample(iface);
2600 return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value);
2603 static HRESULT WINAPI mfsample_GetStringLength(IMFSample *iface, REFGUID key, UINT32 *length)
2605 mfsample *This = impl_from_IMFSample(iface);
2606 return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length);
2609 static HRESULT WINAPI mfsample_GetString(IMFSample *iface, REFGUID key, WCHAR *value,
2610 UINT32 size, UINT32 *length)
2612 mfsample *This = impl_from_IMFSample(iface);
2613 return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length);
2616 static HRESULT WINAPI mfsample_GetAllocatedString(IMFSample *iface, REFGUID key,
2617 WCHAR **value, UINT32 *length)
2619 mfsample *This = impl_from_IMFSample(iface);
2620 return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length);
2623 static HRESULT WINAPI mfsample_GetBlobSize(IMFSample *iface, REFGUID key, UINT32 *size)
2625 mfsample *This = impl_from_IMFSample(iface);
2626 return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size);
2629 static HRESULT WINAPI mfsample_GetBlob(IMFSample *iface, REFGUID key, UINT8 *buf,
2630 UINT32 bufsize, UINT32 *blobsize)
2632 mfsample *This = impl_from_IMFSample(iface);
2633 return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize);
2636 static HRESULT WINAPI mfsample_GetAllocatedBlob(IMFSample *iface, REFGUID key, UINT8 **buf, UINT32 *size)
2638 mfsample *This = impl_from_IMFSample(iface);
2639 return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
2642 static HRESULT WINAPI mfsample_GetUnknown(IMFSample *iface, REFGUID key, REFIID riid, void **ppv)
2644 mfsample *This = impl_from_IMFSample(iface);
2645 return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv);
2648 static HRESULT WINAPI mfsample_SetItem(IMFSample *iface, REFGUID key, REFPROPVARIANT value)
2650 mfsample *This = impl_from_IMFSample(iface);
2651 return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value);
2654 static HRESULT WINAPI mfsample_DeleteItem(IMFSample *iface, REFGUID key)
2656 mfsample *This = impl_from_IMFSample(iface);
2657 return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key);
2660 static HRESULT WINAPI mfsample_DeleteAllItems(IMFSample *iface)
2662 mfsample *This = impl_from_IMFSample(iface);
2663 return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface);
2666 static HRESULT WINAPI mfsample_SetUINT32(IMFSample *iface, REFGUID key, UINT32 value)
2668 mfsample *This = impl_from_IMFSample(iface);
2669 return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value);
2672 static HRESULT WINAPI mfsample_SetUINT64(IMFSample *iface, REFGUID key, UINT64 value)
2674 mfsample *This = impl_from_IMFSample(iface);
2675 return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value);
2678 static HRESULT WINAPI mfsample_SetDouble(IMFSample *iface, REFGUID key, double value)
2680 mfsample *This = impl_from_IMFSample(iface);
2681 return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value);
2684 static HRESULT WINAPI mfsample_SetGUID(IMFSample *iface, REFGUID key, REFGUID value)
2686 mfsample *This = impl_from_IMFSample(iface);
2687 return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value);
2690 static HRESULT WINAPI mfsample_SetString(IMFSample *iface, REFGUID key, const WCHAR *value)
2692 mfsample *This = impl_from_IMFSample(iface);
2693 return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value);
2696 static HRESULT WINAPI mfsample_SetBlob(IMFSample *iface, REFGUID key, const UINT8 *buf, UINT32 size)
2698 mfsample *This = impl_from_IMFSample(iface);
2699 return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
2702 static HRESULT WINAPI mfsample_SetUnknown(IMFSample *iface, REFGUID key, IUnknown *unknown)
2704 mfsample *This = impl_from_IMFSample(iface);
2705 return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown);
2708 static HRESULT WINAPI mfsample_LockStore(IMFSample *iface)
2710 mfsample *This = impl_from_IMFSample(iface);
2711 return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface);
2714 static HRESULT WINAPI mfsample_UnlockStore(IMFSample *iface)
2716 mfsample *This = impl_from_IMFSample(iface);
2717 return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface);
2720 static HRESULT WINAPI mfsample_GetCount(IMFSample *iface, UINT32 *items)
2722 mfsample *This = impl_from_IMFSample(iface);
2723 return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items);
2726 static HRESULT WINAPI mfsample_GetItemByIndex(IMFSample *iface, UINT32 index, GUID *key, PROPVARIANT *value)
2728 mfsample *This = impl_from_IMFSample(iface);
2729 return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value);
2732 static HRESULT WINAPI mfsample_CopyAllItems(IMFSample *iface, IMFAttributes *dest)
2734 mfsample *This = impl_from_IMFSample(iface);
2736 FIXME("%p, %p\n", This, dest);
2738 return E_NOTIMPL;
2741 static HRESULT WINAPI mfsample_GetSampleFlags(IMFSample *iface, DWORD *flags)
2743 mfsample *This = impl_from_IMFSample(iface);
2745 FIXME("%p, %p\n", This, flags);
2747 return E_NOTIMPL;
2750 static HRESULT WINAPI mfsample_SetSampleFlags(IMFSample *iface, DWORD flags)
2752 mfsample *This = impl_from_IMFSample(iface);
2754 FIXME("%p, %x\n", This, flags);
2756 return E_NOTIMPL;
2759 static HRESULT WINAPI mfsample_GetSampleTime(IMFSample *iface, LONGLONG *sampletime)
2761 mfsample *This = impl_from_IMFSample(iface);
2763 FIXME("%p, %p\n", This, sampletime);
2765 return E_NOTIMPL;
2768 static HRESULT WINAPI mfsample_SetSampleTime(IMFSample *iface, LONGLONG sampletime)
2770 mfsample *This = impl_from_IMFSample(iface);
2772 FIXME("%p, %s\n", This, wine_dbgstr_longlong(sampletime));
2774 return E_NOTIMPL;
2777 static HRESULT WINAPI mfsample_GetSampleDuration(IMFSample *iface, LONGLONG *duration)
2779 mfsample *This = impl_from_IMFSample(iface);
2781 FIXME("%p, %p\n", This, duration);
2783 return E_NOTIMPL;
2786 static HRESULT WINAPI mfsample_SetSampleDuration(IMFSample *iface, LONGLONG duration)
2788 mfsample *This = impl_from_IMFSample(iface);
2790 FIXME("%p, %s\n", This, wine_dbgstr_longlong(duration));
2792 return E_NOTIMPL;
2795 static HRESULT WINAPI mfsample_GetBufferCount(IMFSample *iface, DWORD *count)
2797 mfsample *This = impl_from_IMFSample(iface);
2799 FIXME("%p, %p\n", This, count);
2801 if(*count)
2802 *count = 0;
2804 return S_OK;
2807 static HRESULT WINAPI mfsample_GetBufferByIndex(IMFSample *iface, DWORD index, IMFMediaBuffer **buffer)
2809 mfsample *This = impl_from_IMFSample(iface);
2811 FIXME("%p, %u, %p\n", This, index, buffer);
2813 return E_NOTIMPL;
2816 static HRESULT WINAPI mfsample_ConvertToContiguousBuffer(IMFSample *iface, IMFMediaBuffer **buffer)
2818 mfsample *This = impl_from_IMFSample(iface);
2820 FIXME("%p, %p\n", This, buffer);
2822 return E_NOTIMPL;
2825 static HRESULT WINAPI mfsample_AddBuffer(IMFSample *iface, IMFMediaBuffer *buffer)
2827 mfsample *This = impl_from_IMFSample(iface);
2829 FIXME("%p, %p\n", This, buffer);
2831 return E_NOTIMPL;
2834 static HRESULT WINAPI mfsample_RemoveBufferByIndex(IMFSample *iface, DWORD index)
2836 mfsample *This = impl_from_IMFSample(iface);
2838 FIXME("%p, %u\n", This, index);
2840 return E_NOTIMPL;
2843 static HRESULT WINAPI mfsample_RemoveAllBuffers(IMFSample *iface)
2845 mfsample *This = impl_from_IMFSample(iface);
2847 FIXME("%p\n", This);
2849 return E_NOTIMPL;
2852 static HRESULT WINAPI mfsample_GetTotalLength(IMFSample *iface, DWORD *length)
2854 mfsample *This = impl_from_IMFSample(iface);
2856 FIXME("%p, %p\n", This, length);
2858 return E_NOTIMPL;
2861 static HRESULT WINAPI mfsample_CopyToBuffer(IMFSample *iface, IMFMediaBuffer *buffer)
2863 mfsample *This = impl_from_IMFSample(iface);
2865 FIXME("%p, %p\n", This, buffer);
2867 return E_NOTIMPL;
2870 static const IMFSampleVtbl mfsample_vtbl =
2872 mfsample_QueryInterface,
2873 mfsample_AddRef,
2874 mfsample_Release,
2875 mfsample_GetItem,
2876 mfsample_GetItemType,
2877 mfsample_CompareItem,
2878 mfsample_Compare,
2879 mfsample_GetUINT32,
2880 mfsample_GetUINT64,
2881 mfsample_GetDouble,
2882 mfsample_GetGUID,
2883 mfsample_GetStringLength,
2884 mfsample_GetString,
2885 mfsample_GetAllocatedString,
2886 mfsample_GetBlobSize,
2887 mfsample_GetBlob,
2888 mfsample_GetAllocatedBlob,
2889 mfsample_GetUnknown,
2890 mfsample_SetItem,
2891 mfsample_DeleteItem,
2892 mfsample_DeleteAllItems,
2893 mfsample_SetUINT32,
2894 mfsample_SetUINT64,
2895 mfsample_SetDouble,
2896 mfsample_SetGUID,
2897 mfsample_SetString,
2898 mfsample_SetBlob,
2899 mfsample_SetUnknown,
2900 mfsample_LockStore,
2901 mfsample_UnlockStore,
2902 mfsample_GetCount,
2903 mfsample_GetItemByIndex,
2904 mfsample_CopyAllItems,
2905 mfsample_GetSampleFlags,
2906 mfsample_SetSampleFlags,
2907 mfsample_GetSampleTime,
2908 mfsample_SetSampleTime,
2909 mfsample_GetSampleDuration,
2910 mfsample_SetSampleDuration,
2911 mfsample_GetBufferCount,
2912 mfsample_GetBufferByIndex,
2913 mfsample_ConvertToContiguousBuffer,
2914 mfsample_AddBuffer,
2915 mfsample_RemoveBufferByIndex,
2916 mfsample_RemoveAllBuffers,
2917 mfsample_GetTotalLength,
2918 mfsample_CopyToBuffer
2921 HRESULT WINAPI MFCreateSample(IMFSample **sample)
2923 mfsample *object;
2925 TRACE("%p\n", sample);
2927 object = heap_alloc(sizeof(*object));
2928 if(!object)
2929 return E_OUTOFMEMORY;
2931 init_attribute_object(&object->attributes, 0);
2932 object->IMFSample_iface.lpVtbl = &mfsample_vtbl;
2933 *sample = &object->IMFSample_iface;
2935 return S_OK;