From 0eb9258459ae4283e62c18fe6e54791c527c7d8a Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Fri, 17 Aug 2018 16:50:55 +0200 Subject: [PATCH 01/17] align structures for BaseSink, BaseSrc --- .../gstreamer/lowlevel/BaseSinkAPI.java | 17 ++- .../gstreamer/lowlevel/BaseSrcAPI.java | 118 +++++++++--------- 2 files changed, 69 insertions(+), 66 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java index e130cfb8..891bc8d2 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java @@ -86,7 +86,7 @@ public static final class GstBaseSinkStruct extends com.sun.jna.Structure { public volatile boolean flushing; public volatile boolean running; - public volatile boolean max_lateness; + public volatile long max_lateness; /*< private >*/ public volatile Pointer /* GstBaseSinkPrivate */ priv; @@ -121,18 +121,18 @@ public static interface SetCaps extends Callback { public boolean callback(BaseSink sink, Caps caps); } public static interface Fixate extends Callback { - public void callback(BaseSink sink, Caps caps); + public Caps callback(BaseSink sink, Caps caps); } public static interface ActivatePull extends Callback { public boolean callback(BaseSink sink, boolean active); } public static interface GetTimes extends Callback { public void callback(BaseSink sink, Buffer buffer, - Pointer start, Pointer end); + Pointer /* GstClockTime */ start, Pointer /* GstClockTime */ end); + } + public static interface ProposeAllocation extends Callback { + public boolean callback(BaseSink sink, AllocationQuery query); } - public static interface ProposeAllocation extends Callback { - public boolean callback(BaseSink sink, AllocationQuery query); - } public static interface BooleanFunc1 extends Callback { public boolean callback(BaseSink sink); } @@ -148,9 +148,6 @@ public static interface WaitEventNotify extends Callback { public static interface Render extends Callback { public FlowReturn callback(BaseSink sink, Buffer buffer); } - public static interface AsyncPlay extends Callback { - public StateChangeReturn callback(BaseSink sink); - } public static interface RenderList extends Callback { public FlowReturn callback(BaseSink sink, GList bufferList); } @@ -221,7 +218,7 @@ public GstBaseSinkClass(Pointer ptr) { public RenderList render_list; /*< private >*/ - public volatile byte[] _gst_reserved = new byte[Native.POINTER_SIZE * BaseSinkAPI.GST_PADDING_LARGE]; + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING_LARGE]; @Override protected List getFieldOrder() { diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java index bed18e25..b4da317b 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java @@ -19,7 +19,6 @@ package org.freedesktop.gstreamer.lowlevel; -import org.freedesktop.gstreamer.ActivateMode; import org.freedesktop.gstreamer.Buffer; import org.freedesktop.gstreamer.Caps; import org.freedesktop.gstreamer.ClockTime; @@ -40,7 +39,7 @@ import com.sun.jna.ptr.LongByReference; import java.util.Arrays; import java.util.List; -//import org.gstreamer.lowlevel.annotations.CallerOwnsReturn; +import org.freedesktop.gstreamer.Query; public interface BaseSrcAPI extends Library { BaseSrcAPI BASESRC_API = GstNative.load("gstbase", BaseSrcAPI.class); @@ -63,37 +62,37 @@ public static final class GstBaseSrcStruct extends com.sun.jna.Structure { /* MT-protected (with LOCK) */ public volatile int blocksize; /* size of buffers when operating push based */ public volatile boolean can_activate_push; /* some scheduling properties */ - public volatile ActivateMode pad_mode; - public volatile boolean seekable; public volatile boolean random_access; public volatile /* GstClockID */ Pointer clock_id; /* for syncing */ - public volatile /* GstClockTime */ long end_time; /* MT-protected (with STREAM_LOCK) */ public volatile GstSegmentStruct segment; + /* MT-protected (with STREAM_LOCK) */ public volatile boolean need_newsegment; - public volatile /* guint64 */ long offset; /* current offset in the resource, unused */ - public volatile /* guint64 */ long size; /* total size of the resource, unused */ - public volatile int num_buffers; public volatile int num_buffers_left; - /*< private >*/ - public volatile GstBaseSrcAbiData abidata; + public volatile boolean typefind; + public volatile boolean running; + public volatile Event pending_seek; + public volatile Pointer /* GstBaseSrcPrivate */ priv; + + /*< private >*/ + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING_LARGE]; @Override protected List getFieldOrder() { return Arrays.asList(new String[] { - "element", "srcpad", "live_lock", - "live_cond", "is_live", "live_running", - "blocksize", "can_activate_push", "pad_mode", - "seekable", "random_access", "clock_id", - "end_time", "segment", "need_newsegment", - "offset", "size", "num_buffers", - "num_buffers_left", "abidata", "priv" + "element", "srcpad", + "live_lock", "live_cond", "is_live", "live_running", + "blocksize", "can_activate_push", "random_access", + "clock_id", "segment", "need_newsegment", + "num_buffers", "num_buffers_left", + "typefind", "running", "pending_seek", + "priv", "_gst_reserved" }); } } @@ -118,7 +117,7 @@ protected List getFieldOrder() { // -------------- Callbacks ----------------- public static interface GetCaps extends Callback { - public Caps callback(BaseSrc src); + public Caps callback(BaseSrc src, Caps filter); } public static interface SetCaps extends Callback { public boolean callback(BaseSrc src, Caps caps); @@ -126,10 +125,14 @@ public static interface SetCaps extends Callback { public static interface BooleanFunc1 extends Callback { public boolean callback(BaseSrc src); } + public static interface DecideAllocation extends Callback { + public boolean callback(BaseSrc src, Query query); + } + public static interface GetTimes extends Callback { public void callback(BaseSrc src, Buffer buffer, - Pointer start, Pointer end); + Pointer /* GstClockTime */ start, Pointer /* GstClockTime */ end); } public static interface GetSize extends Callback { boolean callback(BaseSrc src, LongByReference size); @@ -141,18 +144,23 @@ public static interface Create extends Callback { public FlowReturn callback(BaseSrc src, long offset, int size, /* GstBuffer ** */ Pointer bufRef); } + public static interface Fill extends Callback { + public FlowReturn callback(BaseSrc src, long offset, int size, + Buffer buffer); + } public static interface Seek extends Callback { boolean callback(BaseSrc src, GstSegmentStruct segment); } - public static interface Query extends Callback { + public static interface QueryFunc extends Callback { boolean callback(BaseSrc src, Query query); } public static interface Fixate extends Callback { - public void callback(BaseSrc src, Caps caps); + public Caps callback(BaseSrc src, Caps caps); } public static interface PrepareSeek extends Callback { boolean callback(BaseSrc src, Event seek, GstSegmentStruct segment); } + public static final class GstBaseSrcClass extends com.sun.jna.Structure { public GstBaseSrcClass() {} public GstBaseSrcClass(Pointer ptr) { @@ -170,12 +178,15 @@ public GstBaseSrcClass(Pointer ptr) { /* get caps from subclass */ public GetCaps get_caps; - /* notify the subclass of new caps */ - public SetCaps set_caps; /* decide on caps */ public BooleanFunc1 negotiate; - /* generate and send a newsegment (UNUSED) */ - public BooleanFunc1 newsegment; + /* called if, in negotation, caps need fixating */ + public Fixate fixate; + /* notify the subclass of new caps */ + public SetCaps set_caps; + + /* setup allocation query */ + public DecideAllocation decide_allocation; /* start and stop processing, ideal for opening/closing the resource */ @@ -194,54 +205,49 @@ public GstBaseSrcClass(Pointer ptr) { /* check if the resource is seekable */ public BooleanFunc1 is_seekable; + /* Prepare the segment on which to perform do_seek(), converting to the + * current basesrc format. */ + public PrepareSeek prepare_seek_segment; + /* notify subclasses of a seek */ + public Seek do_seek; + /* unlock any pending access to the resource. subclasses should unlock * any function ASAP. */ public BooleanFunc1 unlock; + /* Clear any pending unlock request, as we succeeded in unlocking */ + public BooleanFunc1 unlock_stop; + /* notify subclasses of a query */ + public QueryFunc query; /* notify subclasses of an event */ public EventNotify event; - /* ask the subclass to create a buffer with offset and size */ + /* ask the subclass to create a buffer with offset and size, the default + * implementation will call alloc and fill. */ public Create create; - /* additions that change padding... */ - /* notify subclasses of a seek */ - public Seek seek; - /* notify subclasses of a query */ - public Query query; - - /* check whether the source would support pull-based operation if - * it were to be opened now. This vfunc is optional, but should be - * implemented if possible to avoid unnecessary start/stop cycles. - * The default implementation will open and close the resource to - * find out whether get_range is supported and that is usually - * undesirable. */ - public BooleanFunc1 check_get_range; - - /* called if, in negotation, caps need fixating */ - public Fixate fixate; - - /* Clear any pending unlock request, as we succeeded in unlocking */ - public BooleanFunc1 unlock_stop; + /* ask the subclass to allocate an output buffer. The default implementation + * will use the negotiated allocator. */ + public Create alloc; - /* Prepare the segment on which to perform do_seek(), converting to the - * current basesrc format. */ - public PrepareSeek prepare_seek_segment; + public Fill fill; /*< private >*/ - public volatile byte[] _gst_reserved = new byte[Native.POINTER_SIZE * (GST_PADDING_LARGE - 6)]; + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING_LARGE]; @Override protected List getFieldOrder() { return Arrays.asList(new String[] { - "parent_class", "get_caps", "set_caps", - "negotiate", "newsegment", "start", - "stop", "get_times", "get_size", - "is_seekable", "unlock", "event", - "create", "seek", "query", - "check_get_range", "fixate", "unlock_stop", - "prepare_seek_segment", "_gst_reserved" + "parent_class", + "get_caps", "negotiate", "fixate", "set_caps", + "decide_allocation", + "start", "stop", + "get_times", "get_size", "is_seekable", + "prepare_seek_segment", "do_seek", + "unlock", "unlock_stop", + "query", "event", "create", "alloc", "fill", + "_gst_reserved" }); } From b285ce8a3cde9c3d1a9bc4031adeef8e4a59bba2 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Mon, 20 Aug 2018 17:32:04 +0200 Subject: [PATCH 02/17] align BaseTransformAPI structures --- .../gstreamer/lowlevel/BaseTransformAPI.java | 157 ++++++++++-------- 1 file changed, 92 insertions(+), 65 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java index e2c5e6a2..03c98d88 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java @@ -33,11 +33,11 @@ import com.sun.jna.Callback; import com.sun.jna.Library; -import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import java.util.Arrays; import java.util.List; +import org.freedesktop.gstreamer.Query; public interface BaseTransformAPI extends Library { BaseTransformAPI BASETRANSFORM_API = GstNative.load("gstbase", BaseTransformAPI.class); @@ -48,32 +48,19 @@ public static final class GstBaseTransformStruct extends com.sun.jna.Structure { public GstElementStruct element; /*< protected >*/ + /* source and sink pads */ public volatile Pad sinkpad; public volatile Pad srcpad; - /* Set by sub-class */ - public volatile boolean passthrough; - public volatile boolean always_in_place; - - public volatile Caps cache_caps1; - public volatile int cache_caps1_size; - public volatile Caps cache_caps2; - public volatile int cache_caps2_size; - public volatile boolean have_same_caps; - - public volatile boolean delay_configure; - public volatile boolean pending_configure; - public volatile boolean negotiated; - - public volatile boolean have_newsegment; - /* MT-protected (with STREAM_LOCK) */ + public volatile boolean have_segment; public volatile GstSegmentStruct segment; - - public volatile /* GMutex */ Pointer transform_lock; + /* Default submit_input_buffer places the buffer here, + * for consumption by the generate_output method: */ + public volatile Buffer queued_buf; /*< private >*/ - public volatile /* GstBaseTransformPrivate */ Pointer priv; + public volatile Pointer /* GstBaseTransformPrivate */ priv; public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING_LARGE - 1]; @@ -81,57 +68,77 @@ public static final class GstBaseTransformStruct extends com.sun.jna.Structure { protected List getFieldOrder() { return Arrays.asList(new String[]{ "element", "sinkpad", "srcpad", - "passthrough", "always_in_place", "cache_caps1", - "cache_caps1_size", "cache_caps2", "cache_caps2_size", - "have_same_caps", "delay_configure", "pending_configure", - "negotiated", "have_newsegment", "segment", - "transform_lock", "priv", "_gst_reserved" + "have_segment", "segment", "queued_buf", + "priv", "_gst_reserved" }); } - - - } public static interface TransformCaps extends Callback { - public Caps callback(BaseTransform trans, PadDirection direction, Caps caps); + public Caps callback(BaseTransform trans, PadDirection direction, Caps caps, Caps filter); } public static interface FixateCaps extends Callback { - public void callback(BaseTransform trans, PadDirection direction, Caps caps, Caps othercaps); + public Caps callback(BaseTransform trans, PadDirection direction, Caps caps, Caps othercaps); + } + public static interface AcceptCaps extends Callback { + public boolean callback(BaseTransform trans, PadDirection direction, Caps caps); + } + public static interface SetCaps extends Callback { + public boolean callback(BaseTransform trans, Caps incaps, Caps outcaps); + } + public static interface QueryFunc extends Callback { + public boolean callback(BaseTransform trans, PadDirection direction, Query query); } + public static interface DecideAllocation extends Callback { + public boolean callback(BaseTransform trans, Query query); + } + public static interface FilterMeta extends Callback { + public boolean callback(BaseTransform trans, Query query, GType api, Pointer /* GstStructure */ params); + } + public static interface ProposeAllocation extends Callback { + public boolean callback(BaseTransform trans, Query decide_query, Query query); + } public static interface TransformSize extends Callback { public boolean callback(BaseTransform trans, PadDirection direction, Caps caps, int size, Caps othercaps, IntByReference othersize); } public static interface GetUnitSize extends Callback { public boolean callback(BaseTransform trans, Caps caps, IntByReference size); - } - public static interface SetCaps extends Callback { - public boolean callback(BaseTransform trans, Caps caps, Caps outcaps); - } + } public static interface BooleanFunc1 extends Callback { public boolean callback(BaseTransform sink); } public static interface EventNotify extends Callback { public boolean callback(BaseTransform trans, Event event); } - public static interface Transform extends Callback { - public FlowReturn callback(BaseTransform trans, Buffer inbuf, Buffer outbuf); + public static interface PrepareOutput extends Callback { + public FlowReturn callback(BaseTransform trans, Buffer input, Pointer /*GstBuffer ** */ outbuf); } - public static interface TransformIp extends Callback { - public FlowReturn callback(BaseTransform trans, Buffer inbuf); + public static interface CopyMetadata extends Callback { + public boolean callback(BaseTransform trans, Buffer input, Buffer output); } - public static interface PrepareOutput extends Callback { - public FlowReturn callback(BaseTransform trans, Buffer input, int size, Caps caps, - /*GstBuffer ** */ Pointer buf); + public static interface TransformMeta extends Callback { + public boolean callback(BaseTransform trans, Buffer outbuf, Pointer /* GstMeta */ meta, Buffer output); } public static interface BeforeTransform extends Callback { public void callback(BaseTransform trans, Buffer inbuf); + } + public static interface Transform extends Callback { + public FlowReturn callback(BaseTransform trans, Buffer inbuf, Buffer outbuf); } - public static interface AcceptCaps extends Callback { - public boolean callback(BaseTransform trans, PadDirection direction, Caps caps); + public static interface TransformIp extends Callback { + public FlowReturn callback(BaseTransform trans, Buffer buf); + } + public static interface SubmitInputBuffer extends Callback { + public FlowReturn callback(BaseTransform trans, boolean is_discont, Buffer input); } + public static interface GenerateOutput extends Callback { + public FlowReturn callback(BaseTransform trans, Pointer /* GstBuffer ** */ outbuf); + } + + + public static final class GstBaseTransformClass extends com.sun.jna.Structure { public GstBaseTransformClass() {} @@ -142,51 +149,71 @@ public GstBaseTransformClass(Pointer ptr) { // // Actual data members - // + // public GstElementClass parent_class; /*< public >*/ + public volatile boolean passthrough_on_same_caps; + public volatile boolean transform_ip_on_passthrough; + + /* virtual methods for subclasses */ public TransformCaps transform_caps; public FixateCaps fixate_caps; - public TransformSize transform_size; + public AcceptCaps accept_caps; - public GetUnitSize get_unit_size; - public SetCaps set_caps; + + public QueryFunc query; + + /* decide allocation query for output buffers */ + public DecideAllocation decide_allocation; + public FilterMeta filter_meta; + + /* propose allocation query parameters for input buffers */ + public ProposeAllocation propose_allocation; + + /* transform size */ + public TransformSize transform_size; + public GetUnitSize get_unit_size; + /* states */ public BooleanFunc1 start; public BooleanFunc1 stop; - public EventNotify event; - - public Transform transform; - - public TransformIp transform_ip; - - public volatile boolean passthrough_on_same_caps; - - public PrepareOutput prepare_output_buffer; - + /* sink and src pad event handlers */ + public EventNotify sink_event; public EventNotify src_event; + public PrepareOutput prepare_output_buffer; + + /* metadata */ + public CopyMetadata copy_metadata; + public TransformMeta transform_meta; public BeforeTransform before_transform; - public AcceptCaps accept_caps; + /* transform */ + public Transform transform; + public TransformIp transform_ip; + + public SubmitInputBuffer submit_input_buffer; + public GenerateOutput generate_output; /*< private >*/ - public volatile byte[] _gst_reserved = new byte[Native.POINTER_SIZE * (GST_PADDING_LARGE - 3)]; + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING_LARGE - 2]; @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "parent_class", "transform_caps", "fixate_caps", - "transform_size", "get_unit_size", "set_caps", - "start", "stop", "event", - "transform", "transform_ip", "passthrough_on_same_caps", - "prepare_output_buffer", "src_event", "before_transform", - "accept_caps", "_gst_reserved" + "parent_class", "passthrough_on_same_caps", "transform_ip_on_passthrough", + "transform_caps", "fixate_caps", "accept_caps", "set_caps", "query", + "decide_allocation", "filter_meta", "propose_allocation", + "transform_size", "get_unit_size", + "start", "stop", "sink_event", "src_event", + "prepare_output_buffer", "copy_metadata", "transform_meta", + "before_transform", "transform", "transform_ip", + "submit_input_buffer", "generate_output", "_gst_reserved" }); } } From 6dfbb6a00e838a8dba5a62536a9d099ef2b4894b Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Mon, 20 Aug 2018 18:00:30 +0200 Subject: [PATCH 03/17] GstSegmentStruct: minor cleanup, add documentation --- .../gstreamer/lowlevel/GstAPI.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java index 6cba64fd..374215d0 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java @@ -48,6 +48,25 @@ public interface GstAPI extends Library { void gst_segtrap_set_enabled(boolean enabled); void gst_deinit(); + /** + * GstSegment: + * @flags: flags for this segment + * @rate: the playback rate of the segment + * @applied_rate: the already applied rate to the segment + * @format: the format of the segment values + * @base: the running time (plus elapsed time, see offset) of the segment start + * @offset: the amount (in buffer timestamps) that has already been elapsed in + * the segment + * @start: the start of the segment in buffer timestamp time (PTS) + * @stop: the stop of the segment in buffer timestamp time (PTS) + * @time: the stream time of the segment start + * @position: the buffer timestamp position in the segment (used internally by + * elements such as sources, demuxers or parsers to track progress) + * @duration: the duration of the segment + * + * A helper structure that holds the configured region of + * interest in a media file. + */ public static final class GstSegmentStruct extends com.sun.jna.Structure { public GstSegmentStruct() { @@ -88,7 +107,7 @@ public GstSegmentStruct(int flags, double rate, double applied_rate, Format form public long duration; /*< private >*/ - public volatile byte[] _gst_reserved = new byte[(Native.POINTER_SIZE * GST_PADDING) - (Double.SIZE / 8)]; + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; @Override protected List getFieldOrder() { From 18fde01d24ed47e53e0f96ebb2759624055db9d1 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Mon, 20 Aug 2018 18:01:20 +0200 Subject: [PATCH 04/17] GstBufferAPI: add some documentation --- .../freedesktop/gstreamer/lowlevel/GstBufferAPI.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java index 5a895c89..8f5f383f 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java @@ -59,7 +59,7 @@ public interface GstBufferAPI extends com.sun.jna.Library { public static final class MapInfoStruct extends com.sun.jna.Structure { public volatile Pointer memory; // Pointer to GstMemory public volatile int flags; // GstMapFlags - public volatile Pointer data; + public volatile Pointer /* gunit8 */ data; public volatile NativeLong size; public volatile NativeLong maxSize; @@ -88,18 +88,25 @@ protected List getFieldOrder() { } GType gst_buffer_get_type(); + + /* allocation */ @CallerOwnsReturn Buffer gst_buffer_new(); @CallerOwnsReturn Buffer gst_buffer_new_allocate(Pointer allocator, int size, Pointer params); @CallerOwnsReturn Pointer ptr_gst_buffer_new(); @CallerOwnsReturn Pointer ptr_gst_buffer_new_allocate(Pointer allocator, int size, Pointer params); + + /* memory blocks */ NativeLong gst_buffer_get_size(Buffer buffer); boolean gst_buffer_map(Buffer buffer, MapInfoStruct info, int flags); void gst_buffer_unmap(Buffer buffer, MapInfoStruct info); int gst_buffer_n_memory(Buffer buffer); boolean gst_buffer_map_range(Buffer buffer, int idx, int length, MapInfoStruct info, int flags); + + // re-introduces in gstreamer 1.9 int gst_buffer_get_flags(Buffer buffer); boolean gst_buffer_set_flags(Buffer buffer, int flags); boolean gst_buffer_unset_flags(Buffer buffer, int flags); + // boolean gst_buffer_is_metadata_writable(Buffer buf); // Buffer gst_buffer_make_metadata_writable(@Invalidate Buffer buf); // /* creating a subbuffer */ @@ -140,7 +147,8 @@ protected List getFieldOrder() { public static final class BufferStruct extends com.sun.jna.Structure { volatile public MiniObjectStruct mini_object; - public Pointer pool; + /*< public >*/ /* with COW */ + public Pointer /* BufferPool */ pool; /* timestamp */ public ClockTime pts; From bd21f1dc4b8af0fbb4b624587f4a02932cbca779 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Mon, 20 Aug 2018 18:01:52 +0200 Subject: [PATCH 05/17] GstBufferPool: minor cleanup, sort functions --- .../gstreamer/lowlevel/GstBufferPoolAPI.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java index f3dede8a..503ebd89 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java @@ -25,14 +25,19 @@ import com.sun.jna.Pointer; public interface GstBufferPoolAPI extends com.sun.jna.Library { - GstBufferPoolAPI GSTBUFFERPOOL_API = GstNative.load(GstBufferPoolAPI.class); + GstBufferPoolAPI GSTBUFFERPOOL_API = GstNative.load(GstBufferPoolAPI.class); - GType gst_buffer_pool_get_type(); + GType gst_buffer_pool_get_type(); - @CallerOwnsReturn BufferPool gst_buffer_pool_new(); + /* allocation */ + @CallerOwnsReturn BufferPool gst_buffer_pool_new(); Pointer ptr_gst_buffer_pool_new(); + + /* state management */ Structure gst_buffer_pool_get_config(BufferPool pool); + + /* helpers for configuring the config structure */ boolean gst_buffer_pool_config_get_params(Structure config, /* Caps ** */ Pointer[] caps, /* guint * */ int[] size, /* guint * */ int[] min_buffers, /* guint * */ int[] max_buffers); void gst_buffer_pool_config_set_params(Structure config, Caps caps, int size, int min_buffers, int max_buffers); - + } From 9e80e07775d60defc942310538f3ffe13402b332 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 21 Aug 2018 15:27:08 +0200 Subject: [PATCH 06/17] align formating --- .../gstreamer/lowlevel/AppAPI.java | 3 +- .../gstreamer/lowlevel/BaseSinkAPI.java | 6 ++-- .../gstreamer/lowlevel/BaseSrcAPI.java | 9 +++--- .../gstreamer/lowlevel/BaseTransformAPI.java | 4 ++- .../gstreamer/lowlevel/GSignalAPI.java | 8 ++--- .../gstreamer/lowlevel/GValueAPI.java | 8 ++--- .../gstreamer/lowlevel/GioAPI.java | 32 ++++++++----------- .../gstreamer/lowlevel/GlibAPI.java | 14 ++++---- .../gstreamer/lowlevel/GstAPI.java | 3 +- .../gstreamer/lowlevel/GstBufferAPI.java | 1 + .../gstreamer/lowlevel/GstCapsAPI.java | 3 -- 11 files changed, 45 insertions(+), 46 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/AppAPI.java b/src/org/freedesktop/gstreamer/lowlevel/AppAPI.java index 7f8396b8..ad2052da 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/AppAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/AppAPI.java @@ -36,7 +36,8 @@ * @author wayne */ public interface AppAPI extends com.sun.jna.Library { - AppAPI APP_API = GstNative.load("gstapp", AppAPI.class); + + AppAPI APP_API = GstNative.load("gstapp", AppAPI.class); // AppSrc functions GType gst_app_src_get_type(); diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java index 891bc8d2..71a421ab 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java @@ -32,7 +32,6 @@ import org.freedesktop.gstreamer.MiniObject; import org.freedesktop.gstreamer.Pad; import org.freedesktop.gstreamer.Query; -import org.freedesktop.gstreamer.StateChangeReturn; import org.freedesktop.gstreamer.elements.BaseSink; import org.freedesktop.gstreamer.lowlevel.GlibAPI.GList; import org.freedesktop.gstreamer.lowlevel.GstAPI.GstSegmentStruct; @@ -43,7 +42,6 @@ import com.sun.jna.Callback; import com.sun.jna.Library; -import com.sun.jna.Native; import com.sun.jna.Pointer; /** @@ -52,7 +50,9 @@ */ public interface BaseSinkAPI extends Library { - BaseSinkAPI BASESINK_API = GstNative.load("gstbase", BaseSinkAPI.class); + + BaseSinkAPI BASESINK_API = GstNative.load("gstbase", BaseSinkAPI.class); + int GST_PADDING = GstAPI.GST_PADDING; int GST_PADDING_LARGE = GstAPI.GST_PADDING_LARGE; diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java index b4da317b..0113206f 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java @@ -33,7 +33,6 @@ import com.sun.jna.Callback; import com.sun.jna.Library; -import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Union; import com.sun.jna.ptr.LongByReference; @@ -42,7 +41,9 @@ import org.freedesktop.gstreamer.Query; public interface BaseSrcAPI extends Library { - BaseSrcAPI BASESRC_API = GstNative.load("gstbase", BaseSrcAPI.class); + + BaseSrcAPI BASESRC_API = GstNative.load("gstbase", BaseSrcAPI.class); + int GST_PADDING = GstAPI.GST_PADDING; int GST_PADDING_LARGE = GstAPI.GST_PADDING_LARGE; @@ -142,10 +143,10 @@ public static interface EventNotify extends Callback { } public static interface Create extends Callback { public FlowReturn callback(BaseSrc src, long offset, int size, - /* GstBuffer ** */ Pointer bufRef); + Pointer /* GstBuffer ** */ bufRef); } public static interface Fill extends Callback { - public FlowReturn callback(BaseSrc src, long offset, int size, + public FlowReturn callback(BaseSrc src, long offset, int size, Buffer buffer); } public static interface Seek extends Callback { diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java index 03c98d88..02c383a9 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java @@ -40,7 +40,9 @@ import org.freedesktop.gstreamer.Query; public interface BaseTransformAPI extends Library { - BaseTransformAPI BASETRANSFORM_API = GstNative.load("gstbase", BaseTransformAPI.class); + + BaseTransformAPI BASETRANSFORM_API = GstNative.load("gstbase", BaseTransformAPI.class); + int GST_PADDING = GstAPI.GST_PADDING; int GST_PADDING_LARGE = GstAPI.GST_PADDING_LARGE; diff --git a/src/org/freedesktop/gstreamer/lowlevel/GSignalAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GSignalAPI.java index 66494767..657a21fe 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GSignalAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GSignalAPI.java @@ -38,10 +38,10 @@ */ @SuppressWarnings("serial") public interface GSignalAPI extends Library { - GSignalAPI GSIGNAL_API = GNative.loadLibrary("gobject-2.0", GSignalAPI.class, - new HashMap() {{ - put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); - }}); + GSignalAPI GSIGNAL_API = GNative.loadLibrary("gobject-2.0", GSignalAPI.class, + new HashMap() {{ + put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); + }}); public static int G_CONNECT_AFTER = 1 << 0; public static int G_CONNECT_SWAPPED = 1 << 1; diff --git a/src/org/freedesktop/gstreamer/lowlevel/GValueAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GValueAPI.java index 0cd367a0..5bfa2dfa 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GValueAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GValueAPI.java @@ -48,12 +48,12 @@ public interface NoMapperAPI extends Library { } NoMapperAPI GVALUE_NOMAPPER_API = GNative.loadLibrary("gobject-2.0", NoMapperAPI.class, - new HashMap() {}); + new HashMap() {}); GValueAPI GVALUE_API = GNative.loadLibrary("gobject-2.0", GValueAPI.class, - new HashMap() {{ - put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); - }}); + new HashMap() {{ + put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); + }}); public static final class GValue extends com.sun.jna.Structure { public static final String GTYPE_NAME = "GValue"; diff --git a/src/org/freedesktop/gstreamer/lowlevel/GioAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GioAPI.java index 592512bf..abba3681 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GioAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GioAPI.java @@ -5,26 +5,22 @@ public class GioAPI { - static { - Native.register("gio-2.0"); - } + static { + Native.register("gio-2.0"); + } - // GInetAddress - public static native String g_inet_address_to_string(Pointer gInetAddress); + // GInetAddress + public static native String g_inet_address_to_string(Pointer gInetAddress); - // GstSocketAddress - public static native Pointer g_inet_socket_address_new_from_string(String address, int port); - - // GstSocket - public static native Pointer g_socket_new(int gSocketFamilyEnumValue, int gSocketTypeEnumValue, int gSocketProtcolEnumValue, Pointer gErrorStructArrayPointer); - public static native boolean g_socket_bind(Pointer gSocketPointer, Pointer gSocketAddressPointer, boolean allowReuse, Pointer gErrorStructArrayPointer); - public static native boolean g_socket_connect(Pointer gSocketPointer, Pointer gSocketAddressPointer, Pointer gCancellablePointer, Pointer gErrorStructArrayPointer); - - // GCancellable - public static native Pointer g_cancellable_new(); + // GstSocketAddress + public static native Pointer g_inet_socket_address_new_from_string(String address, int port); + // GstSocket + public static native Pointer g_socket_new(int gSocketFamilyEnumValue, int gSocketTypeEnumValue, int gSocketProtcolEnumValue, Pointer gErrorStructArrayPointer); + public static native boolean g_socket_bind(Pointer gSocketPointer, Pointer gSocketAddressPointer, boolean allowReuse, Pointer gErrorStructArrayPointer); + public static native boolean g_socket_connect(Pointer gSocketPointer, Pointer gSocketAddressPointer, Pointer gCancellablePointer, Pointer gErrorStructArrayPointer); + + // GCancellable + public static native Pointer g_cancellable_new(); - - - } diff --git a/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java index 8aacd6c6..8a23c353 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java @@ -35,14 +35,14 @@ */ @SuppressWarnings("serial") public interface GlibAPI extends Library { - GlibAPI GLIB_API = GNative.loadLibrary("glib-2.0", GlibAPI.class, - new HashMap() {{ - put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); - }}); + GlibAPI GLIB_API = GNative.loadLibrary("glib-2.0", GlibAPI.class, + new HashMap() {{ + put(Library.OPTION_TYPE_MAPPER, new GTypeMapper()); + }}); - public static final int GLIB_SYSDEF_AF_UNIX = 1; - public static final int GLIB_SYSDEF_AF_INET = 2; - public static final int GLIB_SYSDEF_AF_INET6 = 23; + public static final int GLIB_SYSDEF_AF_UNIX = 1; + public static final int GLIB_SYSDEF_AF_INET = 2; + public static final int GLIB_SYSDEF_AF_INET6 = 23; Pointer g_main_loop_new(GMainContext context, boolean running); void g_main_loop_run(MainLoop loop); diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java index 374215d0..b0b0ec41 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java @@ -23,7 +23,6 @@ import org.freedesktop.gstreamer.lowlevel.annotations.CallerOwnsReturn; import com.sun.jna.Library; -import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; @@ -34,7 +33,9 @@ * */ public interface GstAPI extends Library { + GstAPI GST_API = GstNative.load(GstAPI.class); + int GST_PADDING = 4; int GST_PADDING_LARGE = 20; diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java index 8f5f383f..b30b3474 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java @@ -36,6 +36,7 @@ * GstBuffer functions */ public interface GstBufferAPI extends com.sun.jna.Library { + GstBufferAPI GSTBUFFER_API = GstNative.load(GstBufferAPI.class); public static final int GST_LOCK_FLAG_READ = (1 << 0); diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstCapsAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstCapsAPI.java index 4a52110a..574bcda8 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstCapsAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstCapsAPI.java @@ -27,9 +27,6 @@ import org.freedesktop.gstreamer.lowlevel.annotations.Invalidate; import com.sun.jna.Pointer; -import com.sun.jna.PointerType; -import java.util.Arrays; -import java.util.List; /** * GstCaps functions From a27012517347bf9086d42e609d6b80bf397b3abe Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 21 Aug 2018 15:28:05 +0200 Subject: [PATCH 07/17] add comments and references to header files for version 1.8 --- src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java | 3 +-- src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java | 4 ++++ src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java | 4 ++++ src/org/freedesktop/gstreamer/lowlevel/GstAPI.java | 2 ++ src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java | 5 ++++- src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java | 4 ++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java index 71a421ab..c24429cb 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSinkAPI.java @@ -46,9 +46,8 @@ /** * GstBaseSink methods and structures - * @see https://github.com/GStreamer/gstreamer/blob/master/libs/gst/base/gstbasesink.h + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/libs/gst/base/gstbasesink.h?h=1.8 */ - public interface BaseSinkAPI extends Library { BaseSinkAPI BASESINK_API = GstNative.load("gstbase", BaseSinkAPI.class); diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java index 0113206f..8cff21ea 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseSrcAPI.java @@ -40,6 +40,10 @@ import java.util.List; import org.freedesktop.gstreamer.Query; +/** + * GstBaseSrc methods and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/libs/gst/base/gstbasesrc.h?h=1.8 + */ public interface BaseSrcAPI extends Library { BaseSrcAPI BASESRC_API = GstNative.load("gstbase", BaseSrcAPI.class); diff --git a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java index 02c383a9..d9011ba8 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/BaseTransformAPI.java @@ -39,6 +39,10 @@ import java.util.List; import org.freedesktop.gstreamer.Query; +/** + * GstBaseTransform methods and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/libs/gst/base/gstbasetransform.h?h=1.8 + */ public interface BaseTransformAPI extends Library { BaseTransformAPI BASETRANSFORM_API = GstNative.load("gstbase", BaseTransformAPI.class); diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java index b0b0ec41..248ca462 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstAPI.java @@ -50,6 +50,8 @@ public interface GstAPI extends Library { void gst_deinit(); /** + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstsegment.h?h=1.8 + * * GstSegment: * @flags: flags for this segment * @rate: the playback rate of the segment diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java index b30b3474..95434a37 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstBufferAPI.java @@ -33,7 +33,8 @@ import static org.freedesktop.gstreamer.lowlevel.GstAPI.GST_PADDING; /** - * GstBuffer functions + * GstBuffer methods and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstbuffer.h?h=1.8 */ public interface GstBufferAPI extends com.sun.jna.Library { @@ -45,6 +46,8 @@ public interface GstBufferAPI extends com.sun.jna.Library { public static final int GST_MAP_WRITE = GST_LOCK_FLAG_WRITE; /** + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstmemory.h?h=1.8 + * * GstMapInfo: * @memory: a pointer to the mapped memory * @flags: flags used when mapping the memory diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java index 503ebd89..ee6ba16c 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstBufferPoolAPI.java @@ -24,6 +24,10 @@ import com.sun.jna.Pointer; +/** + * GstBufferPool methods and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstbufferpool.h?h=1.8 + */ public interface GstBufferPoolAPI extends com.sun.jna.Library { GstBufferPoolAPI GSTBUFFERPOOL_API = GstNative.load(GstBufferPoolAPI.class); From 12fdf2d76b52d221584b486da3700bcb0a98dd67 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 21 Aug 2018 15:31:59 +0200 Subject: [PATCH 08/17] align structures for GstControlSourceAPI, removed ValueArray as of notes in porting-to-1.0.txt --- .../lowlevel/GstControlSourceAPI.java | 115 ++++++++++-------- .../lowlevel/LowLevelStructureTest.java | 1 - 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstControlSourceAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstControlSourceAPI.java index 20abe7db..405596a4 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstControlSourceAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstControlSourceAPI.java @@ -19,26 +19,40 @@ package org.freedesktop.gstreamer.lowlevel; import org.freedesktop.gstreamer.ClockTime; -import org.freedesktop.gstreamer.GObject; import org.freedesktop.gstreamer.controller.ControlSource; -import org.freedesktop.gstreamer.lowlevel.GObjectAPI.GObjectClass; import org.freedesktop.gstreamer.lowlevel.GObjectAPI.GParamSpec; import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValue; import com.sun.jna.Callback; import com.sun.jna.Library; import com.sun.jna.Pointer; +import com.sun.jna.ptr.DoubleByReference; import java.util.Arrays; import java.util.List; +import org.freedesktop.gstreamer.GstObject; +import static org.freedesktop.gstreamer.lowlevel.GstAPI.GST_PADDING; +import org.freedesktop.gstreamer.lowlevel.GstObjectAPI.GstObjectClass; +/** + * GstControlSource methods and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstcontrolsource.h?h=1.8 + */ public interface GstControlSourceAPI extends Library { - GstControlSourceAPI GSTCONTROLSOURCE_API = GstNative.load("gstcontroller", GstControlSourceAPI.class); - int GST_PADDING = GstAPI.GST_PADDING; + + GstControlSourceAPI GSTCONTROLSOURCE_API = GstNative.load("gstcontroller", GstControlSourceAPI.class); - public static final class TimedValue extends com.sun.jna.Structure { + /** + * GstTimedValue: + * @timestamp: timestamp of the value change + * @value: the corresponding value + * + * Structure for saving a timestamp and a value. + */ + public static final class TimedValue extends com.sun.jna.Structure { public static final String GTYPE_NAME = "GstTimedValue"; - public volatile ClockTime timestamp; - public volatile GValue value; + + public volatile ClockTime timestamp; + public volatile double value; @Override protected List getFieldOrder() { @@ -46,74 +60,67 @@ protected List getFieldOrder() { "timestamp", "value" }); } - } - public static final class ValueArray extends com.sun.jna.Structure { - public static final String GTYPE_NAME = "GstValueArray"; - - public volatile String property_name; - public volatile int nbsamples; - public volatile ClockTime sample_interval; - public volatile Pointer values; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{ - "property_name", "nbsamples", "sample_interval", - "values" - }); - } - } + } - public static interface GstControlSourceGetValue extends Callback { - public boolean callback(ControlSource self, ClockTime timestamp, GValue value); + public static interface GstControlSourceGetValue extends Callback { + public boolean callback(ControlSource self, ClockTime timestamp, DoubleByReference value); } - public static interface GstControlSourceGetValueArray extends Callback { - public boolean callback(ControlSource self, ClockTime timestamp, ValueArray value_array); + public static interface GstControlSourceGetValueArray extends Callback { + public boolean callback(ControlSource self, ClockTime timestamp, ClockTime interval, int n_values, DoubleByReference values); } - public static interface GstControlSourceBind extends Callback { + public static interface GstControlSourceBind extends Callback { public boolean callback(ControlSource self, GParamSpec pspec); } - - public static final class GstControlSourceStruct extends com.sun.jna.Structure { - public volatile GObject parent; + + /** + * GstControlSource: + * @get_value: Function for returning a value for a given timestamp + * @get_value_array: Function for returning a values array for a given timestamp + * + * The instance structure of #GstControlSource. + */ + public static final class GstControlSourceStruct extends com.sun.jna.Structure { + public volatile GstObject parent; - /*< public >*/ - public volatile GstControlSourceGetValue get_value; /* Returns the value for a property at a given timestamp */ - public volatile GstControlSourceGetValueArray get_value_array; /* Returns values for a property in a given timespan */ + /*< public >*/ + public volatile GstControlSourceGetValue get_value; /* Returns the value for a property at a given timestamp */ + public volatile GstControlSourceGetValueArray get_value_array; /* Returns values for a property in a given timespan */ - /*< private >*/ - public volatile boolean bound; - public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; + /*< private >*/ + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ "parent", "get_value", "get_value_array", - "bound", "_gst_reserved" + "_gst_reserved" }); } - } - - public static final class GstControlSourceClass extends com.sun.jna.Structure { - public volatile GObjectClass parent_class; - - public volatile GstControlSourceBind bind; /* Binds the GstControlSource to a specific GParamSpec */ + } + + /** + * GstControlSourceClass: + * @parent_class: Parent class + * + * The class structure of #GstControlSource. + */ + public static final class GstControlSourceClass extends com.sun.jna.Structure { + public volatile GstObjectClass parent_class; - /*< private >*/ - public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; + /*< private >*/ + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "parent_class", "bind", "_gst_reserved" + "parent_class", "_gst_reserved" }); } - } + } - GType gst_control_source_get_type(); + GType gst_control_source_get_type(); - /* Functions */ - boolean gst_control_source_get_value(ControlSource self, ClockTime timestamp, GValue value); - boolean gst_control_source_get_value_array(ControlSource self, ClockTime timestamp, ValueArray value_array); - boolean gst_control_source_bind(ControlSource self, GParamSpec pspec); + /* Functions */ + boolean gst_control_source_get_value(ControlSource self, ClockTime timestamp, GValue value); + boolean gst_control_source_get_value_array(ControlSource self, ClockTime timestamp, ClockTime interval, int n_values, DoubleByReference values); } diff --git a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java index a3dbfea7..840cd34c 100644 --- a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java +++ b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java @@ -156,7 +156,6 @@ private static void initStructList() { structs.add(GstColorBalanceAPI.ColorBalanceChannelStruct.class); structs.add(GstControlSourceAPI.TimedValue.class); - structs.add(GstControlSourceAPI.ValueArray.class); structs.add(GstControlSourceAPI.GstControlSourceStruct.class); structs.add(GstControlSourceAPI.GstControlSourceClass.class); From 9cc35db7aa49977b30b04bba80c61b8921c27170 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 21 Aug 2018 15:32:21 +0200 Subject: [PATCH 09/17] add cleanup readme --- src/org/freedesktop/gstreamer/lowlevel/README | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/org/freedesktop/gstreamer/lowlevel/README diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README new file mode 100644 index 00000000..65ee9328 --- /dev/null +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -0,0 +1,13 @@ +lowlevel cleanup log + + +structures in the following classes were aligned to 1.8: +(https://cgit.freedesktop.org/gstreamer/gstreamer/tree/?h=1.8) + +- BaseSinkAPI +- BaseSrcAPI +- BaseTransformAPI +- GstAPI +- GstBufferAPI +- GstBufferPoolAPI +- GstControlSourceAPI From 8bd90bf83c2b733f88e66bfd373ea426a1ecd4c9 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Wed, 22 Aug 2018 16:31:13 +0200 Subject: [PATCH 10/17] remove GstControllerAPI and relates classes (class was removed as described in porting-to-1.0.txt) --- .../gstreamer/controller/ControlSource.java | 2 - .../gstreamer/controller/Controller.java | 78 ----------- .../gstreamer/lowlevel/GstControllerAPI.java | 122 ------------------ src/org/freedesktop/gstreamer/lowlevel/README | 1 + .../lowlevel/LowLevelStructureTest.java | 3 - 5 files changed, 1 insertion(+), 205 deletions(-) delete mode 100644 src/org/freedesktop/gstreamer/controller/Controller.java delete mode 100644 src/org/freedesktop/gstreamer/lowlevel/GstControllerAPI.java diff --git a/src/org/freedesktop/gstreamer/controller/ControlSource.java b/src/org/freedesktop/gstreamer/controller/ControlSource.java index 74baf6a8..6eab0d2c 100644 --- a/src/org/freedesktop/gstreamer/controller/ControlSource.java +++ b/src/org/freedesktop/gstreamer/controller/ControlSource.java @@ -28,8 +28,6 @@ public class ControlSource extends GObject { //private static Logger logger = Logger.getLogger(ControlSource.class.getName()); - //private static final GstControllerAPI gst = GstNative.load(GstControllerAPI.class); - /** * For internal gstreamer-java use only * diff --git a/src/org/freedesktop/gstreamer/controller/Controller.java b/src/org/freedesktop/gstreamer/controller/Controller.java deleted file mode 100644 index cbe0c8d6..00000000 --- a/src/org/freedesktop/gstreamer/controller/Controller.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2010 Levente Farkas - * - * This file is part of gstreamer-java. - * - * This code is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3 only, as - * published by the Free Software Foundation. - * - * This code 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 - * version 3 for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with this work. If not, see . - */ - -package org.freedesktop.gstreamer.controller; - -import java.util.logging.Logger; - -import com.sun.jna.Pointer; - -import org.freedesktop.gstreamer.GObject; -import org.freedesktop.gstreamer.GstException; -import org.freedesktop.gstreamer.Gst.NativeArgs; - -import static org.freedesktop.gstreamer.lowlevel.GstControllerAPI.GSTCONTROLLER_API; - -/** - * The controller subsystem offers a lightweight way to adjust gobject properties over stream-time. - * It works by using time-stamped value pairs that are queued for element-properties. - * At run-time the elements continously pull values changes for the current stream-time. - *

- * What needs to be changed in a GstElement? Very little - it is just two steps to make a plugin controllable! - *

    - *
  • mark gobject-properties paramspecs that make sense to be controlled, by GST_PARAM_CONTROLLABLE. - *
  • when processing data (get, chain, loop function) at the beginning call gst_object_sync_values(element,timestamp). - *
- * This will made the controller to update all gobject properties that are under control with the current values - * based on timestamp. - *

- * What needs to be done in applications? Again its not a lot to change. - *

  • first put some properties under control, by calling controller = gst_object_control_properties (object, "prop1", "prop2",...); - *
  • Get a GstControlSource for the property and set it up. - * csource = gst_interpolation_control_source_new(); - * gst_interpolation_control_source_set_interpolation_mode(csource, mode); - * gst_interpolation_control_source_set (csource,0 * GST_SECOND, value1); - * gst_interpolation_control_source_set (csource,1 * GST_SECOND, value2); - *
  • Set the GstControlSource in the controller. gst_controller_set_control_source (controller, "prop1", csource); - *
  • start your pipeline - *
      - */ -public class Controller extends GObject { - private static Logger logger = Logger.getLogger(Controller.class.getName()); - - static { - NativeArgs argv = new NativeArgs("gstreamer-java", new String[] {}); - if (! GSTCONTROLLER_API.gst_controller_init(argv.argcRef, argv.argvRef)) { - throw new GstException("Can't initialize GstController"); - } - logger.fine("after gst_init, argc=" + argv.argcRef.getValue()); - } - /** - * For internal gstreamer-java use only - * - * @param init initialization data - */ - public Controller(Initializer init) { - super(init); - throw new IllegalArgumentException("Cannot instantiate this class"); - } - - public Controller(Pointer ptr, boolean needRef, boolean ownsHandle) { - super(initializer(ptr, needRef, ownsHandle)); - } -} diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstControllerAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstControllerAPI.java deleted file mode 100644 index 105a1946..00000000 --- a/src/org/freedesktop/gstreamer/lowlevel/GstControllerAPI.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2009 Levente Farkas - * - * This file is part of gstreamer-java. - * - * This code is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License version 3 only, as - * published by the Free Software Foundation. - * - * This code 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 - * version 3 for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with this work. If not, see . - */ - -package org.freedesktop.gstreamer.lowlevel; - -import org.freedesktop.gstreamer.ClockTime; -import org.freedesktop.gstreamer.GObject; -import org.freedesktop.gstreamer.controller.ControlSource; -import org.freedesktop.gstreamer.controller.Controller; -import org.freedesktop.gstreamer.lowlevel.GObjectAPI.GObjectClass; -import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValue; -import org.freedesktop.gstreamer.lowlevel.GlibAPI.GList; -import org.freedesktop.gstreamer.lowlevel.GlibAPI.GSList; - -import com.sun.jna.Library; -import com.sun.jna.Pointer; -import com.sun.jna.ptr.IntByReference; -import com.sun.jna.ptr.PointerByReference; -import java.util.Arrays; -import java.util.List; - -public interface GstControllerAPI extends Library { - GstControllerAPI GSTCONTROLLER_API = GstNative.load("gstcontroller", GstControllerAPI.class); - int GST_PADDING = GstAPI.GST_PADDING; - - public static final class GstControllerStruct extends com.sun.jna.Structure { - public volatile GObjectAPI.GObjectStruct parent; - - public volatile GList properties; /* List of GstControlledProperty */ - public volatile /* GMutex */ Pointer lock; /* Secure property access, elements will access from threads */ - public volatile GObject object; /* the object we control */ - - /*< private >*/ - public volatile /* GstControllerPrivate */ Pointer priv; - public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING - 1]; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{ - "parent", "properties", "lock", - "object", "priv", "_gst_reserved" - }); - } - } - - public static final class GstControllerClass extends com.sun.jna.Structure { - public GstControllerClass() {} - public GstControllerClass(Pointer ptr) { - useMemory(ptr); - read(); - } - - public volatile GObjectClass parent_class; - - /*< private >*/ - public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{ - "parent_class", "_gst_reserved" - }); - } - } - - GType gst_controller_get_type(); - - /* GstController functions */ - Controller gst_controller_new_list(GObject object, GList list); - Controller gst_controller_new(GObject ... object) /*G_GNUC_NULL_TERMINATED*/; - - boolean gst_controller_remove_properties_list(Controller self, GList list); - boolean gst_controller_remove_properties(Controller ... self) /*G_GNUC_NULL_TERMINATED*/; - - void gst_controller_set_disabled(Controller self, boolean disabled); - void gst_controller_set_property_disabled(Controller self, String property_name, boolean disabled); - boolean gst_controller_set_control_source(Controller self, String property_name, ControlSource csource); - ControlSource gst_controller_get_control_source(Controller self, String property_name); - - ClockTime gst_controller_suggest_next_sync(Controller self); - boolean gst_controller_sync_values(Controller self, ClockTime timestamp); - - GValue gst_controller_get(Controller self, String property_name, ClockTime timestamp); - boolean gst_controller_get_value_arrays(Controller self, ClockTime timestamp, GSList value_arrays); - //boolean gst_controller_get_value_array(Controller self, ClockTime timestamp, ValueArray * value_array); - - /* GObject convenience functions */ - Controller gst_object_control_properties(GObject ... object) /*G_GNUC_NULL_TERMINATED*/; - boolean gst_object_uncontrol_properties(GObject ... object) /*G_GNUC_NULL_TERMINATED*/; - - Controller gst_object_get_controller(GObject object); - boolean gst_object_set_controller(GObject object, Controller controller); - - ClockTime gst_object_suggest_next_sync(GObject object); - boolean gst_object_sync_values(GObject object, ClockTime timestamp); - - boolean gst_object_set_control_source(GObject object, String property_name, ControlSource csource); - ControlSource gst_object_get_control_source(GObject object, String property_name); - - boolean gst_object_get_value_arrays(GObject object, ClockTime timestamp, GSList value_arrays); - //boolean gst_object_get_value_array(GObject object, ClockTime timestamp, ValueArray * value_array); - - ClockTime gst_object_get_control_rate(GObject object); - void gst_object_set_control_rate(GObject object, ClockTime control_rate); - /* lib init/done */ - boolean gst_controller_init(IntByReference argc, PointerByReference argv); -} diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 65ee9328..26a1c92d 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -11,3 +11,4 @@ structures in the following classes were aligned to 1.8: - GstBufferAPI - GstBufferPoolAPI - GstControlSourceAPI +- GstControllerAPI - removed diff --git a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java index 840cd34c..158bf7a8 100644 --- a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java +++ b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java @@ -159,9 +159,6 @@ private static void initStructList() { structs.add(GstControlSourceAPI.GstControlSourceStruct.class); structs.add(GstControlSourceAPI.GstControlSourceClass.class); - // error loading native lib? - //structs.add(GstControllerAPI.GstControllerStruct.class); - //structs.add(GstControllerAPI.GstControllerClass.class); structs.add(GstElementAPI.GstElementDetails.class); structs.add(GstElementAPI.GstElementStruct.class); From d6692b6918586fb6b3ed03d8a7968a1332535539 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Wed, 22 Aug 2018 16:34:09 +0200 Subject: [PATCH 11/17] remove GstElementDetails (was removed as described in porting-to-1.0.txt), add lnk to header, add comments, add callback --- .../gstreamer/lowlevel/GstElementAPI.java | 168 +++++++++++++----- .../lowlevel/LowLevelStructureTest.java | 2 - 2 files changed, 126 insertions(+), 44 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstElementAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstElementAPI.java index bda9795f..dc653fbf 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstElementAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstElementAPI.java @@ -48,10 +48,11 @@ /** * GstElement methods and structures - * @see https://github.com/GStreamer/gstreamer/blob/master/gst/gstelement.h + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstelement.h?h=1.8 */ public interface GstElementAPI extends com.sun.jna.Library { + GstElementAPI GSTELEMENT_API = GstNative.load(GstElementAPI.class); GType gst_element_get_type(); @@ -100,48 +101,73 @@ boolean gst_element_link_pads_filtered(Element src, String srcpadname, Element d void gst_element_set_start_time(Element element, ClockTime time); ClockTime gst_element_get_start_time(Element element); - public static final class GstElementDetails extends com.sun.jna.Structure { - /*< public > */ - public volatile String longname; - public volatile String klass; - public volatile String description; - public volatile String author; - /*< private > */ - public volatile Pointer[] _gst_reserved = new Pointer[GstAPI.GST_PADDING]; - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{ - "longname", "klass", "description", - "author", "_gst_reserved" - }); - } - } - + /** + * GstElement: + * @state_lock: Used to serialize execution of gst_element_set_state() + * @state_cond: Used to signal completion of a state change + * @state_cookie: Used to detect concurrent execution of + * gst_element_set_state() and gst_element_get_state() + * @target_state: the target state of an element as set by the application + * @current_state: the current state of an element + * @next_state: the next state of an element, can be #GST_STATE_VOID_PENDING if + * the element is in the correct state. + * @pending_state: the final state the element should go to, can be + * #GST_STATE_VOID_PENDING if the element is in the correct state + * @last_return: the last return value of an element state change + * @bus: the bus of the element. This bus is provided to the element by the + * parent element or the application. A #GstPipeline has a bus of its own. + * @clock: the clock of the element. This clock is usually provided to the + * element by the toplevel #GstPipeline. + * @base_time: the time of the clock right before the element is set to + * PLAYING. Subtracting @base_time from the current clock time in the PLAYING + * state will yield the running_time against the clock. + * @start_time: the running_time of the last PAUSED state + * @numpads: number of pads of the element, includes both source and sink pads. + * @pads: (element-type Gst.Pad): list of pads + * @numsrcpads: number of source pads of the element. + * @srcpads: (element-type Gst.Pad): list of source pads + * @numsinkpads: number of sink pads of the element. + * @sinkpads: (element-type Gst.Pad): list of sink pads + * @pads_cookie: updated whenever the a pad is added or removed + * + * GStreamer element abstract base class. + */ public static final class GstElementStruct extends com.sun.jna.Structure { public GstObjectStruct object; - public volatile Pointer state_lock; - public volatile Pointer state_cond; + + /*< public >*/ /* with LOCK */ + public volatile Pointer /* GRecMutex */ state_lock; + + /* element state */ + public volatile Pointer /* GCond */ state_cond; public volatile int state_cookie; public volatile State target_state; public volatile State current_state; public volatile State next_state; public volatile State pending_state; public volatile StateChangeReturn last_return; - public volatile Pointer bus; - public volatile Pointer clock; + + public volatile Pointer /* GstBus */ bus; + + /* allocated clock */ + public volatile Pointer /* GstClock */ clock; public volatile long base_time; public volatile long start_time; + + /* element pads, these lists can only be iterated while holding + * the LOCK or checking the cookie after each LOCK. */ public volatile short numpads; - public volatile Pointer pads; + public volatile Pointer /* GList */pads; public volatile short numsrcpads; - public volatile Pointer srcpads; + public volatile Pointer /* GList */ srcpads; public volatile short numsinkpads; - public volatile Pointer sinkpads; + public volatile Pointer /* GList */sinkpads; public volatile int pads_cookie; - public volatile Pointer contexts; - // Use an array of byte as arrays of Pointer don't work + /* with object LOCK */ + public volatile Pointer /* GList */contexts; + + /*< private >*/ public volatile Pointer[] _gst_reserved = new Pointer[GstAPI.GST_PADDING-1]; public GstElementStruct(Pointer handle) { @@ -162,22 +188,56 @@ protected List getFieldOrder() { } } + /** - * @see https://github.com/GStreamer/gstreamer/blob/master/gst/gstelement.h - */ + * GstElementClass: + * @parent_class: the parent class structure + * @metadata: metadata for elements of this class + * @elementfactory: the #GstElementFactory that creates these elements + * @padtemplates: a #GList of #GstPadTemplate + * @numpadtemplates: the number of padtemplates + * @pad_templ_cookie: changed whenever the padtemplates change + * @request_new_pad: called when a new pad is requested + * @release_pad: called when a request pad is to be released + * @get_state: get the state of the element + * @set_state: set a new state on the element + * @change_state: called by @set_state to perform an incremental state change + * @set_bus: set a #GstBus on the element + * @provide_clock: gets the #GstClock provided by the element + * @set_clock: set the #GstClock on the element + * @send_event: send a #GstEvent to the element + * @query: perform a #GstQuery on the element + * @state_changed: called immediately after a new state was set. + * @post_message: called when a message is posted on the element. Chain up to + * the parent class' handler to have it posted on the bus. + * @set_context: set a #GstContext on the element + * + * GStreamer element class. Override the vmethods to implement the element + * functionality. + */ public static final class GstElementClass extends com.sun.jna.Structure { // // Callbacks for this class // + public static interface PadAdded extends GstCallback { + public void callback(Element element, Pad pad); + } + public static interface PadRemoved extends GstCallback { + public void callback(Element element, Pad pad); + } + public static interface NoMorePads extends GstCallback { + public void callback(Element element); + } public static interface RequestNewPad extends GstCallback { - public Pad callback(Element element, /* PadTemplate */ Pointer templ, String name); + public Pad callback(Element element, /* PadTemplate */ Pointer templ, + String name, Caps caps); } public static interface ReleasePad extends GstCallback { public void callback(Element element, Pad pad); } public static interface GetState extends GstCallback { - public StateChangeReturn callback(Element element, Pointer p_state, - Pointer p_pending, long timeout); + public StateChangeReturn callback(Element element, Pointer /* GstState */ state, + Pointer /* GstState */ pending, long timeout); } public static interface SetState extends GstCallback { public StateChangeReturn callback(Element element, State state); @@ -188,46 +248,70 @@ public static interface ChangeState extends GstCallback { public static interface StateChanged extends GstCallback { public StateChangeReturn callback(Element element, State oldState, State newState, State pending); } + public static interface SetBus extends GstCallback { + public void callback(Element element, Bus bus); + } + public static interface ProvideClock extends GstCallback { + public void callback(Element element); + } + public static interface SetClock extends GstCallback { + public void callback(Element element, Clock clock); + } + public static interface SendEvent extends GstCallback { + boolean callback(Element element, Event event); + } public static interface QueryNotify extends GstCallback { boolean callback(Element element, Query query); } + public static interface PostMessage extends GstCallback { + boolean callback(Element element, Message message); + } // // Actual data members // public GstObjectClass parent_class; + + /*< public >*/ /* the element metadata */ public volatile Pointer metadata; + /* factory that the element was created from */ public volatile ElementFactory elementfactory; + /* templates for our pads */ - public volatile Pointer padtemplates; + public volatile Pointer /* GList */ padtemplates; public volatile int numpadtemplates; public volatile int pad_templ_cookie; + /*< private >*/ /* signal callbacks */ - public volatile Pointer pad_added; - public volatile Pointer pad_removed; - public volatile Pointer no_more_pads; + public PadAdded pad_added; + public PadRemoved pad_removed; + public NoMorePads no_more_pads; + /* request/release pads */ public RequestNewPad request_new_pad; public ReleasePad release_pad; + /* state changes */ public GetState get_state; public SetState set_state; public ChangeState change_state; public StateChanged state_changed; + /* bus */ - public volatile Pointer set_bus; + public volatile SetBus set_bus; + /* set/get clocks */ - public volatile Pointer provide_clock; - public volatile Pointer set_clock; + public volatile ProvideClock provide_clock; + public volatile SetClock set_clock; /* query functions */ - public volatile Pointer send_event; + public volatile SendEvent send_event; public volatile QueryNotify query; - public volatile Pointer post_message; + public volatile PostMessage post_message; public volatile Pointer set_context; diff --git a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java index 158bf7a8..80cada23 100644 --- a/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java +++ b/test/org/freedesktop/gstreamer/lowlevel/LowLevelStructureTest.java @@ -159,8 +159,6 @@ private static void initStructList() { structs.add(GstControlSourceAPI.GstControlSourceStruct.class); structs.add(GstControlSourceAPI.GstControlSourceClass.class); - - structs.add(GstElementAPI.GstElementDetails.class); structs.add(GstElementAPI.GstElementStruct.class); structs.add(GstElementAPI.GstElementClass.class); From f54fb78613ee9cf2f19017d3866a00d9369b2396 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Wed, 22 Aug 2018 16:34:30 +0200 Subject: [PATCH 12/17] add GstElementAPI to readme --- src/org/freedesktop/gstreamer/lowlevel/README | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 26a1c92d..e00027f9 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -12,3 +12,4 @@ structures in the following classes were aligned to 1.8: - GstBufferPoolAPI - GstControlSourceAPI - GstControllerAPI - removed +- GstElementAPI From 44fbe673764505a7d27dcbffcdc7d03ec7a5732c Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Wed, 22 Aug 2018 16:35:10 +0200 Subject: [PATCH 13/17] add missing fields to EventStruct --- .../gstreamer/lowlevel/GstEventAPI.java | 24 +++++++++++++++---- src/org/freedesktop/gstreamer/lowlevel/README | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstEventAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstEventAPI.java index 205645f1..518d3a2f 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstEventAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstEventAPI.java @@ -36,9 +36,11 @@ import com.sun.jna.Pointer; import com.sun.jna.ptr.PointerByReference; +import org.freedesktop.gstreamer.lowlevel.GstMiniObjectAPI.MiniObjectStruct; /** - * GstEvent functions + * GstEvent functions and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstevent.h?h=1.8 */ public interface GstEventAPI extends com.sun.jna.Library { GstEventAPI GSTEVENT_API = GstNative.load(GstEventAPI.class); @@ -122,10 +124,23 @@ void gst_event_parse_seek(Event event, double[] rate, Format[] format, @CallerOwnsReturn Event gst_event_new_stream_start(final String stream_id); Pointer ptr_gst_event_new_stream_start(final String stream_id); - + /** + * GstEvent: + * @mini_object: the parent structure + * @type: the #GstEventType of the event + * @timestamp: the timestamp of the event + * @seqnum: the sequence number of the event + * + * A #GstEvent. + */ public static final class EventStruct extends com.sun.jna.Structure { - public volatile GstMiniObjectAPI.MiniObjectStruct mini_object; + public volatile MiniObjectStruct mini_object; + + /*< public >*/ /* with COW */ public volatile int type; + public volatile long timestamp; + public volatile int seqnum; + public EventStruct(Pointer ptr) { useMemory(ptr); } @@ -133,7 +148,8 @@ public EventStruct(Pointer ptr) { @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "mini_object", "type" + "mini_object", + "type", "timestamp", "seqnum" }); } } diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index e00027f9..1f5c2ef9 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -13,3 +13,4 @@ structures in the following classes were aligned to 1.8: - GstControlSourceAPI - GstControllerAPI - removed - GstElementAPI +- GstEvent From 348fd18f96f1f49254e5345de989bcb027d7bf4d Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Wed, 22 Aug 2018 16:35:48 +0200 Subject: [PATCH 14/17] align GstObject --- .../gstreamer/lowlevel/GstObjectAPI.java | 76 +++++++++++++------ src/org/freedesktop/gstreamer/lowlevel/README | 1 + 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstObjectAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstObjectAPI.java index 8b83f8fc..59846a6b 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstObjectAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstObjectAPI.java @@ -19,6 +19,7 @@ package org.freedesktop.gstreamer.lowlevel; +import com.sun.jna.Callback; import org.freedesktop.gstreamer.GstObject; import org.freedesktop.gstreamer.lowlevel.annotations.CallerOwnsReturn; import org.freedesktop.gstreamer.lowlevel.annotations.FreeReturnValue; @@ -27,12 +28,17 @@ import com.sun.jna.Pointer; import java.util.Arrays; import java.util.List; +import org.freedesktop.gstreamer.Caps; +import org.freedesktop.gstreamer.elements.BaseSrc; +import org.freedesktop.gstreamer.lowlevel.GlibAPI.GList; /** - * GstObject functions + * GstObject method and structures + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstobject.h?h=1.8 */ public interface GstObjectAPI extends com.sun.jna.Library { - GstObjectAPI GSTOBJECT_API = GstNative.load(GstObjectAPI.class); + + GstObjectAPI GSTOBJECT_API = GstNative.load(GstObjectAPI.class); GType gst_object_get_type(); void gst_object_ref(GstObject ptr); @@ -53,47 +59,71 @@ public interface GstObjectAPI extends com.sun.jna.Library { Pointer gst_implements_interface_cast(GstObject obj, NativeLong gtype); boolean gst_implements_interface_check(GstObject from, NativeLong type); + /** + * GstObject: + * @lock: object LOCK + * @name: The name of the object + * @parent: this object's parent, weak ref + * @flags: flags for this object + * + * GStreamer base object class. + */ public static final class GstObjectStruct extends com.sun.jna.Structure { public GObjectAPI.GObjectStruct object; - public volatile int refcount; - public volatile Pointer lock; - public volatile String name; - public volatile String name_prefix; - public volatile Pointer parent; + + /*< public >*/ /* with LOCK */ + public volatile Pointer /* GMutex */ lock; /* object LOCK */ + public volatile String name; /* object name */ + public volatile Pointer /* GstObject */ parent; /* this object's parent, weak ref */ public volatile int flags; + + /*< private >*/ + public volatile GList control_bindings; + public volatile long control_rate; + public volatile long last_sync; + public volatile Pointer _gst_reserved; @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "object", "refcount", "lock", - "name", "name_prefix", "parent", - "flags", "_gst_reserved" + "object", + "lock", "name", "parent", "flags", + "control_bindings", "control_rate", "last_sync", + "_gst_reserved" }); } } + // -------------- Callbacks ----------------- + public static interface DeepNotify extends Callback { + public void callback(GstObject object, GstObject orig, GObjectAPI.GParamSpec pspec); + } + + /** + * GstObjectClass: + * @parent_class: parent + * @path_string_separator: separator used by gst_object_get_path_string() + * @deep_notify: default signal handler + * + * GStreamer base object class. + */ public static final class GstObjectClass extends com.sun.jna.Structure { public GObjectAPI.GObjectClass parent_class; - public volatile Pointer path_string_separator; - public volatile Pointer signal_object; - public volatile Pointer lock; - // These are really Callbacks, but we don't need them yet - public volatile Pointer parent_set; - public volatile Pointer parent_unset; - public volatile Pointer object_saved; - public volatile Pointer deep_notify; - public volatile Pointer save_thyself; - public volatile Pointer restore_thyself; + + public volatile String path_string_separator; + + /* signals */ + public DeepNotify deep_notify; + public volatile Pointer[] _gst_reserved = new Pointer[GstAPI.GST_PADDING]; @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ "parent_class", "path_string_separator", - "signal_object", "lock", "parent_set", - "parent_unset", "object_saved", "deep_notify", - "save_thyself", "restore_thyself", "_gst_reserved" + "deep_notify", + "_gst_reserved" }); } } diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 1f5c2ef9..5f884528 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -14,3 +14,4 @@ structures in the following classes were aligned to 1.8: - GstControllerAPI - removed - GstElementAPI - GstEvent +- GstObject From 703b68b6d3a7347f30028449ce4c1e386a14910f Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 16 Oct 2018 11:20:44 +0200 Subject: [PATCH 15/17] align GstPadProbeInfo --- .../gstreamer/lowlevel/GstPadProbeInfo.java | 34 ++++++++++++------- src/org/freedesktop/gstreamer/lowlevel/README | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstPadProbeInfo.java b/src/org/freedesktop/gstreamer/lowlevel/GstPadProbeInfo.java index 8a1e7d12..95a96e67 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstPadProbeInfo.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstPadProbeInfo.java @@ -21,21 +21,31 @@ import java.util.List; import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; import com.sun.jna.Structure; +import static org.freedesktop.gstreamer.lowlevel.GstAPI.GST_PADDING; +/** + * GstPadProbeInfo structure + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstpad.h?h=1.8 + */ public class GstPadProbeInfo extends Structure { - public volatile int padProbeType; // GstPadProbeInfo enum constants - public volatile NativeLong id; // id of the probe - public volatile long offset;// offset of pull probe, this field is valid when type contains GST_PAD_PROBE_TYPE_PULL - public volatile int size; // size of pull probe, this field is valid when type contains GST_PAD_PROBE_TYPE_PULL - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { - "padProbeType", "id", "offset", "size" - }); - } - + + public volatile int padProbeType; // GstPadProbeInfo enum constants + public volatile NativeLong id; // id of the probe + public volatile Pointer data; // (allow-none): type specific data, check the @type field to know the datatype. This field can be %NULL. + public volatile long offset; // offset of pull probe, this field is valid when type contains GST_PAD_PROBE_TYPE_PULL + public volatile int size; // size of pull probe, this field is valid when type contains GST_PAD_PROBE_TYPE_PULL + /*< private >*/ + public volatile Pointer[] _gst_reserved = new Pointer[GST_PADDING]; + + @Override + protected List getFieldOrder() { + return Arrays.asList(new String[] { + "padProbeType", "id", "data", "offset", "size", + "_gst_reserved" + }); + } } diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 5f884528..296c5821 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -15,3 +15,4 @@ structures in the following classes were aligned to 1.8: - GstElementAPI - GstEvent - GstObject +- GstPadProbeInfo \ No newline at end of file From ad23ab73b8ba591d5900d4891175fdb059c2f2a5 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 16 Oct 2018 11:30:14 +0200 Subject: [PATCH 16/17] align GstQueryAPI --- .../freedesktop/gstreamer/lowlevel/GstQueryAPI.java | 11 ++++++----- src/org/freedesktop/gstreamer/lowlevel/README | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstQueryAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstQueryAPI.java index 88eee00d..99a298ec 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstQueryAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstQueryAPI.java @@ -35,7 +35,8 @@ import com.sun.jna.Pointer; /** - * GstQuery functions + * GstQueryAPI functions and structure + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstquery.h?h=1.8 */ public interface GstQueryAPI extends com.sun.jna.Library { GstQueryAPI GSTQUERY_API = GstNative.load(GstQueryAPI.class); @@ -106,9 +107,10 @@ void gst_query_parse_seeking(Query query, Format[] format, public static final class QueryStruct extends com.sun.jna.Structure { public volatile GstMiniObjectAPI.MiniObjectStruct mini_object; + + /*< public > *//* with COW */ public volatile int type; - public volatile Pointer structure; - public volatile Pointer _gst_reserved; + public QueryStruct(Pointer ptr) { useMemory(ptr); } @@ -116,8 +118,7 @@ public QueryStruct(Pointer ptr) { @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "mini_object", "type", "structure", - "_gst_reserved" + "mini_object", "type" }); } } diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 296c5821..18135fc2 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -15,4 +15,5 @@ structures in the following classes were aligned to 1.8: - GstElementAPI - GstEvent - GstObject -- GstPadProbeInfo \ No newline at end of file +- GstPadProbeInfo +- GstQueryAPI \ No newline at end of file From 47c0fc3574e1b6bb070f7fcfc27ca6791d3a7090 Mon Sep 17 00:00:00 2001 From: "i.n.g.o" Date: Tue, 16 Oct 2018 11:44:46 +0200 Subject: [PATCH 17/17] align GstSampleAPI --- .../gstreamer/lowlevel/GstSampleAPI.java | 17 ++++++++++------- src/org/freedesktop/gstreamer/lowlevel/README | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/org/freedesktop/gstreamer/lowlevel/GstSampleAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GstSampleAPI.java index 50b55d85..d5ca77ac 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GstSampleAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GstSampleAPI.java @@ -29,20 +29,23 @@ import java.util.List; import org.freedesktop.gstreamer.Buffer; import org.freedesktop.gstreamer.Caps; -import org.freedesktop.gstreamer.lowlevel.annotations.CallerOwnsReturn; +import org.freedesktop.gstreamer.lowlevel.GstAPI.GstSegmentStruct; /** - * GstSample functions + * GstSampleAPI functions and structure + * @see https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstsample.c?h=1.8 */ public interface GstSampleAPI extends com.sun.jna.Library { GstSampleAPI GSTMESSAGE_API = GstNative.load(GstSampleAPI.class); public static final class SampleStruct extends com.sun.jna.Structure { public volatile MiniObjectStruct mini_object; - public volatile Pointer buffer; // to Buffer - public volatile Pointer caps; // to Caps - public volatile Pointer segment; // to Segment - public volatile Pointer info; // to Strucutre + + public volatile Pointer /* GstBuffer* */buffer; // to Buffer + public volatile Pointer /* GstCaps* */ caps; // to Caps + public volatile GstSegmentStruct segment; // Segment + public volatile Pointer /* GstStructure* */ info; // to Strucutre + public volatile Pointer /* GstBufferList* */ buffer_list; // to buffer_list /** * Creates a new instance of MessageStruct @@ -56,7 +59,7 @@ public SampleStruct(Pointer ptr) { @Override protected List getFieldOrder() { return Arrays.asList(new String[]{ - "mini_object", "buffer", "caps", "segment", "info" + "mini_object", "buffer", "caps", "segment", "info", "buffer_list" }); } } diff --git a/src/org/freedesktop/gstreamer/lowlevel/README b/src/org/freedesktop/gstreamer/lowlevel/README index 18135fc2..00d1804f 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/README +++ b/src/org/freedesktop/gstreamer/lowlevel/README @@ -16,4 +16,5 @@ structures in the following classes were aligned to 1.8: - GstEvent - GstObject - GstPadProbeInfo -- GstQueryAPI \ No newline at end of file +- GstQueryAPI +- GstSampleAPI \ No newline at end of file