basecamerabinsrc: Add auto-start property to basecamerabin
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Fri, 4 May 2012 00:36:27 +0000 (20:36 -0400)
committerSjoerd Simons <sjoerd@luon.net>
Mon, 11 Feb 2013 21:04:59 +0000 (22:04 +0100)
gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c
gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h

index 0acfeefe4e73215900fb2a4eecccfa39988512de..abc3a4443355f671b02bb0a695d09f7dca0eab0c 100644 (file)
@@ -87,7 +87,8 @@ enum
   PROP_READY_FOR_CAPTURE,
   PROP_POST_PREVIEW,
   PROP_PREVIEW_CAPS,
-  PROP_PREVIEW_FILTER
+  PROP_PREVIEW_FILTER,
+  PROP_AUTO_START
 };
 
 enum
@@ -100,6 +101,7 @@ enum
 };
 
 #define DEFAULT_POST_PREVIEW TRUE
+#define DEFAULT_AUTO_START FALSE
 
 static guint basecamerasrc_signals[LAST_SIGNAL];
 
@@ -319,6 +321,9 @@ gst_base_camera_src_set_property (GObject * object,
             "Cannot change preview filter, is element in NULL state?");
       }
       break;
+    case PROP_AUTO_START:
+      self->auto_start = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
       break;
@@ -355,6 +360,9 @@ gst_base_camera_src_get_property (GObject * object,
       if (self->preview_filter)
         g_value_set_object (value, self->preview_filter);
       break;
+    case PROP_AUTO_START:
+      g_value_set_boolean (value, self->auto_start);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
       break;
@@ -421,6 +429,8 @@ gst_base_camera_src_change_state (GstElement * element,
        * messages on the pipeline */
       gst_element_set_state (self->preview_pipeline->pipeline,
           GST_STATE_PLAYING);
+      if (self->auto_start)
+        g_signal_emit_by_name (G_OBJECT (self), "start-capture", NULL);
       break;
     default:
       break;
@@ -431,6 +441,8 @@ gst_base_camera_src_change_state (GstElement * element,
   switch (transition) {
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       gst_element_set_state (self->preview_pipeline->pipeline, GST_STATE_READY);
+      if (self->auto_start)
+        g_signal_emit_by_name (G_OBJECT (self), "stop-capture", NULL);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
       gst_element_set_state (self->preview_pipeline->pipeline, GST_STATE_NULL);
@@ -497,6 +509,11 @@ gst_base_camera_src_class_init (GstBaseCameraSrcClass * klass)
           "A custom preview filter to process preview image data",
           GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (gobject_class, PROP_AUTO_START,
+      g_param_spec_boolean ("auto-start", "Auto start capture",
+          "Automatically starts capture when going to the PAUSED state",
+          DEFAULT_AUTO_START, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   /**
    * GstBaseCameraSrc:ready-for-capture:
    *
@@ -545,6 +562,7 @@ gst_base_camera_src_init (GstBaseCameraSrc * self)
   self->max_zoom = MAX_ZOOM;
   self->mode = MODE_IMAGE;
 
+  self->auto_start = DEFAULT_AUTO_START;
   self->capturing = FALSE;
   g_mutex_init (&self->capturing_mutex);
 
index 103326c42ab2aecae5a6a202437558bf9ee79273..1b936638ef44f7ec7db8c13e0e9779b77dab6c39 100644 (file)
@@ -68,6 +68,7 @@ struct _GstBaseCameraSrc
 
   GstCameraBinMode mode;
 
+  gboolean auto_start;
   gboolean capturing;
   GMutex capturing_mutex;