summaryrefslogtreecommitdiff
blob: 15e9ef4cdeee1e5437be17f2959d2d8ce29002f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- trunk/src/cheese-webcam.c	2008/03/13 12:32:22	592
+++ trunk/src/cheese-webcam.c	2008/03/13 12:37:16	594
@@ -562,11 +562,10 @@
   CheeseWebcamPrivate* priv = CHEESE_WEBCAM_GET_PRIVATE (webcam);
   GError *err = NULL;
   char *webcam_input;
-  
+
   if (priv->num_webcam_devices == 0)
   {
-    priv->webcam_source_bin = gst_parse_bin_from_description ("videotestsrc name=video_source",
-                                                              TRUE, &err);
+    goto fallback;
   }
   else
   {
@@ -588,12 +587,16 @@
     format = &(g_array_index (selected_webcam->video_formats, CheeseVideoFormat, 0));
     for (i = 1; i < selected_webcam->num_video_formats; i++)
     {
-      
+
       if (g_array_index (selected_webcam->video_formats, CheeseVideoFormat, i).width >  format->width)
       {
         format = &(g_array_index (selected_webcam->video_formats, CheeseVideoFormat, i));
       }
     }
+
+    if (format == NULL)
+      goto fallback;
+
     /* Select the highest framerate up to 30 Hz*/
     framerate_numerator = 1;
     framerate_denominator = 1;
@@ -620,15 +623,29 @@
 
     priv->webcam_source_bin = gst_parse_bin_from_description (webcam_input,
                                                               TRUE, &err);
-    g_free (webcam_input);    
+    g_free (webcam_input);
+
+    if ( priv->webcam_source_bin == NULL)
+      goto fallback;
   }
+
+  priv->video_source = gst_bin_get_by_name (GST_BIN (priv->webcam_source_bin), "video_source");
+  return TRUE;
+
+fallback:
   if (err != NULL)
   {
     g_error_free (err);
-    return FALSE;
+    err = NULL;
   }
 
-  priv->video_source = gst_bin_get_by_name (GST_BIN (priv->webcam_source_bin), "video_source");
+  priv->webcam_source_bin = gst_parse_bin_from_description ("videotestsrc name=video_source",
+                                                              TRUE, &err);
+  if (err != NULL)
+  {
+    g_error_free (err);
+    return FALSE;
+  }
   return TRUE;
 }