[PATCH v2 16/18] winegstreamer: Calculate the MF_PD_DURATION of the media source's PD.
Derek Lesho
dlesho at codeweavers.com
Wed Apr 1 17:05:37 CDT 2020
Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
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
More information about the wine-devel
mailing list