evr: Add a stub for sample allocator.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-07-03 19:22:15 +03:00 committed by Alexandre Julliard
parent d888f3ba36
commit 2b8462a520
6 changed files with 279 additions and 2 deletions

View file

@ -9,6 +9,7 @@ C_SRCS = \
evr.c \
main.c \
mixer.c \
presenter.c
presenter.c \
sample.c
IDL_SRCS = evr_classes.idl

View file

@ -18,7 +18,7 @@
@ stub MFCreateVideoOTA
@ stub MFCreateVideoPresenter2
@ stdcall MFCreateVideoPresenter(ptr ptr ptr ptr)
@ stub MFCreateVideoSampleAllocator
@ stdcall MFCreateVideoSampleAllocator(ptr ptr)
@ stdcall MFCreateVideoSampleFromSurface(ptr ptr)
@ stub MFGetPlaneSize
@ stub MFGetStrideForBitmapInfoHeader

199
dlls/evr/sample.c Normal file
View file

@ -0,0 +1,199 @@
/*
* Copyright 2020 Nikolay Sivov
*
* 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
*/
#define COBJMACROS
#include "evr.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(evr);
struct sample_allocator
{
IMFVideoSampleAllocator IMFVideoSampleAllocator_iface;
IMFVideoSampleAllocatorCallback IMFVideoSampleAllocatorCallback_iface;
LONG refcount;
};
static struct sample_allocator *impl_from_IMFVideoSampleAllocator(IMFVideoSampleAllocator *iface)
{
return CONTAINING_RECORD(iface, struct sample_allocator, IMFVideoSampleAllocator_iface);
}
static struct sample_allocator *impl_from_IMFVideoSampleAllocatorCallback(IMFVideoSampleAllocatorCallback *iface)
{
return CONTAINING_RECORD(iface, struct sample_allocator, IMFVideoSampleAllocatorCallback_iface);
}
static HRESULT WINAPI sample_allocator_QueryInterface(IMFVideoSampleAllocator *iface, REFIID riid, void **obj)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocator(iface);
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IMFVideoSampleAllocator) ||
IsEqualIID(riid, &IID_IUnknown))
{
*obj = &allocator->IMFVideoSampleAllocator_iface;
}
else if (IsEqualIID(riid, &IID_IMFVideoSampleAllocatorCallback))
{
*obj = &allocator->IMFVideoSampleAllocatorCallback_iface;
}
else
{
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
*obj = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown *)*obj);
return S_OK;
}
static ULONG WINAPI sample_allocator_AddRef(IMFVideoSampleAllocator *iface)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocator(iface);
ULONG refcount = InterlockedIncrement(&allocator->refcount);
TRACE("%p, refcount %u.\n", iface, refcount);
return refcount;
}
static ULONG WINAPI sample_allocator_Release(IMFVideoSampleAllocator *iface)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocator(iface);
ULONG refcount = InterlockedDecrement(&allocator->refcount);
TRACE("%p, refcount %u.\n", iface, refcount);
if (!refcount)
{
heap_free(allocator);
}
return refcount;
}
static HRESULT WINAPI sample_allocator_SetDirectXManager(IMFVideoSampleAllocator *iface,
IUnknown *manager)
{
FIXME("%p, %p.\n", iface, manager);
return E_NOTIMPL;
}
static HRESULT WINAPI sample_allocator_UninitializeSampleAllocator(IMFVideoSampleAllocator *iface)
{
FIXME("%p.\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI sample_allocator_InitializeSampleAllocator(IMFVideoSampleAllocator *iface,
DWORD sample_count, IMFMediaType *media_type)
{
FIXME("%p, %u, %p.\n", iface, sample_count, media_type);
return E_NOTIMPL;
}
static HRESULT WINAPI sample_allocator_AllocateSample(IMFVideoSampleAllocator *iface, IMFSample **sample)
{
FIXME("%p, %p.\n", iface, sample);
return E_NOTIMPL;
}
static const IMFVideoSampleAllocatorVtbl sample_allocator_vtbl =
{
sample_allocator_QueryInterface,
sample_allocator_AddRef,
sample_allocator_Release,
sample_allocator_SetDirectXManager,
sample_allocator_UninitializeSampleAllocator,
sample_allocator_InitializeSampleAllocator,
sample_allocator_AllocateSample,
};
static HRESULT WINAPI sample_allocator_callback_QueryInterface(IMFVideoSampleAllocatorCallback *iface,
REFIID riid, void **obj)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocatorCallback(iface);
return IMFVideoSampleAllocator_QueryInterface(&allocator->IMFVideoSampleAllocator_iface, riid, obj);
}
static ULONG WINAPI sample_allocator_callback_AddRef(IMFVideoSampleAllocatorCallback *iface)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocatorCallback(iface);
return IMFVideoSampleAllocator_AddRef(&allocator->IMFVideoSampleAllocator_iface);
}
static ULONG WINAPI sample_allocator_callback_Release(IMFVideoSampleAllocatorCallback *iface)
{
struct sample_allocator *allocator = impl_from_IMFVideoSampleAllocatorCallback(iface);
return IMFVideoSampleAllocator_Release(&allocator->IMFVideoSampleAllocator_iface);
}
static HRESULT WINAPI sample_allocator_callback_SetCallback(IMFVideoSampleAllocatorCallback *iface,
IMFVideoSampleAllocatorNotify *callback)
{
FIXME("%p, %p.\n", iface, callback);
return E_NOTIMPL;
}
static HRESULT WINAPI sample_allocator_callback_GetFreeSampleCount(IMFVideoSampleAllocatorCallback *iface,
LONG *count)
{
FIXME("%p, %p.\n", iface, count);
return E_NOTIMPL;
}
static const IMFVideoSampleAllocatorCallbackVtbl sample_allocator_callback_vtbl =
{
sample_allocator_callback_QueryInterface,
sample_allocator_callback_AddRef,
sample_allocator_callback_Release,
sample_allocator_callback_SetCallback,
sample_allocator_callback_GetFreeSampleCount,
};
HRESULT WINAPI MFCreateVideoSampleAllocator(REFIID riid, void **obj)
{
struct sample_allocator *object;
HRESULT hr;
TRACE("%s, %p.\n", debugstr_guid(riid), obj);
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
object->IMFVideoSampleAllocator_iface.lpVtbl = &sample_allocator_vtbl;
object->IMFVideoSampleAllocatorCallback_iface.lpVtbl = &sample_allocator_callback_vtbl;
object->refcount = 1;
hr = IMFVideoSampleAllocator_QueryInterface(&object->IMFVideoSampleAllocator_iface, riid, obj);
IMFVideoSampleAllocator_Release(&object->IMFVideoSampleAllocator_iface);
return hr;
}

View file

@ -962,6 +962,24 @@ static void test_MFCreateVideoMixerAndPresenter(void)
IUnknown_Release(presenter);
}
static void test_MFCreateVideoSampleAllocator(void)
{
IUnknown *unk;
HRESULT hr;
hr = MFCreateVideoSampleAllocator(&IID_IUnknown, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocator, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
hr = MFCreateVideoSampleAllocator(&IID_IMFVideoSampleAllocatorCallback, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
}
START_TEST(evr)
{
CoInitialize(NULL);
@ -978,6 +996,7 @@ START_TEST(evr)
test_surface_sample();
test_default_presenter();
test_MFCreateVideoMixerAndPresenter();
test_MFCreateVideoSampleAllocator();
CoUninitialize();
}

View file

@ -303,4 +303,5 @@ cpp_quote("HRESULT WINAPI MFCreateVideoMixer(IUnknown *owner, REFIID riid_device
cpp_quote("HRESULT WINAPI MFCreateVideoMixerAndPresenter(IUnknown *mixer_outer, IUnknown *presenter_outer, ")
cpp_quote(" REFIID riid_mixer, void **mixer, REFIID riid_presenter, void **presenter);")
cpp_quote("HRESULT WINAPI MFCreateVideoPresenter(IUnknown *owner, REFIID riid_device, REFIID riid, void **obj);")
cpp_quote("HRESULT WINAPI MFCreateVideoSampleAllocator(REFIID riid, void **allocator);")
cpp_quote("HRESULT WINAPI MFCreateVideoSampleFromSurface(IUnknown *surface, IMFSample **sample);")

View file

@ -1040,6 +1040,63 @@ interface IMFAudioPolicy : IUnknown
HRESULT GetIconPath([out] LPWSTR *path);
}
[
object,
uuid(86cbc910-e533-4751-8e3b-f19b5b806a03),
local
]
interface IMFVideoSampleAllocator : IUnknown
{
HRESULT SetDirectXManager(
[in, unique] IUnknown *manager
);
HRESULT UninitializeSampleAllocator();
HRESULT InitializeSampleAllocator(
[in] DWORD sample_count,
[in] IMFMediaType *media_type
);
HRESULT AllocateSample(
[out] IMFSample **sample
);
}
[
object,
uuid(a792cdbe-c374-4e89-8335-278e7b9956a4),
local
]
interface IMFVideoSampleAllocatorNotify : IUnknown
{
HRESULT NotifyRelease();
}
[
object,
uuid(3978aa1a-6d5b-4b7f-a340-90899189ae34),
local
]
interface IMFVideoSampleAllocatorNotifyEx : IMFVideoSampleAllocatorNotify
{
HRESULT NotifyPrune(IMFSample *sample);
}
[
object,
uuid(992388b4-3372-4f67-8b6f-c84c071f4751),
local
]
interface IMFVideoSampleAllocatorCallback : IUnknown
{
HRESULT SetCallback(
[in, unique] IMFVideoSampleAllocatorNotify *callback
);
HRESULT GetFreeSampleCount(
[out] LONG *count
);
}
enum
{
MF_ACTIVATE_CUSTOM_MIXER_ALLOWFAIL = 0x00000001,