Blame SOURCES/0002-camerabin-Add-a-camerabin_create_view_finder_caps-he.patch

56b13a
From a07a1138a8cf8ad1029845dfe4cfdf5a0a36e670 Mon Sep 17 00:00:00 2001
56b13a
From: Hans de Goede <hdegoede@redhat.com>
56b13a
Date: Fri, 8 Jun 2012 11:31:05 +0200
56b13a
Subject: [PATCH 2/4] camerabin: Add a camerabin_create_view_finder_caps()
56b13a
 helper function
56b13a
56b13a
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
56b13a
---
56b13a
 gst/camerabin/gstcamerabin.c |   72 +++++++++++++++++++++++-------------------
56b13a
 1 file changed, 40 insertions(+), 32 deletions(-)
56b13a
56b13a
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
56b13a
index 8a36970..3f87ff9 100644
56b13a
--- a/gst/camerabin/gstcamerabin.c
56b13a
+++ b/gst/camerabin/gstcamerabin.c
56b13a
@@ -505,22 +505,15 @@ GST_BOILERPLATE_FULL (GstCameraBin, gst_camerabin, GstPipeline,
56b13a
  */
56b13a
 
56b13a
 /*
56b13a
- * camerabin_setup_src_elements:
56b13a
+ * camerabin_create_view_finder_caps:
56b13a
  * @camera: camerabin object
56b13a
  *
56b13a
- * This function updates camerabin capsfilters according
56b13a
- * to fps, resolution and zoom that have been configured
56b13a
- * to camerabin.
56b13a
+ * This function creates new view_finder_caps, according to
56b13a
+ * fps and resolution that have been configured to camerabin.
56b13a
  */
56b13a
-static void
56b13a
-camerabin_setup_src_elements (GstCameraBin * camera)
56b13a
+static GstCaps *camerabin_create_view_finder_caps (GstCameraBin * camera)
56b13a
 {
56b13a
   GstStructure *st;
56b13a
-  GstCaps *new_caps;
56b13a
-  gboolean detect_framerate = FALSE;
56b13a
-
56b13a
-  /* clear video update status */
56b13a
-  camera->video_capture_caps_update = FALSE;
56b13a
 
56b13a
   if (!camera->view_finder_caps) {
56b13a
     st = gst_structure_from_string (CAMERABIN_DEFAULT_VF_CAPS, NULL);
56b13a
@@ -529,39 +522,54 @@ camerabin_setup_src_elements (GstCameraBin * camera)
56b13a
             0));
56b13a
   }
56b13a
 
56b13a
-  gst_camerabin_monitor_video_source_properties (camera);
56b13a
-
56b13a
   if (camera->app_width > 0 && camera->app_height > 0) {
56b13a
     gst_structure_set (st,
56b13a
         "width", G_TYPE_INT, camera->app_width,
56b13a
         "height", G_TYPE_INT, camera->app_height, NULL);
56b13a
   }
56b13a
 
56b13a
-  if (camera->app_fps_n > 0 && camera->app_fps_d > 0) {
56b13a
-    if (camera->night_mode) {
56b13a
-      GST_INFO_OBJECT (camera, "night mode, lowest allowed fps will be forced");
56b13a
-      camera->pre_night_fps_n = camera->app_fps_n;
56b13a
-      camera->pre_night_fps_d = camera->app_fps_d;
56b13a
-      detect_framerate = TRUE;
56b13a
-    } else {
56b13a
-      gst_structure_set (st,
56b13a
-          "framerate", GST_TYPE_FRACTION, camera->app_fps_n,
56b13a
-          camera->app_fps_d, NULL);
56b13a
-      new_caps = gst_caps_new_full (st, NULL);
56b13a
-    }
56b13a
+  if (!camera->night_mode && camera->app_fps_n > 0 && camera->app_fps_d > 0) {
56b13a
+    gst_structure_set (st,
56b13a
+        "framerate", GST_TYPE_FRACTION, camera->app_fps_n,
56b13a
+        camera->app_fps_d, NULL);
56b13a
   } else {
56b13a
-    GST_DEBUG_OBJECT (camera, "no framerate specified");
56b13a
-    detect_framerate = TRUE;
56b13a
-  }
56b13a
-
56b13a
-  if (detect_framerate) {
56b13a
-    GST_DEBUG_OBJECT (camera, "detecting allowed framerate");
56b13a
     /* Remove old framerate if any */
56b13a
     if (gst_structure_has_field (st, "framerate")) {
56b13a
       gst_structure_remove_field (st, "framerate");
56b13a
     }
56b13a
-    new_caps = gst_caps_new_full (st, NULL);
56b13a
+  }
56b13a
+
56b13a
+  /* The returned caps take ownership of the structure st */
56b13a
+  return gst_caps_new_full (st, NULL);
56b13a
+}
56b13a
 
56b13a
+/*
56b13a
+ * camerabin_setup_src_elements:
56b13a
+ * @camera: camerabin object
56b13a
+ *
56b13a
+ * This function updates camerabin capsfilters according
56b13a
+ * to fps, resolution and zoom that have been configured
56b13a
+ * to camerabin.
56b13a
+ */
56b13a
+static void
56b13a
+camerabin_setup_src_elements (GstCameraBin * camera)
56b13a
+{
56b13a
+  GstCaps *new_caps;
56b13a
+
56b13a
+  /* clear video update status */
56b13a
+  camera->video_capture_caps_update = FALSE;
56b13a
+
56b13a
+  gst_camerabin_monitor_video_source_properties (camera);
56b13a
+
56b13a
+  new_caps = camerabin_create_view_finder_caps (camera);
56b13a
+
56b13a
+  if (camera->night_mode || camera->app_fps_n <= 0 || camera->app_fps_d <= 0) {
56b13a
+    if (camera->night_mode) {
56b13a
+      GST_INFO_OBJECT (camera, "night mode, lowest allowed fps will be forced");
56b13a
+      camera->pre_night_fps_n = camera->app_fps_n;
56b13a
+      camera->pre_night_fps_d = camera->app_fps_d;
56b13a
+    }
56b13a
+    GST_DEBUG_OBJECT (camera, "detecting allowed framerate");
56b13a
     /* Set allowed framerate for the resolution */
56b13a
     gst_camerabin_set_allowed_framerate (camera, new_caps);
56b13a
   }
56b13a
-- 
56b13a
1.7.10.2
56b13a