[PATCH 3/5] winegstreamer: Set MF_PD_DURATION on source's presentation descriptor.

Derek Lesho dlesho at codeweavers.com
Mon Nov 2 10:26:58 CST 2020


Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
 dlls/winegstreamer/media_source.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 41a738525ca..b7f3e6c2946 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -1237,6 +1237,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
 
     struct media_source *object = heap_alloc_zero(sizeof(*object));
     IMFStreamDescriptor **descriptors = NULL;
+    gint64 total_pres_time = 0;
     unsigned int i;
     HRESULT hr;
     int ret;
@@ -1347,6 +1348,28 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
     heap_free(descriptors);
     descriptors = NULL;
 
+    for (unsigned int i = 0; i < object->stream_count; i++)
+    {
+        GstQuery *query = gst_query_new_duration(GST_FORMAT_TIME);
+        if (gst_pad_query(object->streams[i]->their_src, query))
+        {
+            gint64 stream_pres_time;
+            gst_query_parse_duration(query, NULL, &stream_pres_time);
+
+            TRACE("Stream %u has duration %llu\n", i, (unsigned long long int) 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 (object->stream_count)
+        IMFPresentationDescriptor_SetUINT64(object->pres_desc, &MF_PD_DURATION, total_pres_time / 100);
+
     object->state = SOURCE_STOPPED;
 
     *out_media_source = object;
-- 
2.28.0




More information about the wine-devel mailing list