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

com.nextbreakpoint.ffmpeg4java.AVClass Maven / Gradle / Ivy

The newest version!
// Generated by jextract

package com.nextbreakpoint.ffmpeg4java;

import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;

/**
 * {@snippet lang=c :
 * struct AVClass {
 *     char *class_name;
 *     char *(*item_name)(void *);
 *     struct AVOption *option;
 *     int version;
 *     int log_level_offset_offset;
 *     int parent_log_context_offset;
 *     AVClassCategory category;
 *     AVClassCategory (*get_category)(void *);
 *     int (*query_ranges)(struct AVOptionRanges **, void *, char *, int);
 *     void *(*child_next)(void *, void *);
 *     struct AVClass *(*child_class_iterate)(void **);
 * }
 * }
 */
public class AVClass {

    AVClass() {
        // Should not be called directly
    }

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Libffmpeg.C_POINTER.withName("class_name"),
        Libffmpeg.C_POINTER.withName("item_name"),
        Libffmpeg.C_POINTER.withName("option"),
        Libffmpeg.C_INT.withName("version"),
        Libffmpeg.C_INT.withName("log_level_offset_offset"),
        Libffmpeg.C_INT.withName("parent_log_context_offset"),
        Libffmpeg.C_INT.withName("category"),
        Libffmpeg.C_POINTER.withName("get_category"),
        Libffmpeg.C_POINTER.withName("query_ranges"),
        Libffmpeg.C_POINTER.withName("child_next"),
        Libffmpeg.C_POINTER.withName("child_class_iterate")
    ).withName("AVClass");

    /**
     * The layout of this struct
     */
    public static final GroupLayout layout() {
        return $LAYOUT;
    }

    private static final AddressLayout class_name$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("class_name"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * char *class_name
     * }
     */
    public static final AddressLayout class_name$layout() {
        return class_name$LAYOUT;
    }

    private static final long class_name$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * char *class_name
     * }
     */
    public static final long class_name$offset() {
        return class_name$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * char *class_name
     * }
     */
    public static MemorySegment class_name(MemorySegment struct) {
        return struct.get(class_name$LAYOUT, class_name$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * char *class_name
     * }
     */
    public static void class_name(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(class_name$LAYOUT, class_name$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * char *(*item_name)(void *)
     * }
     */
    public static class item_name {

        item_name() {
            // Should not be called directly
        }

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            MemorySegment apply(MemorySegment _x0);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = Libffmpeg.upcallHandle(item_name.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(item_name.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
            try {
                return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

    private static final AddressLayout item_name$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("item_name"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * char *(*item_name)(void *)
     * }
     */
    public static final AddressLayout item_name$layout() {
        return item_name$LAYOUT;
    }

    private static final long item_name$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * char *(*item_name)(void *)
     * }
     */
    public static final long item_name$offset() {
        return item_name$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * char *(*item_name)(void *)
     * }
     */
    public static MemorySegment item_name(MemorySegment struct) {
        return struct.get(item_name$LAYOUT, item_name$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * char *(*item_name)(void *)
     * }
     */
    public static void item_name(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(item_name$LAYOUT, item_name$OFFSET, fieldValue);
    }

    private static final AddressLayout option$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("option"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * struct AVOption *option
     * }
     */
    public static final AddressLayout option$layout() {
        return option$LAYOUT;
    }

    private static final long option$OFFSET = 16;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * struct AVOption *option
     * }
     */
    public static final long option$offset() {
        return option$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * struct AVOption *option
     * }
     */
    public static MemorySegment option(MemorySegment struct) {
        return struct.get(option$LAYOUT, option$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * struct AVOption *option
     * }
     */
    public static void option(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(option$LAYOUT, option$OFFSET, fieldValue);
    }

    private static final OfInt version$LAYOUT = (OfInt)$LAYOUT.select(groupElement("version"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int version
     * }
     */
    public static final OfInt version$layout() {
        return version$LAYOUT;
    }

    private static final long version$OFFSET = 24;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int version
     * }
     */
    public static final long version$offset() {
        return version$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int version
     * }
     */
    public static int version(MemorySegment struct) {
        return struct.get(version$LAYOUT, version$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int version
     * }
     */
    public static void version(MemorySegment struct, int fieldValue) {
        struct.set(version$LAYOUT, version$OFFSET, fieldValue);
    }

    private static final OfInt log_level_offset_offset$LAYOUT = (OfInt)$LAYOUT.select(groupElement("log_level_offset_offset"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int log_level_offset_offset
     * }
     */
    public static final OfInt log_level_offset_offset$layout() {
        return log_level_offset_offset$LAYOUT;
    }

    private static final long log_level_offset_offset$OFFSET = 28;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int log_level_offset_offset
     * }
     */
    public static final long log_level_offset_offset$offset() {
        return log_level_offset_offset$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int log_level_offset_offset
     * }
     */
    public static int log_level_offset_offset(MemorySegment struct) {
        return struct.get(log_level_offset_offset$LAYOUT, log_level_offset_offset$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int log_level_offset_offset
     * }
     */
    public static void log_level_offset_offset(MemorySegment struct, int fieldValue) {
        struct.set(log_level_offset_offset$LAYOUT, log_level_offset_offset$OFFSET, fieldValue);
    }

    private static final OfInt parent_log_context_offset$LAYOUT = (OfInt)$LAYOUT.select(groupElement("parent_log_context_offset"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int parent_log_context_offset
     * }
     */
    public static final OfInt parent_log_context_offset$layout() {
        return parent_log_context_offset$LAYOUT;
    }

    private static final long parent_log_context_offset$OFFSET = 32;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int parent_log_context_offset
     * }
     */
    public static final long parent_log_context_offset$offset() {
        return parent_log_context_offset$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int parent_log_context_offset
     * }
     */
    public static int parent_log_context_offset(MemorySegment struct) {
        return struct.get(parent_log_context_offset$LAYOUT, parent_log_context_offset$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int parent_log_context_offset
     * }
     */
    public static void parent_log_context_offset(MemorySegment struct, int fieldValue) {
        struct.set(parent_log_context_offset$LAYOUT, parent_log_context_offset$OFFSET, fieldValue);
    }

    private static final OfInt category$LAYOUT = (OfInt)$LAYOUT.select(groupElement("category"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * AVClassCategory category
     * }
     */
    public static final OfInt category$layout() {
        return category$LAYOUT;
    }

    private static final long category$OFFSET = 36;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * AVClassCategory category
     * }
     */
    public static final long category$offset() {
        return category$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * AVClassCategory category
     * }
     */
    public static int category(MemorySegment struct) {
        return struct.get(category$LAYOUT, category$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * AVClassCategory category
     * }
     */
    public static void category(MemorySegment struct, int fieldValue) {
        struct.set(category$LAYOUT, category$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * AVClassCategory (*get_category)(void *)
     * }
     */
    public static class get_category {

        get_category() {
            // Should not be called directly
        }

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            Libffmpeg.C_INT,
            Libffmpeg.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = Libffmpeg.upcallHandle(get_category.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(get_category.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

    private static final AddressLayout get_category$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_category"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * AVClassCategory (*get_category)(void *)
     * }
     */
    public static final AddressLayout get_category$layout() {
        return get_category$LAYOUT;
    }

    private static final long get_category$OFFSET = 40;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * AVClassCategory (*get_category)(void *)
     * }
     */
    public static final long get_category$offset() {
        return get_category$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * AVClassCategory (*get_category)(void *)
     * }
     */
    public static MemorySegment get_category(MemorySegment struct) {
        return struct.get(get_category$LAYOUT, get_category$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * AVClassCategory (*get_category)(void *)
     * }
     */
    public static void get_category(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(get_category$LAYOUT, get_category$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * int (*query_ranges)(struct AVOptionRanges **, void *, char *, int)
     * }
     */
    public static class query_ranges {

        query_ranges() {
            // Should not be called directly
        }

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            int apply(MemorySegment _x0, MemorySegment _x1, MemorySegment _x2, int _x3);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            Libffmpeg.C_INT,
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER,
            Libffmpeg.C_INT
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = Libffmpeg.upcallHandle(query_ranges.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(query_ranges.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1, MemorySegment _x2, int _x3) {
            try {
                return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2, _x3);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

    private static final AddressLayout query_ranges$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("query_ranges"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int (*query_ranges)(struct AVOptionRanges **, void *, char *, int)
     * }
     */
    public static final AddressLayout query_ranges$layout() {
        return query_ranges$LAYOUT;
    }

    private static final long query_ranges$OFFSET = 48;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int (*query_ranges)(struct AVOptionRanges **, void *, char *, int)
     * }
     */
    public static final long query_ranges$offset() {
        return query_ranges$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int (*query_ranges)(struct AVOptionRanges **, void *, char *, int)
     * }
     */
    public static MemorySegment query_ranges(MemorySegment struct) {
        return struct.get(query_ranges$LAYOUT, query_ranges$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int (*query_ranges)(struct AVOptionRanges **, void *, char *, int)
     * }
     */
    public static void query_ranges(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(query_ranges$LAYOUT, query_ranges$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * void *(*child_next)(void *, void *)
     * }
     */
    public static class child_next {

        child_next() {
            // Should not be called directly
        }

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            MemorySegment apply(MemorySegment _x0, MemorySegment _x1);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = Libffmpeg.upcallHandle(child_next.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(child_next.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1) {
            try {
                return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

    private static final AddressLayout child_next$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("child_next"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * void *(*child_next)(void *, void *)
     * }
     */
    public static final AddressLayout child_next$layout() {
        return child_next$LAYOUT;
    }

    private static final long child_next$OFFSET = 56;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * void *(*child_next)(void *, void *)
     * }
     */
    public static final long child_next$offset() {
        return child_next$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * void *(*child_next)(void *, void *)
     * }
     */
    public static MemorySegment child_next(MemorySegment struct) {
        return struct.get(child_next$LAYOUT, child_next$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * void *(*child_next)(void *, void *)
     * }
     */
    public static void child_next(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(child_next$LAYOUT, child_next$OFFSET, fieldValue);
    }

    /**
     * {@snippet lang=c :
     * struct AVClass *(*child_class_iterate)(void **)
     * }
     */
    public static class child_class_iterate {

        child_class_iterate() {
            // Should not be called directly
        }

        /**
         * The function pointer signature, expressed as a functional interface
         */
        public interface Function {
            MemorySegment apply(MemorySegment _x0);
        }

        private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
            Libffmpeg.C_POINTER,
            Libffmpeg.C_POINTER
        );

        /**
         * The descriptor of this function pointer
         */
        public static FunctionDescriptor descriptor() {
            return $DESC;
        }

        private static final MethodHandle UP$MH = Libffmpeg.upcallHandle(child_class_iterate.Function.class, "apply", $DESC);

        /**
         * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
         * The lifetime of the returned segment is managed by {@code arena}
         */
        public static MemorySegment allocate(child_class_iterate.Function fi, Arena arena) {
            return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
        }

        private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);

        /**
         * Invoke the upcall stub {@code funcPtr}, with given parameters
         */
        public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
            try {
                return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
            } catch (Throwable ex$) {
                throw new AssertionError("should not reach here", ex$);
            }
        }
    }

    private static final AddressLayout child_class_iterate$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("child_class_iterate"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * struct AVClass *(*child_class_iterate)(void **)
     * }
     */
    public static final AddressLayout child_class_iterate$layout() {
        return child_class_iterate$LAYOUT;
    }

    private static final long child_class_iterate$OFFSET = 64;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * struct AVClass *(*child_class_iterate)(void **)
     * }
     */
    public static final long child_class_iterate$offset() {
        return child_class_iterate$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * struct AVClass *(*child_class_iterate)(void **)
     * }
     */
    public static MemorySegment child_class_iterate(MemorySegment struct) {
        return struct.get(child_class_iterate$LAYOUT, child_class_iterate$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * struct AVClass *(*child_class_iterate)(void **)
     * }
     */
    public static void child_class_iterate(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(child_class_iterate$LAYOUT, child_class_iterate$OFFSET, fieldValue);
    }

    /**
     * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
     * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
     */
    public static MemorySegment asSlice(MemorySegment array, long index) {
        return array.asSlice(layout().byteSize() * index);
    }

    /**
     * The size (in bytes) of this struct
     */
    public static long sizeof() { return layout().byteSize(); }

    /**
     * Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
     */
    public static MemorySegment allocate(SegmentAllocator allocator) {
        return allocator.allocate(layout());
    }

    /**
     * Allocate an array of size {@code elementCount} using {@code allocator}.
     * The returned segment has size {@code elementCount * layout().byteSize()}.
     */
    public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
        return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
        return reinterpret(addr, 1, arena, cleanup);
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code elementCount * layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
        return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy