Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/main.c | 20 ++++++++--- dlls/mfplat/tests/mfplat.c | 74 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 7a6d8d5475..c1f0188a0f 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -731,10 +731,18 @@ static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUI static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hres;
- FIXME("%p, %s, %s, %p\n", This, debugstr_guid(key), debugstr_guid(riid), ppv); + TRACE("(%p, %s, %s, %p)\n", This, debugstr_guid(key), debugstr_guid(riid), ppv);
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = MF_ATTRIBUTE_IUNKNOWN; + hres = mfattributes_getitem(This, key, &attrval, TRUE); + if(SUCCEEDED(hres)) + hres = IUnknown_QueryInterface(attrval.punkVal, riid, ppv); + PropVariantClear(&attrval); + return hres; }
static HRESULT mfattribute_setitem(mfattributes *object, REFGUID key, REFPROPVARIANT value) @@ -901,10 +909,14 @@ static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, co static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- FIXME("%p, %s, %p\n", This, debugstr_guid(key), unknown); + TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), unknown);
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = VT_UNKNOWN; + attrval.punkVal = unknown; + return mfattribute_setitem(This, key, &attrval); }
static HRESULT WINAPI mfattributes_LockStore(IMFAttributes *iface) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 975b40a5f3..c7f8fe6e51 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -53,6 +53,7 @@ DEFINE_GUID(MFT_CATEGORY_OTHER, 0x90175d57,0xb7ea,0x4901,0xae,0xb3,0x93,0x3a,0x8 DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19); DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21); DEFINE_GUID(DUMMY_GUID2, 0x12345678,0x1234,0x1234,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22); +DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23);
static const WCHAR mp4file[] = {'t','e','s','t','.','m','p','4',0};
@@ -419,6 +420,50 @@ static void _check_count(IMFAttributes* obj, ULONG expected, int line) ok_(__FILE__,line)(count == expected, "got %d, expected %d.\n", count, expected); }
+struct unk_impl +{ + IUnknown IUnknown_iface; + LONG ref; +}; + +static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface); +} + +static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_QueryInterface()\n"); + *ppv = &This->IUnknown_iface; + IUnknown_AddRef(iface); + return S_OK; +} + +static ULONG WINAPI unk_AddRef(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_AddRef()\n"); + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI unk_Release(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + if(winetest_debug > 1) + trace("Call to unk_Release()\n"); + return InterlockedDecrement(&This->ref); +} + +static const IUnknownVtbl unk_vtbl = +{ + unk_QueryInterface, + unk_AddRef, + unk_Release +}; + static void test_MFCreateAttributes(void) { IMFAttributes *attributes; @@ -429,6 +474,9 @@ static void test_MFCreateAttributes(void) const static WCHAR stringW[] = {'W','i','n','e',0}; WCHAR bufferW[256] = {0}; WCHAR *allacted_string = NULL; + IUnknown *unk_value = NULL, *unk = NULL; + struct unk_impl unk_obj = {{&unk_vtbl}, 1}; + struct unk_impl unk_obj2 = {{&unk_vtbl}, 22};
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -507,6 +555,32 @@ static void test_MFCreateAttributes(void) ok(hr == E_INVALIDARG, "IMFAttributes_SetString should fail: 0x%08x.\n", hr); CHECK_COUNT(attributes, 3);
+ hr = IMFAttributes_SetUnknown(attributes, &DUMMY_GUID2, &unk_obj.IUnknown_iface); + ok(hr == S_OK, "IMFAttributes_SetUnknown failed: 0x%08x\n", hr); + CHECK_COUNT(attributes, 4); + ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref); + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IUnknown, (void **)&unk_value); + ok(hr == S_OK, "IMFAttributes_GetUnknown failed: 0x%08x\n", hr); + ok(unk_obj.ref == 3, "got wrong refcount: %d.\n", unk_obj.ref); + + hr = IMFAttributes_SetUnknown(attributes, &DUMMY_GUID2, &unk_obj2.IUnknown_iface); + ok(hr == S_OK, "IMFAttributes_SetUnknown failed: 0x%08x\n", hr); + CHECK_COUNT(attributes, 4); + ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref); + ok(unk_obj2.ref == 23, "got wrong refcount: %d.\n", unk_obj.ref); + unk_value = NULL; + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IUnknown, (void **)&unk_value); + ok(hr == S_OK, "IMFAttributes_GetUnknown failed: 0x%08x\n", hr); + ok(unk_obj.ref == 2, "got wrong refcount: %d.\n", unk_obj.ref); + ok(unk_obj2.ref == 24, "got wrong refcount: %d.\n", unk_obj2.ref); + + hr = IMFAttributes_SetUnknown(attributes, &DUMMY_GUID3, unk); + ok(hr == S_OK, "IMFAttributes_SetUnknown failed: 0x%08x\n", hr); + CHECK_COUNT(attributes, 5); + unk_value = NULL; + hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID3, &IID_IUnknown, (void **)&unk_value); + ok(hr == MF_E_INVALIDTYPE, "IMFAttributes_GetUnknown failed: 0x%08x\n", hr); + IMFAttributes_Release(attributes); }