org.freedesktop.gstreamer.gst.Bin Maven / Gradle / Ivy
Show all versions of gst Show documentation
/* Java-GI - Java language bindings for GObject-Introspection-based libraries
* Copyright (C) 2022-2023 Jan-Willem Harmannij
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
/* This file has been generated with Java-GI.
* Do not edit this file directly!
* Visit https://jwharm.github.io/java-gi for more information.
*/
package org.freedesktop.gstreamer.gst;
import io.github.jwharm.javagi.gobject.*;
import io.github.jwharm.javagi.gobject.types.*;
import io.github.jwharm.javagi.base.*;
import io.github.jwharm.javagi.interop.*;
import java.lang.foreign.*;
import java.lang.invoke.*;
import org.jetbrains.annotations.*;
/**
* {@link Bin} is an element that can contain other {@link Element}, allowing them to be
* managed as a group.
* Pads from the child elements can be ghosted to the bin, see {@link GhostPad}.
* This makes the bin look like any other elements and enables creation of
* higher-level abstraction elements.
*
* A new {@link Bin} is created with gst_bin_new(). Use a {@link Pipeline} instead if you
* want to create a toplevel bin because a normal bin doesn't have a bus or
* handle clock distribution of its own.
*
* After the bin has been created you will typically add elements to it with
* gst_bin_add(). You can remove elements with gst_bin_remove().
*
* An element can be retrieved from a bin with gst_bin_get_by_name(), using the
* elements name. gst_bin_get_by_name_recurse_up() is mainly used for internal
* purposes and will query the parent bins when the element is not found in the
* current bin.
*
* An iterator of elements in a bin can be retrieved with
* gst_bin_iterate_elements(). Various other iterators exist to retrieve the
* elements in a bin.
*
* gst_object_unref() is used to drop your reference to the bin.
*
* The {@link Bin}::element-added signal is fired whenever a new element is added to
* the bin. Likewise the {@link Bin}::element-removed signal is fired whenever an
* element is removed from the bin.
*
* A {@link Bin} internally intercepts every {@link Message} posted by its children and
* implements the following default behaviour for each of them:
*
* * {@link MessageType#EOS}: This message is only posted by sinks in the PLAYING
* state. If all sinks posted the EOS message, this bin will post and EOS
* message upwards.
*
* * {@link MessageType#SEGMENT_START}: Just collected and never forwarded upwards.
* The messages are used to decide when all elements have completed playback
* of their segment.
*
* * {@link MessageType#SEGMENT_DONE}: Is posted by {@link Bin} when all elements that posted
* a SEGMENT_START have posted a SEGMENT_DONE.
*
* * {@link MessageType#DURATION_CHANGED}: Is posted by an element that detected a change
* in the stream duration. The duration change is posted to the
* application so that it can refetch the new duration with a duration
* query.
*
* Note that these messages can be posted before the bin is prerolled, in which
* case the duration query might fail.
*
* Note also that there might be a discrepancy (due to internal buffering/queueing)
* between the stream being currently displayed and the returned duration query.
*
* Applications might want to also query for duration (and changes) by
* listening to the {@link MessageType#STREAM_START} message, signaling the active start
* of a (new) stream.
*
* * {@link MessageType#CLOCK_LOST}: This message is posted by an element when it
* can no longer provide a clock.
*
* The default bin behaviour is to check if the lost clock was the one provided
* by the bin. If so and the bin is currently in the PLAYING state, the message
* is forwarded to the bin parent.
*
* This message is also generated when a clock provider is removed from
* the bin. If this message is received by the application, it should
* PAUSE the pipeline and set it back to PLAYING to force a new clock
* distribution.
*
* * {@link MessageType#CLOCK_PROVIDE}: This message is generated when an element
* can provide a clock. This mostly happens when a new clock
* provider is added to the bin.
*
* The default behaviour of the bin is to mark the currently selected clock as
* dirty, which will perform a clock recalculation the next time the bin is
* asked to provide a clock.
*
* This message is never sent to the application but is forwarded to
* the parent of the bin.
*
* * OTHERS: posted upwards.
*
* A {@link Bin} implements the following default behaviour for answering to a
* {@link Query}:
*
* * {@link QueryType#DURATION}: The bin will forward the query to all sink
* elements contained within and will return the maximum value.
* If no sinks are available in the bin, the query fails.
*
* * {@link QueryType#POSITION}: The query is sent to all sink elements in the bin and the
* MAXIMUM of all values is returned. If no sinks are available in the bin,
* the query fails.
*
* * OTHERS: the query is forwarded to all sink elements, the result
* of the first sink that answers the query successfully is returned. If no
* sink is in the bin, the query fails.
*
* A {@link Bin} will by default forward any event sent to it to all sink
* ( {@link EventTypeFlags#DOWNSTREAM} ) or source ( {@link EventTypeFlags#UPSTREAM} ) elements
* depending on the event type.
*
* If all the elements return {@code true}, the bin will also return {@code true}, else {@code false}
* is returned. If no elements of the required type are in the bin, the event
* handler will return {@code true}.
*/
public class Bin extends org.freedesktop.gstreamer.gst.Element implements org.freedesktop.gstreamer.gst.ChildProxy {
static {
Gst.javagi$ensureInitialized();
}
/**
* Get the GType of the GstBin class.
* @return the GType
*/
public static org.gnome.glib.Type getType() {
return Interop.getType("gst_bin_get_type");
}
/**
* The memory layout of the native struct.
* @return the memory layout
*/
public static MemoryLayout getMemoryLayout() {
return MemoryLayout.structLayout(
org.freedesktop.gstreamer.gst.Element.getMemoryLayout().withName("element"),
ValueLayout.JAVA_INT.withName("numchildren"),
MemoryLayout.paddingLayout(4),
ValueLayout.ADDRESS.withName("children"),
ValueLayout.JAVA_INT.withName("children_cookie"),
MemoryLayout.paddingLayout(4),
ValueLayout.ADDRESS.withName("child_bus"),
ValueLayout.ADDRESS.withName("messages"),
ValueLayout.JAVA_INT.withName("polling"),
ValueLayout.JAVA_INT.withName("state_dirty"),
ValueLayout.JAVA_INT.withName("clock_dirty"),
MemoryLayout.paddingLayout(4),
ValueLayout.ADDRESS.withName("provided_clock"),
ValueLayout.ADDRESS.withName("clock_provider"),
ValueLayout.ADDRESS.withName("priv"),
MemoryLayout.sequenceLayout(4, ValueLayout.ADDRESS).withName("_gst_reserved")
).withName("GstBin");
}
/**
* Returns this instance as if it were its parent type. This is mostly synonymous to the Java
* {@code super} keyword, but will set the native typeclass function pointers to the parent
* type. When overriding a native virtual method in Java, "chaining up" with
* {@code super.methodName()} doesn't work, because it invokes the overridden function pointer
* again. To chain up, call {@code asParent().methodName()}. This will call the native function
* pointer of this virtual method in the typeclass of the parent type.
*/
protected org.freedesktop.gstreamer.gst.Bin asParent() {
org.freedesktop.gstreamer.gst.Bin _parent = new org.freedesktop.gstreamer.gst.Bin(handle());
_parent.callParent(true);
return _parent;
}
/**
* Create a Bin proxy instance for the provided memory address.
* @param address the memory address of the native object
*/
public Bin(MemorySegment address) {
super(address == null ? null : Interop.reinterpret(address, getMemoryLayout().byteSize()));
}
/**
* Creates a new bin with the given name.
* @param name the name of the new bin
*/
public Bin(@Nullable java.lang.String name) {
super(constructNew(name));
InstanceCache.put(handle(), this);
}
/**
* Helper function for the {@code gst_bin_new} constructor
*/
private static MemorySegment constructNew(@Nullable java.lang.String name) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_new", _fdesc, false).invokeExact((MemorySegment) (name == null ? MemorySegment.NULL : Interop.allocateNativeString(name, _arena)));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result;
}
}
/**
* Adds the given element to the bin. Sets the element's parent, and thus
* takes ownership of the element. An element can only be added to one bin.
*
* If the element's pads are linked to other pads, the pads will be unlinked
* before the element is added to the bin.
*
*
* When you add an element to an already-running pipeline, you will have to
* take care to set the state of the newly-added element to the desired
* state (usually PLAYING or PAUSED, same you set the pipeline to originally)
* with gst_element_set_state(), or use gst_element_sync_state_with_parent().
* The bin or pipeline will not take care of this for you.
*
* @param element the {@link Element} to add
* @return {@code true} if the element could be added, {@code false} if
* the bin does not want to accept the element.
*/
public boolean add(org.freedesktop.gstreamer.gst.Element element) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_bin_add", _fdesc, false).invokeExact(handle(),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Adds a {@code null}-terminated list of elements to a bin. This function is
* equivalent to calling gst_bin_add() for each member of the list. The return
* value of each gst_bin_add() is ignored.
* @param element1 the {@link Element} element to add to the bin
* @param varargs additional elements to add to the bin
*/
public void addMany(org.freedesktop.gstreamer.gst.Element element1, java.lang.Object... varargs) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
Interop.downcallHandle("gst_bin_add_many", _fdesc, true).invokeExact(handle(),
(MemorySegment) (element1 == null ? MemorySegment.NULL : element1.handle()),
varargs);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Recursively looks for elements with an unlinked pad of the given
* direction within the specified bin and returns an unlinked pad
* if one is found, or {@code null} otherwise. If a pad is found, the caller
* owns a reference to it and should use gst_object_unref() on the
* pad when it is not needed any longer.
* @param direction whether to look for an unlinked source or sink pad
* @return unlinked pad of the given
* direction.
*/
public @Nullable org.freedesktop.gstreamer.gst.Pad findUnlinkedPad(org.freedesktop.gstreamer.gst.PadDirection direction) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_find_unlinked_pad", _fdesc, false).invokeExact(handle(),
direction.getValue());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return (org.freedesktop.gstreamer.gst.Pad) InstanceCache.getForType(_result, org.freedesktop.gstreamer.gst.Pad::new, true);
}
/**
* Looks for an element inside the bin that implements the given
* interface. If such an element is found, it returns the element.
* You can cast this element to the given interface afterwards. If you want
* all elements that implement the interface, use
* gst_bin_iterate_all_by_interface(). This function recurses into child bins.
* @param iface the {@link org.gnome.glib.Type} of an interface
* @return A {@link Element} inside the bin
* implementing the interface
*/
public @Nullable org.freedesktop.gstreamer.gst.Element getByInterface(org.gnome.glib.Type iface) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_get_by_interface", _fdesc, false).invokeExact(handle(),
iface.getValue().longValue());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return (org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(_result, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, true);
}
/**
* Gets the element with the given name from a bin. This
* function recurses into child bins.
* @param name the element name to search for
* @return the {@link Element} with the given
* name
*/
public @Nullable org.freedesktop.gstreamer.gst.Element getByName(java.lang.String name) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_get_by_name", _fdesc, false).invokeExact(handle(),
(MemorySegment) (name == null ? MemorySegment.NULL : Interop.allocateNativeString(name, _arena)));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return (org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(_result, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, true);
}
}
/**
* Gets the element with the given name from this bin. If the
* element is not found, a recursion is performed on the parent bin.
* @param name the element name to search for
* @return the {@link Element} with the given
* name
*/
public @Nullable org.freedesktop.gstreamer.gst.Element getByNameRecurseUp(java.lang.String name) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_get_by_name_recurse_up", _fdesc, false).invokeExact(handle(),
(MemorySegment) (name == null ? MemorySegment.NULL : Interop.allocateNativeString(name, _arena)));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return (org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(_result, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, true);
}
}
public org.freedesktop.gstreamer.gst.ElementFlags getSuppressedFlags() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_bin_get_suppressed_flags", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return new org.freedesktop.gstreamer.gst.ElementFlags(_result);
}
/**
* Looks for all elements inside the bin with the given element factory name.
* The function recurses inside child bins. The iterator will yield a series of
* {@link Element}.
* @param factoryName the name of the {@link ElementFactory}
* @return a {@link Iterator} of {@link Element}
* for all elements in the bin with the given element factory name
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateAllByElementFactoryName(java.lang.String factoryName) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_all_by_element_factory_name", _fdesc, false).invokeExact(handle(),
(MemorySegment) (factoryName == null ? MemorySegment.NULL : Interop.allocateNativeString(factoryName, _arena)));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
}
/**
* Looks for all elements inside the bin that implements the given
* interface. You can safely cast all returned elements to the given interface.
* The function recurses inside child bins. The iterator will yield a series
* of {@link Element}.
* @param iface the {@link org.gnome.glib.Type} of an interface
* @return a {@link Iterator} of {@link Element}
* for all elements in the bin implementing the given interface
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateAllByInterface(org.gnome.glib.Type iface) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_all_by_interface", _fdesc, false).invokeExact(handle(),
iface.getValue().longValue());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Gets an iterator for the elements in this bin.
* @return a {@link Iterator} of {@link Element}
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateElements() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_elements", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Gets an iterator for the elements in this bin.
* This iterator recurses into GstBin children.
* @return a {@link Iterator} of {@link Element}
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateRecurse() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_recurse", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Gets an iterator for all elements in the bin that have the
* {@code GST_ELEMENT_FLAG_SINK} flag set.
* @return a {@link Iterator} of {@link Element}
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateSinks() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_sinks", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Gets an iterator for the elements in this bin in topologically
* sorted order. This means that the elements are returned from
* the most downstream elements (sinks) to the sources.
*
* This function is used internally to perform the state changes
* of the bin elements and for clock selection.
* @return a {@link Iterator} of {@link Element}
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateSorted() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_sorted", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Gets an iterator for all elements in the bin that have the
* {@code GST_ELEMENT_FLAG_SOURCE} flag set.
* @return a {@link Iterator} of {@link Element}
*/
public @Nullable org.freedesktop.gstreamer.gst.Iterator iterateSources() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MemorySegment _result;
try {
_result = (MemorySegment) Interop.downcallHandle("gst_bin_iterate_sources", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.freedesktop.gstreamer.gst.Iterator(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "gst_iterator_free");
}
return _instance;
}
/**
* Queries {@code bin} for the current latency and reconfigures this latency on all the
* elements using a LATENCY event.
*
* This method is typically called on the pipeline when a {@code GST_MESSAGE_LATENCY}
* is posted on the bus.
*
* This function simply emits the {@link Bin}::do-latency signal so any custom latency
* calculations will be performed.
* @return {@code true} if the latency could be queried and reconfigured.
*/
public boolean recalculateLatency() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_bin_recalculate_latency", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Removes the element from the bin, unparenting it as well.
* Unparenting the element means that the element will be dereferenced,
* so if the bin holds the only reference to the element, the element
* will be freed in the process of removing it from the bin. If you
* want the element to still exist after removing, you need to call
* gst_object_ref() before removing it from the bin.
*
* If the element's pads are linked to other pads, the pads will be unlinked
* before the element is removed from the bin.
* @param element the {@link Element} to remove
* @return {@code true} if the element could be removed, {@code false} if
* the bin does not want to remove the element.
*/
public boolean remove(org.freedesktop.gstreamer.gst.Element element) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_bin_remove", _fdesc, false).invokeExact(handle(),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Removes a list of elements from a bin. This function is equivalent
* to calling gst_bin_remove() with each member of the list.
* @param element1 the first {@link Element} to remove from the bin
* @param varargs {@code null}-terminated list of elements to remove from the bin
*/
public void removeMany(org.freedesktop.gstreamer.gst.Element element1, java.lang.Object... varargs) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
Interop.downcallHandle("gst_bin_remove_many", _fdesc, true).invokeExact(handle(),
(MemorySegment) (element1 == null ? MemorySegment.NULL : element1.handle()),
varargs);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Suppresses the given flags on the bin. {@link ElementFlags} of a
* child element are propagated when it is added to the bin.
* When suppressed flags are set, those specified flags will
* not be propagated to the bin.
* @param flags the {@link ElementFlags} to suppress
*/
public void setSuppressedFlags(org.freedesktop.gstreamer.gst.ElementFlags flags) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
try {
Interop.downcallHandle("gst_bin_set_suppressed_flags", _fdesc, false).invokeExact(handle(),
flags.getValue());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Synchronizes the state of every child of {@code bin} with the state
* of {@code bin}. See also gst_element_sync_state_with_parent().
* @return {@code true} if syncing the state was successful for all children,
* otherwise {@code false}.
*/
public boolean syncChildrenStates() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_bin_sync_children_states", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Method to add an element to the bin.
* @param element the element to be added
* @return {@code true} if the {@code element} was added
*/
protected boolean addElement(org.freedesktop.gstreamer.gst.Element element) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
int _result;
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "add_element");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Method called when an element was added somewhere in the bin hierarchy.
* @param subBin the {@link Bin} to which the element was added
* @param child the element that was added
*/
protected void deepElementAdded(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element child) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "deep_element_added");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (subBin == null ? MemorySegment.NULL : subBin.handle()),
(MemorySegment) (child == null ? MemorySegment.NULL : child.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Method called when an element was removed somewhere in the bin hierarchy.
* @param subBin the {@link Bin} from which the element was removed
* @param child the element that was removed
*/
protected void deepElementRemoved(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element child) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "deep_element_removed");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (subBin == null ? MemorySegment.NULL : subBin.handle()),
(MemorySegment) (child == null ? MemorySegment.NULL : child.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
protected boolean doLatency() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
int _result;
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "do_latency");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* Method called when an element was added to the bin.
* @param child the element that was added
*/
protected void elementAdded(org.freedesktop.gstreamer.gst.Element child) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "element_added");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (child == null ? MemorySegment.NULL : child.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Method called when an element was removed from the bin.
* @param child the element that was removed
*/
protected void elementRemoved(org.freedesktop.gstreamer.gst.Element child) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "element_removed");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (child == null ? MemorySegment.NULL : child.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Method to handle a message from the children.
* @param message the message to be handled
*/
protected void handleMessage(org.freedesktop.gstreamer.gst.Message message) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "handle_message");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (message == null ? MemorySegment.NULL : message.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
if (message != null) MemoryCleaner.yieldOwnership(message.handle());
}
/**
* Method to remove an element from the bin.
* @param element the element to be removed
* @return {@code true} if the {@code element} was removed
*/
protected boolean removeElement(org.freedesktop.gstreamer.gst.Element element) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
int _result;
try {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), BinClass.getMemoryLayout(), "remove_element");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle()));
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
@FunctionalInterface
public interface DeepElementAdded {
/**
* Will be emitted after the element was added to {@code sub_bin}.
*/
void run(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment sourceBin, MemorySegment subBin, MemorySegment element) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DeepElementAdded.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Will be emitted after the element was added to {@code sub_bin}.
* @param handler the signal handler
* @return a {@link SignalConnection} object to keep track of the signal connection
*/
public SignalConnection onDeepElementAdded(Bin.DeepElementAdded handler) {
try (Arena _arena = Arena.ofConfined()) {
try {
var _result = (long) Signals.g_signal_connect_data.invokeExact(
handle(), Interop.allocateNativeString("deep-element-added", _arena), handler.toCallback(Arena.global()), MemorySegment.NULL, MemorySegment.NULL, 0);
return new SignalConnection<>(handle(), _result);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
}
/**
* Emits the "deep-element-added" signal. See {@link #onDeepElementAdded}.
*/
public void emitDeepElementAdded(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element element) {
try (Arena _arena = Arena.ofConfined()) {
Signals.g_signal_emit_by_name.invokeExact(
handle(),
Interop.allocateNativeString("deep-element-added", _arena),
new Object[] {(MemorySegment) (subBin == null ? MemorySegment.NULL : subBin.handle()),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle())
}
);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
@FunctionalInterface
public interface DeepElementRemoved {
/**
* Will be emitted after the element was removed from {@code sub_bin}.
*/
void run(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment sourceBin, MemorySegment subBin, MemorySegment element) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DeepElementRemoved.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Will be emitted after the element was removed from {@code sub_bin}.
* @param handler the signal handler
* @return a {@link SignalConnection} object to keep track of the signal connection
*/
public SignalConnection onDeepElementRemoved(Bin.DeepElementRemoved handler) {
try (Arena _arena = Arena.ofConfined()) {
try {
var _result = (long) Signals.g_signal_connect_data.invokeExact(
handle(), Interop.allocateNativeString("deep-element-removed", _arena), handler.toCallback(Arena.global()), MemorySegment.NULL, MemorySegment.NULL, 0);
return new SignalConnection<>(handle(), _result);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
}
/**
* Emits the "deep-element-removed" signal. See {@link #onDeepElementRemoved}.
*/
public void emitDeepElementRemoved(org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element element) {
try (Arena _arena = Arena.ofConfined()) {
Signals.g_signal_emit_by_name.invokeExact(
handle(),
Interop.allocateNativeString("deep-element-removed", _arena),
new Object[] {(MemorySegment) (subBin == null ? MemorySegment.NULL : subBin.handle()),
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle())
}
);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
@FunctionalInterface
public interface DoLatency {
/**
* Will be emitted when the bin needs to perform latency calculations. This
* signal is only emitted for toplevel bins or when {@link Bin}:async-handling is
* enabled.
*
* Only one signal handler is invoked. If no signals are connected, the
* default handler is invoked, which will query and distribute the lowest
* possible latency to all sinks.
*
* Connect to this signal if the default latency calculations are not
* sufficient, like when you need different latencies for different sinks in
* the same pipeline.
*/
boolean run();
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment sourceBin) {
var _result = run();
return _result ? 1 : 0;
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DoLatency.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Will be emitted when the bin needs to perform latency calculations. This
* signal is only emitted for toplevel bins or when {@link Bin}:async-handling is
* enabled.
*
* Only one signal handler is invoked. If no signals are connected, the
* default handler is invoked, which will query and distribute the lowest
* possible latency to all sinks.
*
* Connect to this signal if the default latency calculations are not
* sufficient, like when you need different latencies for different sinks in
* the same pipeline.
* @param handler the signal handler
* @return a {@link SignalConnection} object to keep track of the signal connection
*/
public SignalConnection onDoLatency(Bin.DoLatency handler) {
try (Arena _arena = Arena.ofConfined()) {
try {
var _result = (long) Signals.g_signal_connect_data.invokeExact(
handle(), Interop.allocateNativeString("do-latency", _arena), handler.toCallback(Arena.global()), MemorySegment.NULL, MemorySegment.NULL, 0);
return new SignalConnection<>(handle(), _result);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
}
/**
* Emits the "do-latency" signal. See {@link #onDoLatency}.
*/
public boolean emitDoLatency() {
try (Arena _arena = Arena.ofConfined()) {
MemorySegment _result = _arena.allocate(ValueLayout.JAVA_INT);
Signals.g_signal_emit_by_name.invokeExact(
handle(),
Interop.allocateNativeString("do-latency", _arena),
new Object[] {
_result
}
);
return _result.get(ValueLayout.JAVA_INT, 0) != 0;
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
@FunctionalInterface
public interface ElementAdded {
/**
* Will be emitted after the element was added to the bin.
*/
void run(org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment sourceBin, MemorySegment element) {
run((org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ElementAdded.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Will be emitted after the element was added to the bin.
* @param handler the signal handler
* @return a {@link SignalConnection} object to keep track of the signal connection
*/
public SignalConnection onElementAdded(Bin.ElementAdded handler) {
try (Arena _arena = Arena.ofConfined()) {
try {
var _result = (long) Signals.g_signal_connect_data.invokeExact(
handle(), Interop.allocateNativeString("element-added", _arena), handler.toCallback(Arena.global()), MemorySegment.NULL, MemorySegment.NULL, 0);
return new SignalConnection<>(handle(), _result);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
}
/**
* Emits the "element-added" signal. See {@link #onElementAdded}.
*/
public void emitElementAdded(org.freedesktop.gstreamer.gst.Element element) {
try (Arena _arena = Arena.ofConfined()) {
Signals.g_signal_emit_by_name.invokeExact(
handle(),
Interop.allocateNativeString("element-added", _arena),
new Object[] {
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle())
}
);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
@FunctionalInterface
public interface ElementRemoved {
/**
* Will be emitted after the element was removed from the bin.
*/
void run(org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment sourceBin, MemorySegment element) {
run((org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ElementRemoved.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Will be emitted after the element was removed from the bin.
* @param handler the signal handler
* @return a {@link SignalConnection} object to keep track of the signal connection
*/
public SignalConnection onElementRemoved(Bin.ElementRemoved handler) {
try (Arena _arena = Arena.ofConfined()) {
try {
var _result = (long) Signals.g_signal_connect_data.invokeExact(
handle(), Interop.allocateNativeString("element-removed", _arena), handler.toCallback(Arena.global()), MemorySegment.NULL, MemorySegment.NULL, 0);
return new SignalConnection<>(handle(), _result);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
}
/**
* Emits the "element-removed" signal. See {@link #onElementRemoved}.
*/
public void emitElementRemoved(org.freedesktop.gstreamer.gst.Element element) {
try (Arena _arena = Arena.ofConfined()) {
Signals.g_signal_emit_by_name.invokeExact(
handle(),
Interop.allocateNativeString("element-removed", _arena),
new Object[] {
(MemorySegment) (element == null ? MemorySegment.NULL : element.handle())
}
);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Subclasses can override {@link Bin.BinClass}::add_element and {@link Bin.BinClass}::remove_element
* to update the list of children in the bin.
*
* The {@link Bin.BinClass}::handle_message method can be overridden to implement custom
* message handling.
*
* {@link Bin.BinClass}::deep_element_added will be called when a new element has been
* added to any bin inside this bin, so it will also be called if a new child
* was added to a sub-bin of this bin. {@link Bin} implementations that override
* this message should chain up to the parent class implementation so the
* {@link Bin}::deep-element-added signal is emitted on all parents.
*/
public static class BinClass extends org.freedesktop.gstreamer.gst.Element.ElementClass {
/**
* The memory layout of the native struct.
* @return the memory layout
*/
public static MemoryLayout getMemoryLayout() {
return MemoryLayout.structLayout(
org.freedesktop.gstreamer.gst.Element.ElementClass.getMemoryLayout().withName("parent_class"),
ValueLayout.ADDRESS.withName("pool"),
ValueLayout.ADDRESS.withName("element_added"),
ValueLayout.ADDRESS.withName("element_removed"),
ValueLayout.ADDRESS.withName("add_element"),
ValueLayout.ADDRESS.withName("remove_element"),
ValueLayout.ADDRESS.withName("handle_message"),
ValueLayout.ADDRESS.withName("do_latency"),
ValueLayout.ADDRESS.withName("deep_element_added"),
ValueLayout.ADDRESS.withName("deep_element_removed"),
MemoryLayout.sequenceLayout(2, ValueLayout.ADDRESS).withName("_gst_reserved")
).withName("GstBinClass");
}
/**
* Allocate a new {@link BinClass}.
*
* @param arena to control the memory allocation scope.
* @return A new, uninitialized {@link BinClass}
*/
public static BinClass allocate(Arena arena) {
MemorySegment segment = arena.allocate(getMemoryLayout());
return new BinClass(segment);
}
/**
* Allocate a new {@link BinClass}. A {@link java.lang.ref.Cleaner}
* is assigned to the allocated memory segment that will release the
* memory when the {@link BinClass} instance is garbage-collected.
*
* @return A new, uninitialized {@link BinClass}
* @deprecated See {@link #allocate(Arena)}
*/
@Deprecated
public static BinClass allocate() {
return BinClass.allocate(Arena.ofAuto());
}
/**
* Read the value of the field {@code parent_class}
* @return The value of the field {@code parent_class}
*/
public org.freedesktop.gstreamer.gst.Element.ElementClass readParentClass() {
long _offset = getMemoryLayout().byteOffset(MemoryLayout.PathElement.groupElement("parent_class"));
return MemorySegment.NULL.equals(handle().asSlice(_offset)) ? null : new org.freedesktop.gstreamer.gst.Element.ElementClass(handle().asSlice(_offset));
}
/**
* Write a value in the field {@code parent_class}
* @param parentClass The new value for the field {@code parent_class}
*/
public void writeParentClass(org.freedesktop.gstreamer.gst.Element.ElementClass parentClass) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("parent_class"))
.set(handle(), (parentClass == null ? MemorySegment.NULL : parentClass.handle()));
}
/**
* Read the value of the field {@code pool}
* @return The value of the field {@code pool}
*/
public org.gnome.glib.ThreadPool readPool() {
var _result = (MemorySegment) getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("pool"))
.get(handle());
return MemorySegment.NULL.equals(_result) ? null : new org.gnome.glib.ThreadPool(_result);
}
/**
* Write a value in the field {@code pool}
* @param pool The new value for the field {@code pool}
*/
public void writePool(org.gnome.glib.ThreadPool pool) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("pool"))
.set(handle(), (pool == null ? MemorySegment.NULL : pool.handle()));
}
/**
* Functional interface declaration of the {@code ElementAddedCallback} callback.
*/
@FunctionalInterface
public interface ElementAddedCallback {
void run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Element child);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment bin, MemorySegment child) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ElementAddedCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code element_added}
* @param elementAdded The new value for the field {@code element_added}
*/
public void overrideElementAdded(Arena _arena, ElementAddedCallback elementAdded) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("element_added"))
.set(handle(), (elementAdded == null ? MemorySegment.NULL : elementAdded.toCallback(_arena)));
}
private java.lang.reflect.Method _elementAddedMethod;
/**
* Override virtual method {@code element_added}
* @param method The method to invoke
*/
public void overrideElementAdded(Arena arena, java.lang.reflect.Method method) {
this._elementAddedMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "elementAddedUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("element_added"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private void elementAddedUpcall(MemorySegment bin, MemorySegment child) {
try {
this._elementAddedMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._elementAddedMethod);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code ElementRemovedCallback} callback.
*/
@FunctionalInterface
public interface ElementRemovedCallback {
void run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Element child);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment bin, MemorySegment child) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ElementRemovedCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code element_removed}
* @param elementRemoved The new value for the field {@code element_removed}
*/
public void overrideElementRemoved(Arena _arena, ElementRemovedCallback elementRemoved) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("element_removed"))
.set(handle(), (elementRemoved == null ? MemorySegment.NULL : elementRemoved.toCallback(_arena)));
}
private java.lang.reflect.Method _elementRemovedMethod;
/**
* Override virtual method {@code element_removed}
* @param method The method to invoke
*/
public void overrideElementRemoved(Arena arena, java.lang.reflect.Method method) {
this._elementRemovedMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "elementRemovedUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("element_removed"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private void elementRemovedUpcall(MemorySegment bin, MemorySegment child) {
try {
this._elementRemovedMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._elementRemovedMethod);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code AddElementCallback} callback.
*/
@FunctionalInterface
public interface AddElementCallback {
boolean run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment bin, MemorySegment element) {
var _result = run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
return _result ? 1 : 0;
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), AddElementCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code add_element}
* @param addElement The new value for the field {@code add_element}
*/
public void overrideAddElement(Arena _arena, AddElementCallback addElement) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("add_element"))
.set(handle(), (addElement == null ? MemorySegment.NULL : addElement.toCallback(_arena)));
}
private java.lang.reflect.Method _addElementMethod;
/**
* Override virtual method {@code add_element}
* @param method The method to invoke
*/
public void overrideAddElement(Arena arena, java.lang.reflect.Method method) {
this._addElementMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "addElementUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("add_element"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int addElementUpcall(MemorySegment bin, MemorySegment element) {
try {
var _result = (boolean) this._addElementMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
return _result ? 1 : 0;
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._addElementMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code RemoveElementCallback} callback.
*/
@FunctionalInterface
public interface RemoveElementCallback {
boolean run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Element element);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment bin, MemorySegment element) {
var _result = run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
return _result ? 1 : 0;
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), RemoveElementCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code remove_element}
* @param removeElement The new value for the field {@code remove_element}
*/
public void overrideRemoveElement(Arena _arena, RemoveElementCallback removeElement) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("remove_element"))
.set(handle(), (removeElement == null ? MemorySegment.NULL : removeElement.toCallback(_arena)));
}
private java.lang.reflect.Method _removeElementMethod;
/**
* Override virtual method {@code remove_element}
* @param method The method to invoke
*/
public void overrideRemoveElement(Arena arena, java.lang.reflect.Method method) {
this._removeElementMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "removeElementUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("remove_element"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int removeElementUpcall(MemorySegment bin, MemorySegment element) {
try {
var _result = (boolean) this._removeElementMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(element, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
return _result ? 1 : 0;
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._removeElementMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code HandleMessageCallback} callback.
*/
@FunctionalInterface
public interface HandleMessageCallback {
void run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Message message);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment bin, MemorySegment message) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
MemorySegment.NULL.equals(message) ? null : new org.freedesktop.gstreamer.gst.Message(message));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), HandleMessageCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code handle_message}
* @param handleMessage The new value for the field {@code handle_message}
*/
public void overrideHandleMessage(Arena _arena, HandleMessageCallback handleMessage) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("handle_message"))
.set(handle(), (handleMessage == null ? MemorySegment.NULL : handleMessage.toCallback(_arena)));
}
private java.lang.reflect.Method _handleMessageMethod;
/**
* Override virtual method {@code handle_message}
* @param method The method to invoke
*/
public void overrideHandleMessage(Arena arena, java.lang.reflect.Method method) {
this._handleMessageMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "handleMessageUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("handle_message"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private void handleMessageUpcall(MemorySegment bin, MemorySegment message) {
try {
this._handleMessageMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
MemorySegment.NULL.equals(message) ? null : new org.freedesktop.gstreamer.gst.Message(message));
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._handleMessageMethod);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code DoLatencyCallback} callback.
*/
@FunctionalInterface
public interface DoLatencyCallback {
boolean run(org.freedesktop.gstreamer.gst.Bin bin);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment bin) {
var _result = run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false));
return _result ? 1 : 0;
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DoLatencyCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code do_latency}
* @param doLatency The new value for the field {@code do_latency}
*/
public void overrideDoLatency(Arena _arena, DoLatencyCallback doLatency) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("do_latency"))
.set(handle(), (doLatency == null ? MemorySegment.NULL : doLatency.toCallback(_arena)));
}
private java.lang.reflect.Method _doLatencyMethod;
/**
* Override virtual method {@code do_latency}
* @param method The method to invoke
*/
public void overrideDoLatency(Arena arena, java.lang.reflect.Method method) {
this._doLatencyMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "doLatencyUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("do_latency"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int doLatencyUpcall(MemorySegment bin) {
try {
var _result = (boolean) this._doLatencyMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false));
return _result ? 1 : 0;
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._doLatencyMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code DeepElementAddedCallback} callback.
*/
@FunctionalInterface
public interface DeepElementAddedCallback {
void run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element child);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment bin, MemorySegment subBin, MemorySegment child) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DeepElementAddedCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code deep_element_added}
* @param deepElementAdded The new value for the field {@code deep_element_added}
*/
public void overrideDeepElementAdded(Arena _arena, DeepElementAddedCallback deepElementAdded) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("deep_element_added"))
.set(handle(), (deepElementAdded == null ? MemorySegment.NULL : deepElementAdded.toCallback(_arena)));
}
private java.lang.reflect.Method _deepElementAddedMethod;
/**
* Override virtual method {@code deep_element_added}
* @param method The method to invoke
*/
public void overrideDeepElementAdded(Arena arena, java.lang.reflect.Method method) {
this._deepElementAddedMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "deepElementAddedUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("deep_element_added"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private void deepElementAddedUpcall(MemorySegment bin, MemorySegment subBin, MemorySegment child) {
try {
this._deepElementAddedMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._deepElementAddedMethod);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code DeepElementRemovedCallback} callback.
*/
@FunctionalInterface
public interface DeepElementRemovedCallback {
void run(org.freedesktop.gstreamer.gst.Bin bin, org.freedesktop.gstreamer.gst.Bin subBin, org.freedesktop.gstreamer.gst.Element child);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default void upcall(MemorySegment bin, MemorySegment subBin, MemorySegment child) {
run((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
}
/**
* Creates a callback that can be called from native code and executes the {@code run} method.
* @return the memory address of the callback function
*/
default MemorySegment toCallback(Arena arena) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), DeepElementRemovedCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code deep_element_removed}
* @param deepElementRemoved The new value for the field {@code deep_element_removed}
*/
public void overrideDeepElementRemoved(Arena _arena, DeepElementRemovedCallback deepElementRemoved) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("deep_element_removed"))
.set(handle(), (deepElementRemoved == null ? MemorySegment.NULL : deepElementRemoved.toCallback(_arena)));
}
private java.lang.reflect.Method _deepElementRemovedMethod;
/**
* Override virtual method {@code deep_element_removed}
* @param method The method to invoke
*/
public void overrideDeepElementRemoved(Arena arena, java.lang.reflect.Method method) {
this._deepElementRemovedMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), BinClass.class, "deepElementRemovedUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("deep_element_removed"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private void deepElementRemovedUpcall(MemorySegment bin, MemorySegment subBin, MemorySegment child) {
try {
this._deepElementRemovedMethod.invoke((org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(bin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Bin) InstanceCache.getForType(subBin, org.freedesktop.gstreamer.gst.Bin::new, false),
(org.freedesktop.gstreamer.gst.Element) InstanceCache.getForType(child, org.freedesktop.gstreamer.gst.Element.ElementImpl::new, false));
} catch (java.lang.reflect.InvocationTargetException ite) {
org.gnome.glib.GLib.log(io.github.jwharm.javagi.Constants.LOG_DOMAIN, org.gnome.glib.LogLevelFlags.LEVEL_WARNING, ite.getCause().toString() + " in " + this._deepElementRemovedMethod);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Create a BinClass proxy instance for the provided memory address.
* @param address the memory address of the native object
*/
public BinClass(MemorySegment address) {
super(address == null ? null : Interop.reinterpret(address, getMemoryLayout().byteSize()));
}
}
/**
* A {@link Builder} object constructs a {@code Bin}
* using the builder pattern to set property values.
* Use the various {@code set...()} methods to set properties,
* and finish construction with {@link Builder#build()}.
*/
public static Builder extends Builder> builder() {
return new Builder<>();
}
/**
* Inner class implementing a builder pattern to construct
* a GObject with properties.
* @param the type of the Builder that is returned
*/
public static class Builder> extends org.freedesktop.gstreamer.gst.Element.Builder {
/**
* Default constructor for a {@code Builder} object.
*/
protected Builder() {
}
/**
* Finish building the {@code Bin} object. This will call
* {@link org.gnome.gobject.GObject#withProperties} to create a new
* GObject instance, which is then cast to {@code Bin}.
* @return A new instance of {@code Bin} with the properties
* that were set in the Builder object.
*/
public org.freedesktop.gstreamer.gst.Bin build() {
try {
return (org.freedesktop.gstreamer.gst.Bin) org.gnome.gobject.GObject.withProperties(
org.freedesktop.gstreamer.gst.Bin.getType(), getNames(), getValues()
);
} finally {
for (var _value : getValues()) {
_value.unset();
}
getArena().close();
}
}
/**
* If set to {@code true}, the bin will handle asynchronous state changes.
* This should be used only if the bin subclass is modifying the state
* of its children on its own.
* @param asyncHandling the value for the {@code async-handling} property
* @return the {@code Build} instance is returned, to allow method chaining
* @deprecated Use {@link #setAsyncHandling} instead
*/
@Deprecated
public S asyncHandling(boolean asyncHandling) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(Types.BOOLEAN);
_value.setBoolean(asyncHandling);
addBuilderProperty("async-handling", _value);
return (S) this;
}
/**
* If set to {@code true}, the bin will handle asynchronous state changes.
* This should be used only if the bin subclass is modifying the state
* of its children on its own.
* @param asyncHandling the value for the {@code async-handling} property
* @return the {@code Build} instance is returned, to allow method chaining
*/
public S setAsyncHandling(boolean asyncHandling) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(Types.BOOLEAN);
_value.setBoolean(asyncHandling);
addBuilderProperty("async-handling", _value);
return (S) this;
}
/**
* Forward all children messages, even those that would normally be filtered by
* the bin. This can be interesting when one wants to be notified of the EOS
* state of individual elements, for example.
*
* The messages are converted to an ELEMENT message with the bin as the
* source. The structure of the message is named {@code GstBinForwarded} and contains
* a field named {@code message} that contains the original forwarded {@link Message}.
* @param messageForward the value for the {@code message-forward} property
* @return the {@code Build} instance is returned, to allow method chaining
* @deprecated Use {@link #setMessageForward} instead
*/
@Deprecated
public S messageForward(boolean messageForward) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(Types.BOOLEAN);
_value.setBoolean(messageForward);
addBuilderProperty("message-forward", _value);
return (S) this;
}
/**
* Forward all children messages, even those that would normally be filtered by
* the bin. This can be interesting when one wants to be notified of the EOS
* state of individual elements, for example.
*
* The messages are converted to an ELEMENT message with the bin as the
* source. The structure of the message is named {@code GstBinForwarded} and contains
* a field named {@code message} that contains the original forwarded {@link Message}.
* @param messageForward the value for the {@code message-forward} property
* @return the {@code Build} instance is returned, to allow method chaining
*/
public S setMessageForward(boolean messageForward) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(Types.BOOLEAN);
_value.setBoolean(messageForward);
addBuilderProperty("message-forward", _value);
return (S) this;
}
}
}