Commit 0cec1d54 authored by Val Doroshchuk's avatar Val Doroshchuk

pipeline

parent c71e92af
...@@ -54,6 +54,17 @@ void QGstreamerPipelinePrivate::updateMediaObject() ...@@ -54,6 +54,17 @@ void QGstreamerPipelinePrivate::updateMediaObject()
q->setMediaPlayer(obj); q->setMediaPlayer(obj);
} }
void QGstreamerPipelinePrivate::updatePipeline()
{
Q_Q(QGstreamerPipeline);
auto renderer = session->renderer();
if (!renderer || !renderer->isReady())
return;
q->setPipeline(pendingPipelineDesc);
}
QGstreamerPipeline::QGstreamerPipeline(QObject *parent) QGstreamerPipeline::QGstreamerPipeline(QObject *parent)
: QGstreamerPipeline(new QGstreamerPipelinePrivate(this), nullptr, parent) : QGstreamerPipeline(new QGstreamerPipelinePrivate(this), nullptr, parent)
{ {
...@@ -128,7 +139,10 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src) ...@@ -128,7 +139,10 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src)
if (!d->session) if (!d->session)
return; return;
connect(d->session, &QGstreamerPlayerSession::pipelineChanged, this, &QGstreamerPipeline::pipelineChanged); connect(d->session, &QGstreamerPlayerSession::pipelineChanged,
this, &QGstreamerPipeline::pipelineChanged);
connect(d->session, &QGstreamerPlayerSession::rendererIsReady,
d, &QGstreamerPipelinePrivate::updatePipeline);
d->mediaPlayer = src; d->mediaPlayer = src;
emit mediaPlayerChanged(); emit mediaPlayerChanged();
...@@ -136,18 +150,24 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src) ...@@ -136,18 +150,24 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src)
QString QGstreamerPipeline::pipeline() const QString QGstreamerPipeline::pipeline() const
{ {
return d_func()->pipeline; return d_func()->pipelineDesc;
} }
void QGstreamerPipeline::setPipeline(const QString &desc) void QGstreamerPipeline::setPipeline(const QString &desc)
{ {
Q_D(QGstreamerPipeline); Q_D(QGstreamerPipeline);
d->pipeline = desc; d->pendingPipelineDesc = desc;
if (d->mediaPlayer) { if (!d->mediaPlayer || d->pipelineDesc == desc)
return;
QString pl = QLatin1String("gst-pipeline:") + desc; QString pl = QLatin1String("gst-pipeline:") + desc;
if (d->source)
d->source->setProperty("source", QVariant::fromValue<QUrl>(QUrl(pl)));
else
d->mediaPlayer->setMedia(QMediaContent(pl)); d->mediaPlayer->setMedia(QMediaContent(pl));
} d->pipelineDesc = d->pendingPipelineDesc;
d->pendingPipelineDesc.clear();
} }
template <class T> template <class T>
......
...@@ -70,11 +70,15 @@ public: ...@@ -70,11 +70,15 @@ public:
public Q_SLOTS: public Q_SLOTS:
void updateMediaObject(); void updateMediaObject();
private Q_SLOTS:
void updatePipeline();
protected: protected:
QPointer<QObject> source; QPointer<QObject> source;
QPointer<QMediaPlayer> mediaPlayer; QPointer<QMediaPlayer> mediaPlayer;
QGstreamerPlayerSession *session = nullptr; QGstreamerPlayerSession *session = nullptr;
QString pipeline; QString pipelineDesc;
QString pendingPipelineDesc;
QGstreamerPipeline *q_ptr = nullptr; QGstreamerPipeline *q_ptr = nullptr;
}; };
......
...@@ -69,7 +69,7 @@ public: ...@@ -69,7 +69,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void streamsChanged(); void streamsChanged();
void updatePipeline(); void updatePlaybin();
void mediaPlayerChanged(); void mediaPlayerChanged();
protected: protected:
...@@ -106,9 +106,8 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged() ...@@ -106,9 +106,8 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged()
connect(session, &QGstreamerPlayerSession::streamsChanged, connect(session, &QGstreamerPlayerSession::streamsChanged,
this, &QGstreamerPlaybinPrivate::streamsChanged); this, &QGstreamerPlaybinPrivate::streamsChanged);
// Create pipeline when renderer is ready.
connect(session, &QGstreamerPlayerSession::rendererIsReady, connect(session, &QGstreamerPlayerSession::rendererIsReady,
this, &QGstreamerPlaybinPrivate::updatePipeline); this, &QGstreamerPlaybinPrivate::updatePlaybin);
// In case if these values've been applied // In case if these values've been applied
// before mediaObject is available. // before mediaObject is available.
...@@ -119,7 +118,7 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged() ...@@ -119,7 +118,7 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged()
q->setVideoStream(pendingVideoStream); q->setVideoStream(pendingVideoStream);
q->setTextStream(pendingTextStream); q->setTextStream(pendingTextStream);
updatePipeline(); updatePlaybin();
} }
static GstElement *parseDesc(const QString &name) static GstElement *parseDesc(const QString &name)
...@@ -134,7 +133,7 @@ static GstElement *parseDesc(const QString &name) ...@@ -134,7 +133,7 @@ static GstElement *parseDesc(const QString &name)
return element; return element;
} }
void QGstreamerPlaybinPrivate::updatePipeline() void QGstreamerPlaybinPrivate::updatePlaybin()
{ {
Q_Q(QGstreamerPlaybin); Q_Q(QGstreamerPlaybin);
...@@ -272,7 +271,7 @@ void QGstreamerPlaybin::setVideoSink(const QString &desc) ...@@ -272,7 +271,7 @@ void QGstreamerPlaybin::setVideoSink(const QString &desc)
if (!d->session || d->videoSinkDesc == desc) if (!d->session || d->videoSinkDesc == desc)
return; return;
d->updatePipeline(); d->updatePlaybin();
} }
bool QGstreamerPlaybin::showText() const bool QGstreamerPlaybin::showText() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment