2 title: The event function
7 The event function notifies you of special events that happen in the
8 datastream (such as caps, end-of-stream, newsegment, tags, etc.). Events
9 can travel both upstream and downstream, so you can receive them on sink
10 pads as well as source pads.
12 Below follows a very simple event function that we install on the sink
17 static gboolean gst_my_filter_sink_event (GstPad *pad,
24 gst_my_filter_init (GstMyFilter * filter)
27 /* configure event function on the pad before adding
28 * the pad to the element */
29 gst_pad_set_event_function (filter->sinkpad,
30 gst_my_filter_sink_event);
35 gst_my_filter_sink_event (GstPad *pad,
40 GstMyFilter *filter = GST_MY_FILTER (parent);
42 switch (GST_EVENT_TYPE (event)) {
44 /* we should handle the format here */
46 /* push the event downstream */
47 ret = gst_pad_push_event (filter->srcpad, event);
50 /* end-of-stream, we should close down all stream leftovers here */
51 gst_my_filter_stop_processing (filter);
53 ret = gst_pad_event_default (pad, parent, event);
56 /* just call the default handler */
57 ret = gst_pad_event_default (pad, parent, event);
66 It is a good idea to call the default event handler
67 `gst_pad_event_default ()` for unknown events. Depending on the event
68 type, the default handler will forward the event or simply unref it. The
69 CAPS event is by default not forwarded so we need to do this in the
70 event handler ourselves.