diff options
author | cadubentzen <cadubentzen@gmail.com> | 2017-09-21 16:56:14 -0300 |
---|---|---|
committer | Mathieu Duponchelle <mathieu.duponchelle@opencreed.com> | 2017-09-21 23:49:58 +0200 |
commit | 6fa607b01c28e7c251ed27c3bc56d3c3f95fa127 (patch) | |
tree | e58cd5b954a1e4ee890e3a4e9097a47f7ba767e9 | |
parent | 020bf14d03f01e48836d8c13e186e488755d5527 (diff) |
docs: syntax in event handling example in chainfn.md
Signed-off-by: cadubentzen <cadubentzen@gmail.com>
https://bugzilla.gnome.org/show_bug.cgi?id=788023
-rw-r--r-- | markdown/plugin-development/basics/chainfn.md | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/markdown/plugin-development/basics/chainfn.md b/markdown/plugin-development/basics/chainfn.md index 33db7f6..a08b42d 100644 --- a/markdown/plugin-development/basics/chainfn.md +++ b/markdown/plugin-development/basics/chainfn.md @@ -52,57 +52,59 @@ want to additionally specify an event handling function, which will be called when stream-events are sent (such as caps, end-of-stream, newsegment, tags, etc.). - static void - gst_my_filter_init (GstMyFilter * filter) - { - [..] - gst_pad_set_event_function (filter->sinkpad, - gst_my_filter_sink_event); - [..] - } - - - - static gboolean - gst_my_filter_sink_event (GstPad *pad, - GstObject *parent, - GstEvent *event) - { - GstMyFilter *filter = GST_MY_FILTER (parent); - - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_CAPS: - /* we should handle the format here */ - break; - case GST_EVENT_EOS: - /* end-of-stream, we should close down all stream leftovers here */ - gst_my_filter_stop_processing (filter); - break; - default: - break; - } - - return gst_pad_event_default (pad, parent, event); - } - - static GstFlowReturn - gst_my_filter_chain (GstPad *pad, - GstObject *parent, - GstBuffer *buf) - { - GstMyFilter *filter = GST_MY_FILTER (parent); - GstBuffer *outbuf; - - outbuf = gst_my_filter_process_data (filter, buf); - gst_buffer_unref (buf); - if (!outbuf) { - /* something went wrong - signal an error */ - GST_ELEMENT_ERROR (GST_ELEMENT (filter), STREAM, FAILED, (NULL), (NULL)); - return GST_FLOW_ERROR; - } - - return gst_pad_push (filter->srcpad, outbuf); - } +```c +static void +gst_my_filter_init (GstMyFilter * filter) +{ +[..] + gst_pad_set_event_function (filter->sinkpad, + gst_my_filter_sink_event); +[..] +} + + + +static gboolean +gst_my_filter_sink_event (GstPad *pad, + GstObject *parent, + GstEvent *event) +{ + GstMyFilter *filter = GST_MY_FILTER (parent); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_CAPS: + /* we should handle the format here */ + break; + case GST_EVENT_EOS: + /* end-of-stream, we should close down all stream leftovers here */ + gst_my_filter_stop_processing (filter); + break; + default: + break; + } + + return gst_pad_event_default (pad, parent, event); +} + +static GstFlowReturn +gst_my_filter_chain (GstPad *pad, + GstObject *parent, + GstBuffer *buf) +{ + GstMyFilter *filter = GST_MY_FILTER (parent); + GstBuffer *outbuf; + + outbuf = gst_my_filter_process_data (filter, buf); + gst_buffer_unref (buf); + if (!outbuf) { + /* something went wrong - signal an error */ + GST_ELEMENT_ERROR (GST_ELEMENT (filter), STREAM, FAILED, (NULL), (NULL)); + return GST_FLOW_ERROR; + } + + return gst_pad_push (filter->srcpad, outbuf); +} +``` In some cases, it might be useful for an element to have control over the input data rate, too. In that case, you probably want to write a |