Signed-off-by: Sven Baars sven.wine@gmail.com --- This patch and the next one are patch 153340 split into two parts. This one just moves the IMFAttributes interface up to avoid forward declarations in the next patch.
dlls/mfplat/main.c | 666 ++++++++++++++++++++++----------------------- 1 file changed, 333 insertions(+), 333 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index bd6b99f1fa..598072121d 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -448,339 +448,6 @@ HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG sr return E_NOTIMPL; }
-typedef struct _mfbytestream -{ - IMFByteStream IMFByteStream_iface; - LONG ref; -} mfbytestream; - -static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface) -{ - return CONTAINING_RECORD(iface, mfbytestream, IMFByteStream_iface); -} - -static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID riid, void **out) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out); - - if(IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IMFByteStream)) - { - *out = &This->IMFByteStream_iface; - } - else - { - FIXME("(%s, %p)\n", debugstr_guid(riid), out); - *out = NULL; - return E_NOINTERFACE; - } - - IUnknown_AddRef((IUnknown*)*out); - return S_OK; -} - -static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p) ref=%u\n", This, ref); - - return ref; -} - -static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p) ref=%u\n", This, ref); - - if (!ref) - { - HeapFree(GetProcessHeap(), 0, This); - } - - return ref; -} - -static HRESULT WINAPI mfbytestream_GetCapabilities(IMFByteStream *iface, DWORD *capabilities) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p\n", This, capabilities); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_GetLength(IMFByteStream *iface, QWORD *length) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p\n", This, length); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %s\n", This, wine_dbgstr_longlong(length)); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p\n", This, position); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %s\n", This, wine_dbgstr_longlong(position)); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_IsEndOfStream(IMFByteStream *iface, BOOL *endstream) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p\n", This, endstream); - - if(endstream) - *endstream = TRUE; - - return S_OK; -} - -static HRESULT WINAPI mfbytestream_Read(IMFByteStream *iface, BYTE *data, ULONG count, ULONG *byte_read) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %u, %p\n", This, data, count, byte_read); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_BeginRead(IMFByteStream *iface, BYTE *data, ULONG count, - IMFAsyncCallback *callback, IUnknown *state) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_EndRead(IMFByteStream *iface, IMFAsyncResult *result, ULONG *byte_read) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %p\n", This, result, byte_read); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_Write(IMFByteStream *iface, const BYTE *data, ULONG count, ULONG *written) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %u, %p\n", This, data, count, written); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_BeginWrite(IMFByteStream *iface, const BYTE *data, ULONG count, - IMFAsyncCallback *callback, IUnknown *state) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_EndWrite(IMFByteStream *iface, IMFAsyncResult *result, ULONG *written) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %p, %p\n", This, result, written); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_Seek(IMFByteStream *iface, MFBYTESTREAM_SEEK_ORIGIN seek, LONGLONG offset, - DWORD flags, QWORD *current) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p, %u, %s, 0x%08x, %p\n", This, seek, wine_dbgstr_longlong(offset), flags, current); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_Flush(IMFByteStream *iface) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p\n", This); - - return E_NOTIMPL; -} - -static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface) -{ - mfbytestream *This = impl_from_IMFByteStream(iface); - - FIXME("%p\n", This); - - return E_NOTIMPL; -} - -static const IMFByteStreamVtbl mfbytesteam_vtbl = -{ - mfbytestream_QueryInterface, - mfbytestream_AddRef, - mfbytestream_Release, - mfbytestream_GetCapabilities, - mfbytestream_GetLength, - mfbytestream_SetLength, - mfbytestream_GetCurrentPosition, - mfbytestream_SetCurrentPosition, - mfbytestream_IsEndOfStream, - mfbytestream_Read, - mfbytestream_BeginRead, - mfbytestream_EndRead, - mfbytestream_Write, - mfbytestream_BeginWrite, - mfbytestream_EndWrite, - mfbytestream_Seek, - mfbytestream_Flush, - mfbytestream_Close -}; - -HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream) -{ - mfbytestream *object; - - TRACE("(%p, %p): stub\n", stream, bytestream); - - object = heap_alloc( sizeof(*object) ); - if(!object) - return E_OUTOFMEMORY; - - object->ref = 1; - object->IMFByteStream_iface.lpVtbl = &mfbytesteam_vtbl; - - *bytestream = &object->IMFByteStream_iface; - - return S_OK; -} - -static HRESULT WINAPI MFPluginControl_QueryInterface(IMFPluginControl *iface, REFIID riid, void **ppv) -{ - if(IsEqualGUID(riid, &IID_IUnknown)) { - TRACE("(IID_IUnknown %p)\n", ppv); - *ppv = iface; - }else if(IsEqualGUID(riid, &IID_IMFPluginControl)) { - TRACE("(IID_IMFPluginControl %p)\n", ppv); - *ppv = iface; - }else { - FIXME("(%s %p)\n", debugstr_guid(riid), ppv); - *ppv = NULL; - return E_NOINTERFACE; - } - - IUnknown_AddRef((IUnknown*)*ppv); - return S_OK; -} - -static ULONG WINAPI MFPluginControl_AddRef(IMFPluginControl *iface) -{ - TRACE("\n"); - return 2; -} - -static ULONG WINAPI MFPluginControl_Release(IMFPluginControl *iface) -{ - TRACE("\n"); - return 1; -} - -static HRESULT WINAPI MFPluginControl_GetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type, - const WCHAR *selector, CLSID *clsid) -{ - FIXME("(%d %s %p)\n", plugin_type, debugstr_w(selector), clsid); - return E_NOTIMPL; -} - -static HRESULT WINAPI MFPluginControl_GetPreferredClsidByIndex(IMFPluginControl *iface, DWORD plugin_type, - DWORD index, WCHAR **selector, CLSID *clsid) -{ - FIXME("(%d %d %p %p)\n", plugin_type, index, selector, clsid); - return E_NOTIMPL; -} - -static HRESULT WINAPI MFPluginControl_SetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type, - const WCHAR *selector, const CLSID *clsid) -{ - FIXME("(%d %s %s)\n", plugin_type, debugstr_w(selector), debugstr_guid(clsid)); - return E_NOTIMPL; -} - -static HRESULT WINAPI MFPluginControl_IsDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid) -{ - FIXME("(%d %s)\n", plugin_type, debugstr_guid(clsid)); - return E_NOTIMPL; -} - -static HRESULT WINAPI MFPluginControl_GetDisabledByIndex(IMFPluginControl *iface, DWORD plugin_type, DWORD index, CLSID *clsid) -{ - FIXME("(%d %d %p)\n", plugin_type, index, clsid); - return E_NOTIMPL; -} - -static HRESULT WINAPI MFPluginControl_SetDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid, BOOL disabled) -{ - FIXME("(%d %s %x)\n", plugin_type, debugstr_guid(clsid), disabled); - return E_NOTIMPL; -} - -static const IMFPluginControlVtbl MFPluginControlVtbl = { - MFPluginControl_QueryInterface, - MFPluginControl_AddRef, - MFPluginControl_Release, - MFPluginControl_GetPreferredClsid, - MFPluginControl_GetPreferredClsidByIndex, - MFPluginControl_SetPreferredClsid, - MFPluginControl_IsDisabled, - MFPluginControl_GetDisabledByIndex, - MFPluginControl_SetDisabled -}; - -static IMFPluginControl plugin_control = { &MFPluginControlVtbl }; - -/*********************************************************************** - * MFGetPluginControl (mfplat.@) - */ -HRESULT WINAPI MFGetPluginControl(IMFPluginControl **ret) -{ - TRACE("(%p)\n", ret); - - *ret = &plugin_control; - return S_OK; -} - typedef struct _mfattributes { IMFAttributes IMFAttributes_iface; @@ -1178,6 +845,339 @@ HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size) return S_OK; }
+typedef struct _mfbytestream +{ + IMFByteStream IMFByteStream_iface; + LONG ref; +} mfbytestream; + +static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface) +{ + return CONTAINING_RECORD(iface, mfbytestream, IMFByteStream_iface); +} + +static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID riid, void **out) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out); + + if(IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IMFByteStream)) + { + *out = &This->IMFByteStream_iface; + } + else + { + FIXME("(%s, %p)\n", debugstr_guid(riid), out); + *out = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*out); + return S_OK; +} + +static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%u\n", This, ref); + + return ref; +} + +static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%u\n", This, ref); + + if (!ref) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI mfbytestream_GetCapabilities(IMFByteStream *iface, DWORD *capabilities) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p\n", This, capabilities); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_GetLength(IMFByteStream *iface, QWORD *length) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p\n", This, length); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %s\n", This, wine_dbgstr_longlong(length)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p\n", This, position); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %s\n", This, wine_dbgstr_longlong(position)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_IsEndOfStream(IMFByteStream *iface, BOOL *endstream) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p\n", This, endstream); + + if(endstream) + *endstream = TRUE; + + return S_OK; +} + +static HRESULT WINAPI mfbytestream_Read(IMFByteStream *iface, BYTE *data, ULONG count, ULONG *byte_read) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %u, %p\n", This, data, count, byte_read); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_BeginRead(IMFByteStream *iface, BYTE *data, ULONG count, + IMFAsyncCallback *callback, IUnknown *state) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_EndRead(IMFByteStream *iface, IMFAsyncResult *result, ULONG *byte_read) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %p\n", This, result, byte_read); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_Write(IMFByteStream *iface, const BYTE *data, ULONG count, ULONG *written) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %u, %p\n", This, data, count, written); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_BeginWrite(IMFByteStream *iface, const BYTE *data, ULONG count, + IMFAsyncCallback *callback, IUnknown *state) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_EndWrite(IMFByteStream *iface, IMFAsyncResult *result, ULONG *written) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %p, %p\n", This, result, written); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_Seek(IMFByteStream *iface, MFBYTESTREAM_SEEK_ORIGIN seek, LONGLONG offset, + DWORD flags, QWORD *current) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p, %u, %s, 0x%08x, %p\n", This, seek, wine_dbgstr_longlong(offset), flags, current); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_Flush(IMFByteStream *iface) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p\n", This); + + return E_NOTIMPL; +} + +static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface) +{ + mfbytestream *This = impl_from_IMFByteStream(iface); + + FIXME("%p\n", This); + + return E_NOTIMPL; +} + +static const IMFByteStreamVtbl mfbytesteam_vtbl = +{ + mfbytestream_QueryInterface, + mfbytestream_AddRef, + mfbytestream_Release, + mfbytestream_GetCapabilities, + mfbytestream_GetLength, + mfbytestream_SetLength, + mfbytestream_GetCurrentPosition, + mfbytestream_SetCurrentPosition, + mfbytestream_IsEndOfStream, + mfbytestream_Read, + mfbytestream_BeginRead, + mfbytestream_EndRead, + mfbytestream_Write, + mfbytestream_BeginWrite, + mfbytestream_EndWrite, + mfbytestream_Seek, + mfbytestream_Flush, + mfbytestream_Close +}; + +HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream) +{ + mfbytestream *object; + + TRACE("(%p, %p): stub\n", stream, bytestream); + + object = heap_alloc( sizeof(*object) ); + if(!object) + return E_OUTOFMEMORY; + + object->ref = 1; + object->IMFByteStream_iface.lpVtbl = &mfbytesteam_vtbl; + + *bytestream = &object->IMFByteStream_iface; + + return S_OK; +} + +static HRESULT WINAPI MFPluginControl_QueryInterface(IMFPluginControl *iface, REFIID riid, void **ppv) +{ + if(IsEqualGUID(riid, &IID_IUnknown)) { + TRACE("(IID_IUnknown %p)\n", ppv); + *ppv = iface; + }else if(IsEqualGUID(riid, &IID_IMFPluginControl)) { + TRACE("(IID_IMFPluginControl %p)\n", ppv); + *ppv = iface; + }else { + FIXME("(%s %p)\n", debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI MFPluginControl_AddRef(IMFPluginControl *iface) +{ + TRACE("\n"); + return 2; +} + +static ULONG WINAPI MFPluginControl_Release(IMFPluginControl *iface) +{ + TRACE("\n"); + return 1; +} + +static HRESULT WINAPI MFPluginControl_GetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type, + const WCHAR *selector, CLSID *clsid) +{ + FIXME("(%d %s %p)\n", plugin_type, debugstr_w(selector), clsid); + return E_NOTIMPL; +} + +static HRESULT WINAPI MFPluginControl_GetPreferredClsidByIndex(IMFPluginControl *iface, DWORD plugin_type, + DWORD index, WCHAR **selector, CLSID *clsid) +{ + FIXME("(%d %d %p %p)\n", plugin_type, index, selector, clsid); + return E_NOTIMPL; +} + +static HRESULT WINAPI MFPluginControl_SetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type, + const WCHAR *selector, const CLSID *clsid) +{ + FIXME("(%d %s %s)\n", plugin_type, debugstr_w(selector), debugstr_guid(clsid)); + return E_NOTIMPL; +} + +static HRESULT WINAPI MFPluginControl_IsDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid) +{ + FIXME("(%d %s)\n", plugin_type, debugstr_guid(clsid)); + return E_NOTIMPL; +} + +static HRESULT WINAPI MFPluginControl_GetDisabledByIndex(IMFPluginControl *iface, DWORD plugin_type, DWORD index, CLSID *clsid) +{ + FIXME("(%d %d %p)\n", plugin_type, index, clsid); + return E_NOTIMPL; +} + +static HRESULT WINAPI MFPluginControl_SetDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid, BOOL disabled) +{ + FIXME("(%d %s %x)\n", plugin_type, debugstr_guid(clsid), disabled); + return E_NOTIMPL; +} + +static const IMFPluginControlVtbl MFPluginControlVtbl = { + MFPluginControl_QueryInterface, + MFPluginControl_AddRef, + MFPluginControl_Release, + MFPluginControl_GetPreferredClsid, + MFPluginControl_GetPreferredClsidByIndex, + MFPluginControl_SetPreferredClsid, + MFPluginControl_IsDisabled, + MFPluginControl_GetDisabledByIndex, + MFPluginControl_SetDisabled +}; + +static IMFPluginControl plugin_control = { &MFPluginControlVtbl }; + +/*********************************************************************** + * MFGetPluginControl (mfplat.@) + */ +HRESULT WINAPI MFGetPluginControl(IMFPluginControl **ret) +{ + TRACE("(%p)\n", ret); + + *ret = &plugin_control; + return S_OK; +} + typedef struct _mfsourceresolver { IMFSourceResolver IMFSourceResolver_iface;
Signed-off-by: Sven Baars sven.wine@gmail.com --- This patch follows suggestions from Nikolay and Zebediah to first implement a separate IMFAttributes interface for IMFByteStream.
v2: Split moving the IMFAttributes interface and actually adding the IMFAttributes interface to IMFByteStream.
dlls/mfplat/main.c | 323 ++++++++++++++++++++++++++++++++++++- dlls/mfplat/tests/mfplat.c | 53 +++++- 2 files changed, 369 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 598072121d..620d5e251c 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -847,8 +847,11 @@ HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size)
typedef struct _mfbytestream { + mfattributes attributes; IMFByteStream IMFByteStream_iface; + IMFAttributes IMFAttributes_iface; LONG ref; + } mfbytestream;
static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface) @@ -867,6 +870,10 @@ static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID r { *out = &This->IMFByteStream_iface; } + else if(IsEqualGUID(riid, &IID_IMFAttributes)) + { + *out = &This->IMFAttributes_iface; + } else { FIXME("(%s, %p)\n", debugstr_guid(riid), out); @@ -881,7 +888,7 @@ static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID r static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface) { mfbytestream *This = impl_from_IMFByteStream(iface); - ULONG ref = InterlockedIncrement(&This->ref); + ULONG ref = InterlockedIncrement(&This->attributes.ref);
TRACE("(%p) ref=%u\n", This, ref);
@@ -891,7 +898,7 @@ static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface) static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface) { mfbytestream *This = impl_from_IMFByteStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); + ULONG ref = InterlockedDecrement(&This->attributes.ref);
TRACE("(%p) ref=%u\n", This, ref);
@@ -1044,7 +1051,7 @@ static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface) return E_NOTIMPL; }
-static const IMFByteStreamVtbl mfbytesteam_vtbl = +static const IMFByteStreamVtbl mfbytestream_vtbl = { mfbytestream_QueryInterface, mfbytestream_AddRef, @@ -1066,6 +1073,311 @@ static const IMFByteStreamVtbl mfbytesteam_vtbl = mfbytestream_Close };
+static inline mfbytestream *impl_from_IMFByteStream_IMFAttributes(IMFAttributes *iface) +{ + return CONTAINING_RECORD(iface, mfbytestream, IMFAttributes_iface); +} + +static HRESULT WINAPI mfbytestream_mfattributes_QueryInterface( + IMFAttributes *iface, REFIID riid, void **out) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out); + + if(IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IMFByteStream)) + { + *out = &This->IMFByteStream_iface; + } + else if(IsEqualGUID(riid, &IID_IMFAttributes)) + { + *out = &This->IMFAttributes_iface; + } + else + { + FIXME("(%s, %p)\n", debugstr_guid(riid), out); + *out = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*out); + return S_OK; +} + +static ULONG WINAPI mfbytestream_mfattributes_AddRef(IMFAttributes *iface) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + ULONG ref = InterlockedIncrement(&This->attributes.ref); + + TRACE("(%p) ref=%u\n", This, ref); + + return ref; +} + +static ULONG WINAPI mfbytestream_mfattributes_Release(IMFAttributes *iface) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + ULONG ref = InterlockedDecrement(&This->attributes.ref); + + TRACE("(%p) ref=%u\n", This, ref); + + if (!ref) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetItem( + IMFAttributes *iface, REFGUID key, PROPVARIANT *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetItemType( + IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type); +} + +static HRESULT WINAPI mfbytestream_mfattributes_CompareItem( + IMFAttributes *iface, REFGUID key, REFPROPVARIANT value, BOOL *result) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result); +} + +static HRESULT WINAPI mfbytestream_mfattributes_Compare( + IMFAttributes *iface, IMFAttributes *attrs, MF_ATTRIBUTES_MATCH_TYPE type, + BOOL *result) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, attrs, type, result); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetUINT32( + IMFAttributes *iface, REFGUID key, UINT32 *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetUINT64( + IMFAttributes *iface, REFGUID key, UINT64 *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetDouble( + IMFAttributes *iface, REFGUID key, double *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetGUID( + IMFAttributes *iface, REFGUID key, GUID *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetStringLength( + IMFAttributes *iface, REFGUID key, UINT32 *length) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetString( + IMFAttributes *iface, REFGUID key, WCHAR *value, UINT32 size, UINT32 *length) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetAllocatedString( + IMFAttributes *iface, REFGUID key, WCHAR **value, UINT32 *length) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetBlobSize( + IMFAttributes *iface, REFGUID key, UINT32 *size) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetBlob( + IMFAttributes *iface, REFGUID key, UINT8 *buf, UINT32 bufsize, UINT32 *blobsize) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetAllocatedBlob( + IMFAttributes *iface, REFGUID key, UINT8 **buf, UINT32 *size) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetUnknown( + IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetItem( + IMFAttributes *iface, REFGUID key, REFPROPVARIANT value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_DeleteItem( + IMFAttributes *iface, REFGUID key) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key); +} + +static HRESULT WINAPI mfbytestream_mfattributes_DeleteAllItems( + IMFAttributes *iface) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetUINT32( + IMFAttributes *iface, REFGUID key, UINT32 value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetUINT64( + IMFAttributes *iface, REFGUID key, UINT64 value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetDouble( + IMFAttributes *iface, REFGUID key, double value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetGUID( + IMFAttributes *iface, REFGUID key, REFGUID value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetString( + IMFAttributes *iface, REFGUID key, const WCHAR *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetBlob( + IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size); +} + +static HRESULT WINAPI mfbytestream_mfattributes_SetUnknown( + IMFAttributes *iface, REFGUID key, IUnknown *unknown) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown); +} + +static HRESULT WINAPI mfbytestream_mfattributes_LockStore(IMFAttributes *iface) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface); +} + +static HRESULT WINAPI mfbytestream_mfattributes_UnlockStore(IMFAttributes *iface) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetCount(IMFAttributes *iface, UINT32 *items) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items); +} + +static HRESULT WINAPI mfbytestream_mfattributes_GetItemByIndex( + IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value); +} + +static HRESULT WINAPI mfbytestream_mfattributes_CopyAllItems( + IMFAttributes *iface, IMFAttributes *dest) +{ + mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface); + + FIXME("%p, %p\n", This, dest); + + return E_NOTIMPL; +} + +static const IMFAttributesVtbl mfbytestream_mfattributes_vtbl = +{ + mfbytestream_mfattributes_QueryInterface, + mfbytestream_mfattributes_AddRef, + mfbytestream_mfattributes_Release, + mfbytestream_mfattributes_GetItem, + mfbytestream_mfattributes_GetItemType, + mfbytestream_mfattributes_CompareItem, + mfbytestream_mfattributes_Compare, + mfbytestream_mfattributes_GetUINT32, + mfbytestream_mfattributes_GetUINT64, + mfbytestream_mfattributes_GetDouble, + mfbytestream_mfattributes_GetGUID, + mfbytestream_mfattributes_GetStringLength, + mfbytestream_mfattributes_GetString, + mfbytestream_mfattributes_GetAllocatedString, + mfbytestream_mfattributes_GetBlobSize, + mfbytestream_mfattributes_GetBlob, + mfbytestream_mfattributes_GetAllocatedBlob, + mfbytestream_mfattributes_GetUnknown, + mfbytestream_mfattributes_SetItem, + mfbytestream_mfattributes_DeleteItem, + mfbytestream_mfattributes_DeleteAllItems, + mfbytestream_mfattributes_SetUINT32, + mfbytestream_mfattributes_SetUINT64, + mfbytestream_mfattributes_SetDouble, + mfbytestream_mfattributes_SetGUID, + mfbytestream_mfattributes_SetString, + mfbytestream_mfattributes_SetBlob, + mfbytestream_mfattributes_SetUnknown, + mfbytestream_mfattributes_LockStore, + mfbytestream_mfattributes_UnlockStore, + mfbytestream_mfattributes_GetCount, + mfbytestream_mfattributes_GetItemByIndex, + mfbytestream_mfattributes_CopyAllItems +}; + HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream) { mfbytestream *object; @@ -1076,8 +1388,9 @@ HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **byt if(!object) return E_OUTOFMEMORY;
- object->ref = 1; - object->IMFByteStream_iface.lpVtbl = &mfbytesteam_vtbl; + init_attribute_object(&object->attributes, 0); + object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl; + object->IMFAttributes_iface.lpVtbl = &mfbytestream_mfattributes_vtbl;
*bytestream = &object->IMFByteStream_iface;
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 17cdc46579..4605e20f32 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -258,8 +258,12 @@ static void test_MFCreateAttributes(void) static void test_MFCreateMFByteStreamOnStream(void) { IMFByteStream *bytestream; + IMFByteStream *bytestream2; IStream *stream; + IMFAttributes *attributes = NULL; + IUnknown *unknown; HRESULT hr; + ULONG ref;
if(!pMFCreateMFByteStreamOnStream) { @@ -270,11 +274,56 @@ static void test_MFCreateMFByteStreamOnStream(void) hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "got 0x%08x\n", hr);
- hr = pMFCreateMFByteStreamOnStream(stream, &bytestream ); + hr = pMFCreateMFByteStreamOnStream(stream, &bytestream); ok(hr == S_OK, "got 0x%08x\n", hr);
- IStream_Release(stream); + hr = IUnknown_QueryInterface(bytestream, &IID_IUnknown, + (void **)&unknown); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok((void *)unknown == (void *)bytestream, "got %p\n", unknown); + ref = IUnknown_Release(unknown); + ok(ref == 1, "got %u\n", ref); + + hr = IUnknown_QueryInterface(unknown, &IID_IMFByteStream, + (void **)&bytestream2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bytestream2 == bytestream, "got %p\n", bytestream2); + ref = IMFByteStream_Release(bytestream2); + ok(ref == 1, "got %u\n", ref); + + hr = IUnknown_QueryInterface(bytestream, &IID_IMFAttributes, + (void **)&attributes); + ok(hr == S_OK || + /* w7pro64 */ + broken(hr == E_NOINTERFACE), "got 0x%08x\n", hr); + + if (hr != S_OK) + { + win_skip("Can not retrieve IMFAttributes interface from IMFByteStream\n"); + IStream_Release(stream); + IMFByteStream_Release(bytestream); + return; + } + + ok(attributes != NULL, "got NULL\n"); + + hr = IUnknown_QueryInterface(attributes, &IID_IUnknown, + (void **)&unknown); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok((void *)unknown == (void *)bytestream, "got %p\n", unknown); + ref = IUnknown_Release(unknown); + ok(ref == 2, "got %u\n", ref); + + hr = IUnknown_QueryInterface(attributes, &IID_IMFByteStream, + (void **)&bytestream2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bytestream2 == bytestream, "got %p\n", bytestream2); + ref = IMFByteStream_Release(bytestream2); + ok(ref == 2, "got %u\n", ref); + + IMFAttributes_Release(attributes); IMFByteStream_Release(bytestream); + IStream_Release(stream); }
static void test_MFCreateMemoryBuffer(void)
On 11/02/2018 10:49 PM, Sven Baars wrote:
typedef struct _mfbytestream {
- mfattributes attributes; IMFByteStream IMFByteStream_iface;
- IMFAttributes IMFAttributes_iface; LONG ref;
- } mfbytestream;
mfattributes already has IMFAttributes and refcount members.
+static inline mfbytestream *impl_from_IMFByteStream_IMFAttributes(IMFAttributes *iface) +{
- return CONTAINING_RECORD(iface, mfbytestream, IMFAttributes_iface);
+}
+static HRESULT WINAPI mfbytestream_mfattributes_QueryInterface(
- IMFAttributes *iface, REFIID riid, void **out)
With name like that I think it's better to move it to a separate file.
On 02-11-18 22:01, Nikolay Sivov wrote:
On 11/02/2018 10:49 PM, Sven Baars wrote:
typedef struct _mfbytestream { + mfattributes attributes; IMFByteStream IMFByteStream_iface; + IMFAttributes IMFAttributes_iface; LONG ref;
} mfbytestream;
mfattributes already has IMFAttributes and refcount members.
+static inline mfbytestream *impl_from_IMFByteStream_IMFAttributes(IMFAttributes *iface) +{ + return CONTAINING_RECORD(iface, mfbytestream, IMFAttributes_iface); +}
+static HRESULT WINAPI mfbytestream_mfattributes_QueryInterface( + IMFAttributes *iface, REFIID riid, void **out)
With name like that I think it's better to move it to a separate file.
Hi Nikolay,
I removed the refcount member in the corrected patch that I sent. It seemed to have been added back in when rebasing the patches. Sorry for that. The IMFAttributes_iface (which uses mfbytestream_mfattributes_vtbl) I still need, because I forward it to attributes.IMFAttributes_iface, which is the actual implementation (uses mfattributes_vtbl).
I was not very happy about the long name either, but found another file in Wine where something similar was done, so I chose to do it like this. My personal preference would be to put every interface that I add in a separate file, since even the stubs are already 500+ lines. However, the tendency in Wine seems to be to put as much as possible into a single file. When is it OK to create a new one? Also, what would be the best way to handle different implementations of the same interface? If I add those in the same file, I would still possibly get names like mfbytestream_file_QueryInterface and mfbytestream_stream_QueryInterface (for MFCreateFile and MFCreateMFByteStreamOnStream).
Best, Sven
Signed-off-by: Sven Baars sven.wine@gmail.com --- v3: Actually read the file and handle all flags.
dlls/mfplat/main.c | 78 ++++++++++++++++++++++- dlls/mfplat/mfplat.spec | 2 +- dlls/mfplat/tests/Makefile.in | 2 + dlls/mfplat/tests/mfplat.c | 114 ++++++++++++++++++++++++++++++++++ dlls/mfplat/tests/resource.rc | 24 +++++++ dlls/mfplat/tests/test.mp4 | Bin 0 -> 1554 bytes include/mfapi.h | 2 + 7 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 dlls/mfplat/tests/resource.rc create mode 100644 dlls/mfplat/tests/test.mp4
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 620d5e251c..130597e8e7 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -850,8 +850,8 @@ typedef struct _mfbytestream mfattributes attributes; IMFByteStream IMFByteStream_iface; IMFAttributes IMFAttributes_iface; - LONG ref;
+ HANDLE file; } mfbytestream;
static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface) @@ -895,7 +895,7 @@ static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface) return ref; }
-static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface) +static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface) { mfbytestream *This = impl_from_IMFByteStream(iface); ULONG ref = InterlockedDecrement(&This->attributes.ref); @@ -904,6 +904,8 @@ static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface)
if (!ref) { + if (This->file != INVALID_HANDLE_VALUE) + CloseHandle(This->file); HeapFree(GetProcessHeap(), 0, This); }
@@ -1124,6 +1126,8 @@ static ULONG WINAPI mfbytestream_mfattributes_Release(IMFAttributes *iface)
if (!ref) { + if (This->file != INVALID_HANDLE_VALUE) + CloseHandle(This->file); HeapFree(GetProcessHeap(), 0, This); }
@@ -1391,6 +1395,76 @@ HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **byt init_attribute_object(&object->attributes, 0); object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl; object->IMFAttributes_iface.lpVtbl = &mfbytestream_mfattributes_vtbl; + object->file = INVALID_HANDLE_VALUE; + + *bytestream = &object->IMFByteStream_iface; + + return S_OK; +} + +HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags, + LPCWSTR url, IMFByteStream **bytestream) +{ + mfbytestream *object; + DWORD fileaccessmode = 0; + DWORD filesharemode = FILE_SHARE_READ; + DWORD filecreation_disposition = 0; + DWORD fileattributes = 0; + HANDLE file; + + FIXME("(%d, %d, %d, %s, %p): stub\n", accessmode, openmode, flags, debugstr_w(url), bytestream); + + switch (accessmode) + { + case MF_ACCESSMODE_READ: + fileaccessmode = GENERIC_READ; + break; + case MF_ACCESSMODE_WRITE: + fileaccessmode = GENERIC_WRITE; + break; + case MF_ACCESSMODE_READWRITE: + fileaccessmode = GENERIC_READ | GENERIC_WRITE; + break; + } + + switch (openmode) + { + case MF_OPENMODE_FAIL_IF_NOT_EXIST: + filecreation_disposition = OPEN_EXISTING; + break; + case MF_OPENMODE_FAIL_IF_EXIST: + filecreation_disposition = CREATE_NEW; + break; + case MF_OPENMODE_RESET_IF_EXIST: + filecreation_disposition = TRUNCATE_EXISTING; + break; + case MF_OPENMODE_APPEND_IF_EXIST: + filecreation_disposition = OPEN_ALWAYS; + fileaccessmode |= FILE_APPEND_DATA; + break; + case MF_OPENMODE_DELETE_IF_EXIST: + filecreation_disposition = CREATE_ALWAYS; + break; + } + + if (flags & MF_FILEFLAGS_NOBUFFERING) + fileattributes |= FILE_FLAG_NO_BUFFERING; + + /* Open HANDLE to file */ + file = CreateFileW(url, fileaccessmode, filesharemode, NULL, + filecreation_disposition, fileattributes, 0); + + if(file == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(GetLastError()); + + object = heap_alloc( sizeof(*object) ); + if(!object) + return E_OUTOFMEMORY; + + init_attribute_object(&object->attributes, 0); + object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl; + object->IMFAttributes_iface.lpVtbl = &mfbytestream_mfattributes_vtbl; + object->file = file;
*bytestream = &object->IMFByteStream_iface;
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index 3e42d2fd70..4533eeb71c 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -43,7 +43,7 @@ @ stub MFCreateAudioMediaType @ stub MFCreateCollection @ stdcall MFCreateEventQueue(ptr) -@ stub MFCreateFile +@ stdcall MFCreateFile(long long long wstr ptr) @ stub MFCreateLegacyMediaBufferOnMFMediaBuffer @ stdcall MFCreateMFByteStreamOnStream(ptr ptr) @ stub MFCreateMFVideoFormatFromMFMediaType diff --git a/dlls/mfplat/tests/Makefile.in b/dlls/mfplat/tests/Makefile.in index a5553a5af3..07cf328ad2 100644 --- a/dlls/mfplat/tests/Makefile.in +++ b/dlls/mfplat/tests/Makefile.in @@ -3,3 +3,5 @@ IMPORTS = ole32 mfplat
C_SRCS = \ mfplat.c + +RC_SRCS = resource.rc diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 4605e20f32..8c5df32830 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -49,6 +49,36 @@ DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17, 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);
+static const WCHAR mp4file[] = {'t','e','s','t','.','m','p','4',0}; + +static WCHAR *load_resource(const WCHAR *name) +{ + static WCHAR pathW[MAX_PATH]; + DWORD written; + HANDLE file; + HRSRC res; + void *ptr; + + GetTempPathW(ARRAY_SIZE(pathW), pathW); + lstrcatW(pathW, name); + + file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, + NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", + wine_dbgstr_w(pathW), GetLastError()); + + res = FindResourceW(NULL, name, (LPCWSTR)RT_RCDATA); + ok(res != 0, "couldn't find resource\n"); + ptr = LockResource(LoadResource(GetModuleHandleA(NULL), res)); + WriteFile(file, ptr, SizeofResource(GetModuleHandleA(NULL), res), + &written, NULL); + ok(written == SizeofResource(GetModuleHandleA(NULL), res), + "couldn't write resource\n" ); + CloseHandle(file); + + return pathW; +} + static BOOL check_clsid(CLSID *clsids, UINT32 count) { int i; @@ -326,6 +356,89 @@ static void test_MFCreateMFByteStreamOnStream(void) IStream_Release(stream); }
+static void test_MFCreateFile(void) +{ + IMFByteStream *bytestream; + IMFByteStream *bytestream2; + IMFAttributes *attributes = NULL; + HRESULT hr; + WCHAR *filename; + + static const WCHAR newfilename[] = {'n','e','w','.','m','p','4',0}; + + filename = load_resource(mp4file); + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, filename, &bytestream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IUnknown_QueryInterface(bytestream, &IID_IMFAttributes, + (void **)&attributes); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(attributes != NULL, "got NULL\n"); + IMFAttributes_Release(attributes); + + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, filename, &bytestream2); + ok(hr == S_OK, "got 0x%08x\n", hr); + IMFByteStream_Release(bytestream2); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, filename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, filename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + IMFByteStream_Release(bytestream); + + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, newfilename, &bytestream); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_EXIST, + MF_FILEFLAGS_NONE, filename, &bytestream); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_EXIST, + MF_FILEFLAGS_NONE, newfilename, &bytestream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_NONE, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_ALLOW_WRITE_SHARING, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + IMFByteStream_Release(bytestream); + + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_ALLOW_WRITE_SHARING, newfilename, &bytestream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + /* Opening the file again fails even though MF_FILEFLAGS_ALLOW_WRITE_SHARING is set. */ + hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_FAIL_IF_NOT_EXIST, + MF_FILEFLAGS_ALLOW_WRITE_SHARING, newfilename, &bytestream2); + ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "got 0x%08x\n", hr); + + IMFByteStream_Release(bytestream); + + MFShutdown(); + + DeleteFileW(filename); + DeleteFileW(newfilename); +} + static void test_MFCreateMemoryBuffer(void) { IMFMediaBuffer *buffer; @@ -439,6 +552,7 @@ START_TEST(mfplat) test_MFCreateMediaType(); test_MFCreateAttributes(); test_MFSample(); + test_MFCreateFile(); test_MFCreateMFByteStreamOnStream(); test_MFCreateMemoryBuffer();
diff --git a/dlls/mfplat/tests/resource.rc b/dlls/mfplat/tests/resource.rc new file mode 100644 index 0000000000..e9bf920c31 --- /dev/null +++ b/dlls/mfplat/tests/resource.rc @@ -0,0 +1,24 @@ +/* + * Resources for mfplat test suite. + * + * Copyright 2018 Sven Baars + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windef.h" + +/* @makedep: test.mp4 */ +test.mp4 RCDATA test.mp4 diff --git a/dlls/mfplat/tests/test.mp4 b/dlls/mfplat/tests/test.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a5bbca6bbf7692eab047050b79b8ccc83516e6b4 GIT binary patch literal 1554 zcmZuxeN0nV6u<3bttg}g3M<<3v4A5C7=;cYskS&=aH+Gw(TQ=|2k#+BpKbac6$q26 zgvfMZE^O--6L1NclR1flh8QLw4%rM5#eGC{R2Jv(j|s9(8MANazOwnmo#gk<x#yhw zyZ4@R-$e*%%DGx+CF@`ik|L}DS&UP!LkKM^chNNX_cIj9Atd<{DdnJiN*lZEK&*TH zLUnilE|&Pi#`t<(V2JeCh0xUFbE~$JpP!3QD)e^to@B05Kdu~jt~KuYz}1=h$wy;^ z-(P&iYuL#r*6qMlmYD;w&8gboiuVmim)E`@VY(w}d_`I2ihOP3>WzsJPV$oN<)LWX zeE-6+iWMz`xA<B45szMa^nqwQ5w>wzrc-v;{3ns3&Hgygab@co_v%sWh^~kxZdgv1 zG$e27=y&X0FwfM)&vJ1wQfF>hX5`>p!|hca@<xwAt#6-gnD>;lG>BPmWrt3nUp`73 z+Yr|+TbnzS=UsV1v;C6gviW|rw)-!S-=bHn;0v1+QGDC}Ia|1D&?ob%jF`h$Wc#Ew zV;vf3`obS*$vM<kEDwCQ`|#nw>4L6xr#4wnKY06wGT*}wdIn7LW=}zVn#?n%4mVMz zS*QG<-xMcs%$)a1n<6jX{=IjfF~joa!xMeyYRwY|Cr0Vm>*3w%uu#*`=0;_WapAn$ zU<`El@AbuA79AjpWMkq|c1;#tZJ#~+J(2cx>Nm%BvdmP*5AP|wGW~$TESZLVhn6a1 ztO^C+GL%><v}DW7eXsQJ-HUG|I!ZcwqEv0#Ya@m<t5KG7N5rlo$2IYtr*eGsbj8h0 z?c@jJ8?GH6PW~!_$shUIcJraKf^47ff8>qKKRQs;^7r5rKP{`hCoZsRD*LTIOV>}^ zv}Z#0Dsy%(f4!(s5zT+wRX-W1@{bU&DxT$gcYNB95Wz4GhZ`=WopD!CphZIb3Y&Tt zN#HB;J~@EE6G4Pb;@qcgDO~ywITu+4q3v9iuqGi&TV#WEm&%fL{&(FFn1q2)5>0U| zXbo*=;Rh207#4X2E~$c{DoKbWFx1ksXMtOViZ2NB(km#tOR(VMuB70{eJoZOI||7? zl%2*olCw<Zo^mi$Zbl##Z##(!#x#_R#yMDUJgnMfPYBwQI+iQ7gFVc0?7t1cIX-wf zaHFt@IfI@MICdeJ7+9Xp2>Ks?)jSUa8_iO<Oo;G!Jey%!2<ZHT2<$>SD4dRa20SkU zV;68rdYYqx<dOt*;hjTh6eXe7GH{(SlkT#Yax=1Y8M;ip4CY9n)kw{9LK`q0-qUjY z7J{U}>4bH`mH}`KUjy7ccnDD_0CJHA@_=3toU_OwXamIR7Gqf9{35_wfE7@%h&<3n zKs;bQARC}!xiSZ6ESNJ5P+CoKB<O7nEod-NqPX>NU0kHoiM#Wkq*n&-SMq0^0~2cD TJ;x-N6hTeOp(eUDP!ruh^$B~#
literal 0 HcmV?d00001
diff --git a/include/mfapi.h b/include/mfapi.h index bc832bf95f..0230a08471 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -67,6 +67,8 @@ HRESULT WINAPI MFCancelWorkItem(MFWORKITEM_KEY key); HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG srcstride, DWORD width, DWORD lines); HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size); HRESULT WINAPI MFCreateEventQueue(IMFMediaEventQueue **queue); +HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags, + LPCWSTR url, IMFByteStream **bytestream); HRESULT WINAPI MFCreateMediaType(IMFMediaType **type); HRESULT WINAPI MFCreateSample(IMFSample **sample); HRESULT WINAPI MFCreateMemoryBuffer(DWORD max_length, IMFMediaBuffer **buffer);