1 <chapter id="chapter-motivation">
2 <title>Design principles</title>
6 Linux has historically lagged behind other operating systems in the
7 multimedia arena. Microsoft's <trademark>Windows</trademark> and
8 Apple's <trademark>MacOS</trademark> both have strong support for
9 multimedia devices, multimedia content creation, playback, and
10 realtime processing. Linux, on the other hand, has a poorly integrated
11 collection of multimedia utilities and applications available, which
12 can hardly compete with the professional level of software available
13 for MS Windows and MacOS.
16 GStreamer was designed to provide a solution to the current Linux media
20 <sect1 id="section-motivation-problems">
21 <title>Current problems</title>
23 We describe the typical problems in today's media handling on Linux.
25 <sect2 id="section-motivation-duplicate">
26 <title>Multitude of duplicate code</title>
28 The Linux user who wishes to hear a sound file must hunt through
29 their collection of sound file players in order to play the tens
30 of sound file formats in wide use today. Most of these players
31 basically reimplement the same code over and over again.
34 The Linux developer who wishes to embed a video clip in their
35 application must use crude hacks to run an external video player.
36 There is no library available that a developer can use to create
37 a custom media player.
41 <sect2 id="section-motivation-goal">
42 <title>'One goal' media players/libraries</title>
44 Your typical MPEG player was designed to play MPEG video and audio.
45 Most of these players have implemented a complete infrastructure
46 focused on achieving their only goal: playback. No provisions were
47 made to add filters or special effects to the video or audio data.
50 If you want to convert an MPEG-2 video stream into an AVI file,
51 your best option would be to take all of the MPEG-2 decoding
52 algorithms out of the player and duplicate them into your own
53 AVI encoder. These algorithms cannot easily be shared across
57 Attempts have been made to create libraries for handling various
58 media types. Because they focus on a very specific media type
59 (avifile, libmpeg2, ...), significant work is needed to integrate
60 them due to a lack of a common API. &GStreamer; allows you to
61 wrap these libraries with a common API, which significantly
62 simplifies integration and reuse.
66 <sect2 id="section-motivation-plugin">
67 <title>Non unified plugin mechanisms</title>
69 Your typical media player might have a plugin for different media
70 types. Two media players will typically implement their own plugin
71 mechanism so that the codecs cannot be easily exchanged. The plugin
72 system of the typical media player is also very tailored to the
73 specific needs of the application.
76 The lack of a unified plugin mechanism also seriously hinders the
77 creation of binary only codecs. No company is willing to port their
78 code to all the different plugin mechanisms.
81 While &GStreamer; also uses it own plugin system it offers a very rich
82 framework for the plugin developer and ensures the plugin can be used
83 in a wide range of applications, transparently interacting with other
84 plugins. The framework that &GStreamer; provides for the plugins is
85 flexible enough to host even the most demanding plugins.
89 <sect2 id="section-motivation-experience">
90 <title>Poor user experience</title>
92 Because of the problems mentioned above, application authors have
93 so far often been urged to spend a considerable amount of time in
94 writing their own backends, plugin mechanisms and so on. The result
95 has often been, unfortunately, that both the backend as well as the
96 user interface were only half-finished. Demotivated, the application
97 authors would start rewriting the whole thing and complete the circle.
98 This leads to a <emphasis>poor end user experience</emphasis>.
102 <sect2 id="section-motivation-network">
103 <title>Provision for network transparency</title>
105 No infrastructure is present to allow network transparent media
106 handling. A distributed MPEG encoder will typically duplicate the
107 same encoder algorithms found in a non-distributed encoder.
110 No provisions have been made for use by and use of technologies such
111 as the <ulink url="http://gnome.org/" type="http">GNOME</ulink>
112 desktop platform. Because the wheel is re-invented all the time,
113 it's hard to properly integrate multimedia into the bigger whole of
117 The &GStreamer; core does not use network transparent technologies
118 at the lowest level as it only adds overhead for the local case.
119 That said, it shouldn't be hard to create a wrapper around the
120 core components. There are tcp plugins now that implement a
121 &GStreamer; Data Protocol that allows pipelines to be split over
122 TCP. These are located in the gst-plugins module directory gst/tcp.
126 <sect2 id="section-motivation-catchup">
127 <title>Catch up with the <trademark>Windows</trademark> world</title>
129 We need solid media handling if we want to see Linux succeed on
133 We must clear the road for commercially backed codecs and multimedia
134 applications so that Linux can become an option for doing multimedia.
139 <sect1 id="section-goals-design">
140 <title>The design goals</title>
142 We describe what we try to achieve with &GStreamer;.
146 <section id="section-goals-clean">
147 <title>Clean and powerful</title>
149 &GStreamer; provides a clean interface to:
154 The application programmer who wants to build a media pipeline.
155 The programmer can use an extensive set of powerful tools to create
156 media pipelines without writing a single line of code. Performing
157 complex media manipulations becomes very easy.
162 The plugin programmer. Plugin programmers are provided a clean and
163 simple API to create self-contained plugins. An extensive debugging
164 and tracing mechanism has been integrated. GStreamer also comes with
165 an extensive set of real-life plugins that serve as examples too.
171 <section id="section-goals-object">
172 <title>Object oriented</title>
174 &GStreamer; adheres to GObject, the GLib 2.0 object model. A programmer
175 familiar with GLib 2.0 or GTK+ will be
176 comfortable with &GStreamer;.
179 &GStreamer; uses the mechanism of signals and object properties.
182 All objects can be queried at runtime for their various properties and
186 &GStreamer; intends to be similar in programming methodology to GTK+.
187 This applies to the object model, ownership of objects, reference
192 <section id="section-goals-extensible">
193 <title>Extensible</title>
195 All &GStreamer; Objects can be extended using the GObject
199 All plugins are loaded dynamically and can be extended and upgraded
204 <section id="section-goals-binary">
205 <title>Allow binary-only plugins</title>
207 Plugins are shared libraries that are loaded at runtime. Since all
208 the properties of the plugin can be set using the GObject properties,
209 there is no need (and in fact no way) to have any header files
210 installed for the plugins.
213 Special care has been taken to make plugins completely self-contained.
214 All relevant aspects of plugins can be queried at run-time.
218 <section id="section-goals-performance">
219 <title>High performance</title>
221 High performance is obtained by:
226 using GLib's <classname>GSlice</classname> allocator
231 extremely light-weight links between plugins. Data can travel
232 the pipeline with minimal overhead. Data passing between
233 plugins only involves a pointer dereference in a typical
239 providing a mechanism to directly work on the target memory.
240 A plugin can for example directly write to the X server's
241 shared memory space. Buffers can also point to arbitrary
242 memory, such as a sound card's internal hardware buffer.
247 refcounting and copy on write minimize usage of memcpy.
248 Sub-buffers efficiently split buffers into manageable pieces.
253 dedicated streaming threads, with scheduling handled by the kernel.
258 allowing hardware acceleration by using specialized plugins.
263 using a plugin registry with the specifications of the plugins so
264 that the plugin loading can be delayed until the plugin is actually
271 <section id="section-goals-separation">
272 <title>Clean core/plugins separation</title>
274 The core of &GStreamer; is essentially media-agnostic. It only knows
275 about bytes and blocks, and only contains basic elements.
276 The core of &GStreamer; is functional enough to even implement
277 low-level system tools, like cp.
280 All of the media handling functionality is provided by plugins
281 external to the core. These tell the core how to handle specific
286 <section id="section-goals-testbed">
287 <title>Provide a framework for codec experimentation</title>
289 &GStreamer; also wants to be an easy framework where codec
290 developers can experiment with different algorithms, speeding up
291 the development of open and free multimedia codecs like <ulink
292 url="http://www.xiph.org/ogg/index.html" type="http">Theora and