All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.freedesktop.gstreamer.gst.MapInfo Maven / Gradle / Ivy

The newest version!
// Java-GI - Java language bindings for GObject-Introspection-based libraries
// Copyright (C) 2022-2024 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  for more information.
//
package org.freedesktop.gstreamer.gst;

import io.github.jwharm.javagi.base.ProxyInstance;
import io.github.jwharm.javagi.interop.Interop;
import java.lang.foreign.Arena;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.util.Set;
import javax.annotation.processing.Generated;

/**
 * A structure containing the result of a map operation such as
 * gst_memory_map(). It contains the data and size.
 * 

* {@code GstMapInfo} cannot be used with g_auto() because it is ambiguous whether it * needs to be unmapped using gst_buffer_unmap() or gst_memory_unmap(). Instead, * {@code GstBufferMapInfo} and {@code GstMemoryMapInfo} can be used in that case. */ @Generated("io.github.jwharm.JavaGI") public class MapInfo extends ProxyInstance { static { Gst.javagi$ensureInitialized(); } /** * Create a MapInfo proxy instance for the provided memory address. * * @param address the memory address of the native object */ public MapInfo(MemorySegment address) { super(Interop.reinterpret(address, getMemoryLayout().byteSize())); } /** * Allocate a new MapInfo. * * @param arena to control the memory allocation scope */ public MapInfo(Arena arena) { super(arena.allocate(getMemoryLayout())); } /** * Allocate a new MapInfo. * The memory is allocated with {@link Arena#ofAuto}. */ public MapInfo() { super(Arena.ofAuto().allocate(getMemoryLayout())); } /** * Allocate a new MapInfo with the fields set to the provided values. * * @param memory value for the field {@code memory} * @param flags value for the field {@code flags} * @param data value for the field {@code data} * @param size value for the field {@code size} * @param maxsize value for the field {@code maxsize} * @param userData value for the field {@code userData} * @param arena to control the memory allocation scope */ public MapInfo(Memory memory, Set flags, byte[] data, long size, long maxsize, MemorySegment[] userData, Arena arena) { this(arena); writeMemory(memory); writeFlags(flags); writeData(data, arena); writeSize(size); writeMaxsize(maxsize); writeUserData(userData, arena); } /** * Allocate a new MapInfo with the fields set to the provided values. * The memory is allocated with {@link Arena#ofAuto}. * * @param memory value for the field {@code memory} * @param flags value for the field {@code flags} * @param data value for the field {@code data} * @param size value for the field {@code size} * @param maxsize value for the field {@code maxsize} * @param userData value for the field {@code userData} */ public MapInfo(Memory memory, Set flags, byte[] data, long size, long maxsize, MemorySegment[] userData) { this(Arena.ofAuto()); writeMemory(memory); writeFlags(flags); writeData(data, Arena.ofAuto()); writeSize(size); writeMaxsize(maxsize); writeUserData(userData, Arena.ofAuto()); } /** * The memory layout of the native struct. * @return the memory layout */ public static MemoryLayout getMemoryLayout() { return MemoryLayout.structLayout( ValueLayout.ADDRESS.withName("memory"), ValueLayout.JAVA_INT.withName("flags"), MemoryLayout.paddingLayout(4), ValueLayout.ADDRESS.withName("data"), ValueLayout.JAVA_LONG.withName("size"), ValueLayout.JAVA_LONG.withName("maxsize"), MemoryLayout.sequenceLayout(4, ValueLayout.ADDRESS).withName("user_data"), MemoryLayout.sequenceLayout(4, ValueLayout.ADDRESS).withName("_gst_reserved") ).withName("GstMapInfo"); } /** * Read the value of the field {@code memory}. * * @return The value of the field {@code memory} */ public Memory readMemory() { var _result = (MemorySegment) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("memory")).get(handle(), 0); return MemorySegment.NULL.equals(_result) ? null : new Memory(_result); } /** * Write a value in the field {@code memory}. * * @param memory The new value for the field {@code memory} */ public void writeMemory(Memory memory) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("memory")) .set(handle(), 0, (memory == null ? MemorySegment.NULL : memory.handle())); } /** * Read the value of the field {@code flags}. * * @return The value of the field {@code flags} */ public Set readFlags() { var _result = (int) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("flags")).get(handle(), 0); return Interop.intToEnumSet(MapFlags.class, MapFlags::of, _result); } /** * Write a value in the field {@code flags}. * * @param flags The new value for the field {@code flags} */ public void writeFlags(Set flags) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("flags")) .set(handle(), 0, Interop.enumSetToInt(flags)); } /** * Read the value of the field {@code data}. * * @return The value of the field {@code data} */ public byte[] readData() { Arena _arena = Arena.ofAuto(); var _result = (MemorySegment) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("data")).get(handle(), 0); return Interop.getByteArrayFrom(_result, readSize(), _arena, false); } /** * Write a value in the field {@code data}. * * @param data The new value for the field {@code data} * @param _arena to control the memory allocation scope */ public void writeData(byte[] data, Arena _arena) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("data")) .set(handle(), 0, (data == null ? MemorySegment.NULL : Interop.allocateNativeArray(data, false, _arena))); } /** * Read the value of the field {@code size}. * * @return The value of the field {@code size} */ public long readSize() { var _result = (long) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("size")).get(handle(), 0); return _result; } /** * Write a value in the field {@code size}. * * @param size The new value for the field {@code size} */ public void writeSize(long size) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("size")) .set(handle(), 0, size); } /** * Read the value of the field {@code maxsize}. * * @return The value of the field {@code maxsize} */ public long readMaxsize() { var _result = (long) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("maxsize")).get(handle(), 0); return _result; } /** * Write a value in the field {@code maxsize}. * * @param maxsize The new value for the field {@code maxsize} */ public void writeMaxsize(long maxsize) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("maxsize")) .set(handle(), 0, maxsize); } /** * Read the value of the field {@code user_data}. * * @return The value of the field {@code user_data} */ public MemorySegment[] readUserData() { Arena _arena = Arena.ofAuto(); var _result = (MemorySegment) getMemoryLayout() .varHandle(MemoryLayout.PathElement.groupElement("user_data")).get(handle(), 0); return Interop.getAddressArrayFrom(_result, 4, false); } /** * Write a value in the field {@code user_data}. * * @param userData The new value for the field {@code user_data} * @param _arena to control the memory allocation scope */ public void writeUserData(MemorySegment[] userData, Arena _arena) { getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("user_data")) .set(handle(), 0, (userData == null ? MemorySegment.NULL : Interop.allocateNativeArray(userData, false, _arena))); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy