summaryrefslogtreecommitdiff
path: root/markdown
diff options
context:
space:
mode:
authorCarlos Eduardo R. B. Fonseca <cadubentzen@gmail.com>2017-09-21 19:56:34 -0300
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2017-09-21 21:02:42 -0400
commit14193ec3d78c4478953b1ab87afa4f6adfab6a9c (patch)
treefa472ae8324585925a67af86b3be467579de8cb9 /markdown
parent6fa607b01c28e7c251ed27c3bc56d3c3f95fa127 (diff)
plugin-development: syntax highlighting in code snippets
Signed-off-by: Carlos Eduardo R. B. Fonseca <cadubentzen@gmail.com> https://bugzilla.gnome.org/show_bug.cgi?id=788029
Diffstat (limited to 'markdown')
-rw-r--r--markdown/plugin-development/advanced/scheduling.md56
-rw-r--r--markdown/plugin-development/basics/boiler.md30
-rw-r--r--markdown/plugin-development/basics/states.md87
3 files changed, 89 insertions, 84 deletions
diff --git a/markdown/plugin-development/advanced/scheduling.md b/markdown/plugin-development/advanced/scheduling.md
index 336954b..470cd63 100644
--- a/markdown/plugin-development/advanced/scheduling.md
+++ b/markdown/plugin-development/advanced/scheduling.md
@@ -291,44 +291,46 @@ access:
The following example will show how a `_get_range
()`-function can be implemented in a source element:
- #include "filter.h"
- static GstFlowReturn
- gst_my_filter_get_range (GstPad * pad,
- GstObject * parent,
- guint64 offset,
- guint length,
- GstBuffer ** buf);
+```c
+#include "filter.h"
+static GstFlowReturn
+ gst_my_filter_get_range (GstPad * pad,
+ GstObject * parent,
+ guint64 offset,
+ guint length,
+ GstBuffer ** buf);
- G_DEFINE_TYPE (GstMyFilter, gst_my_filter, GST_TYPE_ELEMENT);
+G_DEFINE_TYPE (GstMyFilter, gst_my_filter, GST_TYPE_ELEMENT);
- static void
- gst_my_filter_init (GstMyFilter * filter)
- {
+static void
+gst_my_filter_init (GstMyFilter * filter)
+{
- [..]
+[..]
- gst_pad_set_getrange_function (filter->srcpad,
- gst_my_filter_get_range);
+ gst_pad_set_getrange_function (filter->srcpad,
+ gst_my_filter_get_range);
- [..]
- }
+[..]
+}
- static GstFlowReturn
- gst_my_filter_get_range (GstPad * pad,
- GstObject * parent,
- guint64 offset,
- guint length,
- GstBuffer ** buf)
- {
+static GstFlowReturn
+gst_my_filter_get_range (GstPad * pad,
+ GstObject * parent,
+ guint64 offset,
+ guint length,
+ GstBuffer ** buf)
+{
- GstMyFilter *filter = GST_MY_FILTER (parent);
+ GstMyFilter *filter = GST_MY_FILTER (parent);
- [.. here, you would fill *buf ..]
+ [.. here, you would fill *buf ..]
- return GST_FLOW_OK;
- }
+ return GST_FLOW_OK;
+}
+```
In practice, many elements that could theoretically do random access,
may in practice often be activated in push-mode scheduling anyway, since
diff --git a/markdown/plugin-development/basics/boiler.md b/markdown/plugin-development/basics/boiler.md
index fd17249..0eed936 100644
--- a/markdown/plugin-development/basics/boiler.md
+++ b/markdown/plugin-development/basics/boiler.md
@@ -262,20 +262,22 @@ a new pad from this template using `gst_pad_new_from_static_template
()`, you will need to declare the pad template as a global variable. More on
this subject in [Specifying the pads][pads].
- static GstStaticPadTemplate sink_factory = [..],
- src_factory = [..];
-
- static void
- gst_my_filter_class_init (GstMyFilterClass * klass)
- {
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- [..]
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
- }
+```c
+static GstStaticPadTemplate sink_factory = [..],
+ src_factory = [..];
+
+static void
+gst_my_filter_class_init (GstMyFilterClass * klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+[..]
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_factory));
+}
+```
The last argument in a template is its type or list of supported types.
In this example, we use 'ANY', which means that this element will accept
diff --git a/markdown/plugin-development/basics/states.md b/markdown/plugin-development/basics/states.md
index f37dcf3..86d4ae6 100644
--- a/markdown/plugin-development/basics/states.md
+++ b/markdown/plugin-development/basics/states.md
@@ -77,49 +77,50 @@ from one state to another.
Do not g\_assert for unhandled state changes; this is taken care of by
the GstElement base class.
- static GstStateChangeReturn
- gst_my_filter_change_state (GstElement *element, GstStateChange transition);
-
- static void
- gst_my_filter_class_init (GstMyFilterClass *klass)
- {
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- element_class->change_state = gst_my_filter_change_state;
- }
-
-
-
- static GstStateChangeReturn
- gst_my_filter_change_state (GstElement *element, GstStateChange transition)
- {
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstMyFilter *filter = GST_MY_FILTER (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (!gst_my_filter_allocate_memory (filter))
- return GST_STATE_CHANGE_FAILURE;
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- gst_my_filter_free_memory (filter);
- break;
- default:
- break;
- }
-
- return ret;
- }
-
+```c
+static GstStateChangeReturn
+gst_my_filter_change_state (GstElement *element, GstStateChange transition);
+
+static void
+gst_my_filter_class_init (GstMyFilterClass *klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+ element_class->change_state = gst_my_filter_change_state;
+}
+
+
+
+static GstStateChangeReturn
+gst_my_filter_change_state (GstElement *element, GstStateChange transition)
+{
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstMyFilter *filter = GST_MY_FILTER (element);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ if (!gst_my_filter_allocate_memory (filter))
+ return GST_STATE_CHANGE_FAILURE;
+ break;
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ return ret;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ gst_my_filter_free_memory (filter);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+```
Note that upwards (NULL=\>READY, READY=\>PAUSED, PAUSED=\>PLAYING) and
downwards (PLAYING=\>PAUSED, PAUSED=\>READY, READY=\>NULL) state changes
are handled in two separate blocks with the downwards state change