Commit 9bc92449 authored by Val Doroshchuk's avatar Val Doroshchuk

VideoSink

parent 8e77ff6b
......@@ -213,16 +213,43 @@ static GstElement *parseDesc(const QString &name)
void QGstreamerMediaPlayerPrivate::updatePipeline()
{
Q_Q(QGstreamerMediaPlayer);
if (pendingPipelineDesc.isEmpty() || !session->renderer() || !session->renderer()->isReady())
return;
GstElement *pipeline = parseDesc(pendingPipelineDesc);
if (!pipeline)
auto renderer = session->renderer();
if (!renderer || !renderer->isReady())
return;
pipelineDesc = pendingPipelineDesc;
session->setPipeline(pipeline);
emit q->pipelineChanged();
if (!pendingVideoSinkDesc.isEmpty()) {
GstElement *videoSink = parseDesc(pendingVideoSinkDesc);
if (videoSink) {
videoSinkDesc = pendingVideoSinkDesc;
pendingVideoSinkDesc.clear();
renderer->setVideoSink(videoSink);
emit q->videoSinkChanged();
}
}
if (!pendingPipelineDesc.isEmpty()) {
GstElement *pipeline = parseDesc(pendingPipelineDesc);
if (pipeline) {
pipelineDesc = pendingPipelineDesc;
pendingPipelineDesc.clear();
session->setPipeline(pipeline);
emit q->pipelineChanged();
auto it = gst_bin_iterate_sinks(GST_BIN(pipeline));
GValue data = { 0, 0 };
while (gst_iterator_next (it, &data) == GST_ITERATOR_OK) {
auto child = (GstElement*) g_value_get_object(&data);
if (QLatin1String(GST_OBJECT_NAME(child)) == QLatin1String("qtvideosink")) {
renderer->setVideoSink(child);
break;
}
}
gst_iterator_free(it);
}
}
}
QGstreamerMediaPlayer::QGstreamerMediaPlayer(QMediaObject *media, QObject *parent)
......@@ -302,7 +329,6 @@ void QGstreamerMediaPlayer::setMediaObject(QMediaObject *src)
// In case if these values've been applied
// before mediaObject is available.
setVideoSink(d->pendingVideoSinkDesc);
setShowText(d->pendingShowText);
setTextUri(d->pendingTextUri);
setTextFont(d->pendingTextFont);
......@@ -340,13 +366,7 @@ void QGstreamerMediaPlayer::setVideoSink(const QString &desc)
if (!d->session || d->videoSinkDesc == desc)
return;
GstElement *videoSink = parseDesc(desc);
if (!videoSink)
return;
d->videoSinkDesc = desc;
d->session->setVideoSink(videoSink);
emit videoSinkChanged();
d->updatePipeline();
}
bool QGstreamerMediaPlayer::showText() const
......@@ -515,7 +535,7 @@ bool QGstreamerMediaPlayer::set(const QString &elementName, const QVariantMap& m
GstElement *element = nullptr;
if (elementName == QLatin1String("videoSink"))
element = d->session ? d->session->videoSink() : nullptr;
element = (d->session && d->session->renderer()) ? d->session->renderer()->videoSink() : nullptr;
else if (d->session->pipeline())
element = gst_bin_get_by_name(GST_BIN(d->session->pipeline()), elementName.toLatin1().constData());
......
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