mfplat: Remove fallback media source.

Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Derek Lesho 2020-09-02 14:25:58 -05:00 committed by Alexandre Julliard
parent 0713b754f0
commit c58bb881a0
2 changed files with 64 additions and 249 deletions

View File

@ -5679,188 +5679,6 @@ HRESULT WINAPI MFGetPluginControl(IMFPluginControl **ret)
return S_OK;
}
typedef struct _mfsource
{
IMFMediaSource IMFMediaSource_iface;
LONG ref;
} mfsource;
static inline mfsource *impl_from_IMFMediaSource(IMFMediaSource *iface)
{
return CONTAINING_RECORD(iface, mfsource, IMFMediaSource_iface);
}
static HRESULT WINAPI mfsource_QueryInterface(IMFMediaSource *iface, REFIID riid, void **out)
{
mfsource *This = impl_from_IMFMediaSource(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
if (IsEqualIID(riid, &IID_IMFMediaSource) ||
IsEqualIID(riid, &IID_IMFMediaEventGenerator) ||
IsEqualIID(riid, &IID_IUnknown))
{
*out = &This->IMFMediaSource_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 mfsource_AddRef(IMFMediaSource *iface)
{
mfsource *This = impl_from_IMFMediaSource(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%u\n", This, ref);
return ref;
}
static ULONG WINAPI mfsource_Release(IMFMediaSource *iface)
{
mfsource *This = impl_from_IMFMediaSource(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%u\n", This, ref);
if (!ref)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI mfsource_GetEvent(IMFMediaSource *iface, DWORD flags, IMFMediaEvent **event)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%#x, %p)\n", This, flags, event);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_BeginGetEvent(IMFMediaSource *iface, IMFAsyncCallback *callback, IUnknown *state)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%p, %p)\n", This, callback, state);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_EndGetEvent(IMFMediaSource *iface, IMFAsyncResult *result, IMFMediaEvent **event)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%p, %p)\n", This, result, event);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_QueueEvent(IMFMediaSource *iface, MediaEventType event_type, REFGUID ext_type,
HRESULT hr, const PROPVARIANT *value)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%d, %s, %#x, %p)\n", This, event_type, debugstr_guid(ext_type), hr, value);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_GetCharacteristics(IMFMediaSource *iface, DWORD *characteristics)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%p): stub\n", This, characteristics);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_CreatePresentationDescriptor(IMFMediaSource *iface, IMFPresentationDescriptor **descriptor)
{
mfsource *This = impl_from_IMFMediaSource(iface);
IMFStreamDescriptor *sd;
IMFMediaType *mediatype;
HRESULT hr;
FIXME("(%p)->(%p): stub\n", This, descriptor);
if (FAILED(hr = MFCreateMediaType(&mediatype)))
return hr;
hr = MFCreateStreamDescriptor(0, 1, &mediatype, &sd);
IMFMediaType_Release(mediatype);
if (FAILED(hr))
return hr;
hr = MFCreatePresentationDescriptor(1, &sd, descriptor);
IMFStreamDescriptor_Release(sd);
return hr;
}
static HRESULT WINAPI mfsource_Start(IMFMediaSource *iface, IMFPresentationDescriptor *descriptor,
const GUID *time_format, const PROPVARIANT *start_position)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%p, %p, %p): stub\n", This, descriptor, time_format, start_position);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_Stop(IMFMediaSource *iface)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p): stub\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_Pause(IMFMediaSource *iface)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p): stub\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI mfsource_Shutdown(IMFMediaSource *iface)
{
mfsource *This = impl_from_IMFMediaSource(iface);
FIXME("(%p): stub\n", This);
return S_OK;
}
static const IMFMediaSourceVtbl mfsourcevtbl =
{
mfsource_QueryInterface,
mfsource_AddRef,
mfsource_Release,
mfsource_GetEvent,
mfsource_BeginGetEvent,
mfsource_EndGetEvent,
mfsource_QueueEvent,
mfsource_GetCharacteristics,
mfsource_CreatePresentationDescriptor,
mfsource_Start,
mfsource_Stop,
mfsource_Pause,
mfsource_Shutdown,
};
enum resolved_object_origin
{
OBJECT_FROM_BYTESTREAM,
@ -6505,7 +6323,7 @@ static HRESULT WINAPI source_resolver_CreateObjectFromByteStream(IMFSourceResolv
return E_POINTER;
if (FAILED(hr = resolver_get_bytestream_handler(stream, url, flags, &handler)))
goto fallback;
return MF_E_UNSUPPORTED_BYTESTREAM_TYPE;
hr = RtwqCreateAsyncResult((IUnknown *)handler, NULL, NULL, &result);
IMFByteStreamHandler_Release(handler);
@ -6528,28 +6346,7 @@ static HRESULT WINAPI source_resolver_CreateObjectFromByteStream(IMFSourceResolv
hr = resolver_end_create_object(resolver, OBJECT_FROM_BYTESTREAM, result, obj_type, object);
IRtwqAsyncResult_Release(result);
/* TODO: following stub is left intentionally until real source plugins are implemented. */
if (SUCCEEDED(hr))
return hr;
fallback:
if (flags & MF_RESOLUTION_MEDIASOURCE)
{
mfsource *new_object;
new_object = HeapAlloc( GetProcessHeap(), 0, sizeof(*new_object) );
if (!new_object)
return E_OUTOFMEMORY;
new_object->IMFMediaSource_iface.lpVtbl = &mfsourcevtbl;
new_object->ref = 1;
*object = (IUnknown *)&new_object->IMFMediaSource_iface;
*obj_type = MF_OBJECT_MEDIASOURCE;
return S_OK;
}
return E_NOTIMPL;
return hr;
}
static HRESULT WINAPI source_resolver_BeginCreateObjectFromURL(IMFSourceResolver *iface, const WCHAR *url,

View File

@ -382,12 +382,16 @@ static HRESULT WINAPI test_create_from_file_handler_callback_Invoke(IMFAsyncCall
handler = (IMFSchemeHandler *)IMFAsyncResult_GetStateNoAddRef(result);
hr = IMFSchemeHandler_EndCreateObject(handler, result, &obj_type, &object);
todo_wine
ok(hr == S_OK, "Failed to create an object, hr %#x.\n", hr);
hr = IMFAsyncResult_GetObject(result, &object2);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IMFAsyncResult_GetObject(result, &object2);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
IUnknown_Release(object);
IUnknown_Release(object);
}
SetEvent(callback->event);
@ -502,15 +506,45 @@ static void test_source_resolver(void)
hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL,
&obj_type, (IUnknown **)&mediasource);
todo_wine ok(hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE, "got 0x%08x\n", hr);
ok(hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE, "got 0x%08x\n", hr);
if (hr == S_OK) IMFMediaSource_Release(mediasource);
hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_BYTESTREAM, NULL,
&obj_type, (IUnknown **)&mediasource);
todo_wine ok(hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE, "got 0x%08x\n", hr);
ok(hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE, "got 0x%08x\n", hr);
IMFByteStream_Release(stream);
/* Create from URL. */
callback.event = CreateEventA(NULL, FALSE, FALSE, NULL);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, L"nonexisting.mp4", MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Unexpected hr %#x.\n", hr);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, filename, MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == S_OK, "Failed to resolve url, hr %#x.\n", hr);
IMFByteStream_Release(stream);
hr = IMFSourceResolver_BeginCreateObjectFromURL(resolver, filename, MF_RESOLUTION_BYTESTREAM, NULL,
&cancel_cookie, &callback.IMFAsyncCallback_iface, (IUnknown *)resolver);
ok(hr == S_OK, "Create request failed, hr %#x.\n", hr);
ok(cancel_cookie != NULL, "Unexpected cancel object.\n");
IUnknown_Release(cancel_cookie);
if (SUCCEEDED(hr))
WaitForSingleObject(callback.event, INFINITE);
/* With explicit scheme. */
lstrcpyW(pathW, fileschemeW);
lstrcatW(pathW, filename);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, pathW, MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == S_OK, "Failed to resolve url, hr %#x.\n", hr);
IMFByteStream_Release(stream);
/* We have to create a new bytestream here, because all following
* calls to CreateObjectFromByteStream will fail. */
hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &stream);
@ -522,14 +556,31 @@ static void test_source_resolver(void)
ok(hr == S_OK, "Failed to set string value, hr %#x.\n", hr);
IMFAttributes_Release(attributes);
/* Start of gstreamer dependent tests */
hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL,
&obj_type, (IUnknown **)&mediasource);
ok(hr == S_OK, "got 0x%08x\n", hr);
if (strcmp(winetest_platform, "wine"))
ok(hr == S_OK, "got 0x%08x\n", hr);
if (FAILED(hr))
{
IMFByteStream_Release(stream);
IMFSourceResolver_Release(resolver);
hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
DeleteFileW(filename);
return;
}
ok(mediasource != NULL, "got %p\n", mediasource);
ok(obj_type == MF_OBJECT_MEDIASOURCE, "got %d\n", obj_type);
hr = IMFMediaSource_CreatePresentationDescriptor(mediasource, &descriptor);
todo_wine
ok(hr == S_OK, "Failed to get presentation descriptor, hr %#x.\n", hr);
if (FAILED(hr))
goto skip_source_tests;
ok(descriptor != NULL, "got %p\n", descriptor);
hr = IMFPresentationDescriptor_GetStreamDescriptorByIndex(descriptor, 0, &selected, &sd);
@ -540,10 +591,7 @@ static void test_source_resolver(void)
IMFStreamDescriptor_Release(sd);
hr = IMFMediaTypeHandler_GetMajorType(handler, &guid);
todo_wine
ok(hr == S_OK, "Failed to get stream major type, hr %#x.\n", hr);
if (FAILED(hr))
goto skip_source_tests;
/* Check major/minor type for the test media. */
ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected major type %s.\n", debugstr_guid(&guid));
@ -624,6 +672,7 @@ todo_wine
get_event((IMFMediaEventGenerator *)mediasource, MEEndOfPresentation, NULL);
IMFMediaTypeHandler_Release(handler);
IMFPresentationDescriptor_Release(descriptor);
hr = IMFMediaSource_Shutdown(mediasource);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
@ -633,42 +682,9 @@ todo_wine
skip_source_tests:
IMFPresentationDescriptor_Release(descriptor);
IMFMediaSource_Release(mediasource);
IMFByteStream_Release(stream);
/* Create from URL. */
callback.event = CreateEventA(NULL, FALSE, FALSE, NULL);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, L"nonexisting.mp4", MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Unexpected hr %#x.\n", hr);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, filename, MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == S_OK, "Failed to resolve url, hr %#x.\n", hr);
IMFByteStream_Release(stream);
hr = IMFSourceResolver_BeginCreateObjectFromURL(resolver, filename, MF_RESOLUTION_BYTESTREAM, NULL,
&cancel_cookie, &callback.IMFAsyncCallback_iface, (IUnknown *)resolver);
ok(hr == S_OK, "Create request failed, hr %#x.\n", hr);
ok(cancel_cookie != NULL, "Unexpected cancel object.\n");
IUnknown_Release(cancel_cookie);
if (SUCCEEDED(hr))
WaitForSingleObject(callback.event, INFINITE);
/* With explicit scheme. */
lstrcpyW(pathW, fileschemeW);
lstrcatW(pathW, filename);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, pathW, MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream);
ok(hr == S_OK, "Failed to resolve url, hr %#x.\n", hr);
IMFByteStream_Release(stream);
IMFSourceResolver_Release(resolver);
/* Create directly through scheme handler. */
hr = CoInitialize(NULL);
ok(SUCCEEDED(hr), "Failed to initialize, hr %#x.\n", hr);
@ -693,12 +709,14 @@ skip_source_tests:
if (do_uninit)
CoUninitialize();
CloseHandle(callback.event);
IMFSourceResolver_Release(resolver);
hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
DeleteFileW(filename);
CloseHandle(callback.event);
}
static void init_functions(void)