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

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