summaryrefslogtreecommitdiff
path: root/gst/camerabin2
diff options
context:
space:
mode:
authorOleksij Rempel <bug-track@fisher-privat.net>2012-03-22 08:47:57 +0100
committerThiago Santos <thiagoss@osg.samsung.com>2015-03-04 07:56:51 -0300
commite8a3973b8f712cb660fa9675c80c2fd3031acdb2 (patch)
tree33cd2688c818b5f36df16637356102fca627d87f /gst/camerabin2
parent2eac4232732912cff7ae6427b72c6b360c330daa (diff)
downloadgstreamer-plugins-bad-e8a3973b8f712cb660fa9675c80c2fd3031acdb2.tar.gz
camerabin2: check negotiated caps avoid reseting of the pipe
To avoid useless renegotiation of the pipe we can check for negotiated caps on src_filter and compare it with requested filter. If the caps intersect, avoid restart. Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net> https://bugzilla.gnome.org/show_bug.cgi?id=672610
Diffstat (limited to 'gst/camerabin2')
-rw-r--r--gst/camerabin2/gstwrappercamerabinsrc.c54
-rw-r--r--gst/camerabin2/gstwrappercamerabinsrc.h1
2 files changed, 40 insertions, 15 deletions
diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c
index 22e96ae49..b1335e223 100644
--- a/gst/camerabin2/gstwrappercamerabinsrc.c
+++ b/gst/camerabin2/gstwrappercamerabinsrc.c
@@ -92,6 +92,10 @@ gst_wrapper_camera_bin_src_dispose (GObject * object)
gst_object_unref (self->app_vid_filter);
self->app_vid_filter = NULL;
}
+ if (self->srcfilter_pad) {
+ gst_object_unref (self->srcfilter_pad);
+ self->srcfilter_pad = NULL;
+ }
gst_caps_replace (&self->image_capture_caps, NULL);
G_OBJECT_CLASS (parent_class)->dispose (object);
@@ -169,23 +173,45 @@ gst_wrapper_camera_bin_src_get_property (GObject * object,
static void
gst_wrapper_camera_bin_reset_video_src_caps (GstWrapperCameraBinSrc * self,
- GstCaps * caps)
+ GstCaps * new_filter_caps)
{
- GST_DEBUG_OBJECT (self, "Resetting src caps to %" GST_PTR_FORMAT, caps);
+ GST_DEBUG_OBJECT (self, "Resetting src caps to %" GST_PTR_FORMAT,
+ new_filter_caps);
if (self->src_vid_src) {
- GstCaps *old_caps;
+ GstCaps *src_neg_caps; /* negotiated caps on src_filter */
+ gboolean ret = FALSE;
+
+ /* After pipe was negotiated src_filter do not have any filter caps.
+ * In this situation we should compare neogotiated caps on capsfilter pad
+ * with requested range of caps. If one of this caps intersect,
+ * then we can avoid reseting.
+ */
+ src_neg_caps = gst_pad_get_current_caps (self->srcfilter_pad);
+ if (src_neg_caps && new_filter_caps && gst_caps_is_fixed (new_filter_caps))
+ ret = gst_caps_can_intersect (src_neg_caps, new_filter_caps);
+ else if (new_filter_caps == NULL) {
+ /* If new_filter_caps = NULL, then some body wont to empty
+ * capsfilter (set to ANY). In this case we will need to reset pipe,
+ * but if capsfilter is actually empthy, then we can avoid
+ * one more reseting.
+ */
+ GstCaps *old_filter_caps; /* range of caps on capsfilter */
+
+ g_object_get (G_OBJECT (self->src_filter),
+ "caps", &old_filter_caps, NULL);
+ ret = gst_caps_is_any (old_filter_caps);
+ gst_caps_unref (old_filter_caps);
+ }
+ if (src_neg_caps)
+ gst_caps_unref (src_neg_caps);
- g_object_get (G_OBJECT (self->src_filter), "caps", &old_caps, NULL);
- if (gst_caps_is_equal (caps, old_caps)) {
- GST_DEBUG_OBJECT (self, "old and new caps are same, do not reset it");
- if (old_caps)
- gst_caps_unref (old_caps);
+ if (ret) {
+ GST_DEBUG_OBJECT (self, "Negotiated caps on srcfilter intersect "
+ "with requested caps, do not reset it.");
return;
}
- if (old_caps)
- gst_caps_unref (old_caps);
- set_capsfilter_caps (self, caps);
+ set_capsfilter_caps (self, new_filter_caps);
}
}
@@ -537,7 +563,6 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
gboolean ret = FALSE;
GstPad *vf_pad;
GstPad *tee_capture_pad;
- GstPad *src_caps_src_pad;
/* checks and adds a new video src if needed */
if (!check_and_replace_src (self))
@@ -569,10 +594,9 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
/* attach to notify::caps on the first capsfilter and use a callback
* to recalculate the zoom properties when these caps change and to
* propagate the caps to the second capsfilter */
- src_caps_src_pad = gst_element_get_static_pad (self->src_filter, "src");
- g_signal_connect (src_caps_src_pad, "notify::caps",
+ self->srcfilter_pad = gst_element_get_static_pad (self->src_filter, "src");
+ g_signal_connect (self->srcfilter_pad, "notify::caps",
G_CALLBACK (gst_wrapper_camera_bin_src_caps_cb), self);
- gst_object_unref (src_caps_src_pad);
if (!(self->src_zoom_crop =
gst_camerabin_create_and_add_element (cbin, "videocrop",
diff --git a/gst/camerabin2/gstwrappercamerabinsrc.h b/gst/camerabin2/gstwrappercamerabinsrc.h
index ecac40ea5..68be6c559 100644
--- a/gst/camerabin2/gstwrappercamerabinsrc.h
+++ b/gst/camerabin2/gstwrappercamerabinsrc.h
@@ -63,6 +63,7 @@ struct _GstWrapperCameraBinSrc
GstCameraBinMode mode;
+ GstPad *srcfilter_pad;
GstPad *vfsrc;
GstPad *imgsrc;
GstPad *vidsrc;