2016-06-04 06:03:13 +00:00
|
|
|
---
|
|
|
|
title: Preface
|
|
|
|
...
|
|
|
|
|
|
|
|
# Preface
|
|
|
|
|
2016-06-17 22:41:07 +00:00
|
|
|
## What is GStreamer?
|
2016-06-04 06:03:13 +00:00
|
|
|
|
|
|
|
GStreamer is a framework for creating streaming media applications. The
|
|
|
|
fundamental design comes from the video pipeline at Oregon Graduate
|
|
|
|
Institute, as well as some ideas from DirectShow.
|
|
|
|
|
|
|
|
GStreamer's development framework makes it possible to write any type of
|
|
|
|
streaming multimedia application. The GStreamer framework is designed to
|
|
|
|
make it easy to write applications that handle audio or video or both.
|
|
|
|
It isn't restricted to audio and video, and can process any kind of data
|
|
|
|
flow. The pipeline design is made to have little overhead above what the
|
|
|
|
applied filters induce. This makes GStreamer a good framework for
|
|
|
|
designing even high-end audio applications which put high demands on
|
|
|
|
latency or performance.
|
|
|
|
|
|
|
|
One of the most obvious uses of GStreamer is using it to build a media
|
|
|
|
player. GStreamer already includes components for building a media
|
|
|
|
player that can support a very wide variety of formats, including MP3,
|
|
|
|
Ogg/Vorbis, MPEG-1/2, AVI, Quicktime, mod, and more. GStreamer, however,
|
|
|
|
is much more than just another media player. Its main advantages are
|
|
|
|
that the pluggable components can be mixed and matched into arbitrary
|
|
|
|
pipelines so that it's possible to write a full-fledged video or audio
|
|
|
|
editing application.
|
|
|
|
|
|
|
|
The framework is based on plugins that will provide the various codec
|
|
|
|
and other functionality. The plugins can be linked and arranged in a
|
|
|
|
pipeline. This pipeline defines the flow of the data.
|
|
|
|
|
|
|
|
The GStreamer core function is to provide a framework for plugins, data
|
|
|
|
flow, synchronization and media type handling/negotiation. It also
|
|
|
|
provides an API to write applications using the various plugins.
|
|
|
|
|
2016-06-17 22:41:07 +00:00
|
|
|
## Who Should Read This Guide?
|
2016-06-04 06:03:13 +00:00
|
|
|
|
|
|
|
This guide explains how to write new modules for GStreamer. The guide is
|
|
|
|
relevant to several groups of people:
|
|
|
|
|
|
|
|
- Anyone who wants to add support for new ways of processing data in
|
|
|
|
GStreamer. For example, a person in this group might want to create
|
|
|
|
a new data format converter, a new visualization tool, or a new
|
|
|
|
decoder or encoder.
|
|
|
|
|
|
|
|
- Anyone who wants to add support for new input and output devices.
|
|
|
|
For example, people in this group might want to add the ability to
|
|
|
|
write to a new video output system or read data from a digital
|
|
|
|
camera or special microphone.
|
|
|
|
|
|
|
|
- Anyone who wants to extend GStreamer in any way. You need to have an
|
|
|
|
understanding of how the plugin system works before you can
|
|
|
|
understand the constraints that the plugin system places on the rest
|
|
|
|
of the code. Also, you might be surprised after reading this at how
|
|
|
|
much can be done with plugins.
|
|
|
|
|
|
|
|
This guide is not relevant to you if you only want to use the existing
|
|
|
|
functionality of GStreamer, or if you just want to use an application
|
|
|
|
that uses GStreamer. If you are only interested in using existing
|
|
|
|
plugins to write a new application - and there are quite a lot of
|
|
|
|
plugins already - you might want to check the *GStreamer Application
|
|
|
|
Development Manual*. If you are just trying to get help with a GStreamer
|
|
|
|
application, then you should check with the user manual for that
|
|
|
|
particular application.
|
|
|
|
|
2016-06-17 22:41:07 +00:00
|
|
|
## Preliminary Reading
|
2016-06-04 06:03:13 +00:00
|
|
|
|
|
|
|
This guide assumes that you are somewhat familiar with the basic
|
|
|
|
workings of GStreamer. For a gentle introduction to programming concepts
|
|
|
|
in GStreamer, you may wish to read the *GStreamer Application
|
|
|
|
Development Manual* first. Also check out the other documentation
|
|
|
|
available on the [GStreamer web
|
|
|
|
site](http://gstreamer.freedesktop.org/documentation/).
|
|
|
|
|
|
|
|
In order to understand this manual, you will need to have a basic
|
|
|
|
understanding of the C language. Since GStreamer adheres to the GObject
|
|
|
|
programming model, this guide also assumes that you understand the
|
|
|
|
basics of [GObject](http://developer.gnome.org/gobject/stable/pt01.html)
|
|
|
|
programming. You may also want to have a look at Eric Harlow's book
|
|
|
|
*Developing Linux Applications with GTK+ and GDK*.
|
|
|
|
|
2016-06-17 22:41:07 +00:00
|
|
|
## Structure of This Guide
|
2016-06-04 06:03:13 +00:00
|
|
|
|
|
|
|
To help you navigate through this guide, it is divided into several
|
|
|
|
large parts. Each part addresses a particular broad topic concerning
|
|
|
|
GStreamer plugin development. The parts of this guide are laid out in
|
|
|
|
the following order:
|
|
|
|
|
2016-11-15 13:14:26 +00:00
|
|
|
- [Building a Plugin][building] - Introduction to the
|
2016-06-04 06:03:13 +00:00
|
|
|
structure of a plugin, using an example audio filter for
|
|
|
|
illustration.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
This part covers all the basic steps you generally need to perform
|
|
|
|
to build a plugin, such as registering the element with GStreamer
|
|
|
|
and setting up the basics so it can receive data from and send data
|
|
|
|
to neighbour elements. The discussion begins by giving examples of
|
|
|
|
generating the basic structures and registering an element in
|
2016-11-15 13:14:26 +00:00
|
|
|
[Constructing the Boilerplate][boilerplate]. Then,
|
2016-06-04 06:03:13 +00:00
|
|
|
you will learn how to write the code to get a basic filter plugin
|
2016-11-15 13:14:26 +00:00
|
|
|
working in [Specifying the pads][pads], [The chain function][chainfunc]
|
|
|
|
and [What are states?][states].
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
After that, we will show some of the GObject concepts on how to make
|
|
|
|
an element configurable for applications and how to do
|
|
|
|
application-element interaction in [Adding
|
2016-11-15 13:14:26 +00:00
|
|
|
Properties][properties] and [Signals][signals]. Next, you will learn to
|
2016-06-04 06:03:13 +00:00
|
|
|
build a quick test application to test all that you've just learned
|
2016-11-15 13:14:26 +00:00
|
|
|
in [Building a Test Application][testapp]. We
|
2016-06-04 06:03:13 +00:00
|
|
|
will just touch upon basics here. For full-blown application
|
|
|
|
development, you should look at [the Application Development
|
2016-11-14 14:41:57 +00:00
|
|
|
Manual](application-development/index.md).
|
2016-06-04 06:03:13 +00:00
|
|
|
|
2016-11-15 13:14:26 +00:00
|
|
|
- [Advanced Filter Concepts][advanced] - Information on
|
2016-06-04 06:03:13 +00:00
|
|
|
advanced features of GStreamer plugin development.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
After learning about the basic steps, you should be able to create a
|
|
|
|
functional audio or video filter plugin with some nice features.
|
|
|
|
However, GStreamer offers more for plugin writers. This part of the
|
|
|
|
guide includes chapters on more advanced topics, such as scheduling,
|
|
|
|
media type definitions in GStreamer, clocks, interfaces and tagging.
|
|
|
|
Since these features are purpose-specific, you can read them in any
|
|
|
|
order, most of them don't require knowledge from other sections.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
The first chapter, named [Different scheduling
|
2016-11-15 13:14:26 +00:00
|
|
|
modes][scheduling], will explain some of the basics of
|
2016-06-04 06:03:13 +00:00
|
|
|
element scheduling. It is not very in-depth, but is mostly some sort
|
|
|
|
of an introduction on why other things work as they do. Read this
|
|
|
|
chapter if you're interested in GStreamer internals. Next, we will
|
|
|
|
apply this knowledge and discuss another type of data transmission
|
2016-11-15 13:14:26 +00:00
|
|
|
than what you learned in [The chain function][chainfunc]: [Different
|
|
|
|
scheduling modes][scheduling]. Loop-based elements will give you
|
2016-06-04 06:03:13 +00:00
|
|
|
more control over input rate. This is useful when writing, for
|
|
|
|
example, muxers or demuxers.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-11-26 11:47:34 +00:00
|
|
|
Next, we will discuss media identification in GStreamer in [Media Types
|
|
|
|
and Properties][media-types]. You will learn how to
|
2016-06-04 06:03:13 +00:00
|
|
|
define new media types and get to know a list of standard media
|
|
|
|
types defined in GStreamer.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
In the next chapter, you will learn the concept of request- and
|
|
|
|
sometimes-pads, which are pads that are created dynamically, either
|
|
|
|
because the application asked for it (request) or because the media
|
|
|
|
stream requires it (sometimes). This will be in [Request and
|
2016-11-15 13:14:26 +00:00
|
|
|
Sometimes pads][request-pads].
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-11-15 13:14:26 +00:00
|
|
|
The next chapter, [Clocking][clocks], will
|
2016-06-04 06:03:13 +00:00
|
|
|
explain the concept of clocks in GStreamer. You need this
|
|
|
|
information when you want to know how elements should achieve
|
|
|
|
audio/video synchronization.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
The next few chapters will discuss advanced ways of doing
|
|
|
|
application-element interaction. Previously, we learned on the
|
2016-11-15 13:14:26 +00:00
|
|
|
GObject-ways of doing this in [Adding Properties][properties] and
|
|
|
|
[Signals][signals]. We will discuss dynamic
|
2016-06-04 06:03:13 +00:00
|
|
|
parameters, which are a way of defining element behaviour over time
|
2016-11-15 13:14:26 +00:00
|
|
|
in advance, in [Supporting Dynamic Parameters][dynamic-params].
|
|
|
|
Next, you will learn about interfaces in [Interfaces][interfaces].
|
|
|
|
Interfaces are very target- specific ways of application-element
|
|
|
|
interaction, based on GObject's GInterface. Lastly, you will learn about
|
|
|
|
how metadata is handled in GStreamer in [Tagging (Metadata and
|
|
|
|
Streaminfo)][tagging].
|
|
|
|
|
|
|
|
The last chapter, [Events: Seeking, Navigation and More][events], will
|
|
|
|
discuss the concept of events in GStreamer. Events are another way of
|
|
|
|
doing application-element interaction. They take care of seeking, for
|
2019-03-27 09:43:09 +00:00
|
|
|
example. They are also yet another way in which elements
|
2016-06-04 06:03:13 +00:00
|
|
|
interact with each other, such as letting each other know about
|
|
|
|
media stream discontinuities, forwarding tags inside a pipeline and
|
|
|
|
so on.
|
|
|
|
|
2016-11-15 13:14:26 +00:00
|
|
|
- [Creating special element types][element-types] - Explanation of
|
2016-06-04 06:03:13 +00:00
|
|
|
writing other plugin types.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
Because the first two parts of the guide use an audio filter as an
|
|
|
|
example, the concepts introduced apply to filter plugins. But many
|
|
|
|
of the concepts apply equally to other plugin types, including
|
|
|
|
sources, sinks, and autopluggers. This part of the guide presents
|
|
|
|
the issues that arise when working on these more specialized plugin
|
|
|
|
types. The chapter starts with a special focus on elements that can
|
2016-11-15 13:14:26 +00:00
|
|
|
be written using a base-class ([Pre-made base classes][base-classes]),
|
|
|
|
and later also goes into writing special types of elements in [Writing a
|
|
|
|
Demuxer or Parser][one-to-n], [Writing a N-to-1 Element or Muxer][n-to-one]
|
|
|
|
and [Writing a Manager][manager].
|
2016-06-04 06:03:13 +00:00
|
|
|
|
2016-11-15 13:14:26 +00:00
|
|
|
- [Appendices][appendix] - Further information for plugin developers.
|
2016-11-05 08:18:49 +00:00
|
|
|
|
2016-06-04 06:03:13 +00:00
|
|
|
The appendices contain some information that stubbornly refuses to
|
|
|
|
fit cleanly in other sections of the guide. Most of this section is
|
|
|
|
not yet finished.
|
|
|
|
|
|
|
|
The remainder of this introductory part of the guide presents a short
|
|
|
|
overview of the basic concepts involved in GStreamer plugin development.
|
2016-11-15 13:14:26 +00:00
|
|
|
Topics covered include [Elements and Plugins][intro-elements],
|
|
|
|
[Pads][intro-pads], [GstMiniObject, Buffers and Events][intro-miniobjects]
|
|
|
|
and [Media types and Properties][intro-mediatypes]. If you are already
|
|
|
|
familiar with this information, you can use this short overview to
|
|
|
|
refresh your memory, or you can skip to [Building a Plugin][building].
|
2016-06-04 06:03:13 +00:00
|
|
|
|
2019-03-27 09:43:09 +00:00
|
|
|
As you can see, there's a lot to learn, so let's get started\!
|
2016-06-04 06:03:13 +00:00
|
|
|
|
|
|
|
- Creating compound and complex elements by extending from a GstBin.
|
|
|
|
This will allow you to create plugins that have other plugins
|
|
|
|
embedded in them.
|
|
|
|
|
|
|
|
- Adding new media types to the registry along with typedetect
|
|
|
|
functions. This will allow your plugin to operate on a completely
|
|
|
|
new media type.
|
2016-11-15 13:14:26 +00:00
|
|
|
|
2016-11-16 09:38:18 +00:00
|
|
|
[building]: plugin-development/basics/index.md
|
|
|
|
[boilerplate]: plugin-development/basics/boiler.md
|
|
|
|
[pads]: plugin-development/basics/pads.md
|
|
|
|
[chainfunc]: plugin-development/basics/chainfn.md
|
2016-11-19 21:30:28 +00:00
|
|
|
[states]: plugin-development/basics/states.md
|
2016-11-16 09:38:18 +00:00
|
|
|
[properties]: plugin-development/basics/args.md
|
|
|
|
[signals]: plugin-development/basics/signals.md
|
|
|
|
[testapp]: plugin-development/basics/testapp.md
|
2016-11-15 13:14:26 +00:00
|
|
|
[advanced]: plugin-development/advanced/index.md
|
|
|
|
[scheduling]: plugin-development/advanced/scheduling.md
|
2016-11-26 11:47:34 +00:00
|
|
|
[media-types]: plugin-development/advanced/media-types.md
|
2016-11-15 13:14:26 +00:00
|
|
|
[request-pads]: plugin-development/advanced/request.md
|
|
|
|
[clocks]: plugin-development/advanced/clock.md
|
|
|
|
[dynamic-params]: plugin-development/advanced/dparams.md
|
|
|
|
[interfaces]: plugin-development/advanced/interfaces.md
|
|
|
|
[tagging]: plugin-development/advanced/tagging.md
|
|
|
|
[events]: plugin-development/advanced/events.md
|
2016-11-16 09:27:05 +00:00
|
|
|
[element-types]: plugin-development/element-types/index.md
|
2016-11-27 12:37:11 +00:00
|
|
|
[base-classes]: plugin-development/element-types/base-classes.md
|
|
|
|
[one-to-n]: plugin-development/element-types/one-to-n.md
|
|
|
|
[n-to-one]: plugin-development/element-types/n-to-one.md
|
2016-11-16 09:27:05 +00:00
|
|
|
[manager]: plugin-development/element-types/manager.md
|
2016-11-15 13:14:26 +00:00
|
|
|
[appendix]: plugin-development/appendix/index.md
|
|
|
|
[intro-elements]: plugin-development/introduction/basics.md#elements-and-plugins
|
|
|
|
[intro-pads]: plugin-development/introduction/basics.md#pads
|
|
|
|
[intro-miniobjects]: plugin-development/introduction/basics.md#gstminiobject-buffers-and-events
|
|
|
|
[intro-mediatypes]: plugin-development/introduction/basics.md#media-types-and-properties
|