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