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 * @templ's reference count will be incremented, and any floating 89 * reference will be removed (see gst_object_ref_sink()) 90 * 91 * Params: 92 * templ = a #GstPadTemplate to add to the element class. 93 */ 94 public void addPadTemplate(PadTemplate templ) 95 { 96 gst_element_class_add_pad_template(gstElementClass, (templ is null) ? null : templ.getPadTemplateStruct()); 97 } 98 99 /** 100 * Set @key with @value as metadata in @klass. 101 * 102 * Same as gst_element_class_add_metadata(), but @value must be a static string 103 * or an inlined string, as it will not be copied. (GStreamer plugins will 104 * be made resident once loaded, so this function can be used even from 105 * dynamically loaded plugins.) 106 * 107 * Params: 108 * key = the key to set 109 * value = the value to set 110 */ 111 public void addStaticMetadata(string key, string value) 112 { 113 gst_element_class_add_static_metadata(gstElementClass, Str.toStringz(key), Str.toStringz(value)); 114 } 115 116 /** 117 * Adds a pad template to an element class based on the static pad template 118 * @templ. This is mainly used in the _class_init functions of element 119 * implementations. If a pad template with the same name already exists, 120 * the old one is replaced by the new one. 121 * 122 * Params: 123 * staticTempl = #GstStaticPadTemplate to add as pad template to the element class. 124 * 125 * Since: 1.8 126 */ 127 public void addStaticPadTemplate(StaticPadTemplate staticTempl) 128 { 129 gst_element_class_add_static_pad_template(gstElementClass, (staticTempl is null) ? null : staticTempl.getStaticPadTemplateStruct()); 130 } 131 132 /** 133 * Adds a pad template to an element class based on the static pad template 134 * @templ. This is mainly used in the _class_init functions of element 135 * implementations. If a pad template with the same name already exists, 136 * the old one is replaced by the new one. 137 * 138 * Params: 139 * staticTempl = #GstStaticPadTemplate to add as pad template to the element class. 140 * padType = The #GType of the pad to create 141 * 142 * Since: 1.14 143 */ 144 public void addStaticPadTemplateWithGtype(StaticPadTemplate staticTempl, GType padType) 145 { 146 gst_element_class_add_static_pad_template_with_gtype(gstElementClass, (staticTempl is null) ? null : staticTempl.getStaticPadTemplateStruct(), padType); 147 } 148 149 /** 150 * Get metadata with @key in @klass. 151 * 152 * Params: 153 * key = the key to get 154 * 155 * Returns: the metadata for @key. 156 */ 157 public string getMetadata(string key) 158 { 159 return Str.toString(gst_element_class_get_metadata(gstElementClass, Str.toStringz(key))); 160 } 161 162 /** 163 * Retrieves a padtemplate from @element_class with the given name. 164 * > If you use this function in the #GInstanceInitFunc of an object class 165 * > that has subclasses, make sure to pass the g_class parameter of the 166 * > #GInstanceInitFunc here. 167 * 168 * Params: 169 * name = the name of the #GstPadTemplate to get. 170 * 171 * Returns: the #GstPadTemplate with the 172 * given name, or %NULL if none was found. No unreferencing is 173 * necessary. 174 */ 175 public PadTemplate getPadTemplate(string name) 176 { 177 auto p = gst_element_class_get_pad_template(gstElementClass, Str.toStringz(name)); 178 179 if(p is null) 180 { 181 return null; 182 } 183 184 return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p); 185 } 186 187 /** 188 * Retrieves a list of the pad templates associated with @element_class. The 189 * list must not be modified by the calling code. 190 * > If you use this function in the #GInstanceInitFunc of an object class 191 * > that has subclasses, make sure to pass the g_class parameter of the 192 * > #GInstanceInitFunc here. 193 * 194 * Returns: the #GList of 195 * pad templates. 196 */ 197 public ListG getPadTemplateList() 198 { 199 auto p = gst_element_class_get_pad_template_list(gstElementClass); 200 201 if(p is null) 202 { 203 return null; 204 } 205 206 return new ListG(cast(GList*) p); 207 } 208 209 /** 210 * Sets the detailed information for a #GstElementClass. 211 * > This function is for use in _class_init functions only. 212 * 213 * Params: 214 * longname = The long English name of the element. E.g. "File Sink" 215 * classification = String describing the type of element, as an unordered list 216 * separated with slashes ('/'). See draft-klass.txt of the design docs 217 * for more details and common types. E.g: "Sink/File" 218 * description = Sentence describing the purpose of the element. 219 * E.g: "Write stream to a file" 220 * author = Name and contact details of the author(s). Use \n to separate 221 * multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>" 222 */ 223 public void setMetadata(string longname, string classification, string description, string author) 224 { 225 gst_element_class_set_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author)); 226 } 227 228 /** 229 * Sets the detailed information for a #GstElementClass. 230 * 231 * > This function is for use in _class_init functions only. 232 * 233 * Same as gst_element_class_set_metadata(), but @longname, @classification, 234 * @description, and @author must be static strings or inlined strings, as 235 * they will not be copied. (GStreamer plugins will be made resident once 236 * loaded, so this function can be used even from dynamically loaded plugins.) 237 * 238 * Params: 239 * longname = The long English name of the element. E.g. "File Sink" 240 * classification = String describing the type of element, as an unordered list 241 * separated with slashes ('/'). See draft-klass.txt of the design docs 242 * for more details and common types. E.g: "Sink/File" 243 * description = Sentence describing the purpose of the element. 244 * E.g: "Write stream to a file" 245 * author = Name and contact details of the author(s). Use \n to separate 246 * multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>" 247 */ 248 public void setStaticMetadata(string longname, string classification, string description, string author) 249 { 250 gst_element_class_set_static_metadata(gstElementClass, Str.toStringz(longname), Str.toStringz(classification), Str.toStringz(description), Str.toStringz(author)); 251 } 252 }