diff options
author | Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com> | 2011-08-02 14:33:38 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-05 07:50:59 +0200 |
commit | e70ebfd2ed8d522478f04ab823b527b48ed24671 (patch) | |
tree | aa52d70121ab80a07ff5036aba3be30be8aba758 /src/plugins/gstreamer/mediacapture | |
parent | 6eac3bd6488f8d8b368d97bdb8d701b804310be6 (diff) |
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>
Diffstat (limited to 'src/plugins/gstreamer/mediacapture')
3 files changed, 16 insertions, 38 deletions
diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercaptureservice.cpp b/src/plugins/gstreamer/mediacapture/qgstreamercaptureservice.cpp index eb4338b3f..d063b0e13 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercaptureservice.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamercaptureservice.cpp @@ -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; diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.cpp b/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.cpp index b092af281..b685f5466 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.cpp +++ b/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.cpp @@ -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) diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.h b/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.h index 63d1b0bf6..e4c734600 100644 --- a/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.h +++ b/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.h @@ -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 }; |