Blob Blame History Raw
From dcccb73f44970d7f8ed8e7d70986f9ffecfc6491 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 3 Sep 2013 15:56:25 +0200
Subject: [PATCH 04/13] cheese-camera: Fix video recording with gstreamer >=
 1.1.4

gstreamer >= 1.1.4 requires us to fully specify the video-capture-source caps,
otherwise cheese prints this:

(cheese:22606): cheese-WARNING **: Filter caps do not completely specify the output format: gstcapsfilter.c(348): gst_capsfilter_prepare_buf (): /GstCameraBin:camerabin/GstCapsFilter:videobin-capsfilter:
Output caps are unfixed: video/x-raw, framerate=(fraction)30/1, width=(int)640, height=(int)480, format=(string){ YUY2, YV12, BGR, RGB, I420 }, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive

And video-recording is broken.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 libcheese/cheese-camera.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index a625359..fdeb973 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -743,7 +743,7 @@ cheese_camera_set_new_caps (CheeseCamera *camera)
 {
   CheeseCameraPrivate *priv;
   CheeseCameraDevice *device;
-  GstCaps *caps;
+  GstCaps *caps, *i420_caps, *video_caps;
   gchar *caps_desc;
   int width, height;
 
@@ -768,8 +768,17 @@ cheese_camera_set_new_caps (CheeseCamera *camera)
     g_object_set (gst_bin_get_by_name (GST_BIN (priv->video_source),
                   "video_source_filter"), "caps", caps, NULL);
     g_object_set (priv->camerabin, "viewfinder-caps", caps,
-                  "image-capture-caps", caps, "video-capture-caps", caps,
-                  NULL);
+                  "image-capture-caps", caps, NULL);
+
+    /* We must pick a format for the video-source, otherwise gstreamer
+       becomes unhappy */
+    i420_caps = gst_caps_new_simple ("video/x-raw",
+                                     "format", G_TYPE_STRING, "I420", NULL);
+    video_caps = gst_caps_intersect (caps, i420_caps);
+    g_object_set (priv->camerabin, "video-capture-caps", video_caps, NULL);
+
+    gst_caps_unref (i420_caps);
+    gst_caps_unref (video_caps);
     gst_caps_unref (caps);
 
     width = priv->current_format->width;
-- 
1.8.3.1