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

pipeline

parent c71e92af
......@@ -54,6 +54,17 @@ void QGstreamerPipelinePrivate::updateMediaObject()
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(new QGstreamerPipelinePrivate(this), nullptr, parent)
{
......@@ -128,7 +139,10 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src)
if (!d->session)
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;
emit mediaPlayerChanged();
......@@ -136,18 +150,24 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src)
QString QGstreamerPipeline::pipeline() const
{
return d_func()->pipeline;
return d_func()->pipelineDesc;
}
void QGstreamerPipeline::setPipeline(const QString &desc)
{
Q_D(QGstreamerPipeline);
d->pipeline = desc;
if (d->mediaPlayer) {
d->pendingPipelineDesc = desc;
if (!d->mediaPlayer || d->pipelineDesc == desc)
return;
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->pipelineDesc = d->pendingPipelineDesc;
d->pendingPipelineDesc.clear();
}
template <class T>
......
......@@ -70,11 +70,15 @@ public:
public Q_SLOTS:
void updateMediaObject();
private Q_SLOTS:
void updatePipeline();
protected:
QPointer<QObject> source;
QPointer<QMediaPlayer> mediaPlayer;
QGstreamerPlayerSession *session = nullptr;
QString pipeline;
QString pipelineDesc;
QString pendingPipelineDesc;
QGstreamerPipeline *q_ptr = nullptr;
};
......
......@@ -69,7 +69,7 @@ public:
public Q_SLOTS:
void streamsChanged();
void updatePipeline();
void updatePlaybin();
void mediaPlayerChanged();
protected:
......@@ -106,9 +106,8 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged()
connect(session, &QGstreamerPlayerSession::streamsChanged,
this, &QGstreamerPlaybinPrivate::streamsChanged);
// Create pipeline when renderer is ready.
connect(session, &QGstreamerPlayerSession::rendererIsReady,
this, &QGstreamerPlaybinPrivate::updatePipeline);
this, &QGstreamerPlaybinPrivate::updatePlaybin);
// In case if these values've been applied
// before mediaObject is available.
......@@ -119,7 +118,7 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged()
q->setVideoStream(pendingVideoStream);
q->setTextStream(pendingTextStream);
updatePipeline();
updatePlaybin();
}
static GstElement *parseDesc(const QString &name)
......@@ -134,7 +133,7 @@ static GstElement *parseDesc(const QString &name)
return element;
}
void QGstreamerPlaybinPrivate::updatePipeline()
void QGstreamerPlaybinPrivate::updatePlaybin()
{
Q_Q(QGstreamerPlaybin);
......@@ -272,7 +271,7 @@ void QGstreamerPlaybin::setVideoSink(const QString &desc)
if (!d->session || d->videoSinkDesc == desc)
return;
d->updatePipeline();
d->updatePlaybin();
}
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