1 <chapter id="chapter-interfaces">
2 <title>Interfaces</title>
5 In <xref linkend="section-elements-properties"/>, you have learned how
6 to use <classname>GObject</classname> properties as a simple way to do
7 interaction between applications and elements. This method suffices for
8 the simple'n'straight settings, but fails for anything more complicated
9 than a getter and setter. For the more complicated use cases, &GStreamer;
10 uses interfaces based on the Glib <classname>GInterface</classname> type.
14 Most of the interfaces handled here will not contain any example code.
15 See the API references for details. Here, we will just describe the
16 scope and purpose of each interface.
19 <sect1 id="section-interfaces-uri">
20 <title>The URI interface</title>
23 In all examples so far, we have only supported local files through the
24 <quote>filesrc</quote> element. &GStreamer;, obviously, supports many
25 more location sources. However, we don't want applications to need to
26 know any particular element implementation details, such as element
27 names for particular network source types and so on. Therefore, there
28 is a URI interface, which can be used to get the source element that
29 supports a particular URI type. There is no strict rule for URI naming,
30 but in general we follow naming conventions that others use, too. For
31 example, assuming you have the correct plugins installed, &GStreamer;
32 supports <quote>file:///<path>/<file></quote>,
33 <quote>http://<host>/<path>/<file></quote>,
34 <quote>mms://<host>/<path>/<file></quote>, and so on.
37 In order to get the source or sink element supporting a particular URI,
38 use <function>gst_element_make_from_uri ()</function>, with the URI
39 type being either <classname>GST_URI_SRC</classname> for a source
40 element, or <classname>GST_URI_SINK</classname> for a sink element.
43 You can convert filenames to and from URIs using GLib's
44 <function>g_filename_to_uri ()</function> and
45 <function>g_uri_to_filename ()</function>.
49 <sect1 id="section-interfaces-mixer">
50 <title>The Mixer interface</title>
53 The mixer interface provides a uniform way to control the volume on a
54 hardware (or software) mixer. The interface is primarily intended to
55 be implemented by elements for audio inputs and outputs that talk
56 directly to the hardware (e.g. OSS or ALSA plugins).
59 Using this interface, it is possible to control a list of tracks
60 (such as Line-in, Microphone, etc.) from a mixer element. They can
61 be muted, their volume can be changed and, for input tracks, their
62 record flag can be set as well.
65 Example plugins implementing this interface include the OSS elements
66 (osssrc, osssink, ossmixer) and the ALSA plugins (alsasrc, alsasink
70 You should not use this interface for volume control in a playback
71 application. Either use a <classname>volume</classname> element or use
72 <classname>playbin</classname>'s <quote>volume</quote> property, or use
73 the audiosink's <quote>volume</quote> property (if it has one).
77 In order for the <classname>GstMixer</classname> interface to be
78 usable, the element implementing it needs to be in the right state,
79 so that the underlying mixer device is open. This usually means the
80 element needs to be at least in <classname>GST_STATE_READY</classname>
81 before you can use this interface. You will get confusing warnings
82 if the element is not in the right state when the interface is used.
87 <sect1 id="section-interfaces-tuner">
88 <title>The Tuner interface</title>
91 The tuner interface is a uniform way to control inputs and outputs
92 on a multi-input selection device. This is primarily used for input
93 selection on elements for TV- and capture-cards.
96 Using this interface, it is possible to select one track from a list
97 of tracks supported by that tuner-element. The tuner will than select
98 that track for media-processing internally. This can, for example, be
99 used to switch inputs on a TV-card (e.g. from Composite to S-video).
102 This interface is currently only implemented by the Video4linux and
103 Video4linux2 elements.
107 In order for the <classname>GstTuner</classname> interface to be
108 usable, the element implementing it needs to be in the right state,
109 so that the underlying device is open. This usually means the
110 element needs to be at least in <classname>GST_STATE_READY</classname>
111 before you can use this interface. You will get confusing warnings
112 if the element is not in the right state when the interface is used.
117 <sect1 id="section-interfaces-colorbalance">
118 <title>The Color Balance interface</title>
121 The colorbalance interface is a way to control video-related properties
122 on an element, such as brightness, contrast and so on. It's sole
123 reason for existance is that, as far as its authors know, there's no
124 way to dynamically register properties using
125 <classname>GObject</classname>.
128 The colorbalance interface is implemented by several plugins, including
129 xvimagesink and the Video4linux and Video4linux2 elements.
133 <sect1 id="section-interfaces-proprobe">
134 <title>The Property Probe interface</title>
137 The property probe is a way to autodetect allowed values for a
138 <classname>GObject</classname> property. It's primary use is to autodetect
139 devices in several elements. For example, the OSS elements use this
140 interface to detect all OSS devices on a system. Applications can then
141 <quote>probe</quote> this property and get a list of detected devices.
145 Given the overlap between HAL and the practical implementations of this
146 interface, this might in time be deprecated in favour of HAL.
150 This interface is currently implemented by many elements, including
151 the ALSA, OSS, XVImageSink, Video4linux and Video4linux2 elements.
155 <sect1 id="section-interfaces-xoverlay">
156 <title>The X Overlay interface</title>
159 The X Overlay interface was created to solve the problem of embedding
160 video streams in an application window. The application provides an
161 X-window to the element implementing this interface to draw on, and
162 the element will then use this X-window to draw on rather than creating
163 a new toplevel window. This is useful to embed video in video players.
166 This interface is implemented by, amongst others, the Video4linux and
167 Video4linux2 elements and by ximagesink, xvimagesink and sdlvideosink.