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 gst.base.FlowCombiner; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gst.base.c.functions; 30 public import gst.base.c.types; 31 private import gstreamer.Pad; 32 private import gtkd.Loader; 33 34 35 /** 36 * Utility struct to help handling #GstFlowReturn combination. Useful for 37 * #GstElement<!-- -->s that have multiple source pads and need to combine 38 * the different #GstFlowReturn for those pads. 39 * 40 * #GstFlowCombiner works by using the last #GstFlowReturn for all #GstPad 41 * it has in its list and computes the combined return value and provides 42 * it to the caller. 43 * 44 * To add a new pad to the #GstFlowCombiner use gst_flow_combiner_add_pad(). 45 * The new #GstPad is stored with a default value of %GST_FLOW_OK. 46 * 47 * In case you want a #GstPad to be removed, use gst_flow_combiner_remove_pad(). 48 * 49 * Please be aware that this struct isn't thread safe as its designed to be 50 * used by demuxers, those usually will have a single thread operating it. 51 * 52 * These functions will take refs on the passed #GstPad<!-- -->s. 53 * 54 * Aside from reducing the user's code size, the main advantage of using this 55 * helper struct is to follow the standard rules for #GstFlowReturn combination. 56 * These rules are: 57 * 58 * * %GST_FLOW_EOS: only if all returns are EOS too 59 * * %GST_FLOW_NOT_LINKED: only if all returns are NOT_LINKED too 60 * * %GST_FLOW_ERROR or below: if at least one returns an error return 61 * * %GST_FLOW_NOT_NEGOTIATED: if at least one returns a not-negotiated return 62 * * %GST_FLOW_FLUSHING: if at least one returns flushing 63 * * %GST_FLOW_OK: otherwise 64 * 65 * %GST_FLOW_ERROR or below, GST_FLOW_NOT_NEGOTIATED and GST_FLOW_FLUSHING are 66 * returned immediatelly from the gst_flow_combiner_update_flow() function. 67 * 68 * Since: 1.4 69 */ 70 public class FlowCombiner 71 { 72 /** the main Gtk struct */ 73 protected GstFlowCombiner* gstFlowCombiner; 74 protected bool ownedRef; 75 76 /** Get the main Gtk struct */ 77 public GstFlowCombiner* getFlowCombinerStruct(bool transferOwnership = false) 78 { 79 if (transferOwnership) 80 ownedRef = false; 81 return gstFlowCombiner; 82 } 83 84 /** the main Gtk struct as a void* */ 85 protected void* getStruct() 86 { 87 return cast(void*)gstFlowCombiner; 88 } 89 90 /** 91 * Sets our main struct and passes it to the parent class. 92 */ 93 public this (GstFlowCombiner* gstFlowCombiner, bool ownedRef = false) 94 { 95 this.gstFlowCombiner = gstFlowCombiner; 96 this.ownedRef = ownedRef; 97 } 98 99 ~this () 100 { 101 if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef ) 102 gst_flow_combiner_unref(gstFlowCombiner); 103 } 104 105 106 /** */ 107 public static GType getType() 108 { 109 return gst_flow_combiner_get_type(); 110 } 111 112 /** 113 * Creates a new #GstFlowCombiner, use gst_flow_combiner_free() to free it. 114 * 115 * Returns: A new #GstFlowCombiner 116 * 117 * Since: 1.4 118 * 119 * Throws: ConstructionException GTK+ fails to create the object. 120 */ 121 public this() 122 { 123 auto p = gst_flow_combiner_new(); 124 125 if(p is null) 126 { 127 throw new ConstructionException("null returned by new"); 128 } 129 130 this(cast(GstFlowCombiner*) p); 131 } 132 133 /** 134 * Adds a new #GstPad to the #GstFlowCombiner. 135 * 136 * Params: 137 * pad = the #GstPad that is being added 138 * 139 * Since: 1.4 140 */ 141 public void addPad(Pad pad) 142 { 143 gst_flow_combiner_add_pad(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct()); 144 } 145 146 /** 147 * Removes all pads from a #GstFlowCombiner and resets it to its initial state. 148 * 149 * Since: 1.6 150 */ 151 public void clear() 152 { 153 gst_flow_combiner_clear(gstFlowCombiner); 154 } 155 156 /** 157 * Frees a #GstFlowCombiner struct and all its internal data. 158 * 159 * Since: 1.4 160 */ 161 public void free() 162 { 163 gst_flow_combiner_free(gstFlowCombiner); 164 ownedRef = false; 165 } 166 167 /** 168 * Increments the reference count on the #GstFlowCombiner. 169 * 170 * Returns: the #GstFlowCombiner. 171 * 172 * Since: 1.12.1 173 */ 174 public FlowCombiner doref() 175 { 176 auto p = gst_flow_combiner_ref(gstFlowCombiner); 177 178 if(p is null) 179 { 180 return null; 181 } 182 183 return ObjectG.getDObject!(FlowCombiner)(cast(GstFlowCombiner*) p, true); 184 } 185 186 /** 187 * Removes a #GstPad from the #GstFlowCombiner. 188 * 189 * Params: 190 * pad = the #GstPad to remove 191 * 192 * Since: 1.4 193 */ 194 public void removePad(Pad pad) 195 { 196 gst_flow_combiner_remove_pad(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct()); 197 } 198 199 /** 200 * Reset flow combiner and all pads to their initial state without removing pads. 201 * 202 * Since: 1.6 203 */ 204 public void reset() 205 { 206 gst_flow_combiner_reset(gstFlowCombiner); 207 } 208 209 /** 210 * Decrements the reference count on the #GstFlowCombiner. 211 * 212 * Since: 1.12.1 213 */ 214 public void unref() 215 { 216 gst_flow_combiner_unref(gstFlowCombiner); 217 } 218 219 /** 220 * Computes the combined flow return for the pads in it. 221 * 222 * The #GstFlowReturn parameter should be the last flow return update for a pad 223 * in this #GstFlowCombiner. It will use this value to be able to shortcut some 224 * combinations and avoid looking over all pads again. e.g. The last combined 225 * return is the same as the latest obtained #GstFlowReturn. 226 * 227 * Params: 228 * fret = the latest #GstFlowReturn received for a pad in this #GstFlowCombiner 229 * 230 * Returns: The combined #GstFlowReturn 231 * 232 * Since: 1.4 233 */ 234 public GstFlowReturn updateFlow(GstFlowReturn fret) 235 { 236 return gst_flow_combiner_update_flow(gstFlowCombiner, fret); 237 } 238 239 /** 240 * Sets the provided pad's last flow return to provided value and computes 241 * the combined flow return for the pads in it. 242 * 243 * The #GstFlowReturn parameter should be the last flow return update for a pad 244 * in this #GstFlowCombiner. It will use this value to be able to shortcut some 245 * combinations and avoid looking over all pads again. e.g. The last combined 246 * return is the same as the latest obtained #GstFlowReturn. 247 * 248 * Params: 249 * pad = the #GstPad whose #GstFlowReturn to update 250 * fret = the latest #GstFlowReturn received for a pad in this #GstFlowCombiner 251 * 252 * Returns: The combined #GstFlowReturn 253 * 254 * Since: 1.6 255 */ 256 public GstFlowReturn updatePadFlow(Pad pad, GstFlowReturn fret) 257 { 258 return gst_flow_combiner_update_pad_flow(gstFlowCombiner, (pad is null) ? null : pad.getPadStruct(), fret); 259 } 260 }