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