GStreamer: runtime check for controls that require GstPhotography.
authorYoann Lopes <yoann.lopes@theqtcompany.com>
Thu, 29 Jan 2015 11:24:45 +0000 (12:24 +0100)
committerYoann Lopes <yoann.lopes@theqtcompany.com>
Wed, 18 Feb 2015 13:15:20 +0000 (13:15 +0000)
Exposure, Flash, Focus and Locks controls were always initialized,
even when the GstPhotography interface was not available (on desktop
for example), causing some warnings and fooling the user in believing
that these features were available.
These controls are now lazily initialized and only when
GstPhotography is available.

The zoom control is not compile-checked anymore since it doesn't
actually require GstPhotography.

Change-Id: I5e8315d796dd920c9c29ccfa4155707f5f0fd7dc
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
src/plugins/gstreamer/camerabin/camerabin.pro
src/plugins/gstreamer/camerabin/camerabinsession.cpp
src/plugins/gstreamer/camerabin/camerabinsession.h
src/plugins/gstreamer/camerabin/camerabinzoom.cpp

index bfbb357..111dbcc 100644 (file)
@@ -24,6 +24,7 @@ HEADERS += \
     $$PWD/camerabinrecorder.h \
     $$PWD/camerabincontainer.h \
     $$PWD/camerabinimagecapture.h \
+    $$PWD/camerabinzoom.h \
     $$PWD/camerabinimageprocessing.h \
     $$PWD/camerabinmetadata.h \
     $$PWD/camerabinvideoencoder.h \
@@ -43,6 +44,7 @@ SOURCES += \
     $$PWD/camerabincontainer.cpp \
     $$PWD/camerabinimagecapture.cpp \
     $$PWD/camerabinimageencoder.cpp \
+    $$PWD/camerabinzoom.cpp \
     $$PWD/camerabinimageprocessing.cpp \
     $$PWD/camerabinmetadata.cpp \
     $$PWD/camerabinrecorder.cpp \
@@ -71,15 +73,13 @@ config_gstreamer_photography {
         $$PWD/camerabinfocus.h \
         $$PWD/camerabinexposure.h \
         $$PWD/camerabinflash.h \
-        $$PWD/camerabinlocks.h \
-        $$PWD/camerabinzoom.h
+        $$PWD/camerabinlocks.h
 
     SOURCES += \
         $$PWD/camerabinexposure.cpp \
         $$PWD/camerabinflash.cpp \
         $$PWD/camerabinfocus.cpp \
-        $$PWD/camerabinlocks.cpp \
-        $$PWD/camerabinzoom.cpp
+        $$PWD/camerabinlocks.cpp
 
     LIBS += -lgstphotography-$$GST_VERSION
     DEFINES += GST_USE_UNSTABLE_API #prevents warnings because of unstable photography API
index 0ed8dcb..7cc082e 100644 (file)
@@ -43,9 +43,9 @@
 #include "camerabinflash.h"
 #include "camerabinfocus.h"
 #include "camerabinlocks.h"
-#include "camerabinzoom.h"
 #endif
 
+#include "camerabinzoom.h"
 #include "camerabinimageprocessing.h"
 #include "camerabinviewfindersettings.h"
 
@@ -121,6 +121,12 @@ CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *pa
      m_videoInputFactory(0),
      m_viewfinder(0),
      m_viewfinderInterface(0),
+#ifdef HAVE_GST_PHOTOGRAPHY
+     m_cameraExposureControl(0),
+     m_cameraFlashControl(0),
+     m_cameraFocusControl(0),
+     m_cameraLocksControl(0),
+#endif
      m_cameraSrc(0),
      m_videoSrc(0),
      m_viewfinderElement(0),
@@ -157,14 +163,7 @@ CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *pa
     m_imageEncodeControl = new CameraBinImageEncoder(this);
     m_recorderControl = new CameraBinRecorder(this);
     m_mediaContainerControl = new CameraBinContainer(this);
-
-#ifdef HAVE_GST_PHOTOGRAPHY
-    m_cameraExposureControl = new CameraBinExposure(this);
-    m_cameraFlashControl = new CameraBinFlash(this);
-    m_cameraFocusControl = new CameraBinFocus(this);
-    m_cameraLocksControl = new CameraBinLocks(this);
     m_cameraZoomControl = new CameraBinZoom(this);
-#endif
     m_imageProcessingControl = new CameraBinImageProcessing(this);
     m_captureDestinationControl = new CameraBinCaptureDestination(this);
     m_captureBufferFormatControl = new CameraBinCaptureBufferFormat(this);
@@ -221,6 +220,34 @@ GstPhotography *CameraBinSession::photography()
 
     return 0;
 }
+
+CameraBinExposure *CameraBinSession::cameraExposureControl()
+{
+    if (!m_cameraExposureControl && photography())
+        m_cameraExposureControl = new CameraBinExposure(this);
+    return m_cameraExposureControl;
+}
+
+CameraBinFlash *CameraBinSession::cameraFlashControl()
+{
+    if (!m_cameraFlashControl && photography())
+        m_cameraFlashControl = new CameraBinFlash(this);
+    return m_cameraFlashControl;
+}
+
+CameraBinFocus *CameraBinSession::cameraFocusControl()
+{
+    if (!m_cameraFocusControl && photography())
+        m_cameraFocusControl = new CameraBinFocus(this);
+    return m_cameraFocusControl;
+}
+
+CameraBinLocks *CameraBinSession::cameraLocksControl()
+{
+    if (!m_cameraLocksControl && photography())
+        m_cameraLocksControl = new CameraBinLocks(this);
+    return m_cameraLocksControl;
+}
 #endif
 
 CameraBinSession::CameraRole CameraBinSession::cameraRole() const
index fa9dba9..7ef5b7a 100644 (file)
@@ -121,13 +121,13 @@ public:
     CameraBinImageEncoder *imageEncodeControl() const { return m_imageEncodeControl; }
 
 #ifdef HAVE_GST_PHOTOGRAPHY
-    CameraBinExposure *cameraExposureControl() const  { return m_cameraExposureControl; }
-    CameraBinFlash *cameraFlashControl() const  { return m_cameraFlashControl; }
-    CameraBinFocus *cameraFocusControl() const  { return m_cameraFocusControl; }
-    CameraBinLocks *cameraLocksControl() const { return m_cameraLocksControl; }
-    CameraBinZoom *cameraZoomControl() const { return m_cameraZoomControl; }
+    CameraBinExposure *cameraExposureControl();
+    CameraBinFlash *cameraFlashControl();
+    CameraBinFocus *cameraFocusControl();
+    CameraBinLocks *cameraLocksControl();
 #endif
 
+    CameraBinZoom *cameraZoomControl() const { return m_cameraZoomControl; }
     CameraBinImageProcessing *imageProcessingControl() const { return m_imageProcessingControl; }
     CameraBinCaptureDestination *captureDestinationControl() const { return m_captureDestinationControl; }
     CameraBinCaptureBufferFormat *captureBufferFormatControl() const { return m_captureBufferFormatControl; }
@@ -238,9 +238,8 @@ private:
     CameraBinFlash *m_cameraFlashControl;
     CameraBinFocus *m_cameraFocusControl;
     CameraBinLocks *m_cameraLocksControl;
-    CameraBinZoom *m_cameraZoomControl;
 #endif
-
+    CameraBinZoom *m_cameraZoomControl;
     CameraBinImageProcessing *m_imageProcessingControl;
     CameraBinCaptureDestination *m_captureDestinationControl;
     CameraBinCaptureBufferFormat *m_captureBufferFormatControl;
index 29fa749..a25cf68 100644 (file)
@@ -34,8 +34,6 @@
 #include "camerabinzoom.h"
 #include "camerabinsession.h"
 
-#include <gst/interfaces/photography.h>
-
 #define ZOOM_PROPERTY "zoom"
 #define MAX_ZOOM_PROPERTY "max-zoom"