1 <chapter id="chapter-programs">
2 <title>Programs</title>
6 <sect1 id="section-programs-gst-launch">
7 <title><command>gst-launch</command></title>
9 This is a tool that will construct pipelines based on a command-line
13 A simple commandline looks like:
16 gst-launch filesrc location=hello.mp3 ! mad ! audioresample ! osssink
19 A more complex pipeline looks like:
22 gst-launch filesrc location=redpill.vob ! dvddemux name=demux \
23 demux.audio_00 ! queue ! a52dec ! audioconvert ! audioresample ! osssink \
24 demux.video_00 ! queue ! mpeg2dec ! ffmpegcolorspace ! xvimagesink
29 You can also use the parser in you own
30 code. <application>GStreamer</application> provides a function
31 gst_parse_launch () that you can use to construct a pipeline.
32 The following program lets you create an MP3 pipeline using the
33 gst_parse_launch () function:
36 #include <gst/gst.h>
39 main (int argc, char *argv[])
47 gst_init (&argc, &argv);
50 g_print ("usage: %s <filename>\n", argv[0]);
54 pipeline = gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error);
56 g_print ("Parse error: %s\n", error->message);
60 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc");
61 g_object_set (filesrc, "location", argv[1], NULL);
63 gst_element_set_state (pipeline, GST_STATE_PLAYING);
65 bus = gst_element_get_bus (pipeline);
67 /* wait until we either get an EOS or an ERROR message. Note that in a real
68 * program you would probably not use gst_bus_poll(), but rather set up an
69 * async signal watch on the bus and run a main loop and connect to the
70 * bus's signals to catch certain messages or all messages */
71 msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
73 switch (GST_MESSAGE_TYPE (msg)) {
74 case GST_MESSAGE_EOS: {
78 case GST_MESSAGE_ERROR: {
79 GError *err = NULL; /* error to show to users */
80 gchar *dbg = NULL; /* additional debug string for developers */
82 gst_message_parse_error (msg, &err, &dbg);
84 g_printerr ("ERROR: %s\n", err->message);
88 g_printerr ("[Debug details: %s]\n", dbg);
93 g_printerr ("Unexpected message of type %d", GST_MESSAGE_TYPE (msg));
96 gst_message_unref (msg);
98 gst_element_set_state (pipeline, GST_STATE_NULL);
99 gst_object_unref (pipeline);
100 gst_object_unref (bus);
106 Note how we can retrieve the filesrc element from the constructed bin using the
110 <title>Grammar Reference</title>
112 The <command>gst-launch</command> syntax is processed by a flex/bison parser. This section
113 is intended to provide a full specification of the grammar; any deviations from this
114 specification is considered a bug.
117 <title>Elements</title>
122 A bare identifier (a string beginning with a letter and containing
123 only letters, numbers, dashes, underscores, percent signs, or colons)
124 will create an element from a given element factory. In this example,
125 an instance of the "mad" MP3 decoding plugin will be created.
134 An exclamation point, optionally having a qualified pad name (an the name of the pad,
135 optionally preceded by the name of the element) on both sides, will link two pads. If
136 the source pad is not specified, a source pad from the immediately preceding element
137 will be automatically chosen. If the sink pad is not specified, a sink pad from the next
138 element to be constructed will be chosen. An attempt will be made to find compatible
139 pads. Pad names may be preceded by an element name, as in
140 <computeroutput>my_element_name.sink_pad</computeroutput>.
144 <title>Properties</title>
146 ... location="http://gstreamer.net" ...
149 The name of a property, optionally qualified with an element name, and a value,
150 separated by an equals sign, will set a property on an element. If the element is not
151 specified, the previous element is assumed. Strings can optionally be enclosed in
152 quotation marks. Characters in strings may be escaped with the backtick
153 (<literal>\</literal>). If the right-hand side is all digits, it is considered to be an
154 integer. If it is all digits and a decimal point, it is a double. If it is "true",
155 "false", "TRUE", or "FALSE" it is considered to be boolean. Otherwise, it is parsed as a
156 string. The type of the property is determined later on in the parsing, and the value is
157 converted to the target type. This conversion is not guaranteed to work, it relies on
158 the g_value_convert routines. No error message will be displayed on an invalid
159 conversion, due to limitations in the value convert API.
163 <title>Bins, Threads, and Pipelines</title>
168 A pipeline description between parentheses is placed into a bin. The open paren may be
169 preceded by a type name, as in <computeroutput>jackbin.( ... )</computeroutput> to make
170 a bin of a specified type. Square brackets make pipelines, and curly braces make
171 threads. The default toplevel bin type is a pipeline, although putting the whole
172 description within parentheses or braces can override this default.
178 <sect1 id="section-programs-gst-inspect">
179 <title><command>gst-inspect</command></title>
181 This is a tool to query a plugin or an element about its properties.
184 To query the information about the element mad, you would specify:
192 Below is the output of a query for the osssink element:
197 Long name: Audio Sink (OSS)
199 Description: Output to a sound card via OSS
201 Author(s): Erik Walthinsen <omega@cse.ogi.edu>, Wim Taymans <wim.taymans@chello.be>
210 SINK template: 'sink'
214 MIME type: 'audio/raw':
216 endianness: Integer: 1234
223 channels: Integer range: 1 - 2
228 rate: Integer range: 1000 - 48000
232 GST_ELEMENT_THREADSUGGESTED
234 Element Implementation:
235 No loopfunc(), must be chain-based or not configured yet
236 Has change_state() function: gst_osssink_change_state
237 Has custom save_thyself() function: gst_element_save_thyself
238 Has custom restore_thyself() function: gst_element_restore_thyself
240 Clocking Interaction:
241 element requires a clock
242 element provides a clock: GstOssClock
247 Has chainfunc(): 0x40056fc0
251 name : String (Default "element")
252 device : String (Default "/dev/dsp")
253 mute : Boolean (Default false)
254 format : Integer (Default 16)
255 channels : Enum "GstAudiosinkChannels" (default 1)
259 frequency : Integer (Default 11025)
260 fragment : Integer (Default 6)
261 buffer-size : Integer (Default 4096)
264 "handoff" : void user_function (GstOssSink* object,
269 To query the information about a plugin, you would do:
273 gst-inspect gstelements