Skip to content

Commit 542aaaa

Browse files
Update and document org.freedesktop.gstreamer.event package.
1 parent 3041573 commit 542aaaa

22 files changed

+452
-456
lines changed
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2019 Neil C Smith
23
* Copyright (c) 2008 Wayne Meissner
34
* Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
45
* 2000 Wim Taymans <[email protected]>
@@ -18,92 +19,91 @@
1819
* You should have received a copy of the GNU Lesser General Public License
1920
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
2021
*/
21-
2222
package org.freedesktop.gstreamer.event;
2323

2424
import org.freedesktop.gstreamer.Format;
2525

26-
import org.freedesktop.gstreamer.lowlevel.GstEventAPI;
26+
import static org.freedesktop.gstreamer.lowlevel.GstEventAPI.GSTEVENT_API;
2727

2828
/**
29-
* Notification of new latency adjustment.
29+
* A buffersize event. The event is sent downstream and notifies elements that
30+
* they should provide a buffer of the specified dimensions.
3031
* <p>
31-
* The event is sent upstream from the sinks and
32-
* notifies elements that they should add an additional latency to the
33-
* timestamps before synchronising against the clock.
32+
* See upstream documentation at
33+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-buffer-size"
34+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-buffer-size</a>
3435
* <p>
35-
* The latency is mostly used in live sinks and is always expressed in
36-
* the time format.
36+
* When the async flag is set, a thread boundary is preferred.
3737
*/
3838
public class BufferSizeEvent extends Event {
3939

40-
private static final GstEventAPI gst = GstEventAPI.GSTEVENT_API;
41-
4240
/**
4341
* This constructor is for internal use only.
42+
*
4443
* @param init initialization data.
4544
*/
46-
public BufferSizeEvent(Initializer init) {
45+
BufferSizeEvent(Initializer init) {
4746
super(init);
4847
}
49-
48+
5049
/**
51-
* Creates a new buffersize event.
52-
* <p> The event is sent downstream and notifies elements that they should
50+
* Creates a new buffersize event.
51+
* <p>
52+
* The event is sent downstream and notifies elements that they should
5353
* provide a buffer of the specified dimensions.
54+
* <p>
55+
* When the <tt>async</tt> flag is set, a thread boundary is preferred.
5456
*
55-
* <p> When the <tt>async</tt> flag is set, a thread boundary is preferred.
56-
*
5757
* @param format buffer format
5858
* @param minsize minimum buffer size
5959
* @param maxsize maximum buffer size
60-
* @param async thread behavior
60+
* @param async thread behaviour
6161
*/
6262
public BufferSizeEvent(Format format, long minsize, long maxsize, boolean async) {
63-
super(initializer(gst.ptr_gst_event_new_buffer_size(format, minsize, maxsize, async)));
63+
super(initializer(GSTEVENT_API.ptr_gst_event_new_buffer_size(format, minsize, maxsize, async)));
6464
}
65-
65+
6666
/**
6767
* Gets the format of the buffersize event.
68-
*
68+
*
6969
* @return the format.
7070
*/
7171
public Format getFormat() {
7272
Format[] format = new Format[1];
73-
gst.gst_event_parse_buffer_size(this, format, null, null, null);
73+
GSTEVENT_API.gst_event_parse_buffer_size(this, format, null, null, null);
7474
return format[0];
7575
}
76-
76+
7777
/**
7878
* Gets the minimum buffer size.
79-
*
79+
*
8080
* @return the minimum buffer size.
8181
*/
8282
public long getMinimumSize() {
83-
long[] size = { 0 };
84-
gst.gst_event_parse_buffer_size(this, null, size, null, null);
83+
long[] size = {0};
84+
GSTEVENT_API.gst_event_parse_buffer_size(this, null, size, null, null);
8585
return size[0];
8686
}
87-
87+
8888
/**
8989
* Gets the maximum buffer size.
90-
*
90+
*
9191
* @return the maximum buffer size.
9292
*/
9393
public long getMaximumSize() {
94-
long[] size = { 0 };
95-
gst.gst_event_parse_buffer_size(this, null, null, size, null);
94+
long[] size = {0};
95+
GSTEVENT_API.gst_event_parse_buffer_size(this, null, null, size, null);
9696
return size[0];
9797
}
98-
98+
9999
/**
100100
* Gets the preferred thread behaviour.
101-
*
101+
*
102102
* @return <tt>true</tt> if a thread boundary is preferred.
103103
*/
104104
public boolean isAsync() {
105-
boolean[] async = { false };
106-
gst.gst_event_parse_buffer_size(this, null, null, null, async);
105+
boolean[] async = {false};
106+
GSTEVENT_API.gst_event_parse_buffer_size(this, null, null, null, async);
107107
return async[0];
108108
}
109109
}
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2019 Neil C Smith
23
* Copyright (c) 2016 Christophe Lafolet
34
*
45
* This file is part of gstreamer-java.
@@ -15,30 +16,36 @@
1516
* You should have received a copy of the GNU Lesser General Public License
1617
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
1718
*/
18-
1919
package org.freedesktop.gstreamer.event;
2020

21-
2221
import org.freedesktop.gstreamer.Caps;
23-
import org.freedesktop.gstreamer.lowlevel.GstEventAPI;
24-
22+
import static org.freedesktop.gstreamer.lowlevel.GstEventAPI.GSTEVENT_API;
2523

24+
/**
25+
* A CAPS event for {@link Caps}. The caps event can only travel downstream
26+
* synchronized with the buffer flow and contains the format of the buffers that
27+
* will follow after the event.
28+
* <p>
29+
* See upstream documentation at
30+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-caps"
31+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-caps</a>
32+
* <p>
33+
*/
2634
public class CapsEvent extends Event {
27-
28-
private static final GstEventAPI gst = GstEventAPI.GSTEVENT_API;
2935

3036
/**
3137
* This constructor is for internal use only.
38+
*
3239
* @param init initialization data.
3340
*/
34-
public CapsEvent(Initializer init) {
41+
CapsEvent(Initializer init) {
3542
super(init);
3643
}
3744

3845
/**
3946
* Creates a new caps event.
4047
*/
4148
public CapsEvent(final Caps caps) {
42-
super(initializer(gst.ptr_gst_event_new_caps(caps)));
49+
super(initializer(GSTEVENT_API.ptr_gst_event_new_caps(caps)));
4350
}
44-
}
51+
}
Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2019 Neil C Smith
23
* Copyright (c) 2008 Wayne Meissner
34
* Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
45
* 2000 Wim Taymans <[email protected]>
@@ -18,42 +19,47 @@
1819
* You should have received a copy of the GNU Lesser General Public License
1920
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
2021
*/
21-
2222
package org.freedesktop.gstreamer.event;
2323

24-
import org.freedesktop.gstreamer.lowlevel.GstEventAPI;
24+
import org.freedesktop.gstreamer.Bus;
25+
import org.freedesktop.gstreamer.FlowReturn;
26+
import static org.freedesktop.gstreamer.lowlevel.GstEventAPI.GSTEVENT_API;
2527

2628
/**
27-
* End-Of-Stream. No more data is to be expected to follow without a {@link NewSegmentEvent}.
29+
* End-Of-Stream event.
30+
* <p>
31+
* See upstream documentation at
32+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-eos"
33+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#gst-event-new-eos</a>
2834
* <p>
29-
* The eos event can only travel downstream
30-
* synchronized with the buffer flow. Elements that receive the EOS
31-
* event on a pad can return {@link org.gstreamer.FlowReturn#UNEXPECTED} when data after
32-
* the EOS event arrives.
35+
* The eos event can only travel downstream synchronized with the buffer flow.
36+
* Elements that receive the EOS event on a pad can return
37+
* {@link FlowReturn#EOS} when data after the EOS event arrives.
3338
* <p>
34-
* The EOS event will travel down to the sink elements in the pipeline
35-
* which will then post the {@link org.gstreamer.Bus.EOS} message on the bus after they have
39+
* The EOS event will travel down to the sink elements in the pipeline which
40+
* will then post the {@link Bus.EOS } message on the bus after they have
3641
* finished playing any buffered data.
3742
* <p>
38-
* When all sinks have posted an EOS message, an EOS message is
39-
* forwarded to the application.
43+
* When all sinks have posted an EOS message, an EOS message is forwarded to the
44+
* application.
45+
* <p>
46+
* The EOS event itself will not cause any state transitions of the pipeline.
4047
*/
4148
public class EOSEvent extends Event {
4249

43-
private static final GstEventAPI gst = GstEventAPI.GSTEVENT_API;
44-
4550
/**
4651
* This constructor is for internal use only.
52+
*
4753
* @param init initialization data.
4854
*/
49-
public EOSEvent(Initializer init) {
55+
EOSEvent(Initializer init) {
5056
super(init);
5157
}
52-
58+
5359
/**
54-
* Creates a new EOS event.
60+
* Creates a new EOS event.
5561
*/
5662
public EOSEvent() {
57-
super(initializer(gst.ptr_gst_event_new_eos()));
63+
super(initializer(GSTEVENT_API.ptr_gst_event_new_eos()));
5864
}
59-
}
65+
}

src/org/freedesktop/gstreamer/event/EventType.java

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919

2020
package org.freedesktop.gstreamer.event;
2121

22-
import org.freedesktop.gstreamer.lowlevel.EnumMapper;
22+
import org.freedesktop.gstreamer.Gst;
23+
import org.freedesktop.gstreamer.glib.NativeEnum;
2324
import org.freedesktop.gstreamer.lowlevel.annotations.DefaultEnumValue;
2425

25-
import static org.freedesktop.gstreamer.lowlevel.GstEventAPI.GSTEVENT_API;
26-
import org.freedesktop.gstreamer.glib.NativeFlags;
27-
2826
/**
2927
* The standard event types that can be sent in a pipeline.
3028
* <p>
29+
* See upstream documentation at
30+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#GstEventType"
31+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstEvent.html#GstEventType</a>
32+
* <p>
3133
* The custom event types can be used for private messages between elements
3234
* that can't be expressed using normal GStreamer buffer passing semantics.
3335
* <p>
3436
* Custom events carry an arbitrary {@link Structure}. Specific custom events
3537
* are distinguished by the name of the structure.
3638
*/
37-
public enum EventType implements NativeFlags {
39+
public enum EventType implements NativeEnum<EventType> {
3840
/** Unknown event */
3941
@DefaultEnumValue UNKNOWN(0, 0),
4042

@@ -67,6 +69,11 @@ public enum EventType implements NativeFlags {
6769
* running-time and stream-time.
6870
*/
6971
SEGMENT(70, Flags.DOWNSTREAM | Flags.SERIALIZED | Flags.STICKY),
72+
/**
73+
* A new #GstStreamCollection is available (Since 1.10)
74+
*/
75+
@Gst.Since(minor = 10)
76+
STREAM_COLLECTION(75, Flags.DOWNSTREAM | Flags.SERIALIZED | Flags.STICKY | Flags.STICKY_MULTI),
7077
/**
7178
* A new set of metadata tags has been found in the stream.
7279
*/
@@ -80,6 +87,13 @@ public enum EventType implements NativeFlags {
8087
* should be emitted in sync with rendering.
8188
*/
8289
SINK_MESSAGE(100, Flags.DOWNSTREAM | Flags.SERIALIZED | Flags.STICKY | Flags.STICKY_MULTI),
90+
/**
91+
* Indicates that there is no more data for the stream group ID in the
92+
* message. Sent before EOS in some instances and should be handled mostly
93+
* the same. (Since 1.10)
94+
*/
95+
@Gst.Since(minor = 10)
96+
STREAM_GROUP_DONE(105, Flags.DOWNSTREAM | Flags.SERIALIZED | Flags.STICKY),
8397
/**
8498
* End-Of-Stream. No more data is to be expected to follow without a SEGMENT
8599
* event.
@@ -139,7 +153,11 @@ public enum EventType implements NativeFlags {
139153
* A request for a new playback position based on TOC entry's UID.
140154
*/
141155
TOC_SELECT(250, Flags.UPSTREAM),
142-
156+
/**
157+
* A request to select one or more streams (Since 1.10)
158+
*/
159+
@Gst.Since(minor = 10)
160+
SELECT_STREAMS(260, Flags.UPSTREAM),
143161
/* custom events start here */
144162
/**
145163
* Upstream custom event
@@ -167,25 +185,19 @@ public enum EventType implements NativeFlags {
167185
CUSTOM_BOTH_OOB(320, Flags.BOTH)
168186
;
169187

170-
EventType(int num, int flags) {
188+
private static final int SHIFT = 8;
189+
190+
private final int value;
191+
192+
private EventType(int num, int flags) {
171193
this.value = (num << SHIFT) | flags;
172194
}
173195

174-
/** Gets the native value of this enum */
196+
@Override
175197
public int intValue() {
176198
return value;
177199
}
178-
/** Gets a human-readable name for this value */
179-
public String getName() {
180-
return GSTEVENT_API.gst_event_type_get_name(this);
181-
}
182200

183-
/** Gets the Enum for a native value */
184-
public static final EventType valueOf(int type) {
185-
return EnumMapper.getInstance().valueOf(type, EventType.class);
186-
}
187-
188-
private static final int SHIFT = 8;
189201
private static final class Flags {
190202
public static final int UPSTREAM = 1 << 0;
191203
public static final int DOWNSTREAM = 1 << 1;
@@ -194,5 +206,4 @@ private static final class Flags {
194206
public static final int STICKY_MULTI = 1 << 4;
195207
public static final int BOTH = UPSTREAM | DOWNSTREAM;
196208
}
197-
private final int value;
198209
}

0 commit comments

Comments
 (0)