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 = gstreamer-GstMiniObject.html 27 * outPack = gstreamer 28 * outFile = MiniObject 29 * strct = GstMiniObject 30 * realStrct= 31 * ctorStrct= 32 * clss = MiniObject 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_mini_object_ 41 * omit structs: 42 * - GstMiniObject 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * structWrap: 48 * - GstMiniObject* -> MiniObject 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module gstreamer.MiniObject; 55 56 public import gstreamerc.gstreamertypes; 57 58 private import gstreamerc.gstreamer; 59 private import glib.ConstructionException; 60 private import gobject.ObjectG; 61 62 63 64 65 66 67 /** 68 * GstMiniObject is a simple structure that can be used to implement refcounted 69 * types. 70 * 71 * Subclasses will include GstMiniObject as the first member in their structure 72 * and then call gst_mini_object_init() to initialize the GstMiniObject fields. 73 * 74 * gst_mini_object_ref() and gst_mini_object_unref() increment and decrement the 75 * refcount respectively. When the refcount of a mini-object reaches 0, the 76 * dispose function is called first and when this returns TRUE, the free 77 * function of the miniobject is called. 78 * 79 * A copy can be made with gst_mini_object_copy(). 80 * 81 * gst_mini_object_is_writable() will return TRUE when the refcount of the 82 * object is exactly 1, meaning the current caller has the only reference to the 83 * object. gst_mini_object_make_writable() will return a writable version of the 84 * object, which might be a new copy when the refcount was not 1. 85 * 86 * Opaque data can be associated with a GstMiniObject with 87 * gst_mini_object_set_qdata() and gst_mini_object_get_qdata(). The data is 88 * meant to be specific to the particular object and is not automatically copied 89 * with gst_mini_object_copy() or similar methods. 90 * 91 * A weak reference can be added and remove with gst_mini_object_weak_ref() 92 * and gst_mini_object_weak_unref() respectively. 93 * 94 * Last reviewed on 2012-06-15 (0.11.93) 95 */ 96 public class MiniObject 97 { 98 99 /** the main Gtk struct */ 100 protected GstMiniObject* gstMiniObject; 101 102 103 public GstMiniObject* getMiniObjectStruct() 104 { 105 return gstMiniObject; 106 } 107 108 109 /** the main Gtk struct as a void* */ 110 protected void* getStruct() 111 { 112 return cast(void*)gstMiniObject; 113 } 114 115 /** 116 * Sets our main struct and passes it to the parent class 117 */ 118 public this (GstMiniObject* gstMiniObject) 119 { 120 this.gstMiniObject = gstMiniObject; 121 } 122 123 /** 124 */ 125 126 /** 127 * Initializes a mini-object with the desired type and copy/dispose/free 128 * functions. 129 * Params: 130 * flags = initial GstMiniObjectFlags 131 * type = the GType of the mini-object to create 132 * copyFunc = the copy function, or NULL. [allow-none] 133 * disposeFunc = the dispose function, or NULL. [allow-none] 134 * freeFunc = the free function or NULL. [allow-none] 135 */ 136 public void init(uint flags, GType type, GstMiniObjectCopyFunction copyFunc, GstMiniObjectDisposeFunction disposeFunc, GstMiniObjectFreeFunction freeFunc) 137 { 138 // void gst_mini_object_init (GstMiniObject *mini_object, guint flags, GType type, GstMiniObjectCopyFunction copy_func, GstMiniObjectDisposeFunction dispose_func, GstMiniObjectFreeFunction free_func); 139 gst_mini_object_init(gstMiniObject, flags, type, copyFunc, disposeFunc, freeFunc); 140 } 141 142 /** 143 * Increase the reference count of the mini-object. 144 * Note that the refcount affects the writeability 145 * of mini-object, see gst_mini_object_is_writable(). It is 146 * important to note that keeping additional references to 147 * GstMiniObject instances can potentially increase the number 148 * of memcpy operations in a pipeline, especially if the miniobject 149 * is a GstBuffer. 150 * Returns: the mini-object. [transfer full] 151 */ 152 public MiniObject doref() 153 { 154 // GstMiniObject * gst_mini_object_ref (GstMiniObject *mini_object); 155 auto p = gst_mini_object_ref(gstMiniObject); 156 157 if(p is null) 158 { 159 return null; 160 } 161 162 return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p); 163 } 164 165 /** 166 * Decreases the reference count of the mini-object, possibly freeing 167 * the mini-object. 168 */ 169 public void unref() 170 { 171 // void gst_mini_object_unref (GstMiniObject *mini_object); 172 gst_mini_object_unref(gstMiniObject); 173 } 174 175 /** 176 * Adds a weak reference callback to a mini object. Weak references are 177 * used for notification when a mini object is finalized. They are called 178 * "weak references" because they allow you to safely hold a pointer 179 * to the mini object without calling gst_mini_object_ref() 180 * (gst_mini_object_ref() adds a strong reference, that is, forces the object 181 * to stay alive). 182 * Params: 183 * notify = callback to invoke before the mini object is freed 184 * data = extra data to pass to notify 185 */ 186 public void weakRef(GstMiniObjectNotify notify, void* data) 187 { 188 // void gst_mini_object_weak_ref (GstMiniObject *object, GstMiniObjectNotify notify, gpointer data); 189 gst_mini_object_weak_ref(gstMiniObject, notify, data); 190 } 191 192 /** 193 * Removes a weak reference callback from a mini object. 194 * Params: 195 * notify = callback to search for 196 * data = data to search for 197 */ 198 public void weakUnref(GstMiniObjectNotify notify, void* data) 199 { 200 // void gst_mini_object_weak_unref (GstMiniObject *object, GstMiniObjectNotify notify, gpointer data); 201 gst_mini_object_weak_unref(gstMiniObject, notify, data); 202 } 203 204 /** 205 * Lock the mini-object with the specified access mode in flags. 206 * Params: 207 * flags = GstLockFlags 208 * Returns: TRUE if object could be locked. 209 */ 210 public int lock(GstLockFlags flags) 211 { 212 // gboolean gst_mini_object_lock (GstMiniObject *object, GstLockFlags flags); 213 return gst_mini_object_lock(gstMiniObject, flags); 214 } 215 216 /** 217 * Unlock the mini-object with the specified access mode in flags. 218 * Params: 219 * flags = GstLockFlags 220 */ 221 public void unlock(GstLockFlags flags) 222 { 223 // void gst_mini_object_unlock (GstMiniObject *object, GstLockFlags flags); 224 gst_mini_object_unlock(gstMiniObject, flags); 225 } 226 227 /** 228 * If mini_object has the LOCKABLE flag set, check if the current EXCLUSIVE 229 * lock on object is the only one, this means that changes to the object will 230 * not be visible to any other object. 231 * If the LOCKABLE flag is not set, check if the refcount of mini_object is 232 * exactly 1, meaning that no other reference exists to the object and that the 233 * object is therefore writable. 234 * Modification of a mini-object should only be done after verifying that it 235 * is writable. 236 * Returns: TRUE if the object is writable. 237 */ 238 public int isWritable() 239 { 240 // gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object); 241 return gst_mini_object_is_writable(gstMiniObject); 242 } 243 244 /** 245 * Checks if a mini-object is writable. If not, a writable copy is made and 246 * returned. This gives away the reference to the original mini object, 247 * and returns a reference to the new object. 248 * MT safe 249 * Returns: a mini-object (possibly the same pointer) that is writable. [transfer full] 250 */ 251 public MiniObject makeWritable() 252 { 253 // GstMiniObject * gst_mini_object_make_writable (GstMiniObject *mini_object); 254 auto p = gst_mini_object_make_writable(gstMiniObject); 255 256 if(p is null) 257 { 258 return null; 259 } 260 261 return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p); 262 } 263 264 /** 265 * Creates a copy of the mini-object. 266 * MT safe 267 * Returns: the new mini-object. [transfer full] 268 */ 269 public MiniObject copy() 270 { 271 // GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object); 272 auto p = gst_mini_object_copy(gstMiniObject); 273 274 if(p is null) 275 { 276 return null; 277 } 278 279 return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p); 280 } 281 282 /** 283 * This sets an opaque, named pointer on a miniobject. 284 * The name is specified through a GQuark (retrived e.g. via 285 * g_quark_from_static_string()), and the pointer 286 * can be gotten back from the object with gst_mini_object_get_qdata() 287 * until the object is disposed. 288 * Setting a previously set user data pointer, overrides (frees) 289 * the old pointer set, using NULL as pointer essentially 290 * removes the data stored. 291 * destroy may be specified which is called with data as argument 292 * when the object is disposed, or the data is being overwritten by 293 * a call to gst_mini_object_set_qdata() with the same quark. 294 * Params: 295 * quark = A GQuark, naming the user data pointer 296 * data = An opaque user data pointer 297 * destroy = Function to invoke with data as argument, when data 298 * needs to be freed 299 */ 300 public void setQdata(GQuark quark, void* data, GDestroyNotify destroy) 301 { 302 // void gst_mini_object_set_qdata (GstMiniObject *object, GQuark quark, gpointer data, GDestroyNotify destroy); 303 gst_mini_object_set_qdata(gstMiniObject, quark, data, destroy); 304 } 305 306 /** 307 * This function gets back user data pointers stored via 308 * gst_mini_object_set_qdata(). 309 * Params: 310 * quark = A GQuark, naming the user data pointer 311 * Returns: The user data pointer set, or NULL. [transfer none] 312 */ 313 public void* getQdata(GQuark quark) 314 { 315 // gpointer gst_mini_object_get_qdata (GstMiniObject *object, GQuark quark); 316 return gst_mini_object_get_qdata(gstMiniObject, quark); 317 } 318 319 /** 320 * This function gets back user data pointers stored via gst_mini_object_set_qdata() 321 * and removes the data from object without invoking its destroy() function (if 322 * any was set). 323 * Params: 324 * quark = A GQuark, naming the user data pointer 325 * Returns: The user data pointer set, or NULL. [transfer full] 326 */ 327 public void* stealQdata(GQuark quark) 328 { 329 // gpointer gst_mini_object_steal_qdata (GstMiniObject *object, GQuark quark); 330 return gst_mini_object_steal_qdata(gstMiniObject, quark); 331 } 332 333 /** 334 * Atomically modifies a pointer to point to a new mini-object. 335 * The reference count of olddata is decreased and the reference count of 336 * newdata is increased. 337 * Either newdata and the value pointed to by olddata may be NULL. 338 * Params: 339 * olddata = pointer to a pointer to a mini-object to 340 * be replaced. [inout][transfer full] 341 * newdata = pointer to new mini-object 342 * Returns: TRUE if newdata was different from olddata 343 */ 344 public static int replace(ref MiniObject olddata, MiniObject newdata) 345 { 346 // gboolean gst_mini_object_replace (GstMiniObject **olddata, GstMiniObject *newdata); 347 GstMiniObject* outolddata = (olddata is null) ? null : olddata.getMiniObjectStruct(); 348 349 auto p = gst_mini_object_replace(&outolddata, (newdata is null) ? null : newdata.getMiniObjectStruct()); 350 351 olddata = ObjectG.getDObject!(MiniObject)(outolddata); 352 return p; 353 } 354 355 /** 356 * Modifies a pointer to point to a new mini-object. The modification 357 * is done atomically. This version is similar to gst_mini_object_replace() 358 * except that it does not increase the refcount of newdata and thus 359 * takes ownership of newdata. 360 * Either newdata and the value pointed to by olddata may be NULL. 361 * Params: 362 * olddata = pointer to a pointer to a mini-object to 363 * be replaced. [inout][transfer full] 364 * newdata = pointer to new mini-object 365 * Returns: TRUE if newdata was different from olddata 366 */ 367 public static int take(GstMiniObject** olddata, MiniObject newdata) 368 { 369 // gboolean gst_mini_object_take (GstMiniObject **olddata, GstMiniObject *newdata); 370 return gst_mini_object_take(olddata, (newdata is null) ? null : newdata.getMiniObjectStruct()); 371 } 372 373 /** 374 * Replace the current GstMiniObject pointer to by olddata with NULL and 375 * return the old value. 376 * Params: 377 * olddata = pointer to a pointer to a mini-object to 378 * be stolen. [inout][transfer full] 379 * Returns: the GstMiniObject at oldata 380 */ 381 public static MiniObject steal(GstMiniObject** olddata) 382 { 383 // GstMiniObject * gst_mini_object_steal (GstMiniObject **olddata); 384 auto p = gst_mini_object_steal(olddata); 385 386 if(p is null) 387 { 388 return null; 389 } 390 391 return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p); 392 } 393 }