1 | <chapter id="chapter-checklist-element"> |
---|
2 | <title>Things to check when writing an application</title> |
---|
3 | <para> |
---|
4 | This chapter contains a fairly random selection of things that can be |
---|
5 | useful to keep in mind when writing &GStreamer;-based applications. It's |
---|
6 | up to you how much you're going to use the information provided here. |
---|
7 | We will shortly discuss how to debug pipeline problems using &GStreamer; |
---|
8 | applications. Also, we will touch upon how to acquire knowledge about |
---|
9 | plugins and elements and how to test simple pipelines before building |
---|
10 | applications around them. |
---|
11 | </para> |
---|
12 | |
---|
13 | <sect1 id="section-checklist-programming"> |
---|
14 | <title>Good programming habits</title> |
---|
15 | <itemizedlist> |
---|
16 | <listitem> |
---|
17 | <para> |
---|
18 | Always connect to the <quote>error</quote> signal of your topmost |
---|
19 | pipeline to be notified of errors in your pipeline. |
---|
20 | </para> |
---|
21 | </listitem> |
---|
22 | <listitem> |
---|
23 | <para> |
---|
24 | Always check return values of &GStreamer; functions. Especially, |
---|
25 | check return values of <function>gst_element_link ()</function> |
---|
26 | and <function>gst_element_set_state ()</function>. |
---|
27 | </para> |
---|
28 | </listitem> |
---|
29 | <listitem> |
---|
30 | <para> |
---|
31 | Always use your pipeline object to keep track of the current state |
---|
32 | of your pipeline. Don't keep private variables in your application. |
---|
33 | Also, don't update your user interface if a user presses the |
---|
34 | <quote>play</quote> button. Instead, connect to the |
---|
35 | <quote>state-changed</quote> signal of your topmost pipeline and |
---|
36 | update the user interface whenever this signal is triggered. |
---|
37 | </para> |
---|
38 | </listitem> |
---|
39 | </itemizedlist> |
---|
40 | </sect1> |
---|
41 | |
---|
42 | <sect1 id="section-checklist-debug"> |
---|
43 | <title>Debugging</title> |
---|
44 | <para> |
---|
45 | Applications can make use of the extensive &GStreamer; debugging system |
---|
46 | to debug pipeline problems. Elements will write output to this system |
---|
47 | to log what they're doing. It's not used for error reporting, but it |
---|
48 | is very useful for tracking what an element is doing exactly, which |
---|
49 | can come in handy when debugging application issues (such as failing |
---|
50 | seeks, out-of-sync media, etc.). |
---|
51 | </para> |
---|
52 | <para> |
---|
53 | Most &GStreamer;-based applications accept the commandline option |
---|
54 | <option>--gst-debug=LIST</option> and related family members. The |
---|
55 | list consists of a comma-separated list of category/level pairs, |
---|
56 | which can set the debugging level for a specific debugging category. |
---|
57 | For example, <option>--gst-debug=oggdemux:5</option> would turn |
---|
58 | on debugging for the Ogg demuxer element. You can use wildcards as |
---|
59 | well. A debugging level of 0 will turn off all debugging, and a level |
---|
60 | of 5 will turn on all debugging. Intermediate values only turn on |
---|
61 | some debugging (based on message severity; 2, for example, will only |
---|
62 | display errors and warnings). Here's a list of all available options: |
---|
63 | </para> |
---|
64 | <para> |
---|
65 | <itemizedlist> |
---|
66 | <listitem> |
---|
67 | <para> |
---|
68 | <option>--gst-debug-help</option> will print available debug |
---|
69 | categories and exit. |
---|
70 | </para> |
---|
71 | </listitem> |
---|
72 | <listitem> |
---|
73 | <para> |
---|
74 | <option>--gst-debug-level=<replaceable>LEVEL</replaceable></option> |
---|
75 | will set the default debug level (which can range from 0 (no |
---|
76 | output) to 5 (everything)). |
---|
77 | </para> |
---|
78 | </listitem> |
---|
79 | <listitem> |
---|
80 | <para> |
---|
81 | <option>--gst-debug=<replaceable>LIST</replaceable></option> |
---|
82 | takes a comma-separated list of category_name:level pairs to |
---|
83 | set specific levels for the individual categories. Example: |
---|
84 | <option>GST_AUTOPLUG:5,avidemux:3</option>. |
---|
85 | </para> |
---|
86 | </listitem> |
---|
87 | <listitem> |
---|
88 | <para> |
---|
89 | <option>--gst-debug-no-color</option> will disable color debugging. |
---|
90 | </para> |
---|
91 | </listitem> |
---|
92 | <listitem> |
---|
93 | <para> |
---|
94 | <option>--gst-debug-disable</option> disables debugging alltogether. |
---|
95 | </para> |
---|
96 | </listitem> |
---|
97 | <listitem> |
---|
98 | <para> |
---|
99 | <option>--gst-plugin-spew</option> enables printout of errors while |
---|
100 | loading &GStreamer; plugins. |
---|
101 | </para> |
---|
102 | </listitem> |
---|
103 | </itemizedlist> |
---|
104 | </para> |
---|
105 | </sect1> |
---|
106 | |
---|
107 | <sect1 id="section-checklist-conversion"> |
---|
108 | <title>Conversion plugins</title> |
---|
109 | <para> |
---|
110 | &GStreamer; contains a bunch of conversion plugins that most |
---|
111 | applications will find useful. Specifically, those are videoscalers |
---|
112 | (videoscale), colorspace convertors (ffmpegcolorspace), audio format |
---|
113 | convertors and channel resamplers (audioconvert) and audio samplerate |
---|
114 | convertors (audioscale). Those convertors don't do anything when not |
---|
115 | required, they will act in passthrough mode. They will activate when |
---|
116 | the hardware doesn't support a specific request, though. All |
---|
117 | applications are recommended to use those elements. |
---|
118 | </para> |
---|
119 | </sect1> |
---|
120 | |
---|
121 | <sect1 id="section-checklist-applications"> |
---|
122 | <title>Utility applications provided with &GStreamer;</title> |
---|
123 | <para> |
---|
124 | &GStreamer; comes with a default set of command-line utilities that |
---|
125 | can help in application development. We will discuss only |
---|
126 | <command>gst-launch</command> and <command>gst-inspect</command> here. |
---|
127 | </para> |
---|
128 | |
---|
129 | <sect2 id="section-applications-launch"> |
---|
130 | <title><command>gst-launch</command></title> |
---|
131 | <para> |
---|
132 | <command>gst-launch</command> is a simple script-like commandline |
---|
133 | application that can be used to test pipelines. For example, the |
---|
134 | command <command>gst-launch sinesrc ! alsasink</command> will run |
---|
135 | a pipeline which generates a sine-wave audio stream and plays it |
---|
136 | to your ALSA audio card. <command>gst-launch</command> also allows |
---|
137 | the use of threads (using curly brackets, so <quote>{</quote> |
---|
138 | and <quote>}</quote>) and bins (using brackets, so <quote>(</quote> |
---|
139 | and <quote>)</quote>). You can use dots to imply padnames on elements, |
---|
140 | or even omit the padname to automatically select a pad. Using |
---|
141 | all this, the pipeline <command>gst-launch filesrc location=file.ogg |
---|
142 | ! oggdemux name=d { d. ! theoradec ! ffmpegcolorspace ! xvimagesink |
---|
143 | } { d. ! vorbisdec ! alsasink }</command> will play an Ogg file |
---|
144 | containing a Theora video-stream and a Vorbis audio-stream. You can |
---|
145 | also use autopluggers such as decodebin on the commandline. See the |
---|
146 | manual page of <command>gst-launch</command> for more information. |
---|
147 | </para> |
---|
148 | </sect2> |
---|
149 | |
---|
150 | <sect2 id="section-applications-inspect"> |
---|
151 | <title><command>gst-inspect</command></title> |
---|
152 | <para> |
---|
153 | <command>gst-inspect</command> can be used to inspect all properties, |
---|
154 | signals, dynamic parameters and the object hierarchy of an element. |
---|
155 | This acn be very useful to see which <classname>GObject</classname> |
---|
156 | properties or which signals (and using what arguments) an element |
---|
157 | supports. Run <command>gst-inspect fakesrc</command> to get an idea |
---|
158 | of what it does. See the manual page of <command>gst-inspect</command> |
---|
159 | for more information. |
---|
160 | </para> |
---|
161 | </sect2> |
---|
162 | </sect1> |
---|
163 | </chapter> |
---|