diff --git a/gst/gstpad.c b/gst/gstpad.c index c6f9b98a7d..5f53460db7 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -741,7 +741,7 @@ gst_pad_set_formats_function (GstPad *pad, GstPadFormatsFunction formats) */ void gst_pad_set_link_function (GstPad *pad, - GstPadLinkFunction link) + GstPadLinkFunction link) { g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_REAL_PAD (pad)); @@ -751,6 +751,25 @@ 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. + * @link: the #GstPadLinkFunction to set. + * + * Sets the given unlink function for the pad. It will be called + * when the pad is unlinked from its peer. + */ +void +gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction link) +{ + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_REAL_PAD (pad)); + + GST_RPAD_UNLINKFUNC (pad) = link; + GST_DEBUG (GST_CAT_PADS, "unlinkfunc for %s:%s set to %s", + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link)); +} + /** * gst_pad_set_getcaps_function: * @pad: a #GstPad to set the getcaps function for. diff --git a/gst/gstpad.h b/gst/gstpad.h index 99f59738fd..ecdb30cf71 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; @@ -263,6 +265,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 link); gboolean gst_pad_link (GstPad *srcpad, GstPad *sinkpad); gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps);