1From 8cedb6530e4f369ad9c4543934aa0b61eeabf798 Mon Sep 17 00:00:00 2001
2From: "james.lin" <james.lin@rock-chips.com>
3Date: Thu, 12 Apr 2018 16:20:36 +0800
4Subject: [PATCH 06/17] qgstreamerplayersession add seek direct to ensure seek
5 effective
6
7Signed-off-by: james.lin <james.lin@rock-chips.com>
8---
9 src/gsttools/qgstreamerplayersession.cpp | 8 +++++++-
10 1 file changed, 7 insertions(+), 1 deletion(-)
11 mode change 100644 => 100755 src/gsttools/qgstreamerplayersession.cpp
12
13diff --git a/src/gsttools/qgstreamerplayersession.cpp b/src/gsttools/qgstreamerplayersession.cpp
14old mode 100644
15new mode 100755
16index a891027..98b7ffb
17--- a/src/gsttools/qgstreamerplayersession.cpp
18+++ b/src/gsttools/qgstreamerplayersession.cpp
19@@ -1091,9 +1091,15 @@ bool QGstreamerPlayerSession::seek(qint64 ms)
20         ms = qMax(ms,qint64(0));
21         qint64 from = m_playbackRate > 0 ? ms : 0;
22         qint64 to = m_playbackRate > 0 ? duration() : ms;
23+        gint64  now = 0;
24+        GstSeekFlags direct_flag = GST_SEEK_FLAG_SNAP_AFTER;
25+
26+        qt_gst_element_query_position(m_playbin, GST_FORMAT_TIME, &now);
27+        if (now > from * 1000000)
28+            direct_flag = GST_SEEK_FLAG_SNAP_BEFORE;
29
30         bool isSeeking = gst_element_seek(m_pipeline, m_playbackRate, GST_FORMAT_TIME,
31-                                          GstSeekFlags(GST_SEEK_FLAG_FLUSH),
32+                                          GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT | direct_flag),
33                                           GST_SEEK_TYPE_SET, from * 1000000,
34                                           GST_SEEK_TYPE_SET, to * 1000000);
35         if (isSeeking)
36--
372.20.1
38
39