Commit 2e9a036f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Add partial implementation of ConvertToContiguousBuffer().

parent 2295d937
...@@ -686,9 +686,29 @@ static HRESULT WINAPI sample_GetBufferByIndex(IMFSample *iface, DWORD index, IMF ...@@ -686,9 +686,29 @@ static HRESULT WINAPI sample_GetBufferByIndex(IMFSample *iface, DWORD index, IMF
static HRESULT WINAPI sample_ConvertToContiguousBuffer(IMFSample *iface, IMFMediaBuffer **buffer) static HRESULT WINAPI sample_ConvertToContiguousBuffer(IMFSample *iface, IMFMediaBuffer **buffer)
{ {
FIXME("%p, %p.\n", iface, buffer); struct sample *sample = impl_from_IMFSample(iface);
HRESULT hr = S_OK;
return E_NOTIMPL; TRACE("%p, %p.\n", iface, buffer);
EnterCriticalSection(&sample->cs);
if (sample->buffer_count == 0)
hr = E_UNEXPECTED;
else if (sample->buffer_count == 1)
{
*buffer = sample->buffers[0];
IMFMediaBuffer_AddRef(*buffer);
}
else
{
FIXME("Samples with multiple buffers are not supported.\n");
hr = E_NOTIMPL;
}
LeaveCriticalSection(&sample->cs);
return hr;
} }
static HRESULT WINAPI sample_AddBuffer(IMFSample *iface, IMFMediaBuffer *buffer) static HRESULT WINAPI sample_AddBuffer(IMFSample *iface, IMFMediaBuffer *buffer)
......
...@@ -1475,6 +1475,53 @@ static void test_sample(void) ...@@ -1475,6 +1475,53 @@ static void test_sample(void)
IMFAttributes_Release(attributes); IMFAttributes_Release(attributes);
IMFSample_Release(sample); IMFSample_Release(sample);
/* ConvertToContiguousBuffer() */
hr = MFCreateSample(&sample);
ok(hr == S_OK, "Failed to create a sample, hr %#x.\n", hr);
hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer);
ok(hr == E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
hr = MFCreateMemoryBuffer(16, &buffer);
ok(hr == S_OK, "Failed to create a buffer, hr %#x.\n", hr);
hr = IMFSample_AddBuffer(sample, buffer);
ok(hr == S_OK, "Failed to add buffer, hr %#x.\n", hr);
hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer2);
ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr);
ok(buffer2 == buffer, "Unexpected buffer instance.\n");
IMFMediaBuffer_Release(buffer2);
hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer2);
ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr);
ok(buffer2 == buffer, "Unexpected buffer instance.\n");
IMFMediaBuffer_Release(buffer2);
hr = MFCreateMemoryBuffer(16, &buffer2);
ok(hr == S_OK, "Failed to create a buffer, hr %#x.\n", hr);
hr = IMFSample_AddBuffer(sample, buffer2);
ok(hr == S_OK, "Failed to add buffer, hr %#x.\n", hr);
IMFMediaBuffer_Release(buffer2);
hr = IMFSample_GetBufferCount(sample, &count);
ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);
ok(count == 2, "Unexpected buffer count %u.\n", count);
hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer2);
todo_wine
ok(hr == S_OK, "Failed to convert, hr %#x.\n", hr);
if (SUCCEEDED(hr))
IMFMediaBuffer_Release(buffer2);
hr = IMFSample_GetBufferCount(sample, &count);
ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr);
todo_wine
ok(count == 1, "Unexpected buffer count %u.\n", count);
IMFSample_Release(sample);
} }
struct test_callback struct test_callback
......
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