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 * Conversion parameters: 26 * inFile = GstPadTemplate.html 27 * outPack = gstreamer 28 * outFile = PadTemplate 29 * strct = GstPadTemplate 30 * realStrct= 31 * ctorStrct= 32 * clss = PadTemplate 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_pad_template_ 41 * - gst_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gstreamer.Caps 49 * structWrap: 50 * - GstCaps* -> Caps 51 * - GstPadTemplate* -> PadTemplate 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gstreamer.PadTemplate; 58 59 public import gstreamerc.gstreamertypes; 60 61 private import gstreamerc.gstreamer; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import gobject.Signals; 66 public import gtkc.gdktypes; 67 68 private import glib.Str; 69 private import gstreamer.Caps; 70 71 72 73 private import gstreamer.ObjectGst; 74 75 /** 76 * Padtemplates describe the possible media types a pad or an elementfactory can 77 * handle. This allows for both inspection of handled types before loading the 78 * element plugin as well as identifying pads on elements that are not yet 79 * created (request or sometimes pads). 80 * 81 * Pad and PadTemplates have GstCaps attached to it to describe the media type 82 * they are capable of dealing with. gst_pad_template_get_caps() or 83 * GST_PAD_TEMPLATE_CAPS() are used to get the caps of a padtemplate. It's not 84 * possible to modify the caps of a padtemplate after creation. 85 * 86 * PadTemplates have a GstPadPresence property which identifies the lifetime 87 * of the pad and that can be retrieved with GST_PAD_TEMPLATE_PRESENCE(). Also 88 * the direction of the pad can be retrieved from the GstPadTemplate with 89 * GST_PAD_TEMPLATE_DIRECTION(). 90 * 91 * The GST_PAD_TEMPLATE_NAME_TEMPLATE() is important for GST_PAD_REQUEST pads 92 * because it has to be used as the name in the gst_element_get_request_pad() 93 * call to instantiate a pad from this template. 94 * 95 * Padtemplates can be created with gst_pad_template_new() or with 96 * gst_static_pad_template_get(), which creates a GstPadTemplate from a 97 * GstStaticPadTemplate that can be filled with the 98 * convenient GST_STATIC_PAD_TEMPLATE() macro. 99 * 100 * A padtemplate can be used to create a pad (see gst_pad_new_from_template() 101 * or gst_pad_new_from_static_template()) or to add to an element class 102 * (see gst_element_class_add_pad_template()). 103 * 104 * The following code example shows the code to create a pad from a padtemplate. 105 * 106 * $(DDOC_COMMENT example) 107 * 108 * The following example shows you how to add the padtemplate to an 109 * element class, this is usually done in the class_init of the class: 110 * 111 * $(DDOC_COMMENT example) 112 * 113 * Last reviewed on 2006-02-14 (0.10.3) 114 */ 115 public class PadTemplate : ObjectGst 116 { 117 118 /** the main Gtk struct */ 119 protected GstPadTemplate* gstPadTemplate; 120 121 122 public GstPadTemplate* getPadTemplateStruct() 123 { 124 return gstPadTemplate; 125 } 126 127 128 /** the main Gtk struct as a void* */ 129 protected override void* getStruct() 130 { 131 return cast(void*)gstPadTemplate; 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class 136 */ 137 public this (GstPadTemplate* gstPadTemplate) 138 { 139 super(cast(GstObject*)gstPadTemplate); 140 this.gstPadTemplate = gstPadTemplate; 141 } 142 143 protected override void setStruct(GObject* obj) 144 { 145 super.setStruct(obj); 146 gstPadTemplate = cast(GstPadTemplate*)obj; 147 } 148 149 /** 150 */ 151 int[string] connectedSignals; 152 153 void delegate(GstPad*, PadTemplate)[] onPadCreatedListeners; 154 /** 155 * This signal is fired when an element creates a pad from this template. 156 * See Also 157 * GstPad, GstElementFactory 158 */ 159 void addOnPadCreated(void delegate(GstPad*, PadTemplate) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 160 { 161 if ( !("pad-created" in connectedSignals) ) 162 { 163 Signals.connectData( 164 getStruct(), 165 "pad-created", 166 cast(GCallback)&callBackPadCreated, 167 cast(void*)this, 168 null, 169 connectFlags); 170 connectedSignals["pad-created"] = 1; 171 } 172 onPadCreatedListeners ~= dlg; 173 } 174 extern(C) static void callBackPadCreated(GstPadTemplate* padTemplateStruct, GstPad* pad, PadTemplate _padTemplate) 175 { 176 foreach ( void delegate(GstPad*, PadTemplate) dlg ; _padTemplate.onPadCreatedListeners ) 177 { 178 dlg(pad, _padTemplate); 179 } 180 } 181 182 183 /** 184 * Converts a GstStaticPadTemplate into a GstPadTemplate. 185 * Params: 186 * padTemplate = the static pad template 187 * Returns: a new GstPadTemplate. [transfer full] 188 */ 189 public static PadTemplate staticPadTemplateGet(GstStaticPadTemplate* padTemplate) 190 { 191 // GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template); 192 auto p = gst_static_pad_template_get(padTemplate); 193 194 if(p is null) 195 { 196 return null; 197 } 198 199 return ObjectG.getDObject!(PadTemplate)(cast(GstPadTemplate*) p); 200 } 201 202 /** 203 * Gets the capabilities of the static pad template. 204 * Params: 205 * templ = a GstStaticPadTemplate to get capabilities of. 206 * Returns: the GstCaps of the static pad template. Unref after usage. Since the core holds an additional ref to the returned caps, use gst_caps_make_writable() on the returned caps to modify it. [transfer full] 207 */ 208 public static Caps staticPadTemplateGetCaps(GstStaticPadTemplate* templ) 209 { 210 // GstCaps * gst_static_pad_template_get_caps (GstStaticPadTemplate *templ); 211 auto p = gst_static_pad_template_get_caps(templ); 212 213 if(p is null) 214 { 215 return null; 216 } 217 218 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 219 } 220 221 /** 222 * Creates a new pad template with a name according to the given template 223 * and with the given arguments. 224 * Params: 225 * nameTemplate = the name template. 226 * direction = the GstPadDirection of the template. 227 * presence = the GstPadPresence of the pad. 228 * caps = a GstCaps set for the template. [transfer none] 229 * Throws: ConstructionException GTK+ fails to create the object. 230 */ 231 public this (string nameTemplate, GstPadDirection direction, GstPadPresence presence, Caps caps) 232 { 233 // GstPadTemplate * gst_pad_template_new (const gchar *name_template, GstPadDirection direction, GstPadPresence presence, GstCaps *caps); 234 auto p = gst_pad_template_new(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct()); 235 if(p is null) 236 { 237 throw new ConstructionException("null returned by gst_pad_template_new(Str.toStringz(nameTemplate), direction, presence, (caps is null) ? null : caps.getCapsStruct())"); 238 } 239 this(cast(GstPadTemplate*) p); 240 } 241 242 /** 243 * Gets the capabilities of the pad template. 244 * Returns: the GstCaps of the pad template. Unref after usage. [transfer full] 245 */ 246 public Caps getCaps() 247 { 248 // GstCaps * gst_pad_template_get_caps (GstPadTemplate *templ); 249 auto p = gst_pad_template_get_caps(gstPadTemplate); 250 251 if(p is null) 252 { 253 return null; 254 } 255 256 return ObjectG.getDObject!(Caps)(cast(GstCaps*) p); 257 } 258 }