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