camerabin2: Various fixes
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Thu, 2 Dec 2010 06:44:37 +0000 (03:44 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 8 Dec 2010 18:38:29 +0000 (15:38 -0300)
As video recording bin's state is locked, we should always
remember of setting it to NULL when camerabin2 goes to NULL

Be more careful when using elements that might not
have been created yet

And do not set location property recursively on videorecordingbin

gst/camerabin2/gstcamerabin2.c
gst/camerabin2/gstvideorecordingbin.c

index a7bd139..171c5bf 100644 (file)
@@ -140,7 +140,8 @@ gst_camera_bin_start_capture (GstCameraBin * camerabin)
 static void
 gst_camera_bin_stop_capture (GstCameraBin * camerabin)
 {
-  g_signal_emit_by_name (camerabin->src, "stop-capture", NULL);
+  if (camerabin->src)
+    g_signal_emit_by_name (camerabin->src, "stop-capture", NULL);
 }
 
 static void
@@ -152,7 +153,8 @@ gst_camera_bin_change_mode (GstCameraBin * camerabin, gint mode)
   /* stop any ongoing capture */
   gst_camera_bin_stop_capture (camerabin);
   camerabin->mode = mode;
-  g_object_set (camerabin->src, "mode", mode, NULL);
+  if (camerabin->src)
+    g_object_set (camerabin->src, "mode", mode, NULL);
 }
 
 static void
@@ -358,6 +360,7 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
       "notify::ready-for-capture",
       G_CALLBACK (gst_camera_bin_src_notify_readyforcapture), camera);
 
+  g_object_set (src, "mode", camera->mode, NULL);
   g_object_set (vid, "location", camera->vid_location, NULL);
   g_object_set (img, "location", camera->img_location, NULL);
 
@@ -385,6 +388,7 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans)
 
   switch (trans) {
     case GST_STATE_CHANGE_READY_TO_NULL:
+      gst_element_set_state (camera->vidbin, GST_STATE_NULL);
       break;
     default:
       break;
@@ -397,7 +401,8 @@ static void
 gst_camera_bin_set_location (GstCameraBin * camera, const gchar * location)
 {
   if (camera->mode == MODE_IMAGE) {
-    g_object_set (camera->imgbin, "location", location, NULL);
+    if (camera->imgbin)
+      g_object_set (camera->imgbin, "location", location, NULL);
     g_free (camera->img_location);
     camera->img_location = g_strdup (location);
   } else {
index d1753e0..ba78a3e 100644 (file)
@@ -75,7 +75,7 @@ gst_video_recording_bin_set_property (GObject * object, guint prop_id,
     case PROP_LOCATION:
       vidbin->location = g_value_dup_string (value);
       if (vidbin->sink) {
-        g_object_set (vidbin, "location", vidbin->location, NULL);
+        g_object_set (vidbin->sink, "location", vidbin->location, NULL);
       }
       break;
     default: