Class GstObject
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Allocator,AudioRingBuffer,BufferPool,Bus,Clock,CollectPads,ControlBinding,ControlSource,Device,DeviceMonitor,DeviceProvider,Element,GstObject.Object$Impl,Pad,PadTemplate,Plugin,PluginFeature,Registry,Stream,StreamCollection,Task,TaskPool,Tracer,TracerRecord
GstObject provides a root for the object hierarchy tree filed in by the
GStreamer library. It is currently a thin wrapper on top of
GInitiallyUnowned. It is an abstract class that is not very usable on its own.
GstObject gives us basic refcounting, parenting functionality and locking.
Most of the functions are just extended for special GStreamer needs and can be
found under the same name in the base class of GstObject which is GObject
(e.g. g_object_ref() becomes gst_object_ref()).
Since GstObject derives from GInitiallyUnowned, it also inherits the
floating reference. Be aware that functions such as gst_bin_add() and
gst_element_add_pad() take ownership of the floating reference.
In contrast to GObject instances, GstObject adds a name property. The functions
gst_object_set_name() and gst_object_get_name() are used to set/get the name
of the object.
controlled properties
Controlled properties offers a lightweight way to adjust gobject properties
over stream-time. It works by using time-stamped value pairs that are queued
for element-properties. At run-time the elements continuously pull value
changes for the current stream-time.
What needs to be changed in a GstElement?
Very little - it is just two steps to make a plugin controllable!
- mark gobject-properties paramspecs that make sense to be controlled, by GST_PARAM_CONTROLLABLE.
- when processing data (get, chain, loop function) at the beginning call gst_object_sync_values(element,timestamp). This will make the controller update all GObject properties that are under its control with the current values based on the timestamp.
What needs to be done in applications? Again it's not a lot to change.
- create a
GstControlSource. csource = gst_interpolation_control_source_new (); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
- Attach the
GstControlSourceon the controller to a property. gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));
- Set the control values gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1); gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
- start your pipeline
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGstObject.Builder<B extends GstObject.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theDeepNotifyCallbackcallback.static classThe Object$Impl type represents a native instance of the abstract GstObject class.static classGStreamer base object class.Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new GstObject.GstObject(MemorySegment address) Create a GstObject proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddControlBinding(ControlBinding binding) Attach theGstControlBindingto the object.protected GstObjectasParent()Returns this instance as if it were its parent type.static booleancheckUniqueness(List<GstObject> list, String name) Checks to see if there is any object namednameinlist.This function does not do any locking of any kind.protected voiddeepNotify(GstObject orig, ParamSpec pspec) default signal handlerstatic voiddefaultDeepNotify(GObject object, GstObject orig, ParamSpec pspec, @Nullable String @Nullable [] excludedProps) A default deep_notify signal callback for an object.voiddefaultError(GError error, @Nullable String debug) A default error function that uses g_printerr() to display the error message and the optional debug string..voidemitDeepNotify(@Nullable String detail, @Nullable GstObject propObject, @Nullable ParamSpec prop) Emits the "deep-notify" signal.@Nullable ControlBindinggetControlBinding(String propertyName) Gets the correspondingGstControlBindingfor the property.Obtain the control-rate for thisobject.Audio processingGstElementobjects will use this rate to sub-divide their processing loop and call gst_object_sync_values() in between.booleangetGValueArray(String propertyName, ClockTime timestamp, ClockTime interval, @Nullable Value @Nullable [] values) Gets a number ofGValuesfor the given controlled property starting at the requested time.static MemoryLayoutThe memory layout of the native struct.@Nullable StringgetName()Returns a copy of the name ofobject.Caller should g_free() the return value after usage.@Nullable GstObjectReturns the parent ofobject.This function increases the refcount of the parent object so you should gst_object_unref() it after usage.Generates a string describing the path of this Object in the object hierarchy.static @Nullable TypegetType()Get the GType of the GstObject class@Nullable ValueGets the value for the given controlled property at the requested time.booleangetValueArray(String propertyName, ClockTime timestamp, ClockTime interval, @Nullable MemorySegment @Nullable [] values) Gets a number of values for the given controlled property starting at the requested time.booleanCheck if the this Object has active controlled properties.booleanhasAncestor(GstObject ancestor) Deprecated.Use gst_object_has_as_ancestor() instead.booleanhasAsAncestor(GstObject ancestor) Check if this Object has an ancestorancestorsomewhere up in the hierarchy.booleanhasAsParent(GstObject parent) Check ifparentis the parent ofobject.E.g.onDeepNotify(@Nullable String detail, GstObject.DeepNotifyCallback handler) The deep notify signal is used to be notified of property changes.ref()Increments the reference count onobject.This function does not take the lock on this Object because it relies on atomic refcounting.static @Nullable MemorySegmentrefSink(@Nullable MemorySegment object) Increase the reference count ofobject,and possibly remove the floating reference, ifobjecthas a floating reference.booleanremoveControlBinding(ControlBinding binding) Removes the correspondingGstControlBinding.static booleanAtomically modifies a pointer to point to a new object.voidsetControlBindingDisabled(String propertyName, boolean disabled) This function is used to disable the control bindings on a property for some time, i.e.voidsetControlBindingsDisabled(boolean disabled) This function is used to disable all controlled properties of the this Object for some time, i.e.voidsetControlRate(ClockTime controlRate) Change the control-rate for thisobject.Audio processingGstElementobjects will use this rate to sub-divide their processing loop and call gst_object_sync_values() in between.booleanSets the name ofobject,or gives this Object a guaranteed unique name (ifnameisnull).booleanSets the parent of this Object toparent.The object's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink()).Returns a suggestion for timestamps where buffers should be split to get best controller results.booleansyncValues(ClockTime timestamp) Sets the properties of the object, according to theGstControlSourcesthat (maybe) handle them and for the given timestamp.voidunparent()Clear the parent ofobject,removing the associated reference.voidunref()Decrements the reference count onobject.If reference count hits zero, destroyobject.This function does not take the lock on this Object as it relies on atomic refcounting.Methods inherited from class org.gnome.gobject.InitiallyUnowned
builderMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
GstObject
Create a GstObject proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
GstObject
public GstObject()Creates a new GstObject.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type.- Overrides:
asParentin classInitiallyUnowned
-
checkUniqueness
Checks to see if there is any object namednameinlist.This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock eachGstObjectin the list to compare the name, so be careful when passing a list with a locked object.- Parameters:
list- a list ofGstObjectto check throughname- the name to search for- Returns:
trueif aGstObjectnamednamedoes not appear inlist,falseif it does.MT safe. Grabs and releases the LOCK of each object in the list.
-
defaultDeepNotify
public static void defaultDeepNotify(GObject object, GstObject orig, ParamSpec pspec, @Nullable String @Nullable [] excludedProps) A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print.MT safe. This function grabs and releases
object'sLOCK for getting its path string.- Parameters:
object- theGObjectthat signalled the notify.orig- aGstObjectthat initiated the notify.pspec- aGParamSpecof the property.excludedProps- a set of user-specified properties to exclude ornullto show all changes.
-
refSink
Increase the reference count ofobject,and possibly remove the floating reference, ifobjecthas a floating reference.In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.
For more background on "floating references" please see the
GObjectdocumentation.- Parameters:
object- aGstObjectto sink
-
replace
Atomically modifies a pointer to point to a new object. The reference count ofoldobjis decreased and the reference count ofnewobjis increased.Either
newobjand the value pointed to byoldobjmay benull.- Parameters:
oldobj- pointer to a place of aGstObjectto replacenewobj- a newGstObject- Returns:
trueifnewobjwas different fromoldobj
-
addControlBinding
Attach theGstControlBindingto the object. If there already was aGstControlBindingfor this property it will be replaced.The object's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())
- Parameters:
binding- theGstControlBindingthat should be used- Returns:
falseif the givenbindinghas not been setup for this object or has been setup for a non suitable property,trueotherwise.
-
defaultError
A default error function that uses g_printerr() to display the error message and the optional debug string..The default handler will simply print the error string using g_print.
- Parameters:
error- the GError.debug- an additional debug information string, ornull
-
getControlBinding
Gets the correspondingGstControlBindingfor the property. This should be unreferenced again after use.- Parameters:
propertyName- name of the property- Returns:
- the
GstControlBindingforpropertyNameornullif the property is not controlled.
-
getControlRate
Obtain the control-rate for thisobject.Audio processingGstElementobjects will use this rate to sub-divide their processing loop and call gst_object_sync_values() in between. The length of the processing segment should be up tocontrolRatenanoseconds.If the this Object is not under property control, this will return
GST_CLOCK_TIME_NONE. This allows the element to avoid the sub-dividing.The control-rate is not expected to change if the element is in
State.PAUSEDorState.PLAYING.- Returns:
- the control rate in nanoseconds
-
getGValueArray
public boolean getGValueArray(String propertyName, ClockTime timestamp, ClockTime interval, @Nullable Value @Nullable [] values) Gets a number ofGValuesfor the given controlled property starting at the requested time. The arrayvaluesneed to hold enough space fornValuesofGValue.This function is useful if one wants to e.g. draw a graph of the control curve or apply a control curve sample by sample.
- Parameters:
propertyName- the name of the property to gettimestamp- the time that should be processedinterval- the time spacing between subsequent valuesvalues- array to put control-values in- Returns:
trueif the given array could be filled,falseotherwise
-
getName
Returns a copy of the name ofobject.Caller should g_free() the return value after usage. For a nameless object, this returnsnull, which you can safely g_free() as well.Free-function: g_free
- Returns:
- the name of
object.g_free() after usage.MT safe. This function grabs and releases
object'sLOCK.
-
getParent
Returns the parent ofobject.This function increases the refcount of the parent object so you should gst_object_unref() it after usage.- Returns:
- parent of
object,this can benullif this Object has no parent. unref after usage.MT safe. Grabs and releases
object'sLOCK.
-
getPathString
Generates a string describing the path of this Object in the object hierarchy. Only useful (or used) for debugging.Free-function: g_free
- 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.
-
getValue
Gets the value for the given controlled property at the requested time.- Parameters:
propertyName- the name of the property to gettimestamp- the time the control-change should be read from- Returns:
- the GValue of the property at the given time,
or
nullif the property isn't controlled.
-
getValueArray
public boolean getValueArray(String propertyName, ClockTime timestamp, ClockTime interval, @Nullable MemorySegment @Nullable [] values) Gets a number of values for the given controlled property starting at the requested time. The arrayvaluesneed to hold enough space fornValuesof the same type as the objects property's type.This function is useful if one wants to e.g. draw a graph of the control curve or apply a control curve sample by sample.
The values are unboxed and ready to be used. The similar function gst_object_get_g_value_array() returns the array as
GValuesand is better suites for bindings.- Parameters:
propertyName- the name of the property to gettimestamp- the time that should be processedinterval- the time spacing between subsequent valuesvalues- array to put control-values in- Returns:
trueif the given array could be filled,falseotherwise
-
hasActiveControlBindings
public boolean hasActiveControlBindings()Check if the this Object has active controlled properties.- Returns:
trueif the object has active controlled properties
-
hasAncestor
Deprecated.Use gst_object_has_as_ancestor() instead.MT safe. Grabs and releases
object'slocks.Check if this Object has an ancestorancestorsomewhere up in the hierarchy. One can e.g. check if aGstElementis inside aGstPipeline.- Parameters:
ancestor- aGstObjectto check as ancestor- Returns:
trueifancestoris an ancestor ofobject.
-
hasAsAncestor
Check if this Object has an ancestorancestorsomewhere up in the hierarchy. One can e.g. check if aGstElementis inside aGstPipeline.- Parameters:
ancestor- aGstObjectto check as ancestor- Returns:
trueifancestoris an ancestor ofobject.MT safe. Grabs and releases
object'slocks.
-
hasAsParent
Check ifparentis the parent ofobject.E.g. aGstElementcan check if it owns a givenGstPad.- Parameters:
parent- aGstObjectto check as parent- Returns:
falseif either this Object orparentisnull.trueifparentis the parent ofobject.Otherwisefalse.MT safe. Grabs and releases
object'slocks.- Since:
- 1.6
-
ref
Increments the reference count onobject.This function does not take the lock on this Object because it relies on atomic refcounting.This object returns the input parameter to ease writing constructs like : result = gst_object_ref (object->parent);
-
removeControlBinding
Removes the correspondingGstControlBinding. If it was the last ref of the binding, it will be disposed.- Parameters:
binding- the binding- Returns:
trueif the binding could be removed.
-
setControlBindingDisabled
This function is used to disable the control bindings on a property for some time, i.e. gst_object_sync_values() will do nothing for the property.- Parameters:
propertyName- property to disabledisabled- boolean that specifies whether to disable the controller or not.
-
setControlBindingsDisabled
public void setControlBindingsDisabled(boolean disabled) This function is used to disable all controlled properties of the this Object for some time, i.e. gst_object_sync_values() will do nothing.- Parameters:
disabled- boolean that specifies whether to disable the controller or not.
-
setControlRate
Change the control-rate for thisobject.Audio processingGstElementobjects will use this rate to sub-divide their processing loop and call gst_object_sync_values() in between. The length of the processing segment should be up tocontrolRatenanoseconds.The control-rate should not change if the element is in
State.PAUSEDorState.PLAYING.- Parameters:
controlRate- the new control-rate in nanoseconds.
-
setName
Sets the name ofobject,or gives this Object a guaranteed unique name (ifnameisnull). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.- Parameters:
name- new name of object- Returns:
trueif the name could be set. Since Objects that have a parent cannot be renamed, this function returnsfalsein those cases.MT safe. This function grabs and releases
object'sLOCK.
-
setParent
Sets the parent of this Object toparent.The object's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink()).- Parameters:
parent- new parent of object- Returns:
trueifparentcould be set orfalsewhen this Object already had a parent or this Object andparentare the same.MT safe. Grabs and releases
object'sLOCK.
-
suggestNextSync
Returns a suggestion for timestamps where buffers should be split to get best controller results.- Returns:
- Returns the suggested timestamp or
GST_CLOCK_TIME_NONEif no control-rate was set.
-
syncValues
Sets the properties of the object, according to theGstControlSourcesthat (maybe) handle them and for the given timestamp.If this function fails, it is most likely the application developers fault. Most probably the control sources are not setup correctly.
- Parameters:
timestamp- the time that should be processed- Returns:
trueif the controller values could be applied to the object properties,falseotherwise
-
unparent
public void unparent()Clear the parent ofobject,removing the associated reference. This function decreases the refcount ofobject.MT safe. Grabs and releases
object'slock. -
unref
public void unref()Decrements the reference count onobject.If reference count hits zero, destroyobject.This function does not take the lock on this Object as it relies on atomic refcounting.The unref method should never be called with the LOCK held since this might deadlock the dispose function.
-
deepNotify
-
onDeepNotify
public SignalConnection<GstObject.DeepNotifyCallback> onDeepNotify(@Nullable String detail, GstObject.DeepNotifyCallback handler) The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.- Parameters:
detail- the signal detailhandler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDeepNotify
public void emitDeepNotify(@Nullable String detail, @Nullable GstObject propObject, @Nullable ParamSpec prop) Emits the "deep-notify" signal. SeeonDeepNotify(java.lang.String, org.freedesktop.gstreamer.gst.GstObject.DeepNotifyCallback).
-