mfplat: Add support for integer attribute values.

Signed-off-by: Jactry Zeng <jzeng@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jactry Zeng 2019-03-14 11:03:11 +03:00 committed by Alexandre Julliard
parent a80b603c03
commit c127fab80e
4 changed files with 91 additions and 19 deletions

View File

@ -1,6 +1,6 @@
MODULE = mfplat.dll MODULE = mfplat.dll
IMPORTLIB = mfplat IMPORTLIB = mfplat
IMPORTS = advapi32 ole32 mfuuid IMPORTS = advapi32 ole32 mfuuid propsys
C_SRCS = \ C_SRCS = \
buffer.c \ buffer.c \

View File

@ -20,6 +20,7 @@
#include <string.h> #include <string.h>
#define COBJMACROS #define COBJMACROS
#define NONAMELESSUNION
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
@ -35,6 +36,7 @@
#include "mfplat_private.h" #include "mfplat_private.h"
#include "mfreadwrite.h" #include "mfreadwrite.h"
#include "propvarutil.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat); WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@ -659,6 +661,29 @@ static struct attribute *attributes_find_item(struct attributes *attributes, REF
return NULL; return NULL;
} }
static HRESULT attributes_get_item(struct attributes *attributes, const GUID *key, PROPVARIANT *value)
{
struct attribute *attribute;
HRESULT hr;
EnterCriticalSection(&attributes->cs);
attribute = attributes_find_item(attributes, key, NULL);
if (attribute)
{
if (attribute->value.vt == value->vt)
hr = PropVariantCopy(value, &attribute->value);
else
hr = MF_E_INVALIDTYPE;
}
else
hr = MF_E_ATTRIBUTENOTFOUND;
LeaveCriticalSection(&attributes->cs);
return hr;
}
static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value)
{ {
struct attributes *attributes = impl_from_IMFAttributes(iface); struct attributes *attributes = impl_from_IMFAttributes(iface);
@ -705,16 +730,34 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value)
{ {
FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
HRESULT hr;
return E_NOTIMPL; TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
PropVariantInit(&attrval);
attrval.vt = VT_UI4;
hr = attributes_get_item(attributes, key, &attrval);
if (SUCCEEDED(hr))
hr = PropVariantToUInt32(&attrval, value);
return hr;
} }
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value) static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value)
{ {
FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
HRESULT hr;
return E_NOTIMPL; TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
PropVariantInit(&attrval);
attrval.vt = VT_UI8;
hr = attributes_get_item(attributes, key, &attrval);
if (SUCCEEDED(hr))
hr = PropVariantToUInt64(&attrval, value);
return hr;
} }
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value)
@ -873,16 +916,26 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value)
{ {
FIXME("%p, %s, %d.\n", iface, debugstr_attr(key), value); struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
return E_NOTIMPL; TRACE("%p, %s, %d.\n", iface, debugstr_attr(key), value);
attrval.vt = VT_UI4;
attrval.u.ulVal = value;
return attributes_set_item(attributes, key, &attrval);
} }
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value) static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value)
{ {
FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value)); struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
return E_NOTIMPL; TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value));
attrval.vt = VT_UI8;
attrval.u.uhVal.QuadPart = value;
return attributes_set_item(attributes, key, &attrval);
} }
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value)
@ -3481,7 +3534,7 @@ static HRESULT WINAPI eventqueue_QueueEventParamUnk(IMFMediaEventQueue *iface, M
TRACE("%p, %d, %s, %#x, %p.\n", iface, event_type, debugstr_guid(extended_type), status, unk); TRACE("%p, %d, %s, %#x, %p.\n", iface, event_type, debugstr_guid(extended_type), status, unk);
value.vt = VT_UNKNOWN; value.vt = VT_UNKNOWN;
value.punkVal = unk; value.u.punkVal = unk;
if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, &value, &event))) if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, &value, &event)))
return hr; return hr;

View File

@ -359,25 +359,21 @@ todo_wine
ok(compressed, "Unexpected value %d.\n", compressed); ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 0); hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 0);
todo_wine
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = FALSE; compressed = FALSE;
hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed);
todo_wine
ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr);
ok(compressed, "Unexpected value %d.\n", compressed); ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1); hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1);
todo_wine
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = TRUE; compressed = TRUE;
hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed);
todo_wine {
ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr);
ok(!compressed, "Unexpected value %d.\n", compressed); ok(!compressed, "Unexpected value %d.\n", compressed);
}
hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
@ -502,7 +498,8 @@ static void test_MFCreateAttributes(void)
{ {
PROPVARIANT propvar, ret_propvar; PROPVARIANT propvar, ret_propvar;
IMFAttributes *attributes; IMFAttributes *attributes;
UINT32 count; UINT32 count, value;
UINT64 value64;
HRESULT hr; HRESULT hr;
GUID key; GUID key;
@ -514,13 +511,35 @@ static void test_MFCreateAttributes(void)
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
ok(count == 0, "got %d\n", count); ok(count == 0, "got %d\n", count);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0); hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "Failed to set UINT32 value, hr %#x.\n", hr);
hr = IMFAttributes_GetCount(attributes, &count); hr = IMFAttributes_GetCount(attributes, &count);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
todo_wine ok(count == 1, "got %d\n", count); todo_wine ok(count == 1, "got %d\n", count);
value = 0xdeadbeef;
hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value);
ok(hr == S_OK, "Failed to get UINT32 value, hr %#x.\n", hr);
ok(value == 123, "Unexpected value %u, expected: 123.\n", value);
value64 = 0xdeadbeef;
hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64);
ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr);
ok(value64 == 0xdeadbeef, "Unexpected value.\n");
hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536);
ok(hr == S_OK, "Failed to set UINT64 value, hr %#x.\n", hr);
hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64);
ok(hr == S_OK, "Failed to get UINT64 value, hr %#x.\n", hr);
ok(value64 == 65536, "Unexpected value.\n");
value = 0xdeadbeef;
hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value);
ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr);
ok(value == 0xdeadbeef, "Unexpected value.\n");
IMFAttributes_Release(attributes); IMFAttributes_Release(attributes);
hr = MFCreateAttributes(&attributes, 0); hr = MFCreateAttributes(&attributes, 0);

View File

@ -67,7 +67,7 @@ static void test_MFCreateSourceReaderFromByteStream(void)
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0); hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0);
todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);