Commit 87a16979 authored by Val Doroshchuk's avatar Val Doroshchuk

remove qobj from private

parent f66b8478
......@@ -55,14 +55,6 @@ GstElement *QGstreamerPipelinePrivate::pipeline() const
return session ? session->pipeline() : nullptr;
}
void QGstreamerPipelinePrivate::updateMediaObject()
{
Q_Q(QGstreamerPipeline);
QMediaPlayer *obj = qobject_cast<QMediaPlayer*>(source->property("mediaObject").value<QObject*>());
q->setMediaPlayer(obj);
}
QGstreamerPipeline::QGstreamerPipeline(QObject *parent)
: QGstreamerPipeline(new QGstreamerPipelinePrivate(this), nullptr, parent)
{
......@@ -98,27 +90,34 @@ void QGstreamerPipeline::setSource(QObject *src)
return;
if (d->source)
disconnect(d->source.data(), 0, d, SLOT(updateMediaObject()));
disconnect(d->source.data(), 0, this, SLOT(updateMediaObject()));
d->source = src;
if (d->source) {
const auto *metaObject = d->source->metaObject();
int propId = metaObject->indexOfProperty("mediaObject");
const auto *metaObj = d->source->metaObject();
int propId = metaObj->indexOfProperty("mediaObject");
if (propId != -1) {
const auto prop = metaObject->property(propId);
const auto prop = metaObj->property(propId);
if (prop.hasNotifySignal()) {
QMetaMethod method = prop.notifySignal();
QMetaObject::connect(d->source.data(), method.methodIndex(),
d, d->metaObject()->indexOfSlot("updateMediaObject()"),
this, metaObject()->indexOfSlot("updateMediaPlayer()"),
Qt::DirectConnection, 0);
}
}
}
d->updateMediaObject();
updateMediaPlayer();
emit sourceChanged();
}
void QGstreamerPipeline::updateMediaPlayer()
{
QMediaPlayer *obj = qobject_cast<QMediaPlayer*>(
d_func()->source->property("mediaObject").value<QObject*>());
setMediaPlayer(obj);
}
QMediaPlayer *QGstreamerPipeline::mediaPlayer() const
{
return d_func()->mediaPlayer.data();
......@@ -137,12 +136,8 @@ 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::rendererIsReady);
d->mediaPlayer = src;
emit mediaPlayerChanged();
......
......@@ -69,13 +69,16 @@ public:
QString pipeline() const;
void setPipeline(const QString &desc);
Q_INVOKABLE bool set(const QString &elementName, const QVariantMap& map);
Q_INVOKABLE bool set(const QString &elementName, const QVariantMap &map);
Q_SIGNALS:
void sourceChanged();
void mediaPlayerChanged();
void pipelineChanged();
private Q_SLOTS:
void updateMediaPlayer();
protected:
QGstreamerPipeline(QGstreamerPipelinePrivate *d,
QMediaPlayer *player = nullptr, QObject *parent = nullptr);
......
......@@ -57,12 +57,11 @@
QT_BEGIN_NAMESPACE
class QMediaPlayer;
class QGstreamerPlayerSession;
class QGstreamerPipeline;
class QGstreamerVideoRendererInterface;
class QGstreamerPipelinePrivate : public QObject
class QGstreamerPlayerSession;
class QGstreamerPipelinePrivate
{
Q_OBJECT
Q_DECLARE_PUBLIC(QGstreamerPipeline)
public:
......@@ -73,17 +72,9 @@ public:
QGstreamerVideoRendererInterface *renderer() const;
GstElement *pipeline() const;
public Q_SLOTS:
void updateMediaObject();
Q_SIGNALS:
void streamsChanged();
void rendererIsReady(bool);
protected:
QGstreamerPipeline *q_ptr = nullptr;
private:
QPointer<QObject> source;
QPointer<QMediaPlayer> mediaPlayer;
QGstreamerPlayerSession *session = nullptr;
......
......@@ -40,6 +40,7 @@
#include "qgstreamerplaybin.h"
#include "qgstreamerpipeline_p.h"
#include <private/qgstreamervideorendererinterface_p.h>
#include <private/qgstreamerplayersession_p.h>
#include <QtMultimedia/qmediametadata.h>
QT_BEGIN_NAMESPACE
......@@ -66,9 +67,8 @@ public:
{
}
public Q_SLOTS:
void onStreamsChanged();
void onMediaPlayerChanged();
void streamsChanged();
void mediaPlayerChanged();
void updatePlaybin();
private:
......@@ -95,13 +95,18 @@ private:
QList<QVariantMap> textStreamProperties;
};
void QGstreamerPlaybinPrivate::onMediaPlayerChanged()
void QGstreamerPlaybinPrivate::mediaPlayerChanged()
{
Q_Q(QGstreamerPlaybin);
if (!isReady())
return;
QObject::connect(session, &QGstreamerPlayerSession::streamsChanged,
q, [this]() { streamsChanged(); });
QObject::connect(session, &QGstreamerPlayerSession::rendererIsReady,
q, [this]() { updatePlaybin(); });
// In case if these values've been applied
// before mediaObject is available.
q->setShowText(pendingShowText);
......@@ -166,7 +171,7 @@ static QVariantMap getStreamProperties(GstElement *pipeline, const char *name, i
return streamProperties;
}
void QGstreamerPlaybinPrivate::onStreamsChanged()
void QGstreamerPlaybinPrivate::streamsChanged()
{
Q_Q(QGstreamerPlaybin);
......@@ -234,12 +239,10 @@ QGstreamerPlaybin::QGstreamerPlaybin(QMediaPlayer *media, QObject *parent)
{
Q_D(QGstreamerPlaybin);
connect(d, &QGstreamerPipelinePrivate::streamsChanged,
d, &QGstreamerPlaybinPrivate::onStreamsChanged);
connect(this, &QGstreamerPipeline::mediaPlayerChanged,
d, &QGstreamerPlaybinPrivate::onMediaPlayerChanged);
connect(d, &QGstreamerPipelinePrivate::rendererIsReady,
d, &QGstreamerPlaybinPrivate::updatePlaybin);
connect(this, &QGstreamerPlaybin::mediaPlayerChanged,
this, [d]() { d->mediaPlayerChanged(); } );
d->mediaPlayerChanged();
}
QGstreamerPlaybin::QGstreamerPlaybin(QObject *parent)
......
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