From: Derek Lesho Subject: [PATCH v2 16/18] winegstreamer: Calculate the MF_PD_DURATION of the media source's PD. Message-Id: <20200401220539.522012-16-dlesho@codeweavers.com> Date: Wed, 1 Apr 2020 17:05:37 -0500 In-Reply-To: <20200401220539.522012-1-dlesho@codeweavers.com> References: <20200401220539.522012-1-dlesho@codeweavers.com> Signed-off-by: Derek Lesho --- dlls/winegstreamer/media_source.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index e6effa0429..4e87546f13 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -1264,6 +1264,46 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, enum source_t CloseHandle(This->init_complete_event); This->init_complete_event = NULL; + /* miscelaneous presentation descriptor setup */ + { + IMFAttributes *byte_stream_attributes; + gint64 total_pres_time = 0; + + if (SUCCEEDED(IMFByteStream_QueryInterface(This->byte_stream, &IID_IMFAttributes, (void **)&byte_stream_attributes))) + { + WCHAR *mimeW = NULL; + DWORD length; + if (SUCCEEDED(IMFAttributes_GetAllocatedString(byte_stream_attributes, &MF_BYTESTREAM_CONTENT_TYPE, &mimeW, &length))) + { + IMFPresentationDescriptor_SetString(This->pres_desc, &MF_PD_MIME_TYPE, mimeW); + CoTaskMemFree(mimeW); + } + IMFAttributes_Release(byte_stream_attributes); + } + + for (unsigned int i = 0; i < This->stream_count; i++) + { + GstQuery *query = gst_query_new_duration(GST_FORMAT_TIME); + if (gst_pad_query(This->streams[i]->their_src, query)) + { + gint64 stream_pres_time; + gst_query_parse_duration(query, NULL, &stream_pres_time); + + TRACE("Stream %u has duration %lu\n", i, stream_pres_time); + + if (stream_pres_time > total_pres_time) + total_pres_time = stream_pres_time; + } + else + { + WARN("Unable to get presentation time of stream %u\n", i); + } + } + + if (This->stream_count) + IMFPresentationDescriptor_SetUINT64(This->pres_desc, &MF_PD_DURATION, total_pres_time / 100); + } + gst_element_set_state(This->container, GST_STATE_READY); if (!(This->pres_desc)) { -- 2.26.0