1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.ElementClass;
26 
27 private import glib.ListG;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gstreamer.PadTemplate;
31 private import gstreamer.StaticPadTemplate;
32 private import gstreamer.c.functions;
33 public  import gstreamer.c.types;
34 public  import gstreamerc.gstreamertypes;
35 
36 
37 /**
38  * GStreamer element class. Override the vmethods to implement the element
39  * functionality.
40  */
41 public class ElementClass
42 {
43 	/** the main Gtk struct */
44 	protected GstElementClass* gstElementClass;
45 	protected bool ownedRef;
46 
47 	/** Get the main Gtk struct */
48 	public GstElementClass* getElementClassStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gstElementClass;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gstElementClass;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GstElementClass* gstElementClass, bool ownedRef = false)
65 	{
66 		this.gstElementClass = gstElementClass;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 
71 	/**
72 	 * Set @key with @value as metadata in @klass.
73 	 *
74 	 * Params:
75 	 *     key = the key to set
76 	 *     value = the value to set
77 	 */
78 	public void addMetadata(string key, string value)
79 	{
80 		gst_element_class_add_metadata(gstElementClass, Str.toStringz(key), Str.toStringz(value));
81 	}
82 
83 	/**
84 	 * Adds a padtemplate to an element class. This is mainly used in the _class_init
85 	 * functions of classes. If a pad template with the same name as an already
86 	 * existing one is added the old one is replaced by the new one.
87 	 *
88 	 * Params:
89 	 *     templ = a #GstPadTemplate to add to the element class.
90 	 */
91 	public void addPadTemplate(PadTemplate templ)
92 	{
93 		gst_element_class_add_pad_template(gstElementClass, (templ is null) ? null : templ.getPadTemplateStruct());
94 	}
95 
96 	/**
97 	 * Set @key with @value as metadata in @klass.
98 	 *
99 	 * Same as gst_element_class_add_metadata(), but @value must be a static string
100 	 * or an inlined string, as it will not be copied. (GStreamer plugins will
101 	 * be made resident once loaded, so this function can be used even from
102 	 * dynamically loaded plugins.)
103 	 *
104 	 * Params:
105 	 *     key = the key to set
106 	 *     value = the value to set
107 	 */
108 	public void addStaticMetadata(string key, string value)
109 	{
110 		gst_element_class_add_static_metadata(gstElementClass, Str.toStringz(key), Str.toStringz(value));
111 	}
112 
113 	/**
114 	 * Adds a pad template to an element class based on the static pad template
115 	 * @templ. This is mainly used in the _class_init functions of element
116 	 * implementations. If a pad template with the same name already exists,
117 	 * the old one is replaced by the new one.
118 	 *
119 	 * Params:
120 	 *     staticTempl = #GstStaticPadTemplate to add as pad template to the element class.
121 	 *
122 	 * Since: 1.8
123 	 */
124 	public void addStaticPadTemplate(StaticPadTemplate staticTempl)
125 	{
126 		gst_element_class_add_static_pad_template(gstElementClass, (staticTempl is null) ? null : staticTempl.getStaticPadTemplateStruct());
127 	}
128 
129 	/**
130 	 * Get metadata with @key in @klass.
131 	 *
132 	 * Params:
133 	 *     key = the key to get
134 	 *
135 	 * Returns: the metadata for @key.
136 	 */
137 	public string getMetadata(string key)
138 	{
139 		return Str.toString(gst_element_class_get_metadata(gstElementClass, Str.toStringz(key)));
140 	}
141 
142 	/**
143 	 * Retrieves a padtemplate from @element_class with the given name.
144 	 * > If you use this function in the #GInstanceInitFunc of an object class
145 	 * > that has subclasses, make sure to pass the g_class parameter of the
146 	 * > #GInstanceInitFunc here.
147 	 *
148 	 * Params:
149 	 *     name = the name of the #GstPadTemplate to get.
150 	 *
151 	 * Returns: the #GstPadTemplate with the
152 	 *     given name, or %NULL if none was found. No unreferencing is
153 	 *     necessary.
154 	 */
155 	public PadTemplate getPadTemplate(string name)
156 	{
157 		auto p = gst_element_class_get_pad_template(gstElementClass, Str.toStringz(name));
158 
159 		if(p is null)
160 		{
161 			return null;
162 		}
163 
164 		return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p);
165 	}
166 
167 	/**
168 	 * Retrieves a list of the pad templates associated with @element_class. The
169 	 * list must not be modified by the calling code.
170 	 * > If you use this function in the #GInstanceInitFunc of an object class
171 	 * > that has subclasses, make sure to pass the g_class parameter of the
172 	 * > #GInstanceInitFunc here.
173 	 *
174 	 * Returns: the #GList of
175 	 *     pad templates.
176 	 */
177 	public ListG getPadTemplateList()
178 	{
179 		auto p = gst_element_class_get_pad_template_list(gstElementClass);
180 
181 		if(p is null)
182 		{
183 			return null;
184 		}
185 
186 		return new ListG(cast(GList*) p);
187 	}
188 
189 	/**
190 	 * Sets the detailed information for a #GstElementClass.
191 	 * > This function is for use in _class_init functions only.
192 	 *
193 	 * Params:
194 	 *     longname = The long English name of the element. E.g. "File Sink"
195 	 *     classification = String describing the type of element, as an unordered list
196 	 *         separated with slashes ('/'). See draft-klass.txt of the design docs
197 	 *         for more details and common types. E.g: "Sink/File"
198 	 *     description = Sentence describing the purpose of the element.
199 	 *         E.g: "Write stream to a file"
200 	 *     author = Name and contact details of the author(s). Use \n to separate
201 	 *         multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
202 	 */
203 	public void setMetadata(string longname, string classification, string description, string author)
204 	{
205 		gst_element_class_set_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author));
206 	}
207 
208 	/**
209 	 * Sets the detailed information for a #GstElementClass.
210 	 *
211 	 * > This function is for use in _class_init functions only.
212 	 *
213 	 * Same as gst_element_class_set_metadata(), but @longname, @classification,
214 	 * @description, and @author must be static strings or inlined strings, as
215 	 * they will not be copied. (GStreamer plugins will be made resident once
216 	 * loaded, so this function can be used even from dynamically loaded plugins.)
217 	 *
218 	 * Params:
219 	 *     longname = The long English name of the element. E.g. "File Sink"
220 	 *     classification = String describing the type of element, as an unordered list
221 	 *         separated with slashes ('/'). See draft-klass.txt of the design docs
222 	 *         for more details and common types. E.g: "Sink/File"
223 	 *     description = Sentence describing the purpose of the element.
224 	 *         E.g: "Write stream to a file"
225 	 *     author = Name and contact details of the author(s). Use \n to separate
226 	 *         multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
227 	 */
228 	public void setStaticMetadata(string longname, string classification, string description, string author)
229 	{
230 		gst_element_class_set_static_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author));
231 	}
232 }