Gstreamer media backend cleanup.
Moved controls specific bus/sync messages handling from player/camera/capture session to corresponding controls. Reviewed-by: Michael Goddard Change-Id: Ieb67976ed335b0ef1cde87dc60e8ad8da3409526 Reviewed-on: http://codereview.qt.nokia.com/2535 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
6eac3bd648
commit
e70ebfd2ed
@@ -160,17 +160,16 @@ QMediaControl *QGstreamerCaptureService::requestControl(const char *name)
|
||||
if (!m_videoOutput) {
|
||||
if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
||||
m_videoOutput = m_videoRenderer;
|
||||
m_captureSession->setVideoPreview(m_videoRenderer);
|
||||
} else if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
|
||||
m_videoOutput = m_videoWindow;
|
||||
m_captureSession->setVideoPreview(m_videoWindow);
|
||||
} else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||
m_captureSession->setVideoPreview(m_videoWidgetControl);
|
||||
m_videoOutput = m_videoWidgetControl;
|
||||
}
|
||||
|
||||
if (m_videoOutput)
|
||||
if (m_videoOutput) {
|
||||
m_captureSession->setVideoPreview(m_videoOutput);
|
||||
return m_videoOutput;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -96,8 +96,8 @@ QGstreamerCaptureSession::QGstreamerCaptureSession(QGstreamerCaptureSession::Cap
|
||||
|
||||
m_bus = gst_element_get_bus(m_pipeline);
|
||||
m_busHelper = new QGstreamerBusHelper(m_bus, this);
|
||||
m_busHelper->installSyncEventFilter(this);
|
||||
connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage)));
|
||||
m_busHelper->installMessageFilter(this);
|
||||
|
||||
m_audioEncodeControl = new QGstreamerAudioEncode(this);
|
||||
m_videoEncodeControl = new QGstreamerVideoEncode(this);
|
||||
m_imageEncodeControl = new QGstreamerImageEncode(this);
|
||||
@@ -735,6 +735,8 @@ void QGstreamerCaptureSession::setVideoPreview(QObject *viewfinder)
|
||||
this, SIGNAL(viewfinderChanged()));
|
||||
disconnect(m_viewfinder, SIGNAL(readyChanged(bool)),
|
||||
this, SIGNAL(readyChanged(bool)));
|
||||
|
||||
m_busHelper->removeMessageFilter(m_viewfinder);
|
||||
}
|
||||
|
||||
m_viewfinder = viewfinder;
|
||||
@@ -745,6 +747,8 @@ void QGstreamerCaptureSession::setVideoPreview(QObject *viewfinder)
|
||||
this, SIGNAL(viewfinderChanged()));
|
||||
connect(m_viewfinder, SIGNAL(readyChanged(bool)),
|
||||
this, SIGNAL(readyChanged(bool)));
|
||||
|
||||
m_busHelper->installMessageFilter(m_viewfinder);
|
||||
}
|
||||
|
||||
emit viewfinderChanged();
|
||||
@@ -917,29 +921,7 @@ void QGstreamerCaptureSession::setMetaData(const QMap<QByteArray, QVariant> &dat
|
||||
}
|
||||
}
|
||||
|
||||
bool QGstreamerCaptureSession::processSyncMessage(const QGstreamerMessage &message)
|
||||
{
|
||||
GstMessage* gm = message.rawMessage();
|
||||
|
||||
if (gm && GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT) {
|
||||
if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_videoPreview))
|
||||
m_viewfinderInterface->handleSyncMessage(gm);
|
||||
|
||||
if (gst_structure_has_name(gm->structure, "prepare-xwindow-id")) {
|
||||
if (m_audioPreviewFactory)
|
||||
m_audioPreviewFactory->prepareWinId();
|
||||
|
||||
if (m_viewfinderInterface)
|
||||
m_viewfinderInterface->precessNewStream();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QGstreamerCaptureSession::busMessage(const QGstreamerMessage &message)
|
||||
bool QGstreamerCaptureSession::processBusMessage(const QGstreamerMessage &message)
|
||||
{
|
||||
GstMessage* gm = message.rawMessage();
|
||||
|
||||
@@ -1027,11 +1009,8 @@ void QGstreamerCaptureSession::busMessage(const QGstreamerMessage &message)
|
||||
}
|
||||
//qDebug() << "New session state:" << ENUM_NAME(QGstreamerCaptureSession,"State",m_state);
|
||||
}
|
||||
|
||||
if (m_videoPreview && m_viewfinderInterface &&
|
||||
GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_videoPreview))
|
||||
m_viewfinderInterface->handleBusMessage(gm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QGstreamerCaptureSession::setMuted(bool muted)
|
||||
|
||||
@@ -76,12 +76,13 @@ public:
|
||||
virtual QList<QSize> supportedResolutions(qreal frameRate = -1) const = 0;
|
||||
};
|
||||
|
||||
class QGstreamerCaptureSession : public QObject, public QGstreamerSyncEventFilter
|
||||
class QGstreamerCaptureSession : public QObject, public QGstreamerBusMessageFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
|
||||
Q_ENUMS(State)
|
||||
Q_ENUMS(CaptureMode)
|
||||
Q_INTERFACES(QGstreamerBusMessageFilter)
|
||||
public:
|
||||
enum CaptureMode { Audio = 1, Video = 2, Image=4, AudioAndVideo = Audio | Video };
|
||||
enum State { StoppedState, PreviewState, PausedState, RecordingState };
|
||||
@@ -89,6 +90,8 @@ public:
|
||||
QGstreamerCaptureSession(CaptureMode captureMode, QObject *parent);
|
||||
~QGstreamerCaptureSession();
|
||||
|
||||
QGstreamerBusHelper *bus() { return m_busHelper; }
|
||||
|
||||
CaptureMode captureMode() const { return m_captureMode; }
|
||||
void setCaptureMode(CaptureMode);
|
||||
|
||||
@@ -122,7 +125,7 @@ public:
|
||||
|
||||
bool isReady() const;
|
||||
|
||||
bool processSyncMessage(const QGstreamerMessage &message);
|
||||
bool processBusMessage(const QGstreamerMessage &message);
|
||||
|
||||
signals:
|
||||
void stateChanged(QGstreamerCaptureSession::State state);
|
||||
@@ -144,9 +147,6 @@ public slots:
|
||||
void setMetaData(const QMap<QByteArray, QVariant>&);
|
||||
void setMuted(bool);
|
||||
|
||||
private slots:
|
||||
void busMessage(const QGstreamerMessage &message);
|
||||
|
||||
private:
|
||||
enum PipelineMode { EmptyPipeline, PreviewPipeline, RecordingPipeline, PreviewAndRecordingPipeline };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user