Class GstObject
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Allocator
,AudioRingBuffer
,BufferPool
,Bus
,Clock
,CollectPads
,ControlBinding
,ControlSource
,Device
,DeviceMonitor
,DeviceProvider
,Element
,GstObject.ObjectImpl
,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
GstControlSource
on 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
Modifier and TypeClassDescriptionstatic class
GstObject.Builder<B extends GstObject.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDeepNotifyCallback
callback.static class
GStreamer base object class.static class
The ObjectImpl type represents a native instance of the abstract GstObject class.Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionGstObject
(MemorySegment address) Create a GstObject proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addControlBinding
(ControlBinding binding) Attach theGstControlBinding
to the object.protected GstObject
asParent()
Returns this instance as if it were its parent type.static GstObject.Builder
<? extends GstObject.Builder> builder()
AGstObject.Builder
object constructs aGstObject
with the specified properties.static boolean
checkUniqueness
(List<GstObject> list, String name) Checks to see if there is any object namedname
inlist
.protected void
deepNotify
(GstObject orig, ParamSpec pspec) default signal handlerstatic void
defaultDeepNotify
(GObject object, GstObject orig, ParamSpec pspec, @Nullable String[] excludedProps) A default deep_notify signal callback for an object.void
defaultError
(GError error, @Nullable String debug) A default error function that uses g_printerr() to display the error message and the optional debug string..void
emitDeepNotify
(@Nullable String detail, GstObject propObject, ParamSpec prop) Emits the "deep-notify" signal.getControlBinding
(String propertyName) Gets the correspondingGstControlBinding
for the property.Obtain the control-rate for this this Object.boolean
getGValueArray
(String propertyName, ClockTime timestamp, ClockTime interval, Value[] values) Gets a number ofGValues
for the given controlled property starting at the requested time.static MemoryLayout
The memory layout of the native struct.getName()
Returns a copy of the name of this Object.Returns the parent of this Object.Generates a string describing the path of this Object in the object hierarchy.static Type
getType()
Get the GType of the GstObject classGets the value for the given controlled property at the requested time.boolean
getValueArray
(String propertyName, ClockTime timestamp, ClockTime interval, MemorySegment[] values) Gets a number of values for the given controlled property starting at the requested time.boolean
Check if the this Object has active controlled properties.boolean
hasAncestor
(GstObject ancestor) Deprecated.Use gst_object_has_as_ancestor() instead.boolean
hasAsAncestor
(GstObject ancestor) Check if this Object has an ancestorancestor
somewhere up in the hierarchy.boolean
hasAsParent
(GstObject parent) Check ifparent
is the parent of this Object.onDeepNotify
(@Nullable String detail, GstObject.DeepNotifyCallback handler) The deep notify signal is used to be notified of property changes.ref()
Increments the reference count on this Object.static MemorySegment
refSink
(@Nullable MemorySegment object) Increase the reference count ofobject
, and possibly remove the floating reference, ifobject
has a floating reference.boolean
removeControlBinding
(ControlBinding binding) Removes the correspondingGstControlBinding
.static boolean
Atomically modifies a pointer to point to a new object.void
setControlBindingDisabled
(String propertyName, boolean disabled) This function is used to disable the control bindings on a property for some time, i.e.void
setControlBindingsDisabled
(boolean disabled) This function is used to disable all controlled properties of the this Object for some time, i.e.void
setControlRate
(ClockTime controlRate) Change the control-rate for this this Object.boolean
Sets the name of this Object, or gives this Object a guaranteed unique name (ifname
isnull
).boolean
Sets the parent of this Object toparent
.Returns a suggestion for timestamps where buffers should be split to get best controller results.boolean
syncValues
(ClockTime timestamp) Sets the properties of the object, according to theGstControlSources
that (maybe) handle them and for the given timestamp.void
unparent()
Clear the parent of this Object, removing the associated reference.void
unref()
Decrements the reference count on this Object.Methods 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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
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 Javasuper
keyword, 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:
asParent
in classInitiallyUnowned
-
checkUniqueness
Checks to see if there is any object namedname
inlist
. 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 eachGstObject
in the list to compare the name, so be careful when passing a list with a locked object.- Parameters:
list
- a list ofGstObject
to check throughname
- the name to search for- Returns:
true
if aGstObject
namedname
does not appear inlist
,false
if 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 @Nullable String[] 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
's LOCK for getting its path string.- Parameters:
object
- theGObject
that signalled the notify.orig
- aGstObject
that initiated the notify.pspec
- aGParamSpec
of the property.excludedProps
- a set of user-specified properties to exclude ornull
to show all changes.
-
refSink
Increase the reference count ofobject
, and possibly remove the floating reference, ifobject
has 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
GObject
documentation.- Parameters:
object
- aGstObject
to sink
-
replace
public static boolean replace(@Nullable @Nullable Out<GstObject> oldobj, @Nullable @Nullable GstObject newobj) Atomically modifies a pointer to point to a new object. The reference count ofoldobj
is decreased and the reference count ofnewobj
is increased.Either
newobj
and the value pointed to byoldobj
may benull
.- Parameters:
oldobj
- pointer to a place of aGstObject
to replacenewobj
- a newGstObject
- Returns:
true
ifnewobj
was different fromoldobj
-
addControlBinding
Attach theGstControlBinding
to the object. If there already was aGstControlBinding
for 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
- theGstControlBinding
that should be used- Returns:
false
if the givenbinding
has not been setup for this object or has been setup for a non suitable property,true
otherwise.
-
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 correspondingGstControlBinding
for the property. This should be unreferenced again after use.- Parameters:
propertyName
- name of the property- Returns:
- the
GstControlBinding
forpropertyName
ornull
if the property is not controlled.
-
getControlRate
Obtain the control-rate for this this Object. Audio processingGstElement
objects 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 tocontrol
-rate nanoseconds.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.PAUSED
orState.PLAYING
.- Returns:
- the control rate in nanoseconds
-
getGValueArray
public boolean getGValueArray(String propertyName, ClockTime timestamp, ClockTime interval, Value[] values) Gets a number ofGValues
for the given controlled property starting at the requested time. The arrayvalues
need to hold enough space fornValues
ofGValue
.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:
true
if the given array could be filled,false
otherwise
-
getName
Returns a copy of the name of this Object. 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 this Object. g_free()
after usage.
MT safe. This function grabs and releases this Object's LOCK.
-
getParent
Returns the parent of this Object. This function increases the refcount of the parent object so you should gst_object_unref() it after usage.- Returns:
- parent of this Object, this can be
null
if this Object has no parent. unref after usage.MT safe. Grabs and releases this Object's LOCK.
-
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 this 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
null
if the property isn't controlled.
-
getValueArray
public boolean getValueArray(String propertyName, ClockTime timestamp, ClockTime interval, MemorySegment[] values) Gets a number of values for the given controlled property starting at the requested time. The arrayvalues
need to hold enough space fornValues
of 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
GValues
and 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:
true
if the given array could be filled,false
otherwise
-
hasActiveControlBindings
public boolean hasActiveControlBindings()Check if the this Object has active controlled properties.- Returns:
true
if the object has active controlled properties
-
hasAncestor
Deprecated.Use gst_object_has_as_ancestor() instead.MT safe. Grabs and releases this Object's locks.
Check if this Object has an ancestorancestor
somewhere up in the hierarchy. One can e.g. check if aGstElement
is inside aGstPipeline
.- Parameters:
ancestor
- aGstObject
to check as ancestor- Returns:
true
ifancestor
is an ancestor of this Object.
-
hasAsAncestor
Check if this Object has an ancestorancestor
somewhere up in the hierarchy. One can e.g. check if aGstElement
is inside aGstPipeline
.- Parameters:
ancestor
- aGstObject
to check as ancestor- Returns:
true
ifancestor
is an ancestor of this Object.MT safe. Grabs and releases this Object's locks.
-
hasAsParent
Check ifparent
is the parent of this Object. E.g. aGstElement
can check if it owns a givenGstPad
.- Parameters:
parent
- aGstObject
to check as parent- Returns:
false
if either this Object orparent
isnull
.true
ifparent
is the parent of this Object. Otherwisefalse
.MT safe. Grabs and releases this Object's locks.
-
ref
Increments the reference count on this Object. 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:
true
if 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 this this Object. Audio processingGstElement
objects 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 tocontrol
-rate nanoseconds.The control-rate should not change if the element is in
State.PAUSED
orState.PLAYING
.- Parameters:
controlRate
- the new control-rate in nanoseconds.
-
setName
Sets the name of this Object, or gives this Object a guaranteed unique name (ifname
isnull
). 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:
true
if the name could be set. Since Objects that have a parent cannot be renamed, this function returnsfalse
in those cases.MT safe. This function grabs and releases this Object's LOCK.
-
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:
true
ifparent
could be set orfalse
when this Object already had a parent or this Object andparent
are the same.MT safe. Grabs and releases this Object's LOCK.
-
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_NONE
if no control-rate was set.
-
syncValues
Sets the properties of the object, according to theGstControlSources
that (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:
true
if the controller values could be applied to the object properties,false
otherwise
-
unparent
public void unparent()Clear the parent of this Object, removing the associated reference. This function decreases the refcount of this Object.MT safe. Grabs and releases this Object's lock.
-
unref
public void unref()Decrements the reference count on this Object. If reference count hits zero, destroy this Object. 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 @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
Emits the "deep-notify" signal. SeeonDeepNotify(java.lang.String, org.freedesktop.gstreamer.gst.GstObject.DeepNotifyCallback)
. -
builder
AGstObject.Builder
object constructs aGstObject
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withGstObject.Builder.build()
.
-