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 gstreamerc.gstreamer;
33 public  import gstreamerc.gstreamertypes;
34 
35 
36 /**
37  * GStreamer element class. Override the vmethods to implement the element
38  * functionality.
39  */
40 public class ElementClass
41 {
42 	/** the main Gtk struct */
43 	protected GstElementClass* gstElementClass;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GstElementClass* getElementClassStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gstElementClass;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gstElementClass;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GstElementClass* gstElementClass, bool ownedRef = false)
64 	{
65 		this.gstElementClass = gstElementClass;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 
70 	/**
71 	 * Set @key with @value as metadata in @klass.
72 	 *
73 	 * Params:
74 	 *     key = the key to set
75 	 *     value = the value to set
76 	 */
77 	public void addMetadata(string key, string value)
78 	{
79 		gst_element_class_add_metadata(gstElementClass, Str.toStringz(key), Str.toStringz(value));
80 	}
81 
82 	/**
83 	 * Adds a padtemplate to an element class. This is mainly used in the _class_init
84 	 * functions of classes. If a pad template with the same name as an already
85 	 * existing one is added the old one is replaced by the new one.
86 	 *
87 	 * Params:
88 	 *     templ = a #GstPadTemplate to add to the element class.
89 	 */
90 	public void addPadTemplate(PadTemplate templ)
91 	{
92 		gst_element_class_add_pad_template(gstElementClass, (templ is null) ? null : templ.getPadTemplateStruct());
93 	}
94 
95 	/**
96 	 * Set @key with @value as metadata in @klass.
97 	 *
98 	 * Same as gst_element_class_add_metadata(), but @value must be a static string
99 	 * or an inlined string, as it will not be copied. (GStreamer plugins will
100 	 * be made resident once loaded, so this function can be used even from
101 	 * dynamically loaded plugins.)
102 	 *
103 	 * Params:
104 	 *     key = the key to set
105 	 *     value = the value to set
106 	 */
107 	public void addStaticMetadata(string key, string value)
108 	{
109 		gst_element_class_add_static_metadata(gstElementClass, Str.toStringz(key), Str.toStringz(value));
110 	}
111 
112 	/**
113 	 * Adds a pad template to an element class based on the static pad template
114 	 * @templ. This is mainly used in the _class_init functions of element
115 	 * implementations. If a pad template with the same name already exists,
116 	 * the old one is replaced by the new one.
117 	 *
118 	 * Params:
119 	 *     staticTempl = #GstStaticPadTemplate to add as pad template to the element class.
120 	 *
121 	 * Since: 1.8
122 	 */
123 	public void addStaticPadTemplate(StaticPadTemplate staticTempl)
124 	{
125 		gst_element_class_add_static_pad_template(gstElementClass, (staticTempl is null) ? null : staticTempl.getStaticPadTemplateStruct());
126 	}
127 
128 	/**
129 	 * Get metadata with @key in @klass.
130 	 *
131 	 * Params:
132 	 *     key = the key to get
133 	 *
134 	 * Returns: the metadata for @key.
135 	 */
136 	public string getMetadata(string key)
137 	{
138 		return Str.toString(gst_element_class_get_metadata(gstElementClass, Str.toStringz(key)));
139 	}
140 
141 	/**
142 	 * Retrieves a padtemplate from @element_class with the given name.
143 	 * > If you use this function in the #GInstanceInitFunc of an object class
144 	 * > that has subclasses, make sure to pass the g_class parameter of the
145 	 * > #GInstanceInitFunc here.
146 	 *
147 	 * Params:
148 	 *     name = the name of the #GstPadTemplate to get.
149 	 *
150 	 * Returns: the #GstPadTemplate with the
151 	 *     given name, or %NULL if none was found. No unreferencing is
152 	 *     necessary.
153 	 */
154 	public PadTemplate getPadTemplate(string name)
155 	{
156 		auto p = gst_element_class_get_pad_template(gstElementClass, Str.toStringz(name));
157 		
158 		if(p is null)
159 		{
160 			return null;
161 		}
162 		
163 		return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p);
164 	}
165 
166 	/**
167 	 * Retrieves a list of the pad templates associated with @element_class. The
168 	 * list must not be modified by the calling code.
169 	 * > If you use this function in the #GInstanceInitFunc of an object class
170 	 * > that has subclasses, make sure to pass the g_class parameter of the
171 	 * > #GInstanceInitFunc here.
172 	 *
173 	 * Returns: the #GList of
174 	 *     pad templates.
175 	 */
176 	public ListG getPadTemplateList()
177 	{
178 		auto p = gst_element_class_get_pad_template_list(gstElementClass);
179 		
180 		if(p is null)
181 		{
182 			return null;
183 		}
184 		
185 		return new ListG(cast(GList*) p);
186 	}
187 
188 	/**
189 	 * Sets the detailed information for a #GstElementClass.
190 	 * > This function is for use in _class_init functions only.
191 	 *
192 	 * Params:
193 	 *     longname = The long English name of the element. E.g. "File Sink"
194 	 *     classification = String describing the type of element, as an unordered list
195 	 *         separated with slashes ('/'). See draft-klass.txt of the design docs
196 	 *         for more details and common types. E.g: "Sink/File"
197 	 *     description = Sentence describing the purpose of the element.
198 	 *         E.g: "Write stream to a file"
199 	 *     author = Name and contact details of the author(s). Use \n to separate
200 	 *         multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
201 	 */
202 	public void setMetadata(string longname, string classification, string description, string author)
203 	{
204 		gst_element_class_set_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author));
205 	}
206 
207 	/**
208 	 * Sets the detailed information for a #GstElementClass.
209 	 *
210 	 * > This function is for use in _class_init functions only.
211 	 *
212 	 * Same as gst_element_class_set_metadata(), but @longname, @classification,
213 	 * @description, and @author must be static strings or inlined strings, as
214 	 * they will not be copied. (GStreamer plugins will be made resident once
215 	 * loaded, so this function can be used even from dynamically loaded plugins.)
216 	 *
217 	 * Params:
218 	 *     longname = The long English name of the element. E.g. "File Sink"
219 	 *     classification = String describing the type of element, as an unordered list
220 	 *         separated with slashes ('/'). See draft-klass.txt of the design docs
221 	 *         for more details and common types. E.g: "Sink/File"
222 	 *     description = Sentence describing the purpose of the element.
223 	 *         E.g: "Write stream to a file"
224 	 *     author = Name and contact details of the author(s). Use \n to separate
225 	 *         multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
226 	 */
227 	public void setStaticMetadata(string longname, string classification, string description, string author)
228 	{
229 		gst_element_class_set_static_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author));
230 	}
231 }