From 02754252128716aca13ed1bde505a1fc9efa4e67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 2 Jun 2008 12:22:56 +0000 Subject: [PATCH] gst/videomixer/videomixer.c: When using gst_element_iterate_pads() one has to unref every pad after usage. Original commit message from CVS: * gst/videomixer/videomixer.c: (gst_videomixer_query_duration), (gst_videomixer_query_latency): When using gst_element_iterate_pads() one has to unref every pad after usage. --- ChangeLog | 7 ++++++ gst/videomixer/videomixer.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/ChangeLog b/ChangeLog index 90495e1..6301725 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-06-02 Sebastian Dröge + + * gst/videomixer/videomixer.c: (gst_videomixer_query_duration), + (gst_videomixer_query_latency): + When using gst_element_iterate_pads() one has to unref every pad + after usage. + 2008-05-31 Edward Hervey Patch by: Bastien Nocera diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c index 09544b3..eadbe5a 100644 --- a/gst/videomixer/videomixer.c +++ b/gst/videomixer/videomixer.c @@ -80,13 +80,16 @@ static GType gst_videomixer_get_type (void); static void gst_videomixer_pad_class_init (GstVideoMixerPadClass * klass); + static void gst_videomixer_pad_init (GstVideoMixerPad * mixerpad); + static void gst_videomixer_pad_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void gst_videomixer_pad_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static gboolean gst_videomixer_src_event (GstPad * pad, GstEvent * event); + static gboolean gst_videomixer_sink_event (GstPad * pad, GstEvent * event); @@ -188,6 +191,7 @@ gst_videomixer_pad_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstVideoMixerPad *pad; + GstVideoMixer *mix; pad = GST_VIDEO_MIXER_PAD (object); @@ -221,7 +225,9 @@ static void gst_videomixer_set_master_geometry (GstVideoMixer * mix) { GSList *walk; + gint width = 0, height = 0, fps_n = 0, fps_d = 0; + GstVideoMixerPad *master = NULL; walk = mix->sinkpads; @@ -264,10 +270,15 @@ static gboolean gst_videomixer_pad_sink_setcaps (GstPad * pad, GstCaps * vscaps) { GstVideoMixer *mix; + GstVideoMixerPad *mixpad; + GstStructure *structure; + gint in_width, in_height; + gboolean ret = FALSE; + const GValue *framerate; mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); @@ -360,6 +371,7 @@ static GType gst_video_mixer_background_get_type (void) { static GType video_mixer_background_type = 0; + static const GEnumValue video_mixer_background[] = { {VIDEO_MIXER_BACKGROUND_CHECKER, "Checker pattern", "checker"}, {VIDEO_MIXER_BACKGROUND_BLACK, "Black", "black"}, @@ -396,6 +408,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d", static void gst_videomixer_finalize (GObject * object); static GstCaps *gst_videomixer_getcaps (GstPad * pad); + static gboolean gst_videomixer_query (GstPad * pad, GstQuery * query); static GstFlowReturn gst_videomixer_collected (GstCollectPads * pads, @@ -403,6 +416,7 @@ static GstFlowReturn gst_videomixer_collected (GstCollectPads * pads, static GstPad *gst_videomixer_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name); static void gst_videomixer_release_pad (GstElement * element, GstPad * pad); + static void gst_videomixer_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_videomixer_get_property (GObject * object, guint prop_id, @@ -437,6 +451,7 @@ gst_videomixer_child_proxy_get_child_by_index (GstChildProxy * child_proxy, guint index) { GstVideoMixer *mix = GST_VIDEO_MIXER (child_proxy); + GstObject *obj; GST_VIDEO_MIXER_STATE_LOCK (mix); @@ -450,6 +465,7 @@ static guint gst_videomixer_child_proxy_get_children_count (GstChildProxy * child_proxy) { guint count = 0; + GstVideoMixer *mix = GST_VIDEO_MIXER (child_proxy); GST_VIDEO_MIXER_STATE_LOCK (mix); @@ -486,6 +502,7 @@ static void gst_videomixer_class_init (GstVideoMixerClass * klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; @@ -595,9 +612,13 @@ static gboolean gst_videomixer_query_duration (GstVideoMixer * mix, GstQuery * query) { gint64 max; + gboolean res; + GstFormat format; + GstIterator *it; + gboolean done; /* parse format */ @@ -611,6 +632,7 @@ gst_videomixer_query_duration (GstVideoMixer * mix, GstQuery * query) it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (mix)); while (!done) { GstIteratorResult ires; + gpointer item; ires = gst_iterator_next (it, &item); @@ -621,6 +643,7 @@ gst_videomixer_query_duration (GstVideoMixer * mix, GstQuery * query) case GST_ITERATOR_OK: { GstPad *pad = GST_PAD_CAST (item); + gint64 duration; /* ask sink peer for duration */ @@ -636,6 +659,7 @@ gst_videomixer_query_duration (GstVideoMixer * mix, GstQuery * query) else if (duration > max) max = duration; } + gst_object_unref (pad); break; } case GST_ITERATOR_RESYNC: @@ -665,9 +689,13 @@ static gboolean gst_videomixer_query_latency (GstVideoMixer * mix, GstQuery * query) { GstClockTime min, max; + gboolean live; + gboolean res; + GstIterator *it; + gboolean done; res = TRUE; @@ -681,6 +709,7 @@ gst_videomixer_query_latency (GstVideoMixer * mix, GstQuery * query) it = gst_element_iterate_sink_pads (GST_ELEMENT_CAST (mix)); while (!done) { GstIteratorResult ires; + gpointer item; ires = gst_iterator_next (it, &item); @@ -691,8 +720,11 @@ gst_videomixer_query_latency (GstVideoMixer * mix, GstQuery * query) case GST_ITERATOR_OK: { GstPad *pad = GST_PAD_CAST (item); + GstQuery *peerquery; + GstClockTime min_cur, max_cur; + gboolean live_cur; peerquery = gst_query_new_latency (); @@ -716,6 +748,7 @@ gst_videomixer_query_latency (GstVideoMixer * mix, GstQuery * query) } gst_query_unref (peerquery); + gst_object_unref (pad); break; } case GST_ITERATOR_RESYNC: @@ -748,6 +781,7 @@ static gboolean gst_videomixer_query (GstPad * pad, GstQuery * query) { GstVideoMixer *mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); + gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { @@ -789,7 +823,9 @@ static GstCaps * gst_videomixer_getcaps (GstPad * pad) { GstVideoMixer *mix; + GstCaps *caps; + GstStructure *structure; mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); @@ -818,7 +854,9 @@ gst_videomixer_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name) { GstVideoMixer *mix = NULL; + GstVideoMixerPad *mixpad = NULL; + GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); g_return_val_if_fail (templ != NULL, NULL); @@ -834,7 +872,9 @@ gst_videomixer_request_new_pad (GstElement * element, if (templ == gst_element_class_get_pad_template (klass, "sink_%d")) { gint serial = 0; + gchar *name = NULL; + GstVideoMixerCollect *mixcol = NULL; if (req_name == NULL || strlen (req_name) < 6) { @@ -894,6 +934,7 @@ static void gst_videomixer_release_pad (GstElement * element, GstPad * pad) { GstVideoMixer *mix = NULL; + GstVideoMixerPad *mixpad; mix = GST_VIDEO_MIXER (element); @@ -1076,9 +1117,13 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos, guint8 * dest, gint dest_width, gint dest_height) { gint alpha, b_alpha; + gint i, j; + gint src_stride, dest_stride; + gint src_add, dest_add; + gint Y, U, V; src_stride = src_width * 4; @@ -1184,6 +1229,7 @@ static gboolean gst_videomixer_fill_queues (GstVideoMixer * mix) { GSList *walk = NULL; + gboolean eos = TRUE; g_return_val_if_fail (GST_IS_VIDEO_MIXER (mix), FALSE); @@ -1192,7 +1238,9 @@ gst_videomixer_fill_queues (GstVideoMixer * mix) walk = mix->collect->data; while (walk) { GstCollectData *data = (GstCollectData *) walk->data; + GstVideoMixerCollect *mixcol = (GstVideoMixerCollect *) data; + GstVideoMixerPad *mixpad = mixcol->mixpad; walk = g_slist_next (walk); @@ -1229,6 +1277,7 @@ gst_videomixer_fill_queues (GstVideoMixer * mix) } if (mix->sendseg && (mixpad == mix->master)) { GstEvent *event; + GstSegment *segment = &data->segment; /* FIXME, use rate/applied_rate as set on all sinkpads. @@ -1269,6 +1318,7 @@ gst_videomixer_blend_buffers (GstVideoMixer * mix, GstBuffer * outbuf) walk = mix->sinkpads; while (walk) { /* We walk with this list because it's ordered */ GstVideoMixerPad *pad = GST_VIDEO_MIXER_PAD (walk->data); + GstVideoMixerCollect *mixcol = pad->mixcol; walk = g_slist_next (walk); @@ -1299,6 +1349,7 @@ static void gst_videomixer_update_queues (GstVideoMixer * mix) { GSList *walk; + guint64 interval; interval = mix->master->queued; @@ -1313,6 +1364,7 @@ gst_videomixer_update_queues (GstVideoMixer * mix) walk = mix->sinkpads; while (walk) { GstVideoMixerPad *pad = GST_VIDEO_MIXER_PAD (walk->data); + GstVideoMixerCollect *mixcol = pad->mixcol; walk = g_slist_next (walk); @@ -1333,8 +1385,11 @@ static GstFlowReturn gst_videomixer_collected (GstCollectPads * pads, GstVideoMixer * mix) { GstFlowReturn ret = GST_FLOW_OK; + GstBuffer *outbuf = NULL; + size_t outsize = 0; + gboolean eos = FALSE; g_return_val_if_fail (GST_IS_VIDEO_MIXER (mix), GST_FLOW_ERROR); @@ -1445,6 +1500,7 @@ static gboolean forward_event (GstVideoMixer * mix, GstEvent * event) { gboolean ret; + GstIterator *it; GValue vret = { 0 }; @@ -1470,6 +1526,7 @@ static gboolean gst_videomixer_src_event (GstPad * pad, GstEvent * event) { GstVideoMixer *mix; + gboolean result; mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); @@ -1482,7 +1539,9 @@ gst_videomixer_src_event (GstPad * pad, GstEvent * event) case GST_EVENT_SEEK: { GstSeekFlags flags; + GstSeekType curtype; + gint64 cur; /* parse the seek parameters */ @@ -1530,6 +1589,7 @@ static gboolean gst_videomixer_sink_event (GstPad * pad, GstEvent * event) { GstVideoMixer *videomixer; + gboolean ret; videomixer = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); @@ -1595,6 +1655,7 @@ static GstStateChangeReturn gst_videomixer_change_state (GstElement * element, GstStateChange transition) { GstVideoMixer *mix; + GstStateChangeReturn ret; g_return_val_if_fail (GST_IS_VIDEO_MIXER (element), GST_STATE_CHANGE_FAILURE); -- 2.7.4