Commit e2893c34 authored by Derek Lesho's avatar Derek Lesho Committed by Alexandre Julliard

winegstreamer: Implement IMFMediaSource::CreatePresentationDescriptor.

parent f26e81cf
......@@ -1452,7 +1452,6 @@ todo_wine
return;
hr = IMFMediaSource_CreatePresentationDescriptor(source, &pd);
todo_wine
ok(hr == S_OK, "Failed to create descriptor, hr %#x.\n", hr);
if (FAILED(hr))
return;
......
......@@ -574,10 +574,7 @@ static void test_source_resolver(void)
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);
......@@ -597,6 +594,7 @@ todo_wine
ok(hr == S_OK, "Failed to get current media type, hr %#x.\n", hr);
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
ok(hr == S_OK, "Failed to get media sub type, hr %#x.\n", hr);
todo_wine
ok(IsEqualGUID(&guid, &MFVideoFormat_M4S2), "Unexpected sub type %s.\n", debugstr_guid(&guid));
IMFMediaType_Release(media_type);
......@@ -605,7 +603,10 @@ todo_wine
var.vt = VT_EMPTY;
hr = IMFMediaSource_Start(mediasource, descriptor, &GUID_NULL, &var);
todo_wine
ok(hr == S_OK, "Failed to start media source, hr %#x.\n", hr);
if (FAILED(hr))
goto skip_source_tests;
get_event((IMFMediaEventGenerator *)mediasource, MENewStream, &var);
ok(var.vt == VT_UNKNOWN, "Unexpected value type %u from MENewStream event.\n", var.vt);
......@@ -668,11 +669,10 @@ todo_wine
get_event((IMFMediaEventGenerator *)mediasource, MEEndOfPresentation, NULL);
skip_source_tests:
IMFMediaTypeHandler_Release(handler);
IMFPresentationDescriptor_Release(descriptor);
skip_source_tests:
hr = IMFMediaSource_Shutdown(mediasource);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
......
......@@ -627,14 +627,13 @@ static void test_source_reader(void)
stream = get_resource_stream("test.wav");
hr = MFCreateSourceReaderFromByteStream(stream, NULL, &reader);
todo_wine
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
if (FAILED(hr))
{
skip("MFCreateSourceReaderFromByteStream() failed, is G-Streamer missing?\n");
IMFByteStream_Release(stream);
return;
}
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
/* Access underlying media source object. */
hr = IMFSourceReader_GetServiceForStream(reader, MF_SOURCE_READER_MEDIASOURCE, &GUID_NULL, &IID_IMFMediaSource,
......@@ -723,7 +722,10 @@ todo_wine
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, &actual_index, &stream_flags,
&timestamp, &sample);
todo_wine
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
if (hr != S_OK)
goto skip_read_sample;
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(!stream_flags, "Unexpected stream flags %#x.\n", stream_flags);
IMFSample_Release(sample);
......@@ -784,6 +786,8 @@ todo_wine
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
skip_read_sample:
/* Flush. */
hr = IMFSourceReader_Flush(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
......@@ -814,10 +818,11 @@ todo_wine
IMFSourceReaderCallback_Release(&callback->IMFSourceReaderCallback_iface);
hr = MFCreateSourceReaderFromByteStream(stream, attributes, &reader);
todo_wine
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
IMFAttributes_Release(attributes);
IMFSourceReader_Release(reader);
if (hr == S_OK)
IMFSourceReader_Release(reader);
IMFByteStream_Release(stream);
}
......
......@@ -67,6 +67,7 @@ struct media_source
IMFByteStream *byte_stream;
struct media_stream **streams;
ULONG stream_count;
IMFPresentationDescriptor *pres_desc;
GstBus *bus;
GstElement *container;
GstElement *decodebin;
......@@ -673,12 +674,12 @@ static HRESULT WINAPI media_source_CreatePresentationDescriptor(IMFMediaSource *
{
struct media_source *source = impl_from_IMFMediaSource(iface);
FIXME("(%p)->(%p): stub\n", source, descriptor);
TRACE("(%p)->(%p)\n", source, descriptor);
if (source->state == SOURCE_SHUTDOWN)
return MF_E_SHUTDOWN;
return E_NOTIMPL;
return IMFPresentationDescriptor_Clone(source->pres_desc, descriptor);
}
static HRESULT WINAPI media_source_Start(IMFMediaSource *iface, IMFPresentationDescriptor *descriptor,
......@@ -741,6 +742,8 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
if (source->their_sink)
gst_object_unref(GST_OBJECT(source->their_sink));
if (source->pres_desc)
IMFPresentationDescriptor_Release(source->pres_desc);
if (source->event_queue)
IMFMediaEventQueue_Shutdown(source->event_queue);
if (source->byte_stream)
......@@ -841,6 +844,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
GST_STATIC_PAD_TEMPLATE("mf_src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);
struct media_source *object = heap_alloc_zero(sizeof(*object));
IMFStreamDescriptor **descriptors = NULL;
unsigned int i;
HRESULT hr;
int ret;
......@@ -928,6 +932,25 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
gst_sample_unref(preroll);
}
/* init presentation descriptor */
descriptors = heap_alloc(object->stream_count * sizeof(IMFStreamDescriptor*));
for (i = 0; i < object->stream_count; i++)
{
IMFMediaStream_GetStreamDescriptor(&object->streams[i]->IMFMediaStream_iface, &descriptors[i]);
}
if (FAILED(hr = MFCreatePresentationDescriptor(object->stream_count, descriptors, &object->pres_desc)))
goto fail;
for (i = 0; i < object->stream_count; i++)
{
IMFPresentationDescriptor_SelectStream(object->pres_desc, i);
IMFStreamDescriptor_Release(descriptors[i]);
}
heap_free(descriptors);
descriptors = NULL;
object->state = SOURCE_STOPPED;
*out_media_source = object;
......@@ -936,6 +959,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
fail:
WARN("Failed to construct MFMediaSource, hr %#x.\n", hr);
heap_free(descriptors);
IMFMediaSource_Release(&object->IMFMediaSource_iface);
return hr;
}
......
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