diff options
Diffstat (limited to 'src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp')
-rw-r--r-- | src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp b/src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp index 392898245..1a7ba6508 100644 --- a/src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp +++ b/src/plugins/multimedia/gstreamer/common/qgstpipeline.cpp @@ -16,9 +16,7 @@ QT_BEGIN_NAMESPACE class QGstPipelinePrivate : public QObject { - Q_OBJECT public: - int m_ref = 0; guint m_tag = 0; GstBus *m_bus = nullptr; @@ -46,8 +44,21 @@ public: void installMessageFilter(QGstreamerBusMessageFilter *filter); void removeMessageFilter(QGstreamerBusMessageFilter *filter); - static GstBusSyncReply syncGstBusFilter(GstBus* bus, GstMessage* message, QGstPipelinePrivate *d) + void processMessage(const QGstreamerMessage &msg) + { + for (QGstreamerBusMessageFilter *filter : std::as_const(busFilters)) { + if (filter->processBusMessage(msg)) + break; + } + } + +private: + static GstBusSyncReply syncGstBusFilter(GstBus *bus, GstMessage *message, + QGstPipelinePrivate *d) { + if (!message) + return GST_BUS_PASS; + Q_UNUSED(bus); QMutexLocker lock(&d->filterMutex); @@ -62,31 +73,17 @@ public: return GST_BUS_PASS; } -private Q_SLOTS: - void interval() - { - GstMessage* message; - while ((message = gst_bus_poll(m_bus, GST_MESSAGE_ANY, 0)) != nullptr) { - processMessage(message); - gst_message_unref(message); - } - } - void doProcessMessage(const QGstreamerMessage& msg) - { - for (QGstreamerBusMessageFilter *filter : std::as_const(busFilters)) { - if (filter->processBusMessage(msg)) - break; - } - } - -private: void processMessage(GstMessage *message) { + if (!message) + return; + QGstreamerMessage msg{ message, QGstreamerMessage::NeedsRef, }; - doProcessMessage(msg); + + processMessage(msg); } static gboolean busCallback(GstBus *, GstMessage *message, gpointer data) @@ -106,7 +103,13 @@ QGstPipelinePrivate::QGstPipelinePrivate(GstBus* bus, QObject* parent) if (!hasGlib) { m_intervalTimer = new QTimer(this); m_intervalTimer->setInterval(250); - connect(m_intervalTimer, SIGNAL(timeout()), SLOT(interval())); + QObject::connect(m_intervalTimer, &QTimer::timeout, this, [this] { + GstMessage *message; + while ((message = gst_bus_poll(m_bus, GST_MESSAGE_ANY, 0)) != nullptr) { + processMessage(message); + gst_message_unref(message); + } + }); m_intervalTimer->start(); } else { m_tag = gst_bus_add_watch_full(bus, G_PRIORITY_DEFAULT, busCallback, this, nullptr); @@ -235,6 +238,16 @@ GstStateChangeReturn QGstPipeline::setState(GstState state) return retval; } +void QGstPipeline::processMessages(GstMessageType types) +{ + QGstPipelinePrivate *d = getPrivate(); + QGstreamerMessage message{ + gst_bus_pop_filtered(d->m_bus, types), + QGstreamerMessage::HasRef, + }; + d->processMessage(message); +} + void QGstPipeline::dumpGraph(const char *fileName) { if (isNull()) @@ -268,8 +281,8 @@ void QGstPipeline::beginConfig() break; } case GST_STATE_CHANGE_FAILURE: { - // should not happen - qCritical() << "QGstPipeline::beginConfig: state change failure"; + qDebug() << "QGstPipeline::beginConfig: state change failure"; + dumpGraph("beginConfigFailure"); break; } @@ -324,12 +337,17 @@ bool QGstPipeline::seek(qint64 pos, double rate) return true; } -bool QGstPipeline::setPlaybackRate(double rate) +bool QGstPipeline::setPlaybackRate(double rate, bool applyToPipeline) { QGstPipelinePrivate *d = getPrivate(); if (rate == d->m_rate) return false; + if (!applyToPipeline) { + d->m_rate = rate; + return true; + } + constexpr GstSeekFlags seekFlags = #if GST_CHECK_VERSION(1, 18, 0) GST_SEEK_FLAG_INSTANT_RATE_CHANGE; @@ -383,6 +401,3 @@ QGstPipelinePrivate *QGstPipeline::getPrivate() const } QT_END_NAMESPACE - -#include "qgstpipeline.moc" - |