Git init
[framework/multimedia/gstreamer0.10.git] / docs / manual / appendix-porting.xml
1 <chapter id="chapter-porting">
2   <title>Porting 0.8 applications to 0.10</title>
3   <para>
4     This section of the appendix will discuss shortly what changes to
5     applications will be needed to quickly and conveniently port most
6     applications from &GStreamer;-0.8 to &GStreamer;-0.10, with references
7     to the relevant sections in this Application Development Manual
8     where needed. With this list, it should be possible to port simple
9     applications to &GStreamer;-0.10 in less than a day.
10   </para>
11
12   <sect1 id="section-porting-objects">
13     <title>List of changes</title>
14     <itemizedlist>
15       <listitem>
16         <para>
17           Most functions returning an object or an object property have
18           been changed to return its own reference rather than a constant
19           reference of the one owned by the object itself. The reason for
20           this change is primarily thread safety. This means, effectively,
21           that return values of functions such as
22           <function>gst_element_get_pad ()</function>,
23           <function>gst_pad_get_name ()</function> and many more like these
24           have to be free'ed or unreferenced after use. Check the API
25           references of each function to know for sure whether return
26           values should be free'ed or not. It is important that all objects
27           derived from GstObject are ref'ed/unref'ed using gst_object_ref()
28           and gst_object_unref() respectively (instead of g_object_ref/unref).
29         </para>
30       </listitem>
31       <listitem>
32         <para>
33           Applications should no longer use signal handlers to be notified
34           of errors, end-of-stream and other similar pipeline events.
35           Instead, they should use the <classname>GstBus</classname>, which
36           has been discussed in <xref linkend="chapter-bus"/>. The bus will
37           take care that the messages will be delivered in the context of a
38           main loop, which is almost certainly the application's main thread.
39           The big advantage of this is that applications no longer need to
40           be thread-aware; they don't need to use <function>g_idle_add
41           ()</function> in the signal handler and do the actual real work
42           in the idle-callback. &GStreamer; now does all that internally.
43         </para>
44       </listitem>
45       <listitem>
46         <para>
47           Related to this, <function>gst_bin_iterate ()</function> has been
48           removed. Pipelines will iterate in their own thread, and applications
49           can simply run a <classname>GMainLoop</classname> (or call the
50           mainloop of their UI toolkit, such as <function>gtk_main
51           ()</function>).
52         </para>
53       </listitem>
54       <listitem>
55         <para>
56           State changes can be delayed (ASYNC). Due to the new fully threaded
57           nature of GStreamer-0.10, state changes are not always immediate,
58           in particular changes including the transition from READY to PAUSED
59           state. This means two things in the context of porting applications:
60           first of all, it is no longer always possible to do
61           <function>gst_element_set_state ()</function> and check for a return
62           value of GST_STATE_CHANGE_SUCCESS, as the state change might be
63           delayed (ASYNC) and the result will not be known until later. You
64           should still check for GST_STATE_CHANGE_FAILURE right away, it is
65           just no longer possible to assume that everything that is not SUCCESS
66           means failure. Secondly, state changes might not be immediate, so
67           your code needs to take that into account. You can wait for a state
68           change to complete if you use GST_CLOCK_TIME_NONE as timeout interval
69           with <function>gst_element_get_state ()</function>.
70         </para>
71       </listitem>
72       <listitem>
73         <para>
74           In 0.8, events and queries had to manually be sent to sinks in
75           pipelines (unless you were using playbin). This is no longer
76           the case in 0.10. In 0.10, queries and events can be sent to
77           toplevel pipelines, and the pipeline will do the dispatching
78           internally for you. This means less bookkeeping in your
79           application. For a short code example, see <xref
80           linkend="chapter-queryevents"/>. Related, seeking is now
81           threadsafe, and your video output will show the new video
82           position's frame while seeking, providing a better user
83           experience.
84         </para>
85       </listitem>
86       <listitem>
87         <para>
88           The <classname>GstThread</classname> object has been removed.
89           Applications can now simply put elements in a pipeline with
90           optionally some <quote>queue</quote> elements in between for
91           buffering, and &GStreamer; will take care of creating threads
92           internally. It is still possible to have parts of a pipeline
93           run in different threads than others, by using the
94           <quote>queue</quote> element. See <xref linkend="chapter-threads"/>
95           for details.
96         </para>
97       </listitem>
98       <listitem>
99         <para>
100           Filtered caps -> capsfilter element (the pipeline syntax for
101           gst-launch has not changed though).
102         </para>
103       </listitem>
104       <listitem>
105         <para>
106           libgstgconf-0.10.la does not exist. Use the
107           <quote>gconfvideosink</quote> and <quote>gconfaudiosink</quote>
108           elements instead, which will do live-updates and require no library
109           linking.
110         </para>
111       </listitem>
112       <listitem>
113         <para>
114           The <quote>new-pad</quote> and <quote>state-change</quote> signals on
115           <classname>GstElement</classname> were renamed to
116           <quote>pad-added</quote> and <quote>state-changed</quote>.
117         </para>
118       </listitem>
119       <listitem>
120         <para>
121           <function>gst_init_get_popt_table ()</function> has been removed
122           in favour of the new GOption command line option API that was
123           added to GLib 2.6. <function>gst_init_get_option_group ()</function>
124           is the new GOption-based equivalent to
125           <function>gst_init_get_ptop_table ()</function>.
126         </para>
127       </listitem>
128     </itemizedlist>
129   </sect1>
130 </chapter>