1 <chapter id="chapter-motivation">
2 <title>Motivation & Goals</title>
4 Linux has historically lagged behind other operating systems in the
5 multimedia arena. Microsoft's <trademark>Windows</trademark> and
6 Apple's <trademark>MacOS</trademark> both have strong support for
7 multimedia devices, multimedia content creation, playback, and
8 realtime processing. Linux, on the other hand, has a poorly integrated
9 collection of multimedia utilities and applications available, which
10 can hardly compete with the professional level of software available
11 for MS Windows and MacOS.
14 GStreamer was designed to provide a solution to the current Linux media
18 <sect1 id="section-motivation-problems">
19 <title>Current problems</title>
21 We describe the typical problems in today's media handling on Linux.
23 <sect2 id="section-motivation-duplicate">
24 <title>Multitude of duplicate code</title>
26 The Linux user who wishes to hear a sound file must hunt through
27 their collection of sound file players in order to play the tens
28 of sound file formats in wide use today. Most of these players
29 basically reimplement the same code over and over again.
32 The Linux developer who wishes to embed a video clip in their
33 application must use crude hacks to run an external video player.
34 There is no library available that a developer can use to create
35 a custom media player.
39 <sect2 id="section-motivation-goal">
40 <title>'One goal' media players/libraries</title>
42 Your typical MPEG player was designed to play MPEG video and audio.
43 Most of these players have implemented a complete infrastructure
44 focused on achieving their only goal: playback. No provisions were
45 made to add filters or special effects to the video or audio data.
48 If you want to convert an MPEG-2 video stream into an AVI file,
49 your best option would be to take all of the MPEG-2 decoding
50 algorithms out of the player and duplicate them into your own
51 AVI encoder. These algorithms cannot easily be shared across
55 Attempts have been made to create libraries for handling various
56 media types. Because they focus on a very specific media type
57 (avifile, libmpeg2, ...), significant work is needed to integrate
58 them due to a lack of a common API. &GStreamer; allows you to
59 wrap these libraries with a common API, which significantly
60 simplifies integration and reuse.
64 <sect2 id="section-motivation-plugin">
65 <title>Non unified plugin mechanisms</title>
67 Your typical media player might have a plugin for different media
68 types. Two media players will typically implement their own plugin
69 mechanism so that the codecs cannot be easily exchanged. The plugin
70 system of the typical media player is also very tailored to the
71 specific needs of the application.
74 The lack of a unified plugin mechanism also seriously hinders the
75 creation of binary only codecs. No company is willing to port their
76 code to all the different plugin mechanisms.
79 While &GStreamer; also uses it own plugin system it offers a very rich
80 framework for the plugin developer and ensures the plugin can be used
81 in a wide range of applications, transparently interacting with other
82 plugins. The framework that &GStreamer; provides for the plugins is
83 flexible enough to host even the most demanding plugins.
87 <sect2 id="section-motivation-experience">
88 <title>Poor user experience</title>
90 Because of the problems mentioned above, application authors have
91 so far often been urged to spend a considerable amount of time in
92 writing their own backends, plugin mechanisms and so on. The result
93 has often been, unfortunately, that both the backend as well as the
94 user interface were only half-finished. Demotivated, the application
95 authors would start rewriting the whole thing and complete the circle.
96 This leads to a <emphasis>poor end user experience</emphasis>.
100 <sect2 id="section-motivation-network">
101 <title>Provision for network transparency</title>
103 No infrastructure is present to allow network transparent media
104 handling. A distributed MPEG encoder will typically duplicate the
105 same encoder algorithms found in a non-distributed encoder.
108 No provisions have been made for use by and use of technologies such
109 as the <ulink url="http://gnome.org/" type="http">GNOME</ulink>
110 desktop platform. Because the wheel is re-invented all the time,
111 it's hard to properly integrate multimedia into the bigger whole of
115 The &GStreamer; core does not use network transparent technologies
116 at the lowest level as it only adds overhead for the local case.
117 That said, it shouldn't be hard to create a wrapper around the
118 core components. There are tcp plugins now that implement a
119 &GStreamer; Data Protocol that allows pipelines to be slit over
120 TCP. These are located in the gst-plugins module directory gst/tcp.
124 <sect2 id="section-motivation-catchup">
125 <title>Catch up with the <trademark>Windows</trademark> world</title>
127 We need solid media handling if we want to see Linux succeed on
131 We must clear the road for commercially backed codecs and multimedia
132 applications so that Linux can become an option for doing multimedia.
137 <sect1 id="section-goals-design">
138 <title>The design goals</title>
140 We describe what we try to achieve with &GStreamer;.
142 <sect2 id="section-goals-clean">
143 <title>Clean and powerful</title>
145 &GStreamer; wants to provide a clean interface to:
150 The application programmer who wants to build a media pipeline.
151 The programmer can use an extensive set of powerful tools to create
152 media pipelines without writing a single line of code. Performing
153 complex media manipulations becomes very easy.
158 The plugin programmer. Plugin programmers are provided a clean and
159 simple API to create self-contained plugins. An extensive debugging
160 and tracing mechanism has been integrated. GStreamer also comes with
161 an extensive set of real-life plugins that serve as examples too.
167 <sect2 id="section-goals-object">
168 <title>Object oriented</title>
170 &GStreamer; adheres to the GLib 2.0 object model. A programmer
171 familiar with GLib 2.0 or older versions of GTK+ will be
172 comfortable with &GStreamer;.
175 &GStreamer; uses the mechanism of signals and object properties.
178 All objects can be queried at runtime for their various properties and
182 &GStreamer; intends to be similar in programming methodology to GTK+.
183 This applies to the object model, ownership of objects, reference
188 <sect2 id="section-goals-extensible">
189 <title>Extensible</title>
191 All &GStreamer; Objects can be extended using the GObject
195 All plugins are loaded dynamically and can be extended and upgraded
200 <sect2 id="section-goals-binary">
201 <title>Allow binary only plugins</title>
203 Plugins are shared libraries that are loaded at runtime. Since all
204 the properties of the plugin can be set using the GObject properties,
205 there is no need (and in fact no way) to have any header files
206 installed for the plugins.
209 Special care has been taken to make plugins completely self-contained.
210 All relevant aspects of plugins can be queried at run-time.
214 <sect2 id="section-goals-performance">
215 <title>High performance</title>
217 High performance is obtained by:
222 using GLib's <function>g_mem_chunk</function> and fast
223 non-blocking allocation algorithms where possible to
224 minimize dynamic memory allocation.
229 extremely light-weight links between plugins. Data can travel
230 the pipeline with minimal overhead. Data passing between
231 plugins only involves a pointer dereference in a typical
237 providing a mechanism to directly work on the target memory.
238 A plugin can for example directly write to the X server's
239 shared memory space. Buffers can also point to arbitrary
240 memory, such as a sound card's internal hardware buffer.
245 refcounting and copy on write minimize usage of memcpy.
246 Sub-buffers efficiently split buffers into manageable pieces.
251 the use of cothreads to minimize the threading overhead.
252 Cothreads are a simple and fast user-space method for
253 switching between subtasks. Cothreads were measured to
254 consume as little as 600 cpu cycles.
259 allowing hardware acceleration by using specialized plugins.
264 using a plugin registry with the specifications of the plugins so
265 that the plugin loading can be delayed until the plugin is actually
271 all critical data passing is free of locks and mutexes.
277 <sect2 id="section-goals-separation">
278 <title>Clean core/plugins separation</title>
280 The core of &GStreamer; is essentially media-agnostic. It only knows
281 about bytes and blocks, and only contains basic elements.
282 The core of &GStreamer; is functional enough to even implement
283 low-level system tools, like cp.
286 All of the media handling functionality is provided by plugins
287 external to the core. These tell the core how to handle specific
292 <sect2 id="section-goals-testbed">
293 <title>Provide a framework for codec experimentation</title>
295 &GStreamer; also wants to be an easy framework where codec
296 developers can experiment with different algorithms, speeding up
297 the development of open and free multimedia codecs like <ulink
298 url="http://www.xiph.org/ogg/index.html" type="http">Theora and