camerabin: handle preview-caps only in image mode and only when they change
authorTommi Myöhänen <ext-tommi.1.myohanen@nokia.com>
Thu, 27 Aug 2009 11:35:26 +0000 (14:35 +0300)
committerRené Stadler <rene.stadler@nokia.com>
Thu, 1 Oct 2009 15:06:55 +0000 (18:06 +0300)
This prevents camerabin to create preview pipeline every time when
application re-sets the same caps again.

gst/camerabin/gstcamerabin.c

index 6d02850..40ba837 100644 (file)
@@ -2891,11 +2891,23 @@ gst_camerabin_set_property (GObject * object, guint prop_id,
       }
       break;
     case ARG_PREVIEW_CAPS:
-      GST_OBJECT_LOCK (camera);
-      gst_caps_replace (&camera->preview_caps,
-          (GstCaps *) gst_value_get_caps (value));
-      GST_OBJECT_UNLOCK (camera);
-      gst_camerabin_preview_create_pipeline (camera);
+      /* Currently camerabin only provides preview for images, so we don't
+       * even handle video mode */
+      if (camera->mode == MODE_IMAGE) {
+        GstCaps *new_caps = NULL;
+
+        new_caps = (GstCaps *) gst_value_get_caps (value);
+        GST_DEBUG_OBJECT (camera,
+            "setting preview caps: %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT,
+             camera->preview_caps, new_caps);
+
+        if (!gst_caps_is_equal (camera->preview_caps, new_caps)) {
+          GST_OBJECT_LOCK (camera);
+          gst_caps_replace (&camera->preview_caps, new_caps);
+          GST_OBJECT_UNLOCK (camera);
+          gst_camerabin_preview_create_pipeline (camera);
+        }
+      }
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);