1 <chapter id="chapter-intro-basics">
2 <title>Foundations</title>
3 <para><!-- synchronize with PWG -->
4 This chapter of the guide introduces the basic concepts of &GStreamer;.
5 Understanding these concepts will be important in reading any of the
6 rest of this guide, all of them assume understanding of these basic
10 <sect1 id="section-intro-basics-elements">
11 <title>Elements</title>
13 An <emphasis>element</emphasis> is the most important class of objects
14 in &GStreamer;. You will usually create a chain of elements linked
15 together and let data flow through this chain of elements. An element
16 has one specific function, which can be the reading of data from a
17 file, decoding of this data or outputting this data to your sound
18 card (or anything else). By chaining together several such elements,
19 you create a <emphasis>pipeline</emphasis> that can do a specific task,
20 for example media playback or capture. &GStreamer; ships with a large
21 collection of elements by default, making the development of a large
22 variety of media applications possible. If needed, you can also write
23 new elements. That topic is explained in great deal in the &GstPWG;.
27 <sect1 id="section-intro-basics-bins">
28 <title>Bins and pipelines</title>
31 A <emphasis>bin</emphasis> is a container for a collection of elements.
32 A pipeline is a special subtype of a bin that allows execution of all
33 of its contained child elements. Since bins are subclasses of elements
34 themselves, you can mostly control a bin as if it were an element,
35 thereby abstracting away a lot of complexity for your application. You
36 can, for example change state on all elements in a bin by changing the
37 state of that bin itself. Bins also forward bus messages from their
38 contained children (such as error messages, tag messages or EOS messages).
41 A pipeline is a top-level bin. As you set it to PAUSED or PLAYING state,
42 data flow will start and media processing will take place. Once started,
43 pipelines will run in a separate thread until you stop them or the end
44 of the data stream is reached.
48 <sect1 id="section-intro-basics-pads">
51 <emphasis>Pads</emphasis> are used to negotiate links and data flow
52 between elements in &GStreamer;. A pad can be viewed as a
53 <quote>plug</quote> or <quote>port</quote> on an element where
54 links may be made with other elements, and through which data can
55 flow to or from those elements. Pads have specific data handling
56 capabilities: A pad can restrict the type of data that flows
57 through it. Links are only allowed between two pads when the
58 allowed data types of the two pads are compatible. Data types are
59 negotiated between pads using a process called <emphasis>caps
60 negotiation</emphasis>. Data types are described as a
61 <classname>GstCaps</classname>.
64 An analogy may be helpful here. A pad is similar to a plug or jack on a
65 physical device. Consider, for example, a home theater system consisting
66 of an amplifier, a DVD player, and a (silent) video projector. Linking
67 the DVD player to the amplifier is allowed because both devices have audio
68 jacks, and linking the projector to the DVD player is allowed because
69 both devices have compatible video jacks. Links between the
70 projector and the amplifier may not be made because the projector and
71 amplifier have different types of jacks. Pads in &GStreamer; serve the
72 same purpose as the jacks in the home theater system.
75 For the most part, all data in &GStreamer; flows one way through a link
76 between elements. Data flows out of one element through one or more
77 <emphasis>source pads</emphasis>, and elements accept incoming data
78 through one or more <emphasis>sink pads</emphasis>. Source and sink
79 elements have only source and sink pads, respectively. Data usually
80 means buffers (described by the <ulink type="http"
81 url="&URLAPI;/gstreamer-GstBuffer.html"><classname>GstBuffer
82 </classname></ulink> object) and events (described by the <ulink
83 type="http" url="&URLAPI;/gstreamer-GstEvent.html"><classname>
84 GstEvent</classname></ulink> object).