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.PadTemplate; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gstreamer.Caps; 32 private import gstreamer.ObjectGst; 33 private import gstreamer.Pad; 34 private import gstreamer.StaticPadTemplate; 35 private import gstreamer.c.functions; 36 public import gstreamer.c.types; 37 private import std.algorithm; 38 39 40 /** 41 * Padtemplates describe the possible media types a pad or an elementfactory can 42 * handle. This allows for both inspection of handled types before loading the 43 * element plugin as well as identifying pads on elements that are not yet 44 * created (request or sometimes pads). 45 * 46 * Pad and PadTemplates have #GstCaps attached to it to describe the media type 47 * they are capable of dealing with. gst_pad_template_get_caps() or 48 * GST_PAD_TEMPLATE_CAPS() are used to get the caps of a padtemplate. It's not 49 * possible to modify the caps of a padtemplate after creation. 50 * 51 * PadTemplates have a #GstPadPresence property which identifies the lifetime 52 * of the pad and that can be retrieved with GST_PAD_TEMPLATE_PRESENCE(). Also 53 * the direction of the pad can be retrieved from the #GstPadTemplate with 54 * GST_PAD_TEMPLATE_DIRECTION(). 55 * 56 * The GST_PAD_TEMPLATE_NAME_TEMPLATE () is important for GST_PAD_REQUEST pads 57 * because it has to be used as the name in the gst_element_get_request_pad() 58 * call to instantiate a pad from this template. 59 * 60 * Padtemplates can be created with gst_pad_template_new() or with 61 * gst_static_pad_template_get (), which creates a #GstPadTemplate from a 62 * #GstStaticPadTemplate that can be filled with the 63 * convenient GST_STATIC_PAD_TEMPLATE() macro. 64 * 65 * A padtemplate can be used to create a pad (see gst_pad_new_from_template() 66 * or gst_pad_new_from_static_template ()) or to add to an element class 67 * (see gst_element_class_add_static_pad_template ()). 68 * 69 * The following code example shows the code to create a pad from a padtemplate. 70 * |[<!-- language="C" --> 71 * GstStaticPadTemplate my_template = 72 * GST_STATIC_PAD_TEMPLATE ( 73 * "sink", // the name of the pad 74 * GST_PAD_SINK, // the direction of the pad 75 * GST_PAD_ALWAYS, // when this pad will be present 76 * GST_STATIC_CAPS ( // the capabilities of the padtemplate 77 * "audio/x-raw, " 78 * "channels = (int) [ 1, 6 ]" 79 * ) 80 * ); 81 * void 82 * my_method (void) 83 * { 84 * GstPad *pad; 85 * pad = gst_pad_new_from_static_template (&my_template, "sink"); 86 * ... 87 * } 88 * ]| 89 * 90 * The following example shows you how to add the padtemplate to an 91 * element class, this is usually done in the class_init of the class: 92 * |[<!-- language="C" --> 93 * static void 94 * my_element_class_init (GstMyElementClass *klass) 95 * { 96 * GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); 97 * 98 * gst_element_class_add_static_pad_template (gstelement_class, &my_template); 99 * } 100 * ]| 101 */ 102 public class PadTemplate : ObjectGst 103 { 104 /** the main Gtk struct */ 105 protected GstPadTemplate* gstPadTemplate; 106 107 /** Get the main Gtk struct */ 108 public GstPadTemplate* getPadTemplateStruct(bool transferOwnership = false) 109 { 110 if (transferOwnership) 111 ownedRef = false; 112 return gstPadTemplate; 113 } 114 115 /** the main Gtk struct as a void* */ 116 protected override void* getStruct() 117 { 118 return cast(void*)gstPadTemplate; 119 } 120 121 /** 122 * Sets our main struct and passes it to the parent class. 123 */ 124 public this (GstPadTemplate* gstPadTemplate, bool ownedRef = false) 125 { 126 this.gstPadTemplate = gstPadTemplate; 127 super(cast(GstObject*)gstPadTemplate, ownedRef); 128 } 129 130 131 /** */ 132 public static GType getType() 133 { 134 return gst_pad_template_get_type(); 135 } 136 137 /** 138 * Creates a new pad template with a name according to the given template 139 * and with the given arguments. 140 * 141 * Params: 142 * nameTemplate = the name template. 143 * direction = the #GstPadDirection of the template. 144 * presence = the #GstPadPresence of the pad. 145 * caps = a #GstCaps set for the template. 146 * 147 * Returns: a new #GstPadTemplate. 148 * 149 * Throws: ConstructionException GTK+ fails to create the object. 150 */ 151 public this(string nameTemplate, GstPadDirection direction, GstPadPresence presence, Caps caps) 152 { 153 auto __p = gst_pad_template_new(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct()); 154 155 if(__p is null) 156 { 157 throw new ConstructionException("null returned by new"); 158 } 159 160 this(cast(GstPadTemplate*) __p); 161 } 162 163 /** 164 * Converts a #GstStaticPadTemplate into a #GstPadTemplate with a type. 165 * 166 * Params: 167 * padTemplate = the static pad template 168 * padType = The #GType of the pad to create 169 * 170 * Returns: a new #GstPadTemplate. 171 * 172 * Since: 1.14 173 * 174 * Throws: ConstructionException GTK+ fails to create the object. 175 */ 176 public this(StaticPadTemplate padTemplate, GType padType) 177 { 178 auto __p = gst_pad_template_new_from_static_pad_template_with_gtype((padTemplate is null) ? null : padTemplate.getStaticPadTemplateStruct(), padType); 179 180 if(__p is null) 181 { 182 throw new ConstructionException("null returned by new_from_static_pad_template_with_gtype"); 183 } 184 185 this(cast(GstPadTemplate*) __p); 186 } 187 188 /** 189 * Creates a new pad template with a name according to the given template 190 * and with the given arguments. 191 * 192 * Params: 193 * nameTemplate = the name template. 194 * direction = the #GstPadDirection of the template. 195 * presence = the #GstPadPresence of the pad. 196 * caps = a #GstCaps set for the template. 197 * padType = The #GType of the pad to create 198 * 199 * Returns: a new #GstPadTemplate. 200 * 201 * Since: 1.14 202 * 203 * Throws: ConstructionException GTK+ fails to create the object. 204 */ 205 public this(string nameTemplate, GstPadDirection direction, GstPadPresence presence, Caps caps, GType padType) 206 { 207 auto __p = gst_pad_template_new_with_gtype(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct(), padType); 208 209 if(__p is null) 210 { 211 throw new ConstructionException("null returned by new_with_gtype"); 212 } 213 214 this(cast(GstPadTemplate*) __p); 215 } 216 217 /** 218 * Gets the capabilities of the pad template. 219 * 220 * Returns: the #GstCaps of the pad template. 221 * Unref after usage. 222 */ 223 public Caps getCaps() 224 { 225 auto __p = gst_pad_template_get_caps(gstPadTemplate); 226 227 if(__p is null) 228 { 229 return null; 230 } 231 232 return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true); 233 } 234 235 /** 236 * See gst_pad_template_set_documentation_caps(). 237 * 238 * Returns: The caps to document. For convenience, this will return 239 * gst_pad_template_get_caps() when no documentation caps were set. 240 * 241 * Since: 1.18 242 */ 243 public Caps getDocumentationCaps() 244 { 245 auto __p = gst_pad_template_get_documentation_caps(gstPadTemplate); 246 247 if(__p is null) 248 { 249 return null; 250 } 251 252 return ObjectG.getDObject!(Caps)(cast(GstCaps*) __p, true); 253 } 254 255 /** 256 * Emit the pad-created signal for this template when created by this pad. 257 * 258 * Params: 259 * pad = the #GstPad that created it 260 */ 261 public void padCreated(Pad pad) 262 { 263 gst_pad_template_pad_created(gstPadTemplate, (pad is null) ? null : pad.getPadStruct()); 264 } 265 266 /** 267 * Certain elements will dynamically construct the caps of their 268 * pad templates. In order not to let environment-specific information 269 * into the documentation, element authors should use this method to 270 * expose "stable" caps to the reader. 271 * 272 * Params: 273 * caps = the documented capabilities 274 * 275 * Since: 1.18 276 */ 277 public void setDocumentationCaps(Caps caps) 278 { 279 gst_pad_template_set_documentation_caps(gstPadTemplate, (caps is null) ? null : caps.getCapsStruct()); 280 } 281 282 /** 283 * This signal is fired when an element creates a pad from this template. 284 * 285 * Params: 286 * pad = the pad that was created. 287 */ 288 gulong addOnPadCreated(void delegate(Pad, PadTemplate) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 289 { 290 return Signals.connect(this, "pad-created", dlg, connectFlags ^ ConnectFlags.SWAPPED); 291 } 292 }