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 GObject <ulink type="http"
11 url="http://library.gnome.org/devel/gobject/stable/gtype-non-instantiable-classed.html"><classname>GTypeInterface</classname></ulink>
16 Most of the interfaces handled here will not contain any example code.
17 See the API references for details. Here, we will just describe the
18 scope and purpose of each interface.
21 <sect1 id="section-interfaces-uri">
22 <title>The URI interface</title>
25 In all examples so far, we have only supported local files through the
26 <quote>filesrc</quote> element. &GStreamer;, obviously, supports many
27 more location sources. However, we don't want applications to need to
28 know any particular element implementation details, such as element
29 names for particular network source types and so on. Therefore, there
30 is a URI interface, which can be used to get the source element that
31 supports a particular URI type. There is no strict rule for URI naming,
32 but in general we follow naming conventions that others use, too. For
33 example, assuming you have the correct plugins installed, &GStreamer;
34 supports <quote>file:///<path>/<file></quote>,
35 <quote>http://<host>/<path>/<file></quote>,
36 <quote>mms://<host>/<path>/<file></quote>, and so on.
39 In order to get the source or sink element supporting a particular URI,
40 use <function>gst_element_make_from_uri ()</function>, with the URI
41 type being either <classname>GST_URI_SRC</classname> for a source
42 element, or <classname>GST_URI_SINK</classname> for a sink element.
45 You can convert filenames to and from URIs using GLib's
46 <function>g_filename_to_uri ()</function> and
47 <function>g_uri_to_filename ()</function>.
51 <sect1 id="section-interfaces-mixer">
52 <title>The Mixer interface</title>
55 The mixer interface provides a uniform way to control the volume on a
56 hardware (or software) mixer. The interface is primarily intended to
57 be implemented by elements for audio inputs and outputs that talk
58 directly to the hardware (e.g. OSS or ALSA plugins).
61 Using this interface, it is possible to control a list of tracks
62 (such as Line-in, Microphone, etc.) from a mixer element. They can
63 be muted, their volume can be changed and, for input tracks, their
64 record flag can be set as well.
67 Example plugins implementing this interface include the OSS elements
68 (osssrc, osssink, ossmixer) and the ALSA plugins (alsasrc, alsasink
72 You should not use this interface for volume control in a playback
73 application. Either use a <classname>volume</classname> element or use
74 <classname>playbin</classname>'s <quote>volume</quote> property, or use
75 the <classname>audiosink</classname>'s <quote>volume</quote> property (if it has one).
79 In order for the <ulink type="http"
80 url="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstmixer.html"><classname>GstMixer</classname></ulink>
82 usable, the element implementing it needs to be in the right state,
83 so that the underlying mixer device is open. This usually means the
84 element needs to be at least in <classname>GST_STATE_READY</classname>
85 before you can use this interface. You will get confusing warnings
86 if the element is not in the right state when the interface is used.
91 <sect1 id="section-interfaces-tuner">
92 <title>The Tuner interface</title>
95 The tuner interface is a uniform way to control inputs and outputs
96 on a multi-input selection device. This is primarily used for input
97 selection on elements for TV- and capture-cards.
100 Using this interface, it is possible to select one track from a list
101 of tracks supported by that tuner-element. The tuner will then select
102 that track for media-processing internally. This can, for example, be
103 used to switch inputs on a TV-card (e.g. from Composite to S-video).
106 This interface is currently only implemented by the Video4linux and
107 Video4linux2 elements.
111 In order for the <ulink type="http"
112 url="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gsttuner.html"><classname>GstTuner</classname></ulink>
114 usable, the element implementing it needs to be in the right state,
115 so that the underlying device is open. This usually means the
116 element needs to be at least in <classname>GST_STATE_READY</classname>
117 before you can use this interface. You will get confusing warnings
118 if the element is not in the right state when the interface is used.
123 <sect1 id="section-interfaces-colorbalance">
124 <title>The Color Balance interface</title>
127 The colorbalance interface is a way to control video-related properties
128 on an element, such as brightness, contrast and so on. It's sole
129 reason for existence is that, as far as its authors know, there's no
130 way to dynamically register properties using
131 <classname>GObject</classname>.
134 The colorbalance interface is implemented by several plugins, including
135 xvimagesink and the Video4linux and Video4linux2 elements.
139 <sect1 id="section-interfaces-proprobe">
140 <title>The Property Probe interface</title>
143 The property probe is a way to autodetect allowed values for a
144 <classname>GObject</classname> property. It's primary use is to autodetect
145 devices in several elements. For example, the OSS elements use this
146 interface to detect all OSS devices on a system. Applications can then
147 <quote>probe</quote> this property and get a list of detected devices.
151 Given the overlap between HAL and the practical implementations of this
152 interface, this might in time be deprecated in favour of HAL.
156 This interface is currently implemented by many elements, including
157 the ALSA, OSS, XVideo, Video4linux and Video4linux2 elements.
161 <sect1 id="section-interfaces-xoverlay">
162 <title>The X Overlay interface</title>
165 The X Overlay interface was created to solve the problem of embedding
166 video streams in an application window. The application provides an
167 X-window to the element implementing this interface to draw on, and
168 the element will then use this X-window to draw on rather than creating
169 a new toplevel window. This is useful to embed video in video players.
172 This interface is implemented by, amongst others, the Video4linux and
173 Video4linux2 elements and by ximagesink, xvimagesink and sdlvideosink.