subtitleoverlay: Use new, public ghostpad functions

This commit is contained in:
Sebastian Dröge 2011-05-06 17:01:53 +02:00
parent cf3cc57ca7
commit 45bf51dcdf
2 changed files with 24 additions and 65 deletions

View file

@ -1589,7 +1589,7 @@ gst_subtitle_overlay_src_proxy_chain (GstPad * proxypad, GstBuffer * buffer)
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
ret = self->src_proxy_chain (proxypad, buffer); ret = gst_proxy_pad_chain_default (proxypad, buffer);
if (IS_VIDEO_CHAIN_IGNORE_ERROR (ret)) { if (IS_VIDEO_CHAIN_IGNORE_ERROR (ret)) {
GST_ERROR_OBJECT (self, "Downstream chain error: %s", GST_ERROR_OBJECT (self, "Downstream chain error: %s",
@ -1626,7 +1626,7 @@ gst_subtitle_overlay_src_proxy_event (GstPad * proxypad, GstEvent * event)
event = NULL; event = NULL;
ret = TRUE; ret = TRUE;
} else { } else {
ret = self->src_proxy_event (proxypad, event); ret = gst_proxy_pad_event_default (proxypad, event);
event = NULL; event = NULL;
} }
@ -1664,7 +1664,7 @@ gst_subtitle_overlay_video_sink_setcaps (GstPad * pad, GstCaps * caps)
} }
GST_SUBTITLE_OVERLAY_UNLOCK (self); GST_SUBTITLE_OVERLAY_UNLOCK (self);
ret = self->video_sink_setcaps (pad, caps); ret = gst_ghost_pad_setcaps_default (pad, caps);
out: out:
gst_object_unref (self); gst_object_unref (self);
@ -1684,7 +1684,7 @@ gst_subtitle_overlay_video_sink_event (GstPad * pad, GstEvent * event)
self->fps_n = self->fps_d = 0; self->fps_n = self->fps_d = 0;
} }
ret = self->video_sink_event (pad, gst_event_ref (event)); ret = gst_proxy_pad_event_default (pad, gst_event_ref (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) { if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
gboolean update; gboolean update;
@ -1722,7 +1722,7 @@ static GstFlowReturn
gst_subtitle_overlay_video_sink_chain (GstPad * pad, GstBuffer * buffer) gst_subtitle_overlay_video_sink_chain (GstPad * pad, GstBuffer * buffer)
{ {
GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (GST_PAD_PARENT (pad)); GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (GST_PAD_PARENT (pad));
GstFlowReturn ret = self->video_sink_chain (pad, buffer); GstFlowReturn ret = gst_proxy_pad_chain_default (pad, buffer);
if (G_UNLIKELY (self->downstream_chain_error) || self->passthrough_identity) { if (G_UNLIKELY (self->downstream_chain_error) || self->passthrough_identity) {
return ret; return ret;
@ -1755,7 +1755,7 @@ gst_subtitle_overlay_subtitle_sink_chain (GstPad * pad, GstBuffer * buffer)
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} else { } else {
GstFlowReturn ret = self->subtitle_sink_chain (pad, buffer); GstFlowReturn ret = gst_proxy_pad_chain_default (pad, buffer);
if (IS_SUBTITLE_CHAIN_IGNORE_ERROR (ret)) { if (IS_SUBTITLE_CHAIN_IGNORE_ERROR (ret)) {
GST_DEBUG_OBJECT (self, "Subtitle chain error: %s", GST_DEBUG_OBJECT (self, "Subtitle chain error: %s",
@ -1826,7 +1826,7 @@ gst_subtitle_overlay_subtitle_sink_setcaps (GstPad * pad, GstCaps * caps)
if (target && gst_pad_accept_caps (target, caps)) { if (target && gst_pad_accept_caps (target, caps)) {
GST_DEBUG_OBJECT (pad, "Target accepts caps"); GST_DEBUG_OBJECT (pad, "Target accepts caps");
ret = self->subtitle_sink_setcaps (pad, caps); ret = gst_ghost_pad_setcaps_default (pad, caps);
GST_SUBTITLE_OVERLAY_UNLOCK (self); GST_SUBTITLE_OVERLAY_UNLOCK (self);
goto out; goto out;
} }
@ -1887,7 +1887,7 @@ gst_subtitle_overlay_subtitle_sink_link (GstPad * pad, GstPad * peer)
gst_caps_unref (caps); gst_caps_unref (caps);
} }
ret = self->subtitle_sink_link (pad, peer); ret = gst_ghost_pad_link_default (pad, peer);
gst_object_unref (self); gst_object_unref (self);
return ret; return ret;
@ -1906,7 +1906,7 @@ gst_subtitle_overlay_subtitle_sink_unlink (GstPad * pad)
GST_DEBUG_OBJECT (pad, "Pad unlinking"); GST_DEBUG_OBJECT (pad, "Pad unlinking");
gst_caps_replace (&self->subcaps, NULL); gst_caps_replace (&self->subcaps, NULL);
self->subtitle_sink_unlink (pad); gst_ghost_pad_unlink_default (pad);
GST_SUBTITLE_OVERLAY_LOCK (self); GST_SUBTITLE_OVERLAY_LOCK (self);
self->subtitle_error = FALSE; self->subtitle_error = FALSE;
@ -1993,7 +1993,7 @@ gst_subtitle_overlay_subtitle_sink_event (GstPad * pad, GstEvent * event)
break; break;
} }
ret = self->subtitle_sink_event (pad, gst_event_ref (event)); ret = gst_proxy_pad_event_default (pad, gst_event_ref (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) { if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
gboolean update; gboolean update;
@ -2031,7 +2031,6 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self,
GstSubtitleOverlayClass * klass) GstSubtitleOverlayClass * klass)
{ {
GstPadTemplate *templ; GstPadTemplate *templ;
GstIterator *it;
GstPad *proxypad = NULL; GstPad *proxypad = NULL;
self->lock = g_mutex_new (); self->lock = g_mutex_new ();
@ -2039,67 +2038,44 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self,
templ = gst_static_pad_template_get (&srctemplate); templ = gst_static_pad_template_get (&srctemplate);
self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ); self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ);
it = gst_pad_iterate_internal_links (self->srcpad);
if (G_UNLIKELY (!it proxypad =
|| gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (self->srcpad)));
|| proxypad == NULL)) { gst_pad_set_event_function (proxypad,
GST_ERROR_OBJECT (self, "Failed to get proxypad of srcpad"); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_event));
} else { gst_pad_set_chain_function (proxypad,
self->src_proxy_event = GST_PAD_EVENTFUNC (proxypad); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_chain));
gst_pad_set_event_function (proxypad, gst_object_unref (proxypad);
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_event));
self->src_proxy_chain = GST_PAD_CHAINFUNC (proxypad);
gst_pad_set_chain_function (proxypad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_chain));
gst_object_unref (proxypad);
}
if (it)
gst_iterator_free (it);
gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad); gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad);
templ = gst_static_pad_template_get (&video_sinktemplate); templ = gst_static_pad_template_get (&video_sinktemplate);
self->video_sinkpad = self->video_sinkpad =
gst_ghost_pad_new_no_target_from_template ("video_sink", templ); gst_ghost_pad_new_no_target_from_template ("video_sink", templ);
self->video_sink_event = GST_PAD_EVENTFUNC (self->video_sinkpad);
gst_pad_set_event_function (self->video_sinkpad, gst_pad_set_event_function (self->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_event)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_event));
self->video_sink_setcaps = GST_PAD_SETCAPSFUNC (self->video_sinkpad);
gst_pad_set_setcaps_function (self->video_sinkpad, gst_pad_set_setcaps_function (self->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_setcaps)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_setcaps));
self->video_sink_chain = GST_PAD_CHAINFUNC (self->video_sinkpad);
gst_pad_set_chain_function (self->video_sinkpad, gst_pad_set_chain_function (self->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_chain)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_chain));
proxypad = NULL; proxypad =
it = gst_pad_iterate_internal_links (self->video_sinkpad); GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
if (G_UNLIKELY (!it (self->video_sinkpad)));
|| gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK
|| proxypad == NULL)) {
GST_ERROR_OBJECT (self,
"Failed to get internally linked pad from video sinkpad");
}
if (it)
gst_iterator_free (it);
self->video_block_pad = proxypad; self->video_block_pad = proxypad;
gst_element_add_pad (GST_ELEMENT_CAST (self), self->video_sinkpad); gst_element_add_pad (GST_ELEMENT_CAST (self), self->video_sinkpad);
templ = gst_static_pad_template_get (&subtitle_sinktemplate); templ = gst_static_pad_template_get (&subtitle_sinktemplate);
self->subtitle_sinkpad = self->subtitle_sinkpad =
gst_ghost_pad_new_no_target_from_template ("subtitle_sink", templ); gst_ghost_pad_new_no_target_from_template ("subtitle_sink", templ);
self->subtitle_sink_link = GST_PAD_LINKFUNC (self->subtitle_sinkpad);
gst_pad_set_link_function (self->subtitle_sinkpad, gst_pad_set_link_function (self->subtitle_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_link)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_link));
self->subtitle_sink_unlink = GST_PAD_UNLINKFUNC (self->subtitle_sinkpad);
gst_pad_set_unlink_function (self->subtitle_sinkpad, gst_pad_set_unlink_function (self->subtitle_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_unlink)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_unlink));
self->subtitle_sink_event = GST_PAD_EVENTFUNC (self->subtitle_sinkpad);
gst_pad_set_event_function (self->subtitle_sinkpad, gst_pad_set_event_function (self->subtitle_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_event)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_event));
self->subtitle_sink_setcaps = GST_PAD_SETCAPSFUNC (self->subtitle_sinkpad);
gst_pad_set_setcaps_function (self->subtitle_sinkpad, gst_pad_set_setcaps_function (self->subtitle_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_setcaps)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_setcaps));
self->subtitle_sink_chain = GST_PAD_CHAINFUNC (self->subtitle_sinkpad);
gst_pad_set_chain_function (self->subtitle_sinkpad, gst_pad_set_chain_function (self->subtitle_sinkpad,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_chain)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_chain));
gst_pad_set_getcaps_function (self->subtitle_sinkpad, gst_pad_set_getcaps_function (self->subtitle_sinkpad,
@ -2108,16 +2084,9 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self,
GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_acceptcaps)); GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_acceptcaps));
gst_pad_set_bufferalloc_function (self->subtitle_sinkpad, NULL); gst_pad_set_bufferalloc_function (self->subtitle_sinkpad, NULL);
proxypad = NULL; proxypad =
it = gst_pad_iterate_internal_links (self->subtitle_sinkpad); GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
if (G_UNLIKELY (!it (self->subtitle_sinkpad)));
|| gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK
|| proxypad == NULL)) {
GST_ERROR_OBJECT (self,
"Failed to get internally linked pad from subtitle sinkpad");
}
if (it)
gst_iterator_free (it);
self->subtitle_block_pad = proxypad; self->subtitle_block_pad = proxypad;
gst_element_add_pad (GST_ELEMENT_CAST (self), self->subtitle_sinkpad); gst_element_add_pad (GST_ELEMENT_CAST (self), self->subtitle_sinkpad);

View file

@ -68,26 +68,16 @@ struct _GstSubtitleOverlay
gboolean do_async; gboolean do_async;
GstPad *srcpad; GstPad *srcpad;
GstPadEventFunction src_proxy_event;
GstPadChainFunction src_proxy_chain;
gboolean downstream_chain_error; gboolean downstream_chain_error;
GstPad *video_sinkpad; GstPad *video_sinkpad;
GstPad *video_block_pad; GstPad *video_block_pad;
GstPadSetCapsFunction video_sink_setcaps;
GstPadEventFunction video_sink_event;
GstPadChainFunction video_sink_chain;
gboolean video_sink_blocked; gboolean video_sink_blocked;
GstSegment video_segment; GstSegment video_segment;
gint fps_n, fps_d; gint fps_n, fps_d;
GstPad *subtitle_sinkpad; GstPad *subtitle_sinkpad;
GstPad *subtitle_block_pad; GstPad *subtitle_block_pad;
GstPadLinkFunction subtitle_sink_link;
GstPadUnlinkFunction subtitle_sink_unlink;
GstPadEventFunction subtitle_sink_event;
GstPadChainFunction subtitle_sink_chain;
GstPadSetCapsFunction subtitle_sink_setcaps;
gboolean subtitle_sink_blocked; gboolean subtitle_sink_blocked;
GstSegment subtitle_segment; GstSegment subtitle_segment;
gboolean subtitle_flush; gboolean subtitle_flush;