This commit is contained in:
Akkariin Meiko
2022-03-12 03:16:09 +08:00
Unverified
parent 12b76e0c7a
commit 27c4ec74a1
10075 changed files with 5122287 additions and 1 deletions
@@ -0,0 +1,126 @@
---
title: Things to check when writing an element
...
# Things to check when writing an element
This chapter contains a fairly random selection of things to take care
of when writing an element. It's up to you how far you're going to stick
to those guidelines. However, keep in mind that when you're writing an
element and hope for it to be included in the mainstream GStreamer
distribution, it *has to* meet those requirements. As far as possible,
we will try to explain why those requirements are set.
## About states
- Make sure the state of an element gets reset when going to `NULL`.
Ideally, this should set all object properties to their original
state. This function should also be called from \_init.
- Make sure an element forgets *everything* about its contained stream
when going from `PAUSED` to `READY`. In `READY`, all stream states
are reset. An element that goes from `PAUSED` to `READY` and back to
`PAUSED` should start reading the stream from the start again.
- People that use `gst-launch` for testing have the tendency to not
care about cleaning up. This is *wrong*. An element should be tested
using various applications, where testing not only means to “make
sure it doesn't crash”, but also to test for memory leaks using
tools such as `valgrind`. Elements have to be reusable in a pipeline
after having been reset.
## Debugging
- Elements should *never* use their standard output for debugging
(using functions such as `printf
()` or `g_print ()`). Instead, elements should use the logging
functions provided by GStreamer, named `GST_DEBUG ()`, `GST_LOG ()`,
`GST_INFO ()`, `GST_WARNING ()` and `GST_ERROR ()`. The various
logging levels can be turned on and off at runtime and can thus be
used for solving issues as they turn up. Instead of `GST_LOG ()` (as
an example), you can also use `GST_LOG_OBJECT
()` to print the object that you're logging output for.
- Ideally, elements should use their own debugging category. Most
elements use the following code to do that:
``` c
GST_DEBUG_CATEGORY_STATIC (myelement_debug);
#define GST_CAT_DEFAULT myelement_debug
[..]
static void
gst_myelement_class_init (GstMyelementClass *klass)
{
[..]
GST_DEBUG_CATEGORY_INIT (myelement_debug, "myelement",
0, "My own element");
}
```
At runtime, you can turn on debugging using the commandline option
`--gst-debug=myelement:5`.
- Elements should use GST\_DEBUG\_FUNCPTR when setting pad functions
or overriding element class methods, for example:
``` c
gst_pad_set_event_func (myelement->srcpad,
GST_DEBUG_FUNCPTR (my_element_src_event));
```
This makes debug output much easier to read later on.
- Elements that are aimed for inclusion into one of the GStreamer
modules should ensure consistent naming of the element name,
structures and function names. For example, if the element type is
GstYellowFooDec, functions should be prefixed with
gst\_yellow\_foo\_dec\_ and the element should be registered as
'yellowfoodec'. Separate words should be separate in this scheme, so
it should be GstFooDec and gst\_foo\_dec, and not GstFoodec and
gst\_foodec.
## Querying, events and the like
- All elements to which it applies (sources, sinks, demuxers) should
implement query functions on their pads, so that applications and
neighbour elements can request the current position, the stream
length (if known) and so on.
- Elements should make sure they forward events they do not handle
with gst\_pad\_event\_default (pad, parent, event) instead of just
dropping them. Events should never be dropped unless specifically
intended.
- Elements should make sure they forward queries they do not handle
with gst\_pad\_query\_default (pad, parent, query) instead of just
dropping them.
## Testing your element
- `gst-launch` is *not* a good tool to show that your element is
finished. Applications such as Rhythmbox and Totem (for GNOME) or
AmaroK (for KDE) *are*. `gst-launch` will not test various things
such as proper clean-up on reset, event handling, querying and so
on.
- Parsers and demuxers should make sure to check their input. Input
cannot be trusted. Prevent possible buffer overflows and the like.
Feel free to error out on unrecoverable stream errors. Test your
demuxer using stream corruption elements such as `breakmydata`
(included in gst-plugins). It will randomly insert, delete and
modify bytes in a stream, and is therefore a good test for
robustness. If your element crashes when adding this element, your
element needs fixing. If it errors out properly, it's good enough.
Ideally, it'd just continue to work and forward data as much as
possible.
- Demuxers should not assume that seeking works. Be prepared to work
with unseekable input streams (e.g. network sources) as well.
- Sources and sinks should be prepared to be assigned another clock
then the one they expose themselves. Always use the provided clock
for synchronization, else you'll get A/V sync issues.
@@ -0,0 +1,7 @@
---
title: Appendices
...
# Appendices
This chapter contains things that don't belong anywhere else.
@@ -0,0 +1,37 @@
---
title: GStreamer licensing
...
# GStreamer licensing
## How to license the code you write for GStreamer
GStreamer is a plugin-based framework licensed under the LGPL. The
reason for this choice in licensing is to ensure that everyone can use
GStreamer to build applications using licenses of their choice.
To keep this policy viable, the GStreamer community has made a few
licensing rules for code to be included in GStreamer's core or
GStreamer's official modules, like our plugin packages. We require that
all code going into our core package is LGPL. For the plugin code, we
require the use of the LGPL for all plugins written from scratch or
linking to external libraries. The only exception to this is when
plugins contain older code under more liberal licenses (like the MPL or
BSD). They can use those licenses instead and will still be considered
for inclusion. We do not accept GPL code to be added to our plugins
module, but we do accept LGPL-licensed plugins using an external GPL
library. The reason for demanding plugins be licensed under the LGPL,
even when using a GPL library, is that other developers might want to
use the plugin code as a template for plugins linking to non-GPL
libraries.
We also plan on splitting out the plugins using GPL libraries into a
separate package eventually and implement a system which makes sure an
application will not be able to access these plugins unless it uses some
special code to do so. The point of this is not to block GPL-licensed
plugins from being used and developed, but to make sure people are not
unintentionally violating the GPL license of said plugins.
This advisory is part of a bigger advisory with a FAQ which you can find
on the [GStreamer
website](http://gstreamer.freedesktop.org/documentation/licensing.html)
@@ -0,0 +1,9 @@
---
title: Porting 0.10 plug-ins to 1.0
...
# Porting 0.10 plug-ins to 1.0
You can find the list of changes in the [Porting
to 1.0](http://gitlab.freedesktop.org/gstreamer/gstreamer/raw/master/docs/random/porting-to-1.0.txt)
document.