diff --git a/gst/gstpad.c b/gst/gstpad.c index 45d3694a89..a4789db7da 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -760,6 +760,26 @@ gst_pad_set_link_function (GstPad *pad, GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link)); } +/** + * gst_pad_set_unlink_function: + * @pad: a #GstPad to set the unlink function for. + * @unlink: the #GstPadUnlinkFunction to set. + * + * Sets the given unlink function for the pad. It will be called + * when the pad is unlinked. + */ +void +gst_pad_set_unlink_function (GstPad *pad, + GstPadUnlinkFunction unlink) +{ + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_REAL_PAD (pad)); + + GST_RPAD_UNLINKFUNC (pad) = unlink; + GST_CAT_DEBUG (GST_CAT_PADS, "unlinkfunc for %s:%s set to %s", + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink)); +} + /** * gst_pad_set_getcaps_function: * @pad: a #GstPad to set the getcaps function for. @@ -841,6 +861,13 @@ gst_pad_unlink (GstPad *srcpad, g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) && (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK)); + if (GST_RPAD_UNLINKFUNC (srcpad)) { + GST_RPAD_UNLINKFUNC (srcpad) (srcpad); + } + if (GST_RPAD_UNLINKFUNC (sinkpad)) { + GST_RPAD_UNLINKFUNC (sinkpad) (sinkpad); + } + /* get the schedulers before we unlink */ src_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsrc)); sink_sched = gst_pad_get_scheduler (GST_PAD_CAST (realsink)); diff --git a/gst/gstpad.h b/gst/gstpad.h index 0280e503af..d335f5388c 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -147,6 +147,7 @@ typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad); typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad); typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstCaps *caps); +typedef void (*GstPadUnlinkFunction) (GstPad *pad); typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad, GstCaps *caps); typedef GstBufferPool* (*GstPadBufferPoolFunction) (GstPad *pad); @@ -189,6 +190,7 @@ struct _GstRealPad { GstPadDirection direction; GstPadLinkFunction linkfunc; + GstPadUnlinkFunction unlinkfunc; GstRealPad *peer; gpointer sched_private; @@ -264,6 +266,7 @@ struct _GstGhostPadClass { #define GST_RPAD_EVENTMASKFUNC(pad) (((GstRealPad *)(pad))->eventmaskfunc) #define GST_RPAD_LINKFUNC(pad) (((GstRealPad *)(pad))->linkfunc) +#define GST_RPAD_UNLINKFUNC(pad) (((GstRealPad *)(pad))->unlinkfunc) #define GST_RPAD_GETCAPSFUNC(pad) (((GstRealPad *)(pad))->getcapsfunc) #define GST_RPAD_BUFFERPOOLFUNC(pad) (((GstRealPad *)(pad))->bufferpoolfunc) @@ -426,6 +429,7 @@ const GstEventMask* gst_pad_get_event_masks_default (GstPad *pad); void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link); gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad); gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps); +void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink); gboolean gst_pad_link (GstPad *srcpad, GstPad *sinkpad); gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);