[cheese/camerabin2: 11/24] camerabin2: 'image-done' is now a bus message, not a signal



commit 38b111468037974805a1acba4bad34bf78116b95
Author: Raluca Elena Podiuc <ralucaelena1985 gmail com>
Date:   Wed Jul 13 18:31:37 2011 +0300

    camerabin2: 'image-done' is now a bus message, not a signal
    
    Quote from camerabin2's PORTING guide:
    
          In camerabin, image-done is a signal, in camerabin2, it is a bus message
    
    Signed-off-by: Raluca Elena Podiuc <ralucaelena1985 gmail com>

 configure.ac              |    3 ++
 libcheese/cheese-camera.c |   70 +++++++++++++++------------------------------
 2 files changed, 26 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f6f95f1..5c5f8d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,8 @@ GDK_PIXBUF_REQUIRED="gdk-pixbuf-2.0"
 LIBGNOMEDESKTOP_REQUIRED="gnome-desktop-3.0 >= 2.91.6"
 GSTREAMER_VERSION=0.10.32
 GSTREAMER_REQUIRED="gstreamer-plugins-base-0.10 >= $GSTREAMER_VERSION gstreamer-0.10 >= $GSTREAMER_VERSION"
+GSTREAMER_PLUGINS_BAD_VERSION=0.10.22
+GSTREAMER_PLUGINS_BAD_REQUIRED="gstreamer-plugins-bad-0.10 >= $GSTREAMER_PLUGINS_BAD_VERSION"
 CAIRO_REQUIRED="cairo >= 1.10.0"
 PANGOCAIRO_REQUIRED="pangocairo >= 1.28.0"
 LIBRSVG_REQUIRED="librsvg-2.0 >= 2.32.0"
@@ -109,6 +111,7 @@ PKG_CHECK_MODULES([CHEESE],
   $GOBJECT_REQUIRED
   $GDK_PIXBUF_REQUIRED
   $GSTREAMER_REQUIRED
+  $GSTREAMER_PLUGINS_BAD_REQUIRED
   $CAIRO_REQUIRED
   $PANGOCAIRO_REQUIRED
   $CLUTTER_REQUIRED
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 58a9f00..c08a800 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -91,8 +91,6 @@ struct _CheeseCameraPrivate
 
   GstCaps *preview_caps;
 
-  gulong photo_handler_signal_id;
-
   gboolean is_recording;
   gboolean pipeline_is_playing;
   gchar *photo_filename;
@@ -194,6 +192,8 @@ cheese_camera_photo_data (CheeseCamera *camera, GstBuffer *buffer)
 static void
 cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *camera)
 {
+  CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+
   switch (GST_MESSAGE_TYPE (message))
   {
     case GST_MESSAGE_WARNING:
@@ -263,6 +263,15 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
             }
           }
         }
+        if (strcmp (gst_structure_get_name (structure), "image-done") == 0)
+        {
+          const gchar *filename = gst_structure_get_string (structure, "filename");
+          if (priv->photo_filename != NULL && filename != NULL &&
+              (strcmp (priv->photo_filename, filename) == 0))
+          {
+            g_signal_emit (camera, camera_signals[PHOTO_SAVED], 0);
+          }
+        }
       }
       break;
     }
@@ -1054,26 +1063,6 @@ cheese_camera_stop_video_recording (CheeseCamera *camera)
   }
 }
 
-/*
- * cheese_camera_image_done_cb:
- * @camerabin: a CameraBin #GstElement
- * @filename: (type filename): path to where the photo was saved
- * @camera: a #CheeseCamera
- *
- * Emits the ::photo-saved signal, if a filename was provided.
- */
-static void
-cheese_camera_image_done_cb (GstElement *camerabin, const gchar *filename,
-                             CheeseCamera *camera)
-{
-  CheeseCameraPrivate *priv = camera->priv;
-  g_signal_handler_disconnect (G_OBJECT (priv->camerabin),
-                               priv->photo_handler_signal_id);
-  priv->photo_handler_signal_id = 0;
-  if (priv->photo_filename != NULL)
-    g_signal_emit (camera, camera_signals[PHOTO_SAVED], 0);
-}
-
 /**
  * cheese_camera_take_photo:
  * @camera: a #CheeseCamera
@@ -1087,20 +1076,18 @@ gboolean
 cheese_camera_take_photo (CheeseCamera *camera, const gchar *filename)
 {
   CheeseCameraPrivate *priv;
+  gboolean             ready;
 
   g_return_val_if_fail (CHEESE_IS_CAMERA (camera), FALSE);
 
   priv = camera->priv;
 
-  if (priv->photo_handler_signal_id != 0)
+  g_object_get (priv->camera_source, "ready-for-capture", &ready, NULL);
+  if (!ready)
   {
     GST_WARNING ("Still waiting for previous photo data, ignoring new request");
     return FALSE;
   }
-  priv->photo_handler_signal_id = g_signal_connect (G_OBJECT (priv->camerabin),
-                                                    "image-done",
-                                                    G_CALLBACK (cheese_camera_image_done_cb),
-                                                    camera);
 
   g_free (priv->photo_filename);
   priv->photo_filename = g_strdup (filename);
@@ -1109,22 +1096,13 @@ cheese_camera_take_photo (CheeseCamera *camera, const gchar *filename)
 
   /* Only copy the data if we're giving away a pixbuf,
    * not if we're throwing everything away straight away */
-
-  if (priv->photo_filename != NULL)
-  {
-    g_object_set (priv->camerabin, "location", priv->photo_filename, NULL);
-    g_object_set (priv->camerabin, "mode", MODE_IMAGE, NULL);
-    cheese_camera_set_tags (camera);
-    g_signal_emit_by_name (priv->camerabin, "start-capture", 0);
-  }
-  else
-  {
-    g_signal_handler_disconnect (G_OBJECT (priv->camerabin),
-                                 priv->photo_handler_signal_id);
-    priv->photo_handler_signal_id = 0;
+  if (priv->photo_filename == NULL)
     return FALSE;
-  }
 
+  g_object_set (priv->camerabin, "location", priv->photo_filename, NULL);
+  g_object_set (priv->camerabin, "mode", MODE_IMAGE, NULL);
+  cheese_camera_set_tags (camera);
+  g_signal_emit_by_name (priv->camerabin, "start-capture", 0);
   return TRUE;
 }
 
@@ -1142,20 +1120,19 @@ cheese_camera_take_photo_pixbuf (CheeseCamera *camera)
 {
   CheeseCameraPrivate *priv;
   GstCaps             *caps;
+  gboolean             ready;
 
   g_return_val_if_fail (CHEESE_IS_CAMERA (camera), FALSE);
 
   priv = camera->priv;
 
-  if (priv->photo_handler_signal_id != 0)
+  g_object_get (priv->camera_source, "ready-for-capture", &ready, NULL);
+  if (!ready)
   {
     GST_WARNING ("Still waiting for previous photo data, ignoring new request");
     return FALSE;
   }
-  priv->photo_handler_signal_id = g_signal_connect (G_OBJECT (priv->camerabin),
-                                                    "image-done",
-                                                    G_CALLBACK (cheese_camera_image_done_cb),
-                                                    camera);
+
   caps = gst_caps_new_simple ("video/x-raw-rgb",
                               "bpp", G_TYPE_INT, 24,
                               "depth", G_TYPE_INT, 24,
@@ -1395,7 +1372,6 @@ cheese_camera_init (CheeseCamera *camera)
   priv->photo_filename          = NULL;
   priv->camera_devices          = NULL;
   priv->device_node             = NULL;
-  priv->photo_handler_signal_id = 0;
   priv->current_format          = NULL;
   priv->monitor                 = NULL;
   priv->camera_source           = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]