Commit 77d1701b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Add IMFGetService stub for 2D memory buffer.

parent 8e13b0b9
......@@ -31,6 +31,7 @@ struct memory_buffer
{
IMFMediaBuffer IMFMediaBuffer_iface;
IMF2DBuffer2 IMF2DBuffer2_iface;
IMFGetService IMFGetService_iface;
LONG refcount;
BYTE *data;
......@@ -88,6 +89,11 @@ static struct memory_buffer *impl_from_IMF2DBuffer2(IMF2DBuffer2 *iface)
return CONTAINING_RECORD(iface, struct memory_buffer, IMF2DBuffer2_iface);
}
static struct memory_buffer *impl_from_IMFGetService(IMFGetService *iface)
{
return CONTAINING_RECORD(iface, struct memory_buffer, IMFGetService_iface);
}
static inline struct sample *impl_from_IMFSample(IMFSample *iface)
{
return CONTAINING_RECORD(iface, struct sample, IMFSample_iface);
......@@ -240,6 +246,10 @@ static HRESULT WINAPI memory_1d_2d_buffer_QueryInterface(IMFMediaBuffer *iface,
{
*out = &buffer->IMF2DBuffer2_iface;
}
else if (IsEqualIID(riid, &IID_IMFGetService))
{
*out = &buffer->IMFGetService_iface;
}
else
{
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
......@@ -511,6 +521,39 @@ static const IMF2DBuffer2Vtbl memory_2d_buffer_vtbl =
memory_2d_buffer_Copy2DTo,
};
static HRESULT WINAPI memory_2d_buffer_gs_QueryInterface(IMFGetService *iface, REFIID riid, void **obj)
{
struct memory_buffer *buffer = impl_from_IMFGetService(iface);
return IMFMediaBuffer_QueryInterface(&buffer->IMFMediaBuffer_iface, riid, obj);
}
static ULONG WINAPI memory_2d_buffer_gs_AddRef(IMFGetService *iface)
{
struct memory_buffer *buffer = impl_from_IMFGetService(iface);
return IMFMediaBuffer_AddRef(&buffer->IMFMediaBuffer_iface);
}
static ULONG WINAPI memory_2d_buffer_gs_Release(IMFGetService *iface)
{
struct memory_buffer *buffer = impl_from_IMFGetService(iface);
return IMFMediaBuffer_Release(&buffer->IMFMediaBuffer_iface);
}
static HRESULT WINAPI memory_2d_buffer_gs_GetService(IMFGetService *iface, REFGUID service, REFIID riid, void **obj)
{
TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj);
return E_NOTIMPL;
}
static const IMFGetServiceVtbl memory_2d_buffer_gs_vtbl =
{
memory_2d_buffer_gs_QueryInterface,
memory_2d_buffer_gs_AddRef,
memory_2d_buffer_gs_Release,
memory_2d_buffer_gs_GetService,
};
static HRESULT memory_buffer_init(struct memory_buffer *buffer, DWORD max_length, DWORD alignment,
const IMFMediaBufferVtbl *vtbl)
{
......@@ -620,6 +663,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
}
object->IMF2DBuffer2_iface.lpVtbl = &memory_2d_buffer_vtbl;
object->IMFGetService_iface.lpVtbl = &memory_2d_buffer_gs_vtbl;
object->_2d.plane_size = plane_size;
object->_2d.width = stride;
object->_2d.height = height;
......
......@@ -1818,6 +1818,7 @@ static void test_system_memory_buffer(void)
HRESULT hr;
DWORD length, max;
BYTE *data, *data2;
IUnknown *unk;
hr = MFCreateMemoryBuffer(1024, NULL);
ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr);
......@@ -1836,6 +1837,9 @@ static void test_system_memory_buffer(void)
hr = MFCreateMemoryBuffer(1024, &buffer);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_GetMaxLength(buffer, NULL);
ok(hr == E_INVALIDARG || hr == E_POINTER, "got 0x%08x\n", hr);
......@@ -5155,6 +5159,7 @@ static void test_MFCreate2DMediaBuffer(void)
IMF2DBuffer *_2dbuffer;
IMFMediaBuffer *buffer;
int i, pitch, pitch2;
IUnknown *unk;
HRESULT hr;
BOOL ret;
......@@ -5177,6 +5182,10 @@ static void test_MFCreate2DMediaBuffer(void)
hr = pMFCreate2DMediaBuffer(2, 3, MAKEFOURCC('N','V','1','2'), FALSE, &buffer);
ok(hr == S_OK, "Failed to create a buffer, hr %#x.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IUnknown_Release(unk);
/* Full backing buffer size, with 64 bytes per row alignment. */
hr = IMFMediaBuffer_GetMaxLength(buffer, &max_length);
ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr);
......@@ -5405,6 +5414,7 @@ static void test_MFCreateMediaBufferFromMediaType(void)
HRESULT hr;
IMFMediaType *media_type;
unsigned int i;
IUnknown *unk;
if (!pMFCreateMediaBufferFromMediaType)
{
......@@ -5437,6 +5447,9 @@ static void test_MFCreateMediaBufferFromMediaType(void)
if (FAILED(hr))
break;
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMFGetService, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaBuffer_GetMaxLength(buffer, &length);
ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr);
ok(ptr->buffer_length == length, "%d: unexpected buffer length %u, expected %u.\n", i, length, ptr->buffer_length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment