docs: manual: fix formatting
[platform/upstream/gstreamer.git] / docs / manual / appendix-compiling.xml
1 <chapter id="chapter-compiling">
2   <title>Compiling</title>
3   <para>
4     This section talks about the different things you can do when building
5     and shipping your applications and plugins.
6   </para>
7
8   <sect1 id="section-compiling-embedding">
9     <title>Embedding static elements in your application</title>
10     <para>
11       The <ulink type="http"
12       url="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html">Plugin
13       Writer's Guide</ulink> describes in great detail how to write elements
14       for the &GStreamer; framework. In this section, we will solely discuss
15       how to embed such elements statically in your application. This can be
16       useful for application-specific elements that have no use elsewhere in
17       &GStreamer;.
18     </para>
19     <para>
20       Dynamically loaded plugins contain a structure that's defined using
21       <function>GST_PLUGIN_DEFINE ()</function>. This structure is loaded
22       when the plugin is loaded by the &GStreamer; core. The structure
23       contains an initialization function (usually called
24       <function>plugin_init</function>) that will be called right after that.
25       It's purpose is to register the elements provided by the plugin with
26       the &GStreamer; framework. 
27       If you want to embed elements directly in
28       your application, the only thing you need to do is to replace
29           <function>GST_PLUGIN_DEFINE ()</function> with a call to
30           <function>gst_plugin_register_static ()</function>. As soon as you
31       call <function>gst_plugin_register_static ()</function>, the elements
32       will from then on be available like any other element, without them
33       having to be dynamically loadable libraries. In the example below, you
34       would be able to call <function>gst_element_factory_make
35       ("my-element-name", "some-name")</function> to create an instance of the
36       element.
37     </para>
38
39     <programlisting>
40 <![CDATA[
41 /*
42  * Here, you would write the actual plugin code.
43  */
44
45 [..]
46
47 static gboolean
48 register_elements (GstPlugin *plugin)
49 {
50   return gst_element_register (plugin, "my-element-name",
51                                GST_RANK_NONE, MY_PLUGIN_TYPE);
52 }
53
54 static
55 my_code_init (void)
56 {
57   ...
58
59   gst_plugin_register_static (
60     GST_VERSION_MAJOR,
61     GST_VERSION_MINOR,
62     "my-private-plugins",
63     "Private elements of my application",
64     register_elements,
65     VERSION,
66     "LGPL",
67     "my-application-source",
68     "my-application",
69     "http://www.my-application.net/")
70
71   ...
72 }
73 ]]>
74     </programlisting>
75   </sect1>
76 </chapter>