From b04854b48920f9d3fa72f2b271b361a6f1805004 Mon Sep 17 00:00:00 2001 From: Mohammed Hassan Date: Thu, 30 Jun 2016 02:42:02 +0300 Subject: [PATCH] nemo: Add basic ready-for-capture handling to CameraBinSession This property is provided and controlled by the camera source and should be used to tell whether the camera source can capture more or not Conflicts: src/plugins/gstreamer/camerabin/camerabinsession.h --- .../gstreamer/camerabin/camerabinsession.cpp | 26 ++++++++++++++++++- .../gstreamer/camerabin/camerabinsession.h | 4 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 52d60778..5e8cbadd 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -116,6 +116,7 @@ CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *pa m_pendingState(QCamera::UnloadedState), m_muted(false), m_busy(false), + m_readyForCapture(false), m_captureMode(QCamera::CaptureStillImage), m_audioInputFactory(0), m_videoInputFactory(0), @@ -530,8 +531,11 @@ GstElement *CameraBinSession::buildCameraSource() } } - if (m_cameraSrc != camSrc) + if (m_cameraSrc != camSrc) { g_object_set(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, m_cameraSrc, NULL); + g_signal_connect(G_OBJECT(m_cameraSrc), "notify::ready-for-capture", G_CALLBACK(updateReadyForCapture), this); + + } if (camSrc) gst_object_unref(GST_OBJECT(camSrc)); @@ -841,6 +845,11 @@ bool CameraBinSession::isBusy() const return m_busy; } +bool CameraBinSession::isReadyForCapture() const +{ + return m_readyForCapture; +} + void CameraBinSession::updateBusyStatus(GObject *o, GParamSpec *p, gpointer d) { Q_UNUSED(p); @@ -858,6 +867,21 @@ void CameraBinSession::updateBusyStatus(GObject *o, GParamSpec *p, gpointer d) } } +void CameraBinSession::updateReadyForCapture(GObject *o, GParamSpec *p, gpointer d) +{ + Q_UNUSED(o); + Q_UNUSED(p); + + CameraBinSession *session = reinterpret_cast(d); + gboolean ready = false; + g_object_get(o, "ready-for-capture", &ready, NULL); + if (session->m_readyForCapture != ready) { + session->m_readyForCapture = ready; + QMetaObject::invokeMethod(session, "handleReadyForCaptureChanged", + Qt::QueuedConnection, Q_ARG(bool, ready)); + } +} + qint64 CameraBinSession::duration() const { if (m_camerabin) { diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.h b/src/plugins/gstreamer/camerabin/camerabinsession.h index f25a8474..3493bd01 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.h +++ b/src/plugins/gstreamer/camerabin/camerabinsession.h @@ -145,6 +145,7 @@ public: QCamera::Status status() const; QCamera::State pendingState() const; bool isBusy() const; + bool isReadyForCapture() const; qint64 duration() const; @@ -169,6 +170,7 @@ signals: void viewfinderChanged(); void readyChanged(bool); void busyChanged(bool); + void handleReadyForCaptureChanged(bool); public slots: void setDevice(const QString &device); @@ -197,6 +199,7 @@ private: GstCaps *supportedCaps(QCamera::CaptureModes mode) const; void updateSupportedViewfinderSettings(); static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d); + static void updateReadyForCapture(GObject *o, GParamSpec *p, gpointer d); QString currentContainerFormat() const; @@ -212,6 +215,7 @@ private: QString m_inputDevice; bool m_muted; bool m_busy; + bool m_readyForCapture; QMediaStorageLocation m_mediaStorageLocation; QCamera::CaptureModes m_captureMode;