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.GhostPad; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gstreamer.ObjectGst; 31 private import gstreamer.Pad; 32 private import gstreamer.PadTemplate; 33 private import gstreamer.ProxyPad; 34 private import gstreamerc.gstreamer; 35 public import gstreamerc.gstreamertypes; 36 37 38 /** 39 * GhostPads are useful when organizing pipelines with #GstBin like elements. 40 * The idea here is to create hierarchical element graphs. The bin element 41 * contains a sub-graph. Now one would like to treat the bin-element like any 42 * other #GstElement. This is where GhostPads come into play. A GhostPad acts as 43 * a proxy for another pad. Thus the bin can have sink and source ghost-pads 44 * that are associated with sink and source pads of the child elements. 45 * 46 * If the target pad is known at creation time, gst_ghost_pad_new() is the 47 * function to use to get a ghost-pad. Otherwise one can use gst_ghost_pad_new_no_target() 48 * to create the ghost-pad and use gst_ghost_pad_set_target() to establish the 49 * association later on. 50 * 51 * Note that GhostPads add overhead to the data processing of a pipeline. 52 */ 53 public class GhostPad : ProxyPad 54 { 55 /** the main Gtk struct */ 56 protected GstGhostPad* gstGhostPad; 57 58 /** Get the main Gtk struct */ 59 public GstGhostPad* getGhostPadStruct() 60 { 61 return gstGhostPad; 62 } 63 64 /** the main Gtk struct as a void* */ 65 protected override void* getStruct() 66 { 67 return cast(void*)gstGhostPad; 68 } 69 70 protected override void setStruct(GObject* obj) 71 { 72 gstGhostPad = cast(GstGhostPad*)obj; 73 super.setStruct(obj); 74 } 75 76 /** 77 * Sets our main struct and passes it to the parent class. 78 */ 79 public this (GstGhostPad* gstGhostPad, bool ownedRef = false) 80 { 81 this.gstGhostPad = gstGhostPad; 82 super(cast(GstProxyPad*)gstGhostPad, ownedRef); 83 } 84 85 /** 86 */ 87 88 public static GType getType() 89 { 90 return gst_ghost_pad_get_type(); 91 } 92 93 /** 94 * Create a new ghostpad with @target as the target. The direction will be taken 95 * from the target pad. @target must be unlinked. 96 * 97 * Will ref the target. 98 * 99 * Params: 100 * name = the name of the new pad, or %NULL to assign a default name 101 * target = the pad to ghost. 102 * 103 * Return: a new #GstPad, or %NULL in 104 * case of an error. 105 * 106 * Throws: ConstructionException GTK+ fails to create the object. 107 */ 108 public this(string name, Pad target) 109 { 110 auto p = gst_ghost_pad_new(Str.toStringz(name), (target is null) ? null : target.getPadStruct()); 111 112 if(p is null) 113 { 114 throw new ConstructionException("null returned by new"); 115 } 116 117 this(cast(GstGhostPad*) p); 118 } 119 120 /** 121 * Create a new ghostpad with @target as the target. The direction will be taken 122 * from the target pad. The template used on the ghostpad will be @template. 123 * 124 * Will ref the target. 125 * 126 * Params: 127 * name = the name of the new pad, or %NULL to assign a default name. 128 * target = the pad to ghost. 129 * templ = the #GstPadTemplate to use on the ghostpad. 130 * 131 * Return: a new #GstPad, or %NULL in 132 * case of an error. 133 * 134 * Throws: ConstructionException GTK+ fails to create the object. 135 */ 136 public this(string name, Pad target, PadTemplate templ) 137 { 138 auto p = gst_ghost_pad_new_from_template(Str.toStringz(name), (target is null) ? null : target.getPadStruct(), (templ is null) ? null : templ.getPadTemplateStruct()); 139 140 if(p is null) 141 { 142 throw new ConstructionException("null returned by new_from_template"); 143 } 144 145 this(cast(GstGhostPad*) p, true); 146 } 147 148 /** 149 * Create a new ghostpad without a target with the given direction. 150 * A target can be set on the ghostpad later with the 151 * gst_ghost_pad_set_target() function. 152 * 153 * The created ghostpad will not have a padtemplate. 154 * 155 * Params: 156 * name = the name of the new pad, or %NULL to assign a default name. 157 * dir = the direction of the ghostpad 158 * 159 * Return: a new #GstPad, or %NULL in 160 * case of an error. 161 * 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this(string name, GstPadDirection dir) 165 { 166 auto p = gst_ghost_pad_new_no_target(Str.toStringz(name), dir); 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by new_no_target"); 171 } 172 173 this(cast(GstGhostPad*) p, true); 174 } 175 176 /** 177 * Create a new ghostpad based on @templ, without setting a target. The 178 * direction will be taken from the @templ. 179 * 180 * Params: 181 * name = the name of the new pad, or %NULL to assign a default name 182 * templ = the #GstPadTemplate to create the ghostpad from. 183 * 184 * Return: a new #GstPad, or %NULL in 185 * case of an error. 186 * 187 * Throws: ConstructionException GTK+ fails to create the object. 188 */ 189 public this(string name, PadTemplate templ) 190 { 191 auto p = gst_ghost_pad_new_no_target_from_template(Str.toStringz(name), (templ is null) ? null : templ.getPadTemplateStruct()); 192 193 if(p is null) 194 { 195 throw new ConstructionException("null returned by new_no_target_from_template"); 196 } 197 198 this(cast(GstGhostPad*) p, true); 199 } 200 201 /** 202 * Invoke the default activate mode function of a ghost pad. 203 * 204 * Params: 205 * pad = the #GstPad to activate or deactivate. 206 * parent = the parent of @pad or %NULL 207 * mode = the requested activation mode 208 * active = whether the pad should be active or not. 209 * 210 * Return: %TRUE if the operation was successful. 211 */ 212 public static bool activateModeDefault(Pad pad, ObjectGst parent, GstPadMode mode, bool active) 213 { 214 return gst_ghost_pad_activate_mode_default((pad is null) ? null : pad.getPadStruct(), (parent is null) ? null : parent.getObjectGstStruct(), mode, active) != 0; 215 } 216 217 /** 218 * Invoke the default activate mode function of a proxy pad that is 219 * owned by a ghost pad. 220 * 221 * Params: 222 * pad = the #GstPad to activate or deactivate. 223 * parent = the parent of @pad or %NULL 224 * mode = the requested activation mode 225 * active = whether the pad should be active or not. 226 * 227 * Return: %TRUE if the operation was successful. 228 */ 229 public static bool internalActivateModeDefault(Pad pad, ObjectGst parent, GstPadMode mode, bool active) 230 { 231 return gst_ghost_pad_internal_activate_mode_default((pad is null) ? null : pad.getPadStruct(), (parent is null) ? null : parent.getObjectGstStruct(), mode, active) != 0; 232 } 233 234 /** 235 * Finish initialization of a newly allocated ghost pad. 236 * 237 * This function is most useful in language bindings and when subclassing 238 * #GstGhostPad; plugin and application developers normally will not call this 239 * function. Call this function directly after a call to g_object_new 240 * (GST_TYPE_GHOST_PAD, "direction", @dir, ..., NULL). 241 * 242 * Return: %TRUE if the construction succeeds, %FALSE otherwise. 243 */ 244 public bool construct() 245 { 246 return gst_ghost_pad_construct(gstGhostPad) != 0; 247 } 248 249 /** 250 * Get the target pad of @gpad. Unref target pad after usage. 251 * 252 * Return: the target #GstPad, can be 253 * %NULL if the ghostpad has no target set. Unref target pad after 254 * usage. 255 */ 256 public Pad getTarget() 257 { 258 auto p = gst_ghost_pad_get_target(gstGhostPad); 259 260 if(p is null) 261 { 262 return null; 263 } 264 265 return ObjectG.getDObject!(Pad)(cast(GstPad*) p, true); 266 } 267 268 /** 269 * Set the new target of the ghostpad @gpad. Any existing target 270 * is unlinked and links to the new target are established. if @newtarget is 271 * %NULL the target will be cleared. 272 * 273 * Params: 274 * newtarget = the new pad target 275 * 276 * Return: %TRUE if the new target could be set. This function 277 * can return %FALSE when the internal pads could not be linked. 278 */ 279 public bool setTarget(Pad newtarget) 280 { 281 return gst_ghost_pad_set_target(gstGhostPad, (newtarget is null) ? null : newtarget.getPadStruct()) != 0; 282 } 283 }