Media is always set to be seekable with the gstreamer backend
authorAndras Becsi <andras.becsi@digia.com>
Mon, 19 Nov 2012 12:59:32 +0000 (13:59 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 20 Nov 2012 10:54:49 +0000 (11:54 +0100)
Since the used mechanism for querying whether the media is seekable
was unreliable the code has been commented out and the media always
set to be seekable.
Query for seeking capabilities after the duration is known in
updateDuration() which retries to determine the duration multiple
times if unsuccessful and use gst_query_parse_seeking to check
if the media is seekable or not.

Change-Id: I141dfb1616dc59f8c92a698ddb2867f63a2656b9
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp

index 081893d..1c23a69 100644 (file)
@@ -1031,23 +1031,9 @@ bool QGstreamerPlayerSession::processBusMessage(const QGstreamerMessage &message
                             //information is ready, GST_MESSAGE_DURATION is not sent by most elements
                             //the duration is queried up to 5 times with increasing delay
                             m_durationQueries = 5;
+                            // This should also update the seekable flag.
                             updateDuration();
 
-                            /*
-                                //gst_element_seek_simple doesn't work reliably here, have to find a better solution
-
-                                GstFormat   format = GST_FORMAT_TIME;
-                                gint64      position = 0;
-                                bool seekable = false;
-                                if (gst_element_query_position(m_playbin, &format, &position)) {
-                                    seekable = gst_element_seek_simple(m_playbin, format, GST_SEEK_FLAG_NONE, position);
-                                }
-
-                                setSeekable(seekable);
-                                */
-
-                            setSeekable(true);
-
                             if (!qFuzzyCompare(m_playbackRate, qreal(1.0))) {
                                 qreal rate = m_playbackRate;
                                 m_playbackRate = 1.0;
@@ -1401,8 +1387,15 @@ void QGstreamerPlayerSession::updateDuration()
         emit durationChanged(m_duration);
     }
 
-    if (m_duration > 0)
+    gboolean seekable = false;
+    if (m_duration > 0) {
         m_durationQueries = 0;
+        GstQuery *query = gst_query_new_seeking(GST_FORMAT_TIME);
+        if (gst_element_query(m_playbin, query))
+            gst_query_parse_seeking(query, 0, &seekable, 0, 0);
+        gst_query_unref(query);
+    }
+    setSeekable(seekable);
 
     if (m_durationQueries > 0) {
         //increase delay between duration requests