summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-07-28 13:51:48 +0200
committerLars Knoll <lars.knoll@qt.io>2021-07-30 10:18:07 +0200
commit6fc0b29b053492c1071be80059547f54af8d15b5 (patch)
treed6ac86a14386b7bcd0fb25b3cd11318562a9f02a
parentc917c16293fa9fb385fd54e08d95f11302e32337 (diff)
Move the m_position and m_rate members into the shared d-pointer
QGstPipeline can be copied, but the position and rate variables should be explicitly shared. Move them into the d pointer to get correct semantics. Change-Id: I257893e292ad7255d9c7d3796e097fa352952ca4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstpipeline.cpp57
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstpipeline_p.h53
2 files changed, 64 insertions, 46 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp b/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
index a8853803c..e240b52e2 100644
--- a/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstpipeline.cpp
@@ -63,6 +63,8 @@ public:
QList<QGstreamerSyncMessageFilter*> syncFilters;
QList<QGstreamerBusMessageFilter*> busFilters;
QProperty<bool> inStoppedState;
+ mutable qint64 m_position = 0;
+ double m_rate = 1.;
QGstPipelinePrivate(GstBus* bus, QObject* parent = 0);
~QGstPipelinePrivate();
@@ -260,6 +262,61 @@ void QGstPipeline::removeMessageFilter(QGstreamerBusMessageFilter *filter)
d->removeMessageFilter(filter);
}
+void QGstPipeline::flush()
+{
+ seek(position(), d->m_rate);
+}
+
+bool QGstPipeline::seek(qint64 pos, double rate)
+{
+ // always adjust the rate, so it can be set before playback starts
+ // setting position needs a loaded media file that's seekable
+ d->m_rate = rate;
+ bool success = gst_element_seek(element(), rate, GST_FORMAT_TIME,
+ GstSeekFlags(GST_SEEK_FLAG_FLUSH),
+ GST_SEEK_TYPE_SET, pos,
+ GST_SEEK_TYPE_SET, -1);
+ if (!success)
+ return false;
+
+ d->m_position = pos;
+ return true;
+}
+
+bool QGstPipeline::setPlaybackRate(double rate)
+{
+ if (rate == d->m_rate)
+ return false;
+ seek(position(), rate);
+ return true;
+}
+
+double QGstPipeline::playbackRate() const
+{
+ return d->m_rate;
+}
+
+bool QGstPipeline::setPosition(qint64 pos)
+{
+ return seek(pos, d->m_rate);
+}
+
+qint64 QGstPipeline::position() const
+{
+ gint64 pos;
+ if (gst_element_query_position(element(), GST_FORMAT_TIME, &pos))
+ d->m_position = pos;
+ return d->m_position;
+}
+
+qint64 QGstPipeline::duration() const
+{
+ gint64 d;
+ if (!gst_element_query_duration(element(), GST_FORMAT_TIME, &d))
+ return 0.;
+ return d;
+}
+
QT_END_NAMESPACE
#include "qgstpipeline.moc"
diff --git a/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h b/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
index 28ccba6e8..d49a318cb 100644
--- a/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgstpipeline_p.h
@@ -112,55 +112,16 @@ public:
#endif
}
- void flush() { seek(position(), m_rate); }
+ void flush();
- bool seek(qint64 pos, double rate)
- {
- // always adjust the rate, so it can be set before playback starts
- // setting position needs a loaded media file that's seekable
- m_rate = rate;
- bool success = gst_element_seek(element(), rate, GST_FORMAT_TIME,
- GstSeekFlags(GST_SEEK_FLAG_FLUSH),
- GST_SEEK_TYPE_SET, pos,
- GST_SEEK_TYPE_SET, -1);
- if (!success)
- return false;
-
- m_position = pos;
- return true;
- }
- bool setPlaybackRate(double rate)
- {
- if (rate == m_rate)
- return false;
- seek(position(), rate);
- return true;
- }
- double playbackRate() const { return m_rate; }
+ bool seek(qint64 pos, double rate);
+ bool setPlaybackRate(double rate);
+ double playbackRate() const;
- bool setPosition(qint64 pos)
- {
- return seek(pos, m_rate);
- }
- qint64 position() const
- {
- gint64 pos;
- if (gst_element_query_position(element(), GST_FORMAT_TIME, &pos))
- m_position = pos;
- return m_position;
- }
-
- qint64 duration() const
- {
- gint64 d;
- if (!gst_element_query_duration(element(), GST_FORMAT_TIME, &d))
- return 0.;
- return d;
- }
+ bool setPosition(qint64 pos);
+ qint64 position() const;
-private:
- mutable qint64 m_position = 0;
- double m_rate = 1.;
+ qint64 duration() const;
};
QT_END_NAMESPACE