org.freedesktop.gstreamer.gst.ControlBinding 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.*;
/**
* A base class for value mapping objects that attaches control sources to {@link org.gnome.gobject.GObject}
* properties. Such an object is taking one or more {@link ControlSource} instances,
* combines them and maps the resulting value to the type and value range of the
* bound property.
*/
public abstract class ControlBinding extends org.freedesktop.gstreamer.gst.GstObject {
static {
Gst.javagi$ensureInitialized();
}
/**
* Get the GType of the GstControlBinding class.
* @return the GType
*/
public static org.gnome.glib.Type getType() {
return Interop.getType("gst_control_binding_get_type");
}
/**
* The memory layout of the native struct.
* @return the memory layout
*/
public static MemoryLayout getMemoryLayout() {
return MemoryLayout.unionLayout(
org.freedesktop.gstreamer.gst.GstObject.getMemoryLayout().withName("parent"),
ValueLayout.ADDRESS.withName("name"),
ValueLayout.ADDRESS.withName("pspec"),
ValueLayout.ADDRESS.withName("object"),
ValueLayout.JAVA_INT.withName("disabled")
).withName("GstControlBinding");
}
/**
* 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.ControlBinding asParent() {
org.freedesktop.gstreamer.gst.ControlBinding _parent = new org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl(handle());
_parent.callParent(true);
return _parent;
}
/**
* Create a ControlBinding proxy instance for the provided memory address.
* @param address the memory address of the native object
*/
public ControlBinding(MemorySegment address) {
super(address == null ? null : Interop.reinterpret(address, getMemoryLayout().byteSize()));
}
/**
* Gets a number of {@code GValues} for the given controlled property starting at the
* requested time. The array {@code values} need to hold enough space for {@code n_values} of
* {@link org.gnome.gobject.Value}.
*
* 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.
* @param timestamp the time that should be processed
* @param interval the time spacing between subsequent values
* @param values array to put control-values in
* @return {@code true} if the given array could be filled, {@code false} otherwise
*/
public boolean getGValueArray(org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime interval, org.gnome.gobject.Value[] values) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
int nValues = values == null ? 0 : values.length;
int _result;
try {
if (callParent()) {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), ControlBindingClass.getMemoryLayout(), "get_g_value_array");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
timestamp.getValue().longValue(),
interval.getValue().longValue(),
nValues,
(MemorySegment) (values == null ? MemorySegment.NULL : Interop.allocateNativeArray(values, org.gnome.gobject.Value.getMemoryLayout(), false, _arena)));
} else {
_result = (int) Interop.downcallHandle("gst_control_binding_get_g_value_array", _fdesc, false).invokeExact(handle(),
timestamp.getValue().longValue(),
interval.getValue().longValue(),
nValues,
(MemorySegment) (values == null ? MemorySegment.NULL : Interop.allocateNativeArray(values, org.gnome.gobject.Value.getMemoryLayout(), false, _arena)));
}
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
}
/**
* Gets the value for the given controlled property at the requested time.
* @param timestamp the time the control-change should be read from
* @return the GValue of the property at the given time,
* or {@code null} if the property isn't controlled.
*/
public @Nullable org.gnome.gobject.Value getValue(org.freedesktop.gstreamer.gst.ClockTime timestamp) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG);
MemorySegment _result;
try {
if (callParent()) {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), ControlBindingClass.getMemoryLayout(), "get_value");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (MemorySegment) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
timestamp.getValue().longValue());
} else {
_result = (MemorySegment) Interop.downcallHandle("gst_control_binding_get_value", _fdesc, false).invokeExact(handle(),
timestamp.getValue().longValue());
}
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
var _instance = MemorySegment.NULL.equals(_result) ? null : new org.gnome.gobject.Value(_result);
if (_instance != null) {
MemoryCleaner.takeOwnership(_instance.handle());
MemoryCleaner.setFreeFunc(_instance.handle(), "g_boxed_free");
MemoryCleaner.setBoxedType(_instance.handle(), org.gnome.gobject.Value.getType());
}
return _instance;
}
/**
* Gets a number of values for the given controlled property starting at the
* requested time. The array {@code values} needs to hold enough space for {@code n_values} 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_control_binding_get_g_value_array() returns the array as {@code GValues} and is
* more suitable for bindings.
* @param timestamp the time that should be processed
* @param interval the time spacing between subsequent values
* @param values array to put control-values in
* @return {@code true} if the given array could be filled, {@code false} otherwise
*/
public boolean getValueArray(org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime interval, java.lang.foreign.MemorySegment[] values) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
try (Arena _arena = Arena.ofConfined()) {
int nValues = values == null ? 0 : values.length;
int _result;
try {
if (callParent()) {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), ControlBindingClass.getMemoryLayout(), "get_value_array");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
timestamp.getValue().longValue(),
interval.getValue().longValue(),
nValues,
(MemorySegment) (values == null ? MemorySegment.NULL : Interop.allocateNativeArray(values, false, _arena)));
} else {
_result = (int) Interop.downcallHandle("gst_control_binding_get_value_array", _fdesc, false).invokeExact(handle(),
timestamp.getValue().longValue(),
interval.getValue().longValue(),
nValues,
(MemorySegment) (values == null ? MemorySegment.NULL : Interop.allocateNativeArray(values, false, _arena)));
}
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
}
/**
* Checks if the control binding is disabled.
* @return {@code true} if the binding is inactive
*/
public boolean isDisabled() {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
int _result;
try {
_result = (int) Interop.downcallHandle("gst_control_binding_is_disabled", _fdesc, false).invokeExact(handle());
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* This function is used to disable a control binding for some time, i.e.
* gst_object_sync_values() will do nothing.
* @param disabled boolean that specifies whether to disable the controller
* or not.
*/
public void setDisabled(boolean disabled) {
FunctionDescriptor _fdesc = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
try {
Interop.downcallHandle("gst_control_binding_set_disabled", _fdesc, false).invokeExact(handle(),
disabled ? 1 : 0);
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
}
/**
* Sets the property of the {@code object}, according to the {@code GstControlSources} that
* handles it 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.
* @param object the object that has controlled properties
* @param timestamp the time that should be processed
* @param lastSync the last time this was called
* @return {@code true} if the controller value could be applied to the object
* property, {@code false} otherwise
*/
public boolean syncValues(org.freedesktop.gstreamer.gst.GstObject object, org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime lastSync) {
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG);
int _result;
try {
if (callParent()) {
MemorySegment _func = Overrides.lookupVirtualMethodParent(handle(), ControlBindingClass.getMemoryLayout(), "sync_values");
if (MemorySegment.NULL.equals(_func)) {
throw new NullPointerException();
}
_result = (int) Interop.downcallHandle(_func, _fdesc).invokeExact(handle(),
(MemorySegment) (object == null ? MemorySegment.NULL : object.handle()),
timestamp.getValue().longValue(),
lastSync.getValue().longValue());
} else {
_result = (int) Interop.downcallHandle("gst_control_binding_sync_values", _fdesc, false).invokeExact(handle(),
(MemorySegment) (object == null ? MemorySegment.NULL : object.handle()),
timestamp.getValue().longValue(),
lastSync.getValue().longValue());
}
} catch (Throwable _err) {
throw new AssertionError("Unexpected exception occurred: ", _err);
}
return _result != 0;
}
/**
* The class structure of {@link ControlBinding}.
*/
public static class ControlBindingClass extends org.freedesktop.gstreamer.gst.GstObject.ObjectClass {
/**
* The memory layout of the native struct.
* @return the memory layout
*/
public static MemoryLayout getMemoryLayout() {
return MemoryLayout.structLayout(
org.freedesktop.gstreamer.gst.GstObject.ObjectClass.getMemoryLayout().withName("parent_class"),
ValueLayout.ADDRESS.withName("sync_values"),
ValueLayout.ADDRESS.withName("get_value"),
ValueLayout.ADDRESS.withName("get_value_array"),
ValueLayout.ADDRESS.withName("get_g_value_array"),
MemoryLayout.sequenceLayout(4, ValueLayout.ADDRESS).withName("_gst_reserved")
).withName("GstControlBindingClass");
}
/**
* Allocate a new {@link ControlBindingClass}.
*
* @param arena to control the memory allocation scope.
* @return A new, uninitialized {@link ControlBindingClass}
*/
public static ControlBindingClass allocate(Arena arena) {
MemorySegment segment = arena.allocate(getMemoryLayout());
return new ControlBindingClass(segment);
}
/**
* Allocate a new {@link ControlBindingClass}. A {@link java.lang.ref.Cleaner}
* is assigned to the allocated memory segment that will release the
* memory when the {@link ControlBindingClass} instance is garbage-collected.
*
* @return A new, uninitialized {@link ControlBindingClass}
* @deprecated See {@link #allocate(Arena)}
*/
@Deprecated
public static ControlBindingClass allocate() {
return ControlBindingClass.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.GstObject.ObjectClass readParentClass() {
long _offset = getMemoryLayout().byteOffset(MemoryLayout.PathElement.groupElement("parent_class"));
return MemorySegment.NULL.equals(handle().asSlice(_offset)) ? null : new org.freedesktop.gstreamer.gst.GstObject.ObjectClass(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.GstObject.ObjectClass parentClass) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("parent_class"))
.set(handle(), (parentClass == null ? MemorySegment.NULL : parentClass.handle()));
}
/**
* Functional interface declaration of the {@code SyncValuesCallback} callback.
*/
@FunctionalInterface
public interface SyncValuesCallback {
boolean run(org.freedesktop.gstreamer.gst.ControlBinding binding, org.freedesktop.gstreamer.gst.GstObject object, org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime lastSync);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment binding, MemorySegment object, long timestamp, long lastSync) {
var _result = run((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
(org.freedesktop.gstreamer.gst.GstObject) InstanceCache.getForType(object, org.freedesktop.gstreamer.gst.GstObject.GstObjectImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(lastSync));
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, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), SyncValuesCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code sync_values}
* @param syncValues The new value for the field {@code sync_values}
*/
public void overrideSyncValues(Arena _arena, SyncValuesCallback syncValues) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("sync_values"))
.set(handle(), (syncValues == null ? MemorySegment.NULL : syncValues.toCallback(_arena)));
}
private java.lang.reflect.Method _syncValuesMethod;
/**
* Override virtual method {@code sync_values}
* @param method The method to invoke
*/
public void overrideSyncValues(Arena arena, java.lang.reflect.Method method) {
this._syncValuesMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ControlBindingClass.class, "syncValuesUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("sync_values"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int syncValuesUpcall(MemorySegment binding, MemorySegment object, long timestamp, long lastSync) {
try {
var _result = (boolean) this._syncValuesMethod.invoke((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
(org.freedesktop.gstreamer.gst.GstObject) InstanceCache.getForType(object, org.freedesktop.gstreamer.gst.GstObject.GstObjectImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(lastSync));
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._syncValuesMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code GetValueCallback} callback.
*/
@FunctionalInterface
public interface GetValueCallback {
@Nullable org.gnome.gobject.Value run(org.freedesktop.gstreamer.gst.ControlBinding binding, org.freedesktop.gstreamer.gst.ClockTime timestamp);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default MemorySegment upcall(MemorySegment binding, long timestamp) {
var _result = run((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp));
if (_result != null) {
return _result.handle();
} else {
return MemorySegment.NULL;
}
}
/**
* 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.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), GetValueCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code get_value}
* @param getValue The new value for the field {@code get_value}
*/
public void overrideGetValue(Arena _arena, GetValueCallback getValue) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_value"))
.set(handle(), (getValue == null ? MemorySegment.NULL : getValue.toCallback(_arena)));
}
private java.lang.reflect.Method _getValueMethod;
/**
* Override virtual method {@code get_value}
* @param method The method to invoke
*/
public void overrideGetValue(Arena arena, java.lang.reflect.Method method) {
this._getValueMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ControlBindingClass.class, "getValueUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_value"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private MemorySegment getValueUpcall(MemorySegment binding, long timestamp) {
try {
var _result = (org.gnome.gobject.Value) this._getValueMethod.invoke((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp));
if (_result != null) {
return _result.handle();
} else {
return MemorySegment.NULL;
}
} 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._getValueMethod);
return MemorySegment.NULL;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code GetValueArrayCallback} callback.
*/
@FunctionalInterface
public interface GetValueArrayCallback {
boolean run(org.freedesktop.gstreamer.gst.ControlBinding binding, org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime interval, java.lang.foreign.MemorySegment[] values);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment binding, long timestamp, long interval, int nValues, MemorySegment values) {
try (Arena _arena = Arena.ofConfined()) {
var _result = run((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(interval),
Interop.getAddressArrayFrom(values, nValues, 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.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), GetValueArrayCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code get_value_array}
* @param getValueArray The new value for the field {@code get_value_array}
*/
public void overrideGetValueArray(Arena _arena, GetValueArrayCallback getValueArray) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_value_array"))
.set(handle(), (getValueArray == null ? MemorySegment.NULL : getValueArray.toCallback(_arena)));
}
private java.lang.reflect.Method _getValueArrayMethod;
/**
* Override virtual method {@code get_value_array}
* @param method The method to invoke
*/
public void overrideGetValueArray(Arena arena, java.lang.reflect.Method method) {
this._getValueArrayMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ControlBindingClass.class, "getValueArrayUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_value_array"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int getValueArrayUpcall(MemorySegment binding, long timestamp, long interval, int nValues, MemorySegment values) {
try {
try (Arena _arena = Arena.ofConfined()) {
var _result = (boolean) this._getValueArrayMethod.invoke((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(interval),
(Object) Interop.getAddressArrayFrom(values, nValues, 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._getValueArrayMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Functional interface declaration of the {@code GetGValueArrayCallback} callback.
*/
@FunctionalInterface
public interface GetGValueArrayCallback {
boolean run(org.freedesktop.gstreamer.gst.ControlBinding binding, org.freedesktop.gstreamer.gst.ClockTime timestamp, org.freedesktop.gstreamer.gst.ClockTime interval, org.gnome.gobject.Value[] values);
/**
* The {@code upcall} method is called from native code. The parameters
* are marshalled and {@link #run} is executed.
*/
@ApiStatus.Internal default int upcall(MemorySegment binding, long timestamp, long interval, int nValues, MemorySegment values) {
try (Arena _arena = Arena.ofConfined()) {
var _result = run((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(interval),
Interop.getStructArrayFrom(values, (int) nValues, org.gnome.gobject.Value.class, org.gnome.gobject.Value::new, org.gnome.gobject.Value.getMemoryLayout()));
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.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), GetGValueArrayCallback.class, _fdesc);
return Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
}
}
/**
* Write a value in the field {@code get_g_value_array}
* @param getGValueArray The new value for the field {@code get_g_value_array}
*/
public void overrideGetGValueArray(Arena _arena, GetGValueArrayCallback getGValueArray) {
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_g_value_array"))
.set(handle(), (getGValueArray == null ? MemorySegment.NULL : getGValueArray.toCallback(_arena)));
}
private java.lang.reflect.Method _getGValueArrayMethod;
/**
* Override virtual method {@code get_g_value_array}
* @param method The method to invoke
*/
public void overrideGetGValueArray(Arena arena, java.lang.reflect.Method method) {
this._getGValueArrayMethod = method;
FunctionDescriptor _fdesc = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MethodHandle _handle = Interop.upcallHandle(MethodHandles.lookup(), ControlBindingClass.class, "getGValueArrayUpcall", _fdesc);
MemorySegment _address = Linker.nativeLinker().upcallStub(_handle.bindTo(this), _fdesc, arena);
getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("get_g_value_array"))
.set(handle(), (method == null ? MemorySegment.NULL : _address));
}
private int getGValueArrayUpcall(MemorySegment binding, long timestamp, long interval, int nValues, MemorySegment values) {
try {
try (Arena _arena = Arena.ofConfined()) {
var _result = (boolean) this._getGValueArrayMethod.invoke((org.freedesktop.gstreamer.gst.ControlBinding) InstanceCache.getForType(binding, org.freedesktop.gstreamer.gst.ControlBinding.ControlBindingImpl::new, false),
new org.freedesktop.gstreamer.gst.ClockTime(timestamp),
new org.freedesktop.gstreamer.gst.ClockTime(interval),
(Object) Interop.getStructArrayFrom(values, (int) nValues, org.gnome.gobject.Value.class, org.gnome.gobject.Value::new, org.gnome.gobject.Value.getMemoryLayout()));
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._getGValueArrayMethod);
return 0;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Create a ControlBindingClass proxy instance for the provided memory address.
* @param address the memory address of the native object
*/
public ControlBindingClass(MemorySegment address) {
super(address == null ? null : Interop.reinterpret(address, getMemoryLayout().byteSize()));
}
}
/**
* A {@link Builder} object constructs a {@code ControlBinding}
* 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.GstObject.Builder {
/**
* Default constructor for a {@code Builder} object.
*/
protected Builder() {
}
/**
* Finish building the {@code ControlBinding} object. This will call
* {@link org.gnome.gobject.GObject#withProperties} to create a new
* GObject instance, which is then cast to {@code ControlBinding}.
* @return A new instance of {@code ControlBinding} with the properties
* that were set in the Builder object.
*/
public org.freedesktop.gstreamer.gst.ControlBinding build() {
try {
return (org.freedesktop.gstreamer.gst.ControlBinding) org.gnome.gobject.GObject.withProperties(
org.freedesktop.gstreamer.gst.ControlBinding.getType(), getNames(), getValues()
);
} finally {
for (var _value : getValues()) {
_value.unset();
}
getArena().close();
}
}
@Deprecated
public S name(java.lang.String name) {
Arena _arena = getArena();
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(_arena);
_value.init(Types.STRING);
_value.setString(name);
addBuilderProperty("name", _value);
return (S) this;
}
public S setName(java.lang.String name) {
Arena _arena = getArena();
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(_arena);
_value.init(Types.STRING);
_value.setString(name);
addBuilderProperty("name", _value);
return (S) this;
}
@Deprecated
public S object(org.freedesktop.gstreamer.gst.GstObject object) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(org.freedesktop.gstreamer.gst.GstObject.getType());
_value.setObject((org.gnome.gobject.GObject) object);
addBuilderProperty("object", _value);
return (S) this;
}
public S setObject(org.freedesktop.gstreamer.gst.GstObject object) {
org.gnome.gobject.Value _value = org.gnome.gobject.Value.allocate(getArena());
_value.init(org.freedesktop.gstreamer.gst.GstObject.getType());
_value.setObject((org.gnome.gobject.GObject) object);
addBuilderProperty("object", _value);
return (S) this;
}
}
/**
* The ControlBindingImpl type represents a native instance of the abstract ControlBinding class.
*/
public static class ControlBindingImpl extends ControlBinding {
static {
Gst.javagi$ensureInitialized();
}
/**
* Creates a new instance of ControlBinding for the provided memory address.
* @param address the memory address of the instance
*/
public ControlBindingImpl(MemorySegment address) {
super(address);
}
}
}