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 = GstObject.html 27 * outPack = gstreamer 28 * outFile = ObjectGst 29 * strct = GstObject 30 * realStrct= 31 * ctorStrct= 32 * clss = ObjectGst 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_object_ 41 * omit structs: 42 * - GstObjectClass 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.ListG 50 * - gobject.ObjectG 51 * - gobject.ParamSpec 52 * - gobject.Value 53 * - gstreamer.ControlBinding 54 * structWrap: 55 * - GError* -> ErrorG 56 * - GList* -> ListG 57 * - GObject* -> ObjectG 58 * - GParamSpec* -> ParamSpec 59 * - GValue* -> Value 60 * - GstControlBinding* -> ControlBinding 61 * - GstObject* -> ObjectGst 62 * module aliases: 63 * local aliases: 64 * overrides: 65 */ 66 67 module gstreamer.ObjectGst; 68 69 public import gstreamerc.gstreamertypes; 70 71 private import gstreamerc.gstreamer; 72 private import glib.ConstructionException; 73 private import gobject.ObjectG; 74 75 private import gobject.Signals; 76 public import gtkc.gdktypes; 77 private import glib.Str; 78 private import glib.ErrorG; 79 private import glib.ListG; 80 private import gobject.ObjectG; 81 private import gobject.ParamSpec; 82 private import gobject.Value; 83 private import gstreamer.ControlBinding; 84 85 86 private import gobject.ObjectG; 87 88 /** 89 * GstObject provides a root for the object hierarchy tree filed in by the 90 * GStreamer library. It is currently a thin wrapper on top of 91 * GInitiallyUnowned. It is an abstract class that is not very usable on its own. 92 * 93 * GstObject gives us basic refcounting, parenting functionality and locking. 94 * Most of the function are just extended for special GStreamer needs and can be 95 * found under the same name in the base class of GstObject which is GObject 96 * (e.g. g_object_ref() becomes gst_object_ref()). 97 * 98 * Since GstObject dereives from GInitiallyUnowned, it also inherits the 99 * floating reference. Be aware that functions such as gst_bin_add() and 100 * gst_element_add_pad() take ownership of the floating reference. 101 * 102 * In contrast to GObject instances, GstObject adds a name property. The functions 103 * gst_object_set_name() and gst_object_get_name() are used to set/get the name 104 * of the object. 105 * 106 * controlled properties 107 * 108 * Controlled properties offers a lightweight way to adjust gobject 109 * properties over stream-time. It works by using time-stamped value pairs that 110 * are queued for element-properties. At run-time the elements continuously pull 111 * values changes for the current stream-time. 112 * 113 * What needs to be changed in a GstElement? 114 * Very little - it is just two steps to make a plugin controllable! 115 * 116 * mark gobject-properties paramspecs that make sense to be controlled, 117 * by GST_PARAM_CONTROLLABLE. 118 * 119 * when processing data (get, chain, loop function) at the beginning call 120 * gst_object_sync_values(element,timestamp). 121 * This will made the controller to update all gobject properties that are under 122 * control with the current values based on timestamp. 123 * 124 * What needs to be done in applications? 125 * Again it's not a lot to change. 126 * 127 * create a GstControlSource. 128 * csource = gst_interpolation_control_source_new(); 129 * g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); 130 * 131 * Attach the GstControlSource on the controller to a property. 132 * gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource)); 133 * 134 * Set the control values 135 * gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1); 136 * gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2); 137 * 138 * start your pipeline 139 * 140 * Last reviewed on 2012-03-29 (0.11.3) 141 */ 142 public class ObjectGst : ObjectG 143 { 144 145 /** the main Gtk struct */ 146 protected GstObject* gstObject; 147 148 149 /** Get the main Gtk struct */ 150 public GstObject* getObjectGstStruct() 151 { 152 return gstObject; 153 } 154 155 156 /** the main Gtk struct as a void* */ 157 protected override void* getStruct() 158 { 159 return cast(void*)gstObject; 160 } 161 162 /** 163 * Sets our main struct and passes it to the parent class 164 */ 165 public this (GstObject* gstObject) 166 { 167 super(cast(GObject*)gstObject); 168 this.gstObject = gstObject; 169 } 170 171 protected override void setStruct(GObject* obj) 172 { 173 super.setStruct(obj); 174 gstObject = cast(GstObject*)obj; 175 } 176 177 /** 178 */ 179 int[string] connectedSignals; 180 181 void delegate(ObjectGst, ParamSpec, ObjectGst)[] onDeepNotifyListeners; 182 /** 183 * The deep notify signal is used to be notified of property changes. It is 184 * typically attached to the toplevel bin to receive notifications from all 185 * the elements contained in that bin. 186 */ 187 void addOnDeepNotify(void delegate(ObjectGst, ParamSpec, ObjectGst) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 188 { 189 if ( !("deep-notify" in connectedSignals) ) 190 { 191 Signals.connectData( 192 getStruct(), 193 "deep-notify", 194 cast(GCallback)&callBackDeepNotify, 195 cast(void*)this, 196 null, 197 connectFlags); 198 connectedSignals["deep-notify"] = 1; 199 } 200 onDeepNotifyListeners ~= dlg; 201 } 202 extern(C) static void callBackDeepNotify(GstObject* gstobjectStruct, GstObject* propObject, GParamSpec* prop, ObjectGst _objectGst) 203 { 204 foreach ( void delegate(ObjectGst, ParamSpec, ObjectGst) dlg ; _objectGst.onDeepNotifyListeners ) 205 { 206 dlg(ObjectG.getDObject!(ObjectGst)(propObject), ObjectG.getDObject!(ParamSpec)(prop), _objectGst); 207 } 208 } 209 210 211 /** 212 * Sets the name of object, or gives object a guaranteed unique 213 * name (if name is NULL). 214 * This function makes a copy of the provided name, so the caller 215 * retains ownership of the name it sent. 216 * Params: 217 * name = new name of object 218 * Returns: TRUE if the name could be set. Since Objects that have a parent cannot be renamed, this function returns FALSE in those cases. MT safe. This function grabs and releases object's LOCK. 219 */ 220 public int setName(string name) 221 { 222 // gboolean gst_object_set_name (GstObject *object, const gchar *name); 223 return gst_object_set_name(gstObject, Str.toStringz(name)); 224 } 225 226 /** 227 * Returns a copy of the name of object. 228 * Caller should g_free() the return value after usage. 229 * For a nameless object, this returns NULL, which you can safely g_free() 230 * as well. 231 * Free-function: g_free 232 * Returns: the name of object. g_free() after usage. MT safe. This function grabs and releases object's LOCK. [transfer full] 233 */ 234 public string getName() 235 { 236 // gchar * gst_object_get_name (GstObject *object); 237 return Str.toString(gst_object_get_name(gstObject)); 238 } 239 240 /** 241 * Sets the parent of object to parent. The object's reference count will 242 * be incremented, and any floating reference will be removed (see gst_object_ref_sink()). 243 * Params: 244 * parent = new parent of object 245 * Returns: TRUE if parent could be set or FALSE when object already had a parent or object and parent are the same. MT safe. Grabs and releases object's LOCK. 246 */ 247 public int setParent(ObjectGst parent) 248 { 249 // gboolean gst_object_set_parent (GstObject *object, GstObject *parent); 250 return gst_object_set_parent(gstObject, (parent is null) ? null : parent.getObjectGstStruct()); 251 } 252 253 /** 254 * Returns the parent of object. This function increases the refcount 255 * of the parent object so you should gst_object_unref() it after usage. 256 * Returns: parent of object, this can be NULL if object has no parent. unref after usage. MT safe. Grabs and releases object's LOCK. [transfer full] 257 */ 258 public ObjectGst getParent() 259 { 260 // GstObject * gst_object_get_parent (GstObject *object); 261 auto p = gst_object_get_parent(gstObject); 262 263 if(p is null) 264 { 265 return null; 266 } 267 268 return ObjectG.getDObject!(ObjectGst)(cast(GstObject*) p); 269 } 270 271 /** 272 * Clear the parent of object, removing the associated reference. 273 * This function decreases the refcount of object. 274 * MT safe. Grabs and releases object's lock. 275 */ 276 public void unparent() 277 { 278 // void gst_object_unparent (GstObject *object); 279 gst_object_unparent(gstObject); 280 } 281 282 /** 283 * A default deep_notify signal callback for an object. The user data 284 * should contain a pointer to an array of strings that should be excluded 285 * from the notify. The default handler will print the new value of the property 286 * using g_print. 287 * MT safe. This function grabs and releases object's LOCK for getting its 288 * path string. 289 * Params: 290 * object = the GObject that signalled the notify. 291 * orig = a GstObject that initiated the notify. 292 * pspec = a GParamSpec of the property. 293 * excludedProps = a set of user-specified properties to exclude or NULL to show 294 * all changes. [array zero-terminated=1][element-type gchar*][allow-none] 295 */ 296 public static void defaultDeepNotify(ObjectG object, ObjectGst orig, ParamSpec pspec, string[] excludedProps) 297 { 298 // void gst_object_default_deep_notify (GObject *object, GstObject *orig, GParamSpec *pspec, gchar **excluded_props); 299 gst_object_default_deep_notify((object is null) ? null : object.getObjectGStruct(), (orig is null) ? null : orig.getObjectGstStruct(), (pspec is null) ? null : pspec.getParamSpecStruct(), Str.toStringzArray(excludedProps)); 300 } 301 302 /** 303 * A default error function that uses g_printerr() to display the error message 304 * and the optional debug sting.. 305 * The default handler will simply print the error string using g_print. 306 * Params: 307 * error = the GError. [in] 308 */ 309 public void defaultError(ErrorG error, ref char dbug) 310 { 311 // void gst_object_default_error (GstObject *source, const GError *error, const gchar *debug); 312 gst_object_default_error(gstObject, (error is null) ? null : error.getErrorGStruct(), &dbug); 313 } 314 315 /** 316 * Checks to see if there is any object named name in list. This function 317 * does not do any locking of any kind. You might want to protect the 318 * provided list with the lock of the owner of the list. This function 319 * will lock each GstObject in the list to compare the name, so be 320 * carefull when passing a list with a locked object. 321 * Params: 322 * list = a list of GstObject to 323 * check through. [transfer none][element-type Gst.Object] 324 * name = the name to search for 325 * Returns: TRUE if a GstObject named name does not appear in list, FALSE if it does. MT safe. Grabs and releases the LOCK of each object in the list. 326 */ 327 public static int checkUniqueness(ListG list, string name) 328 { 329 // gboolean gst_object_check_uniqueness (GList *list, const gchar *name); 330 return gst_object_check_uniqueness((list is null) ? null : list.getListGStruct(), Str.toStringz(name)); 331 } 332 333 /** 334 * Check if object has an ancestor ancestor somewhere up in 335 * the hierarchy. One can e.g. check if a GstElement is inside a GstPipeline. 336 * Params: 337 * ancestor = a GstObject to check as ancestor 338 * Returns: TRUE if ancestor is an ancestor of object. MT safe. Grabs and releases object's locks. 339 */ 340 public int hasAncestor(ObjectGst ancestor) 341 { 342 // gboolean gst_object_has_ancestor (GstObject *object, GstObject *ancestor); 343 return gst_object_has_ancestor(gstObject, (ancestor is null) ? null : ancestor.getObjectGstStruct()); 344 } 345 346 /** 347 * Increments the reference count on object. This function 348 * does not take the lock on object because it relies on 349 * atomic refcounting. 350 * This object returns the input parameter to ease writing 351 * Params: 352 * object = a GstObject to reference. [type Gst.Object] 353 * Returns: A pointer to object. [transfer full][type Gst.Object] 354 */ 355 public static void* doref(void* object) 356 { 357 // gpointer gst_object_ref (gpointer object); 358 return gst_object_ref(object); 359 } 360 361 /** 362 * Decrements the reference count on object. If reference count hits 363 * zero, destroy object. This function does not take the lock 364 * on object as it relies on atomic refcounting. 365 * The unref method should never be called with the LOCK held since 366 * this might deadlock the dispose function. 367 * Params: 368 * object = a GstObject to unreference. [type Gst.Object] 369 */ 370 public static void unref(void* object) 371 { 372 // void gst_object_unref (gpointer object); 373 gst_object_unref(object); 374 } 375 376 /** 377 * Increase the reference count of object, and possibly remove the floating 378 * reference, if object has a floating reference. 379 * In other words, if the object is floating, then this call "assumes ownership" 380 * of the floating reference, converting it to a normal reference by clearing 381 * the floating flag while leaving the reference count unchanged. If the object 382 * is not floating, then this call adds a new normal reference increasing the 383 * reference count by one. 384 * Params: 385 * object = a GstObject to sink 386 */ 387 public static void* refSink(void* object) 388 { 389 // gpointer gst_object_ref_sink (gpointer object); 390 return gst_object_ref_sink(object); 391 } 392 393 /** 394 * Atomically modifies a pointer to point to a new object. 395 * The reference count of oldobj is decreased and the reference count of 396 * newobj is increased. 397 * Either newobj and the value pointed to by oldobj may be NULL. 398 * Params: 399 * oldobj = pointer to a place of a GstObject to 400 * replace. [inout][transfer full] 401 * newobj = a new GstObject. [transfer none] 402 * Returns: TRUE if newobj was different from oldobj 403 */ 404 public static int replace(ref ObjectGst oldobj, ObjectGst newobj) 405 { 406 // gboolean gst_object_replace (GstObject **oldobj, GstObject *newobj); 407 GstObject* outoldobj = (oldobj is null) ? null : oldobj.getObjectGstStruct(); 408 409 auto p = gst_object_replace(&outoldobj, (newobj is null) ? null : newobj.getObjectGstStruct()); 410 411 oldobj = ObjectG.getDObject!(ObjectGst)(outoldobj); 412 return p; 413 } 414 415 /** 416 * Generates a string describing the path of object in 417 * the object hierarchy. Only useful (or used) for debugging. 418 * Free-function: g_free 419 * Returns: a string describing the path of object. You must g_free() the string after usage. MT safe. Grabs and releases the GstObject's LOCK for all objects in the hierarchy. [transfer full] 420 */ 421 public string getPathString() 422 { 423 // gchar * gst_object_get_path_string (GstObject *object); 424 return Str.toString(gst_object_get_path_string(gstObject)); 425 } 426 427 /** 428 * Returns a suggestion for timestamps where buffers should be split 429 * to get best controller results. 430 * Returns: Returns the suggested timestamp or GST_CLOCK_TIME_NONE if no control-rate was set. 431 */ 432 public GstClockTime suggestNextSync() 433 { 434 // GstClockTime gst_object_suggest_next_sync (GstObject *object); 435 return gst_object_suggest_next_sync(gstObject); 436 } 437 438 /** 439 * Sets the properties of the object, according to the GstControlSources that 440 * (maybe) handle them and for the given timestamp. 441 * If this function fails, it is most likely the application developers fault. 442 * Most probably the control sources are not setup correctly. 443 * Params: 444 * timestamp = the time that should be processed 445 * Returns: TRUE if the controller values could be applied to the object properties, FALSE otherwise 446 */ 447 public int syncValues(GstClockTime timestamp) 448 { 449 // gboolean gst_object_sync_values (GstObject *object, GstClockTime timestamp); 450 return gst_object_sync_values(gstObject, timestamp); 451 } 452 453 /** 454 * Check if the object has an active controlled properties. 455 * Returns: TRUE if the object has active controlled properties 456 */ 457 public int hasActiveControlBindings() 458 { 459 // gboolean gst_object_has_active_control_bindings (GstObject *object); 460 return gst_object_has_active_control_bindings(gstObject); 461 } 462 463 /** 464 * This function is used to disable all controlled properties of the object for 465 * some time, i.e. gst_object_sync_values() will do nothing. 466 * Params: 467 * disabled = boolean that specifies whether to disable the controller 468 * or not. 469 */ 470 public void setControlBindingsDisabled(int disabled) 471 { 472 // void gst_object_set_control_bindings_disabled (GstObject *object, gboolean disabled); 473 gst_object_set_control_bindings_disabled(gstObject, disabled); 474 } 475 476 /** 477 * This function is used to disable the GstController on a property for 478 * some time, i.e. gst_controller_sync_values() will do nothing for the 479 * property. 480 * Params: 481 * propertyName = property to disable 482 * disabled = boolean that specifies whether to disable the controller 483 * or not. 484 */ 485 public void setControlBindingDisabled(string propertyName, int disabled) 486 { 487 // void gst_object_set_control_binding_disabled (GstObject *object, const gchar *property_name, gboolean disabled); 488 gst_object_set_control_binding_disabled(gstObject, Str.toStringz(propertyName), disabled); 489 } 490 491 /** 492 * Attach the GstControlBinding to the object. If there already was a 493 * GstControlBinding for this property it will be replaced. 494 * The object will take ownership of the binding. 495 * Params: 496 * binding = the GstControlBinding that should be used. [transfer full] 497 * Returns: FALSE if the given binding has not been setup for this object or has been setup for a non suitable property, TRUE otherwise. 498 */ 499 public int addControlBinding(ControlBinding binding) 500 { 501 // gboolean gst_object_add_control_binding (GstObject *object, GstControlBinding *binding); 502 return gst_object_add_control_binding(gstObject, (binding is null) ? null : binding.getControlBindingStruct()); 503 } 504 505 /** 506 * Gets the corresponding GstControlBinding for the property. This should be 507 * unreferenced again after use. 508 * Params: 509 * propertyName = name of the property 510 * Returns: the GstControlBinding for property_name or NULL if the property is not controlled. [transfer full] 511 */ 512 public ControlBinding getControlBinding(string propertyName) 513 { 514 // GstControlBinding * gst_object_get_control_binding (GstObject *object, const gchar *property_name); 515 auto p = gst_object_get_control_binding(gstObject, Str.toStringz(propertyName)); 516 517 if(p is null) 518 { 519 return null; 520 } 521 522 return ObjectG.getDObject!(ControlBinding)(cast(GstControlBinding*) p); 523 } 524 525 /** 526 * Removes the corresponding GstControlBinding. If it was the 527 * last ref of the binding, it will be disposed. 528 * Params: 529 * binding = the binding 530 * Returns: TRUE if the binding could be removed. 531 */ 532 public int removeControlBinding(ControlBinding binding) 533 { 534 // gboolean gst_object_remove_control_binding (GstObject *object, GstControlBinding *binding); 535 return gst_object_remove_control_binding(gstObject, (binding is null) ? null : binding.getControlBindingStruct()); 536 } 537 538 /** 539 * Gets the value for the given controlled property at the requested time. 540 * Params: 541 * propertyName = the name of the property to get 542 * timestamp = the time the control-change should be read from 543 * Returns: the GValue of the property at the given time, or NULL if the property isn't controlled. 544 */ 545 public Value getValue(string propertyName, GstClockTime timestamp) 546 { 547 // GValue * gst_object_get_value (GstObject *object, const gchar *property_name, GstClockTime timestamp); 548 auto p = gst_object_get_value(gstObject, Str.toStringz(propertyName), timestamp); 549 550 if(p is null) 551 { 552 return null; 553 } 554 555 return ObjectG.getDObject!(Value)(cast(GValue*) p); 556 } 557 558 /** 559 * Gets a number of values for the given controlled property starting at the 560 * requested time. The array values need to hold enough space for n_values of 561 * the same type as the objects property's type. 562 * This function is useful if one wants to e.g. draw a graph of the control 563 * curve or apply a control curve sample by sample. 564 * The values are unboxed and ready to be used. The similar function 565 * gst_object_get_g_value_array() returns the array as GValues and is 566 * better suites for bindings. 567 * Params: 568 * propertyName = the name of the property to get 569 * timestamp = the time that should be processed 570 * interval = the time spacing between subsequent values 571 * values = array to put control-values in 572 * Returns: TRUE if the given array could be filled, FALSE otherwise 573 */ 574 public int getValueArray(string propertyName, GstClockTime timestamp, GstClockTime interval, void[] values) 575 { 576 // gboolean gst_object_get_value_array (GstObject *object, const gchar *property_name, GstClockTime timestamp, GstClockTime interval, guint n_values, gpointer values); 577 return gst_object_get_value_array(gstObject, Str.toStringz(propertyName), timestamp, interval, cast(int) values.length, values.ptr); 578 } 579 580 /** 581 * Gets a number of GValues for the given controlled property starting at the 582 * requested time. The array values need to hold enough space for n_values of 583 * GValue. 584 * This function is useful if one wants to e.g. draw a graph of the control 585 * curve or apply a control curve sample by sample. 586 * Params: 587 * propertyName = the name of the property to get 588 * timestamp = the time that should be processed 589 * interval = the time spacing between subsequent values 590 * nValues = the number of values 591 * values = array to put control-values in 592 * Returns: TRUE if the given array could be filled, FALSE otherwise 593 */ 594 public int getGValueArray(string propertyName, GstClockTime timestamp, GstClockTime interval, uint nValues, Value values) 595 { 596 // gboolean gst_object_get_g_value_array (GstObject *object, const gchar *property_name, GstClockTime timestamp, GstClockTime interval, guint n_values, GValue *values); 597 return gst_object_get_g_value_array(gstObject, Str.toStringz(propertyName), timestamp, interval, nValues, (values is null) ? null : values.getValueStruct()); 598 } 599 600 /** 601 * Obtain the control-rate for this object. Audio processing GstElement 602 * objects will use this rate to sub-divide their processing loop and call 603 * gst_object_sync_values() inbetween. The length of the processing segment 604 * should be up to control-rate nanoseconds. 605 * If the object is not under property control, this will return 606 * GST_CLOCK_TIME_NONE. This allows the element to avoid the sub-dividing. 607 * The control-rate is not expected to change if the element is in 608 * GST_STATE_PAUSED or GST_STATE_PLAYING. 609 * Returns: the control rate in nanoseconds 610 */ 611 public GstClockTime getControlRate() 612 { 613 // GstClockTime gst_object_get_control_rate (GstObject *object); 614 return gst_object_get_control_rate(gstObject); 615 } 616 617 /** 618 * Change the control-rate for this object. Audio processing GstElement 619 * objects will use this rate to sub-divide their processing loop and call 620 * gst_object_sync_values() inbetween. The length of the processing segment 621 * should be up to control-rate nanoseconds. 622 * The control-rate should not change if the element is in GST_STATE_PAUSED or 623 * GST_STATE_PLAYING. 624 * Params: 625 * controlRate = the new control-rate in nanoseconds. 626 */ 627 public void setControlRate(GstClockTime controlRate) 628 { 629 // void gst_object_set_control_rate (GstObject *object, GstClockTime control_rate); 630 gst_object_set_control_rate(gstObject, controlRate); 631 } 632 }