From 9bf4db1325d303a876bf282543289e15f9c698ad Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 12 Mar 2019 09:07:46 +0300 Subject: [PATCH] mfreadwrite: Implement MFCreateSourceReaderFromURL(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfreadwrite/main.c | 60 ++++++++++++++++++++++++++++++- dlls/mfreadwrite/mfreadwrite.spec | 2 +- include/mfreadwrite.idl | 1 + 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/dlls/mfreadwrite/main.c b/dlls/mfreadwrite/main.c index bcf79a8fbd9..88903ceddf9 100644 --- a/dlls/mfreadwrite/main.c +++ b/dlls/mfreadwrite/main.c @@ -273,6 +273,47 @@ static HRESULT create_source_reader_from_stream(IMFByteStream *stream, IMFAttrib return hr; } +static HRESULT create_source_reader_from_url(const WCHAR *url, IMFAttributes *attributes, REFIID riid, void **out) +{ + IMFSourceResolver *resolver; + IUnknown *object = NULL; + MF_OBJECT_TYPE obj_type; + IMFMediaSource *source; + HRESULT hr; + + if (FAILED(hr = MFCreateSourceResolver(&resolver))) + return hr; + + hr = IMFSourceResolver_CreateObjectFromURL(resolver, url, MF_RESOLUTION_MEDIASOURCE, NULL, &obj_type, + (IUnknown **)&object); + if (SUCCEEDED(hr)) + { + switch (obj_type) + { + case MF_OBJECT_BYTESTREAM: + hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, (IMFByteStream *)object, NULL, + MF_RESOLUTION_MEDIASOURCE, NULL, &obj_type, (IUnknown **)&source); + break; + case MF_OBJECT_MEDIASOURCE: + source = (IMFMediaSource *)object; + IMFMediaSource_AddRef(source); + break; + default: + WARN("Unknown object type %d.\n", obj_type); + hr = E_UNEXPECTED; + } + IUnknown_Release(object); + } + + IMFSourceResolver_Release(resolver); + if (FAILED(hr)) + return hr; + + hr = create_source_reader_from_source(source, attributes, riid, out); + IMFMediaSource_Release(source); + return hr; +} + static HRESULT WINAPI sink_writer_QueryInterface(IMFSinkWriter *iface, REFIID riid, void **out) { TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out); @@ -480,6 +521,16 @@ HRESULT WINAPI MFCreateSourceReaderFromMediaSource(IMFMediaSource *source, IMFAt return create_source_reader_from_source(source, attributes, &IID_IMFSourceReader, (void **)reader); } +/*********************************************************************** + * MFCreateSourceReaderFromURL (mfreadwrite.@) + */ +HRESULT WINAPI MFCreateSourceReaderFromURL(const WCHAR *url, IMFAttributes *attributes, IMFSourceReader **reader) +{ + TRACE("%s, %p, %p.\n", debugstr_w(url), attributes, reader); + + return create_source_reader_from_url(url, attributes, &IID_IMFSourceReader, (void **)reader); +} + static HRESULT WINAPI readwrite_factory_QueryInterface(IMFReadWriteClassFactory *iface, REFIID riid, void **out) { if (IsEqualIID(riid, &IID_IMFReadWriteClassFactory) || @@ -508,7 +559,14 @@ static ULONG WINAPI readwrite_factory_Release(IMFReadWriteClassFactory *iface) static HRESULT WINAPI readwrite_factory_CreateInstanceFromURL(IMFReadWriteClassFactory *iface, REFCLSID clsid, const WCHAR *url, IMFAttributes *attributes, REFIID riid, void **out) { - FIXME("%s, %s, %p, %s, %p.\n", debugstr_guid(clsid), debugstr_w(url), attributes, debugstr_guid(riid), out); + TRACE("%s, %s, %p, %s, %p.\n", debugstr_guid(clsid), debugstr_w(url), attributes, debugstr_guid(riid), out); + + if (IsEqualGUID(clsid, &CLSID_MFSourceReader)) + { + return create_source_reader_from_url(url, attributes, &IID_IMFSourceReader, out); + } + + FIXME("Unsupported %s.\n", debugstr_guid(clsid)); return E_NOTIMPL; } diff --git a/dlls/mfreadwrite/mfreadwrite.spec b/dlls/mfreadwrite/mfreadwrite.spec index d8ed6942eb0..3a215a9cc6c 100644 --- a/dlls/mfreadwrite/mfreadwrite.spec +++ b/dlls/mfreadwrite/mfreadwrite.spec @@ -6,4 +6,4 @@ @ stub MFCreateSinkWriterFromURL @ stdcall MFCreateSourceReaderFromByteStream(ptr ptr ptr) @ stdcall MFCreateSourceReaderFromMediaSource(ptr ptr ptr) -@ stub MFCreateSourceReaderFromURL +@ stdcall MFCreateSourceReaderFromURL(wstr ptr ptr) diff --git a/include/mfreadwrite.idl b/include/mfreadwrite.idl index 82f67d499cc..264712778f0 100644 --- a/include/mfreadwrite.idl +++ b/include/mfreadwrite.idl @@ -151,3 +151,4 @@ cpp_quote( "HRESULT WINAPI MFCreateSourceReaderFromByteStream(IMFByteStream *str cpp_quote( " IMFSourceReader **reader);" ) cpp_quote( "HRESULT WINAPI MFCreateSourceReaderFromMediaSource(IMFMediaSource *source, IMFAttributes *attributes," ) cpp_quote( " IMFSourceReader **reader);" ) +cpp_quote( "HRESULT WINAPI MFCreateSourceReaderFromURL(const WCHAR *url, IMFAttributes *attributes, IMFSourceReader **reader);" )