Commit 5403698c authored by Val Doroshchuk's avatar Val Doroshchuk

refact

parent 0b5045ed
......@@ -45,6 +45,16 @@
QT_BEGIN_NAMESPACE
QGstreamerVideoRendererInterface *QGstreamerPipelinePrivate::renderer() const
{
return session ? session->renderer() : nullptr;
}
GstElement *QGstreamerPipelinePrivate::pipeline() const
{
return session ? session->pipeline() : nullptr;
}
void QGstreamerPipelinePrivate::updateMediaObject()
{
Q_Q(QGstreamerPipeline);
......@@ -54,12 +64,12 @@ void QGstreamerPipelinePrivate::updateMediaObject()
q->setMediaPlayer(obj);
}
void QGstreamerPipelinePrivate::updatePipeline()
void QGstreamerPipelinePrivate::updatePipeline(bool ready)
{
Q_Q(QGstreamerPipeline);
auto renderer = session->renderer();
if (!renderer || !renderer->isReady())
emit rendererIsReady(ready);
if (!ready)
return;
q->setPipeline(pendingPipelineDesc);
......@@ -139,8 +149,12 @@ void QGstreamerPipeline::setMediaPlayer(QMediaPlayer *src)
if (!d->session)
return;
connect(d->session, &QGstreamerPlayerSession::streamsChanged,
d, &QGstreamerPipelinePrivate::streamsChanged);
connect(d->session, &QGstreamerPlayerSession::pipelineChanged,
this, &QGstreamerPipeline::pipelineChanged);
connect(d->session, &QGstreamerPlayerSession::rendererIsReady,
d, &QGstreamerPipelinePrivate::updatePipeline);
......
......@@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE
class QMediaPlayer;
class QGstreamerPlayerSession;
class QGstreamerPipeline;
class QGstreamerVideoRendererInterface;
typedef struct _GstElement GstElement;
class QGstreamerPipelinePrivate : public QObject
{
Q_OBJECT
......@@ -67,20 +69,29 @@ public:
QGstreamerPipelinePrivate(QGstreamerPipeline *q) : q_ptr(q) { }
~QGstreamerPipelinePrivate() { }
bool isReady() const { return session; }
QGstreamerVideoRendererInterface *renderer() const;
GstElement *pipeline() const;
public Q_SLOTS:
void updateMediaObject();
private Q_SLOTS:
void updatePipeline();
void updatePipeline(bool);
Q_SIGNALS:
void streamsChanged();
void rendererIsReady(bool);
protected:
QGstreamerPipeline *q_ptr = nullptr;
private:
QPointer<QObject> source;
QPointer<QMediaPlayer> mediaPlayer;
QGstreamerPlayerSession *session = nullptr;
QString pipelineDesc;
QString pendingPipelineDesc;
QGstreamerPipeline *q_ptr = nullptr;
};
QT_END_NAMESPACE
......
......@@ -39,9 +39,9 @@
#include "qgstreamerplaybin.h"
#include "qgstreamerpipeline_p.h"
#include <private/qgstreamervideorenderer_p.h>
#include <private/qgstreamerplayersession_p.h>
#include <private/qgstreamervideorendererinterface_p.h>
#include <QtMultimedia/qmediametadata.h>
#include <gst/gst.h>
QT_BEGIN_NAMESPACE
......@@ -68,7 +68,7 @@ public:
}
public Q_SLOTS:
void streamsChanged();
void onStreamsChanged();
void updatePlaybin();
void mediaPlayerChanged();
......@@ -100,13 +100,13 @@ void QGstreamerPlaybinPrivate::mediaPlayerChanged()
{
Q_Q(QGstreamerPlaybin);
if (!session)
if (!isReady())
return;
connect(session, &QGstreamerPlayerSession::streamsChanged,
this, &QGstreamerPlaybinPrivate::streamsChanged);
connect(this, &QGstreamerPipelinePrivate::streamsChanged,
this, &QGstreamerPlaybinPrivate::onStreamsChanged);
connect(session, &QGstreamerPlayerSession::rendererIsReady,
connect(this, &QGstreamerPipelinePrivate::rendererIsReady,
this, &QGstreamerPlaybinPrivate::updatePlaybin);
// In case if these values've been applied
......@@ -137,8 +137,8 @@ void QGstreamerPlaybinPrivate::updatePlaybin()
{
Q_Q(QGstreamerPlaybin);
auto renderer = session->renderer();
if (!renderer || !renderer->isReady())
auto r = renderer();
if (!r || !r->isReady())
return;
if (!pendingVideoSinkDesc.isEmpty()) {
......@@ -146,7 +146,7 @@ void QGstreamerPlaybinPrivate::updatePlaybin()
if (videoSink) {
videoSinkDesc = pendingVideoSinkDesc;
pendingVideoSinkDesc.clear();
renderer->setVideoSink(videoSink);
r->setVideoSink(videoSink);
emit q->videoSinkChanged();
}
......@@ -175,11 +175,11 @@ static QVariantMap getStreamProperties(GstElement *pipeline, const char *name, i
return streamProperties;
}
void QGstreamerPlaybinPrivate::streamsChanged()
void QGstreamerPlaybinPrivate::onStreamsChanged()
{
Q_Q(QGstreamerPlaybin);
GstElement *playbin = session ? session->playbin() : nullptr;
GstElement *playbin = pipeline();
if (!playbin)
return;
......@@ -268,7 +268,7 @@ void QGstreamerPlaybin::setVideoSink(const QString &desc)
Q_D(QGstreamerPlaybin);
d->pendingVideoSinkDesc = desc;
if (!d->session || d->videoSinkDesc == desc)
if (!d->isReady() || d->videoSinkDesc == desc)
return;
d->updatePlaybin();
......@@ -284,7 +284,7 @@ void QGstreamerPlaybin::setShowText(bool show)
Q_D(QGstreamerPlaybin);
d->pendingShowText = show;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->showText == show)
return;
......@@ -311,7 +311,7 @@ void QGstreamerPlaybin::setTextUri(const QUrl &uri)
Q_D(QGstreamerPlaybin);
d->pendingTextUri = uri;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->textUri == uri)
return;
......@@ -332,7 +332,7 @@ void QGstreamerPlaybin::setTextFont(const QString &str)
Q_D(QGstreamerPlaybin);
d->pendingTextFont = str;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->textFont == str)
return;
......@@ -356,7 +356,7 @@ void QGstreamerPlaybin::setAudioStream(int i)
Q_D(QGstreamerPlaybin);
d->pendingAudioStream = i;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->audioStream == i)
return;
......@@ -385,7 +385,7 @@ void QGstreamerPlaybin::setVideoStream(int i)
Q_D(QGstreamerPlaybin);
d->pendingVideoStream = i;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->videoStream == i)
return;
......@@ -414,7 +414,7 @@ void QGstreamerPlaybin::setTextStream(int i)
Q_D(QGstreamerPlaybin);
d->pendingTextStream = i;
GstElement *playbin = d->session ? d->session->playbin() : nullptr;
GstElement *playbin = d->pipeline();
if (!playbin || d->textStream == i)
return;
......
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