Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/Makefile.in | 2 +- dlls/mfplat/main.c | 39 ++++++++++++++++++++++++++++++-------- dlls/mfplat/tests/mfplat.c | 28 +++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in index 76843f5f25..9a4e41c430 100644 --- a/dlls/mfplat/Makefile.in +++ b/dlls/mfplat/Makefile.in @@ -1,6 +1,6 @@ MODULE = mfplat.dll IMPORTLIB = mfplat -IMPORTS = advapi32 ole32 +IMPORTS = advapi32 ole32 propsys
C_SRCS = \ main.c diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 6e056b3609..1d8b110a09 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -31,6 +31,7 @@ #include "mfapi.h" #include "mfidl.h" #include "mferror.h" +#include "propvarutil.h"
#include "wine/heap.h" #include "wine/debug.h" @@ -589,19 +590,33 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes * static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hres;
- FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = MF_ATTRIBUTE_UINT32; + hres = mfattributes_getitem(This, key, &attrval, TRUE); + if(SUCCEEDED(hres)) + hres = PropVariantToUInt32(&attrval, value); + return hres; }
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hres;
- FIXME("%p, %s, %p\n", This, debugstr_guid(key), value); + TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = MF_ATTRIBUTE_UINT64; + hres = mfattributes_getitem(This, key, &attrval, TRUE); + if(SUCCEEDED(hres)) + hres = PropVariantToUInt64(&attrval, value); + return hres; }
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) @@ -776,19 +791,27 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface) static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- FIXME("%p, %s, %d\n", This, debugstr_guid(key), value); + TRACE("(%p, %s, %d)\n", This, debugstr_guid(key), value);
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = VT_UI4; + attrval.ulVal = value; + return mfattribute_setitem(This, key, &attrval); }
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value) { mfattributes *This = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- FIXME("%p, %s, %s\n", This, debugstr_guid(key), wine_dbgstr_longlong(value)); + FIXME("(%p, %s, %s)\n", This, debugstr_guid(key), wine_dbgstr_longlong(value));
- return E_NOTIMPL; + PropVariantInit(&attrval); + attrval.vt = MF_ATTRIBUTE_UINT64; + attrval.uhVal.QuadPart = value; + return mfattribute_setitem(This, key, &attrval); }
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index fff424e798..7ae87c2fc1 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -413,6 +413,8 @@ static void test_MFCreateAttributes(void) IMFAttributes *attributes; HRESULT hr; UINT32 count; + UINT32 uint32_value; + UINT64 uint64_value;
hr = MFCreateAttributes( &attributes, 3 ); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -422,13 +424,35 @@ static void test_MFCreateAttributes(void) todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); ok(count == 0, "got %d\n", count);
- hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123); + ok(hr == S_OK, "IMFAttributes_SetUINT32 failed: 0x%08x.\n", hr);
hr = IMFAttributes_GetCount(attributes, &count); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(count == 1, "got %d\n", count);
+ uint32_value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint32_value); + ok(hr == S_OK, "IMFAttributes_GetUINT32 failed: 0x%08x.\n", hr); + ok(uint32_value == 123, "got wrong value: %d, expected: 123.\n", uint32_value); + + uint64_value = 0xdeadbeef; + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint64_value); + ok(hr == MF_E_INVALIDTYPE, "IMFAttributes_GetUINT64 should fail: 0x%08x.\n", hr); + ok(uint64_value == 0xdeadbeef, "got wrong value: %lld, expected: 0xdeadbeef.\n", uint64_value); + + hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536); + ok(hr == S_OK, "IMFAttributes_SetUINT64 failed: 0x%08x.\n", hr); + + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint64_value); + ok(hr == S_OK, "IMFAttributes_GetUINT64 failed: 0x%08x.\n", hr); + ok(uint64_value == 65536, "got wrong value: %lld, expected: 65536.\n", uint64_value); + + uint32_value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint32_value); + ok(hr == MF_E_INVALIDTYPE, "IMFAttributes_GetUINT32 should fail: 0x%08x.\n", hr); + ok(uint32_value == 0xdeadbeef, "got wrong value: %d, expected: 0xdeadbeef.\n", uint32_value); + IMFAttributes_Release(attributes); }
On 12/28/18 6:43 PM, Jactry Zeng wrote:
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) { mfattributes *This = impl_from_IMFAttributes(iface);
- PROPVARIANT attrval;
- HRESULT hres;
- FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
- TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
- return E_NOTIMPL;
- PropVariantInit(&attrval);
- attrval.vt = MF_ATTRIBUTE_UINT32;
- hres = mfattributes_getitem(This, key, &attrval, TRUE);
- if(SUCCEEDED(hres))
hres = PropVariantToUInt32(&attrval, value);
- return hres; }
I think it's better to use VT_* naming.
Last argument of getitem helper is supposed to trigger type validation, so successful path implies that types are matching and you probably don't need additional coercion call.