From b34dac9a8737eb5b9e16e86ba2553c9758990e3a Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 17 Oct 2011 17:54:27 +0000 Subject: [PATCH] playsink: cache inner converter bin caps https://bugzilla.gnome.org/show_bug.cgi?id=661262 --- gst/playback/gstplaysinkconvertbin.c | 28 ++++++++++++++++++++++++++++ gst/playback/gstplaysinkconvertbin.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/gst/playback/gstplaysinkconvertbin.c b/gst/playback/gstplaysinkconvertbin.c index c3949dc..8754449 100644 --- a/gst/playback/gstplaysinkconvertbin.c +++ b/gst/playback/gstplaysinkconvertbin.c @@ -386,6 +386,29 @@ gst_play_sink_convert_bin_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +gst_play_sink_convert_bin_cache_converter_caps (GstPlaySinkConvertBin * self) +{ + GstElement *head; + GstPad *pad; + + self->converter_caps = NULL; + + if (!self->conversion_elements) + return; + + head = GST_ELEMENT (g_list_first (self->conversion_elements)->data); + pad = gst_element_get_static_pad (head, "sink"); + if (!pad) + return; + + self->converter_caps = gst_pad_get_caps_reffed (pad); + GST_INFO_OBJECT (self, "Converter caps: %" GST_PTR_FORMAT, + self->converter_caps); + + gst_object_unref (pad); +} + static GstStateChangeReturn gst_play_sink_convert_bin_change_state (GstElement * element, GstStateChange transition) @@ -401,6 +424,7 @@ gst_play_sink_convert_bin_change_state (GstElement * element, GST_ELEMENT_ERROR (self, CORE, PAD, (NULL), ("Failed to configure the converter bin.")); } + gst_play_sink_convert_bin_cache_converter_caps (self); gst_play_sink_convert_bin_add_identity (self); GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); break; @@ -449,6 +473,10 @@ gst_play_sink_convert_bin_change_state (GstElement * element, gst_bin_remove (GST_BIN_CAST (self), self->identity); self->identity = NULL; } + if (self->converter_caps) { + gst_caps_unref (self->converter_caps); + self->converter_caps = NULL; + } GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); break; default: diff --git a/gst/playback/gstplaysinkconvertbin.h b/gst/playback/gstplaysinkconvertbin.h index 2665651..7fac18d 100644 --- a/gst/playback/gstplaysinkconvertbin.h +++ b/gst/playback/gstplaysinkconvertbin.h @@ -74,6 +74,8 @@ struct _GstPlaySinkConvertBin GList *conversion_elements; GstElement *identity; + GstCaps *converter_caps; + /* configuration for derived classes */ gboolean audio; gboolean (*add_conversion_elements)(GstPlaySinkConvertBin *); -- 2.7.4