Commit 23fb8a6b authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

quartz/tests: Add tests for MPEG audio decoder sample processing.

parent bf6aa078
...@@ -794,6 +794,7 @@ struct testfilter ...@@ -794,6 +794,7 @@ struct testfilter
struct strmbase_source source; struct strmbase_source source;
struct strmbase_sink sink; struct strmbase_sink sink;
const AM_MEDIA_TYPE *mt; const AM_MEDIA_TYPE *mt;
unsigned int got_sample;
}; };
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface) static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface)
...@@ -867,11 +868,27 @@ static HRESULT testsink_connect(struct strmbase_sink *iface, IPin *peer, const A ...@@ -867,11 +868,27 @@ static HRESULT testsink_connect(struct strmbase_sink *iface, IPin *peer, const A
return S_OK; return S_OK;
} }
static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample *sample)
{
struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
LONG size;
++filter->got_sample;
size = IMediaSample_GetSize(sample);
ok(size == 3072, "Got size %lu.\n", size);
size = IMediaSample_GetActualDataLength(sample);
ok(size == 768, "Got valid size %lu.\n", size);
return S_OK;
}
static const struct strmbase_sink_ops testsink_ops = static const struct strmbase_sink_ops testsink_ops =
{ {
.base.pin_query_interface = testsink_query_interface, .base.pin_query_interface = testsink_query_interface,
.base.pin_get_media_type = testsink_get_media_type, .base.pin_get_media_type = testsink_get_media_type,
.sink_connect = testsink_connect, .sink_connect = testsink_connect,
.pfnReceive = testsink_Receive,
}; };
static void testfilter_init(struct testfilter *filter) static void testfilter_init(struct testfilter *filter)
...@@ -1040,6 +1057,62 @@ static void test_source_allocator(IFilterGraph2 *graph, IMediaControl *control, ...@@ -1040,6 +1057,62 @@ static void test_source_allocator(IFilterGraph2 *graph, IMediaControl *control,
IFilterGraph2_Disconnect(graph, &testsource->source.pin.IPin_iface); IFilterGraph2_Disconnect(graph, &testsource->source.pin.IPin_iface);
} }
static void test_sample_processing(IMediaControl *control, IMemInputPin *input, struct testfilter *sink)
{
IMemAllocator *allocator;
IMediaSample *sample;
HRESULT hr;
BYTE *data;
LONG size;
hr = IMemInputPin_ReceiveCanBlock(input);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_GetAllocator(input, &allocator);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaControl_Pause(control);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#lx.\n", hr);
hr = IMemAllocator_Commit(allocator);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaSample_GetPointer(sample, &data);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
size = IMediaSample_GetSize(sample);
ok(size == 256, "Got size %ld.\n", size);
memset(data, 0, 48);
data[0] = 0xff;
data[1] = 0xff;
data[2] = 0x18;
data[3] = 0xc4;
hr = IMediaSample_SetActualDataLength(sample, 48);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_Receive(input, sample);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_Receive(input, sample);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_Receive(input, sample);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
todo_wine ok(sink->got_sample >= 1, "Got %u calls to Receive().\n", sink->got_sample);
sink->got_sample = 0;
hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMemInputPin_Receive(input, sample);
todo_wine ok(hr == VFW_E_WRONG_STATE, "Got hr %#lx.\n", hr);
IMediaSample_Release(sample);
IMemAllocator_Release(allocator);
}
static void test_connect_pin(void) static void test_connect_pin(void)
{ {
IBaseFilter *filter = create_mpeg_audio_codec(); IBaseFilter *filter = create_mpeg_audio_codec();
...@@ -1233,6 +1306,8 @@ static void test_connect_pin(void) ...@@ -1233,6 +1306,8 @@ static void test_connect_pin(void)
hr = IMediaControl_Stop(control); hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_sample_processing(control, meminput, &testsink);
hr = IFilterGraph2_Disconnect(graph, source); hr = IFilterGraph2_Disconnect(graph, source);
ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IFilterGraph2_Disconnect(graph, source); hr = IFilterGraph2_Disconnect(graph, source);
......
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