From b11342d325fa68e73bd408e6dd15dd7109c3c45f Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Sat, 4 Dec 2010 00:27:17 -0300 Subject: [PATCH] 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. --- gst/camerabin2/gstcamerabin2.c | 14 +++++++++++++- gst/camerabin2/gstcamerabin2.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c index cc7358ec08..0a9c0cd345 100644 --- a/gst/camerabin2/gstcamerabin2.c +++ b/gst/camerabin2/gstcamerabin2.c @@ -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. diff --git a/gst/camerabin2/gstcamerabin2.h b/gst/camerabin2/gstcamerabin2.h index 247e186092..a4c7bb4c9d 100644 --- a/gst/camerabin2/gstcamerabin2.h +++ b/gst/camerabin2/gstcamerabin2.h @@ -41,6 +41,9 @@ struct _GstCameraBin gulong src_capture_notify_id; GstElement *vidbin; + GstElement *vid_queue; + GstElement *vid_capsfilter; + GstElement *imgbin; gint vid_index;