After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739002 - capsfilter: Add an optional delayed caps change mode
capsfilter: Add an optional delayed caps change mode
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal enhancement
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 668001 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-10-22 12:14 UTC by Sebastian Dröge (slomo)
Modified: 2014-11-03 07:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
capsfilter: Add an optional delayed caps change mode (15.34 KB, patch)
2014-10-22 12:14 UTC, Sebastian Dröge (slomo)
reviewed Details | Review
capsfilter: Add an optional delayed caps change mode (15.72 KB, patch)
2014-10-22 12:53 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2014-10-22 12:14:16 UTC
In this mode we accept previously set filter caps until
upstream renegotiates to something that is compatible
to the current filter caps.

This allows dynamic caps changes in the pipeline even
if there is a queue between any conversion element
and the capsfilter. With this we would get not-negotiated
errors if timing is bad.
Comment 1 Sebastian Dröge (slomo) 2014-10-22 12:14:19 UTC
Created attachment 289122 [details] [review]
capsfilter: Add an optional delayed caps change mode
Comment 2 Tim-Philipp Müller 2014-10-22 12:26:55 UTC
Comment on attachment 289122 [details] [review]
capsfilter: Add an optional delayed caps change mode

>With this we would get not-negotiated
>errors if timing is bad.

"Without this" you mean?

>+#define GST_TYPE_CAPS_FILTER_PULL_MODE (gst_caps_filter_pull_mode_get_type())
>+static GType
>+gst_caps_filter_pull_mode_get_type (void)

The naming of the function isn't right, it should match the GType name (copy'n'past I presume).

>+  g_object_class_install_property (gobject_class, PROP_CAPS_CHANGE_MODE,
>+      g_param_spec_enum ("caps-change-mode", _("Caps Change Mode"),
>+          _("Filter caps change behaviour"), GST_TYPE_CAPS_FILTER_PULL_MODE,
>+          DEFAULT_CAPS_CHANGE_MODE,
>+          G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
>+          G_PARAM_STATIC_STRINGS));
>+
>   gstelement_class = GST_ELEMENT_CLASS (klass);
>   gst_element_class_set_static_metadata (gstelement_class,
>       "CapsFilter",
>@@ -136,6 +165,7 @@ gst_capsfilter_init (GstCapsFilter * filter)
>   gst_base_transform_set_gap_aware (trans, TRUE);
>   gst_base_transform_set_prefer_passthrough (trans, FALSE);
>   filter->filter_caps = gst_caps_new_any ();
>+  filter->caps_change_mode = DEFAULT_CAPS_CHANGE_MODE;
> }
> 
> static void
>@@ -160,6 +190,11 @@ gst_capsfilter_set_property (GObject * object, guint prop_id,
>       GST_OBJECT_LOCK (capsfilter);
>       old_caps = capsfilter->filter_caps;
>       capsfilter->filter_caps = new_caps;
>+      if (old_caps
>+          && capsfilter->caps_change_mode ==
>+          GST_CAPS_FILTER_CAPS_CHANGE_MODE_DELAYED)
>+        capsfilter->previous_caps =
>+            g_list_prepend (capsfilter->previous_caps, gst_caps_ref (old_caps));
>       GST_OBJECT_UNLOCK (capsfilter);

Should setting the mode to IMMEDIATE clear the previous_caps list? Both makes sense, just wondering.

>@@ -211,11 +252,13 @@ gst_capsfilter_transform_caps (GstBaseTransform * base,
> {
>   GstCapsFilter *capsfilter = GST_CAPSFILTER (base);
>   GstCaps *ret, *filter_caps, *tmp;
>+  gboolean retried = FALSE;
> 
>   GST_OBJECT_LOCK (capsfilter);
>   filter_caps = gst_caps_ref (capsfilter->filter_caps);
>   GST_OBJECT_UNLOCK (capsfilter);

I think you should read the caps_change_mode into a local variable here as well, within the object lock.
Comment 3 Mathieu Duponchelle 2014-10-22 12:49:28 UTC
Review of attachment 289122 [details] [review]:

Only this to add to tim's review, seems fine by me.

::: tests/check/elements/capsfilter.c
@@ +357,3 @@
+      GST_STATE_CHANGE_SUCCESS);
+
+  /* push the stream start */

Can't you just use gst_check_setup_events here ?
Comment 4 Sebastian Dröge (slomo) 2014-10-22 12:53:04 UTC
Created attachment 289124 [details] [review]
capsfilter: Add an optional delayed caps change mode

In this mode we accept previously set filter caps until
upstream renegotiates to something that is compatible
to the current filter caps.

This allows dynamic caps changes in the pipeline even
if there is a queue between any conversion element
and the capsfilter. Without this we would get not-negotiated
errors if timing is bad.
Comment 5 Tim-Philipp Müller 2014-10-30 11:44:20 UTC
*** Bug 668001 has been marked as a duplicate of this bug. ***
Comment 6 Sebastian Dröge (slomo) 2014-11-03 07:27:09 UTC
commit 9606e0489585b34d666b76c536b208608c1fa37e
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Wed Oct 22 14:07:09 2014 +0200

    capsfilter: Add an optional delayed caps change mode
    
    In this mode we accept previously set filter caps until
    upstream renegotiates to something that is compatible
    to the current filter caps.
    
    This allows dynamic caps changes in the pipeline even
    if there is a queue between any conversion element
    and the capsfilter. Without this we would get not-negotiated
    errors if timing is bad.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739002