camerabin2: Reset all elements on video recording branch before capture

We need to reset the elements from the video recording branch, including
the queue and capsfilter in order to clear the eos state and activate
the pads.

This makes it possible to record multiple videos with camerabin2 in a
sequence, otherwise the source would get a unexpected return and
push EOS, stopping the whole pipeline.
This commit is contained in:
Thiago Santos 2010-12-04 00:27:17 -03:00
parent b57405665a
commit b11342d325
2 changed files with 16 additions and 1 deletions

View file

@ -171,13 +171,18 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
if (!ready) {
gchar *location;
/* a video recording is about to start, we reset the videobin */
/* a video recording is about to start, we reset the videobin to clear eos/flushing state
* also need to clean the queue ! capsfilter before it */
gst_element_set_state (camera->vidbin, GST_STATE_NULL);
gst_element_set_state (camera->vid_queue, GST_STATE_NULL);
gst_element_set_state (camera->vid_capsfilter, GST_STATE_NULL);
location = g_strdup_printf (camera->vid_location, camera->vid_index++);
GST_DEBUG_OBJECT (camera, "Switching vidbin location to %s", location);
g_object_set (camera->vidbin, "location", location, NULL);
g_free (location);
gst_element_set_state (camera->vidbin, GST_STATE_PLAYING);
gst_element_set_state (camera->vid_capsfilter, GST_STATE_PLAYING);
gst_element_set_state (camera->vid_queue, GST_STATE_PLAYING);
}
}
}
@ -198,6 +203,10 @@ gst_camera_bin_dispose (GObject * object)
if (camerabin->vidbin)
gst_object_unref (camerabin->vidbin);
if (camerabin->vid_queue)
gst_object_unref (camerabin->vid_queue);
if (camerabin->vid_capsfilter)
gst_object_unref (camerabin->vid_capsfilter);
if (camerabin->imgbin)
gst_object_unref (camerabin->imgbin);
@ -349,6 +358,9 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
gst_element_link_pads (src, "imgsrc", img_queue, "sink");
gst_element_link_pads (src, "vidsrc", vid_queue, "sink");
camera->vid_queue = gst_object_ref (vid_queue);
camera->vid_capsfilter = gst_object_ref (vid_capsfilter);
/*
* Video can't get into playing as its internal filesink will open
* a file for writing and leave it empty if unused.

View file

@ -41,6 +41,9 @@ struct _GstCameraBin
gulong src_capture_notify_id;
GstElement *vidbin;
GstElement *vid_queue;
GstElement *vid_capsfilter;
GstElement *imgbin;
gint vid_index;