[cheese/camerabin] cheese-camera: Setting resolution in camerabin



commit 53e34e22eb80070b81df4980934cc815e01f2b3e
Author: Luciana Fujii Pontello <luciana fujii eti br>
Date:   Tue Jan 18 17:19:42 2011 -0200

    cheese-camera: Setting resolution in camerabin
    
    Cheese was using a capsfilter after video source to configure the
    desired resolution for pictures and video. We now use the camerabin
    signal set-video-resolution-fps to set desired resolution.

 libcheese/cheese-camera.c |   57 +++++++++++++++------------------------------
 1 files changed, 19 insertions(+), 38 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index ee2dd76..2badb5f 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -58,12 +58,10 @@ typedef struct
   GstBus *bus;
 
   GstElement *camerabin;
-  GstElement *camera_source_bin;
   GstElement *video_filter_bin;
   GstElement *effects_preview_bin;
 
   GstElement *video_source;
-  GstElement *capsfilter;
   GstElement *video_file_sink;
   GstElement *photo_sink;
   GstElement *audio_source;
@@ -267,7 +265,7 @@ cheese_camera_detect_camera_devices (CheeseCamera *camera)
 }
 
 static gboolean
-cheese_camera_create_camera_source_bin (CheeseCamera *camera)
+cheese_camera_set_camera_source (CheeseCamera *camera)
 {
   CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
 
@@ -294,31 +292,25 @@ cheese_camera_create_camera_source_bin (CheeseCamera *camera)
   }
 
   camera_input = g_strdup_printf (
-    "%s name=video_source device=%s ! capsfilter name=capsfilter ! identity",
+    "%s name=video_source device=%s",
     cheese_camera_device_get_src (selected_camera),
     cheese_camera_device_get_device_file (selected_camera));
 
-  priv->camera_source_bin = gst_parse_bin_from_description (camera_input,
-                                                            TRUE, &err);
+  priv->video_source = gst_parse_bin_from_description (camera_input, TRUE, &err);
   g_free (camera_input);
 
-  if (priv->camera_source_bin == NULL)
+  if (priv->video_source == NULL)
   {
-    goto fallback;
+    if (err != NULL)
+    {
+      g_error_free (err);
+      err = NULL;
+    }
+    return FALSE;
   }
-
-  priv->video_source = gst_bin_get_by_name (GST_BIN (priv->camera_source_bin), "video_source");
-  priv->capsfilter   = gst_bin_get_by_name (GST_BIN (priv->camera_source_bin), "capsfilter");
+  g_object_set (priv->camerabin, "video-source", priv->video_source, NULL);
 
   return TRUE;
-
-fallback:
-  if (err != NULL)
-  {
-    g_error_free (err);
-    err = NULL;
-  }
-  return FALSE;
 }
 
 static void
@@ -468,16 +460,6 @@ cheese_camera_create_video_filter_bin (CheeseCamera *camera, GError **error)
   return TRUE;
 }
 
-static void
-cheese_camera_relink_camera_source_bin (CheeseCamera *camera)
-{
-  CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
-
-  cheese_camera_create_camera_source_bin (camera);
-
-  g_object_set (priv->camerabin, "video-source", priv->camera_source_bin, NULL);
-}
-
 int
 cheese_camera_get_num_camera_devices (CheeseCamera *camera)
 {
@@ -518,7 +500,7 @@ cheese_camera_switch_camera_device (CheeseCamera *camera)
     pipeline_was_playing = TRUE;
   }
 
-  cheese_camera_relink_camera_source_bin (camera);
+  cheese_camera_set_camera_source (camera);
 
   if (pipeline_was_playing)
   {
@@ -549,14 +531,14 @@ cheese_camera_play (CheeseCamera *camera)
     priv->current_format = cheese_camera_device_get_best_format (device);
     g_object_notify (G_OBJECT (camera), "format");
     caps = cheese_camera_device_get_caps_for_format (device, priv->current_format);
-    if (G_UNLIKELY (gst_caps_is_empty (caps)))
-    {
-      gst_caps_unref (caps);
-      caps = gst_caps_new_any ();
-    }
   }
 
-  g_object_set (priv->capsfilter, "caps", caps, NULL);
+  if (!gst_caps_is_empty (caps))
+  {
+    g_signal_emit_by_name (priv->camerabin, "set-video-resolution-fps",
+                           priv->current_format->width,
+                           priv->current_format->height, 0, 1, 0);
+  }
   gst_caps_unref (caps);
 
   gst_element_set_state (priv->camerabin, GST_STATE_PLAYING);
@@ -1022,7 +1004,6 @@ cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
     cheese_camera_set_device_by_dev_udi (camera, id);
   }
 
-  cheese_camera_create_camera_source_bin (camera);
 
   if ((priv->camerabin = gst_element_factory_make ("camerabin", "camerabin")) == NULL)
   {
@@ -1030,7 +1011,6 @@ cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
   }
   g_object_set (priv->camerabin, "video-capture-height", 0,
                 "video-capture-width", 0, NULL);
-  g_object_set (priv->camerabin, "video-source", priv->camera_source_bin, NULL);
 
   /* Create a clutter-gst sink and set it as camerabin sink*/
 
@@ -1044,6 +1024,7 @@ cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
   /* Set flags to enable conversions*/
 
   g_object_set (G_OBJECT (priv->camerabin), "flags", 0xd9, NULL);
+  cheese_camera_set_camera_source (camera);
 
   cheese_camera_create_video_filter_bin (camera, &tmp_error);
 



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