Skip to content

Commit 69664cb

Browse files
Update and document org.freedesktop.gstreamer.message package.
1 parent 542aaaa commit 69664cb

14 files changed

+178
-134
lines changed

src/org/freedesktop/gstreamer/Bus.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.sun.jna.Native;
3636
import com.sun.jna.Pointer;
3737
import com.sun.jna.ptr.PointerByReference;
38+
import java.util.Locale;
3839

3940
import org.freedesktop.gstreamer.lowlevel.GstAPI.GErrorStruct;
4041
import org.freedesktop.gstreamer.lowlevel.GstBusAPI;
@@ -755,7 +756,7 @@ public void run() {
755756
* @param callback The callback to call when the signal is emitted.
756757
*/
757758
private <T> void connect(Class<T> listenerClass, T listener, BusCallback callback) {
758-
final String signal = listenerClass.getSimpleName().toLowerCase().replaceAll("_", "-");
759+
final String signal = listenerClass.getSimpleName().toLowerCase(Locale.ROOT).replace('_', '-');
759760
connect(signal, listenerClass, listener, callback);
760761
}
761762

@@ -777,15 +778,17 @@ public synchronized <T> void connect(String signal, Class<T> listenerClass, T li
777778
super.connect(signal, listenerClass, listener, callback);
778779
return;
779780
}
780-
MessageType type = MessageType.forName(signal);
781-
if (type == MessageType.UNKNOWN && "message".equals(signal)) {
781+
MessageType type;
782+
if ("message".equals(signal)) {
782783
type = MessageType.ANY;
783-
}
784-
if (type == MessageType.UNKNOWN) {
785-
throw new IllegalArgumentException("Illegal signal: " + signal);
784+
} else {
785+
//@TODO refactor to stop unnecessary String operations
786+
type = MessageType.valueOf(signal.toUpperCase(Locale.ROOT).replace('-', '_'));
786787
}
787788
final Map<Class<?>, Map<Object, MessageProxy>> signals = getListenerMap();
788-
Map<Object, MessageProxy> m = signals.get(type);
789+
// @TODO this was using type so doubtful ever worked
790+
// these maps needs relooking at!
791+
Map<Object, MessageProxy> m = signals.get(listenerClass);
789792
if (m == null) {
790793
m = new HashMap<Object, MessageProxy>();
791794
signals.put(listenerClass, m);

src/org/freedesktop/gstreamer/message/BufferingMessage.java

Lines changed: 10 additions & 3 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) 2004 Wim Taymans <[email protected]>
45
*
@@ -26,8 +27,13 @@
2627
* This message can be posted by an element that
2728
* needs to buffer data before it can continue processing. {@code percent} should be a
2829
* value between 0 and 100. A value of 100 means that the buffering completed.
29-
*
30-
* When <tt>percent}</tt> is &lt; 100 the application should PAUSE a PLAYING pipeline. When
30+
* <p>
31+
* See upstream documentation
32+
* at
33+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-buffering"
34+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-buffering</a>
35+
* <p>
36+
* When <tt>percent</tt> is &lt; 100 the application should PAUSE a PLAYING pipeline. When
3137
* <tt>percent</tt> is 100, the application can set the pipeline (back) to PLAYING.
3238
* The application must be prepared to receive BUFFERING messages in the
3339
* PREROLLING state and may only set the pipeline to PLAYING after receiving a
@@ -40,13 +46,14 @@ public class BufferingMessage extends Message {
4046
* Creates a new Buffering message.
4147
* @param init internal initialization data.
4248
*/
43-
public BufferingMessage(Initializer init) {
49+
BufferingMessage(Initializer init) {
4450
super(init);
4551
}
4652

4753
/**
4854
* Creates a new Buffering message.
4955
* @param src The object originating the message.
56+
* @param percent The buffering percent
5057
*/
5158
public BufferingMessage(GstObject src, int percent) {
5259
this(initializer(GSTMESSAGE_API.ptr_gst_message_new_buffering(src, percent)));

src/org/freedesktop/gstreamer/message/DurationChangedMessage.java

Lines changed: 16 additions & 5 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) 2004 Wim Taymans <[email protected]>
45
*
@@ -16,27 +17,37 @@
1617
* You should have received a copy of the GNU Lesser General Public License
1718
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
1819
*/
19-
2020
package org.freedesktop.gstreamer.message;
2121

2222
import org.freedesktop.gstreamer.GstObject;
2323
import static org.freedesktop.gstreamer.lowlevel.GstMessageAPI.GSTMESSAGE_API;
2424

2525
/**
26-
* The duration of a pipeline has changed. The application can get the new
27-
* duration with a duration query.
26+
* A duration changed message.
27+
* <p>
28+
* See upstream documentation at
29+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-duration-changed"
30+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-duration-changed</a>
31+
* <p>
32+
* This message is posted by elements that know the duration of a stream when
33+
* the duration changes. This message is received by bins and is used to
34+
* calculate the total duration of a pipeline.
2835
*/
2936
public class DurationChangedMessage extends Message {
37+
3038
/**
3139
* Creates a new DurationChanged message.
40+
*
3241
* @param init internal initialization data.
3342
*/
34-
public DurationChangedMessage(Initializer init) {
43+
DurationChangedMessage(Initializer init) {
3544
super(init);
3645
}
37-
46+
3847
/**
3948
* Creates a new DurationChanged Message
49+
*
50+
* @param src The object originating the message.
4051
*/
4152
public DurationChangedMessage(GstObject src) {
4253
this(initializer(GSTMESSAGE_API.ptr_gst_message_new_duration_changed(src)));

src/org/freedesktop/gstreamer/message/EOSMessage.java

Lines changed: 14 additions & 5 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) 2004 Wim Taymans <[email protected]>
45
*
@@ -16,29 +17,37 @@
1617
* You should have received a copy of the GNU Lesser General Public License
1718
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
1819
*/
19-
2020
package org.freedesktop.gstreamer.message;
2121

22+
import org.freedesktop.gstreamer.Bin;
2223
import org.freedesktop.gstreamer.GstObject;
2324
import static org.freedesktop.gstreamer.lowlevel.GstMessageAPI.GSTMESSAGE_API;
2425

2526
/**
26-
* This message is generated and posted in the sink elements of a {@link org.freedesktop.gstreamer.Bin}.
27-
* The bin will only forward the EOS message to the application if all sinks
27+
* An End-of-Stream Message.
28+
* <p>
29+
* See upstream documentation at
30+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-eos"
31+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-eos</a>
32+
* <p>
33+
* This message is generated and posted in the sink elements of a {@link Bin}.
34+
* The bin will only forward the EOS message to the application if all sinks
2835
* have posted an EOS message.
2936
*/
3037
public class EOSMessage extends Message {
3138

3239
/**
3340
* Creates a new eos message.
41+
*
3442
* @param init internal initialization data.
3543
*/
36-
public EOSMessage(Initializer init) {
44+
EOSMessage(Initializer init) {
3745
super(init);
3846
}
39-
47+
4048
/**
4149
* Creates a new eos message.
50+
*
4251
* @param src The object originating the message.
4352
*/
4453
public EOSMessage(GstObject src) {

src/org/freedesktop/gstreamer/message/ErrorMessage.java

Lines changed: 6 additions & 1 deletion
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) 2004 Wim Taymans <[email protected]>
45
*
@@ -25,6 +26,10 @@
2526
/**
2627
* This message is posted by element when a fatal event occurs.
2728
* <p>
29+
* See upstream documentation at
30+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-error"
31+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-error</a>
32+
* <p>
2833
* The pipeline will probably (partially) stop. The application
2934
* receiving this message should stop the pipeline.
3035
*/
@@ -35,7 +40,7 @@ public class ErrorMessage extends GErrorMessage {
3540
*
3641
* @param init internal initialization data.
3742
*/
38-
public ErrorMessage(Initializer init) {
43+
ErrorMessage(Initializer init) {
3944
super(init);
4045
}
4146

src/org/freedesktop/gstreamer/message/GErrorMessage.java

Lines changed: 4 additions & 2 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
*
45
* This file is part of gstreamer-java.
@@ -24,9 +25,9 @@
2425
import static org.freedesktop.gstreamer.lowlevel.GlibAPI.GLIB_API;
2526

2627
/**
27-
* Base class for ERROR, WARNING and INFO messages.
28+
* Package private base class for ERROR, WARNING and INFO messages.
2829
*/
29-
abstract public class GErrorMessage extends Message {
30+
abstract class GErrorMessage extends Message {
3031

3132
/**
3233
* Creates a new GError message.
@@ -35,6 +36,7 @@ abstract public class GErrorMessage extends Message {
3536
GErrorMessage(Initializer init) {
3637
super(init);
3738
}
39+
3840
abstract GstAPI.GErrorStruct parseMessage();
3941

4042
/**

src/org/freedesktop/gstreamer/message/InfoMessage.java

Lines changed: 11 additions & 6 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) 2004 Wim Taymans <[email protected]>
45
*
@@ -16,34 +17,38 @@
1617
* You should have received a copy of the GNU Lesser General Public License
1718
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
1819
*/
19-
2020
package org.freedesktop.gstreamer.message;
2121

2222
import org.freedesktop.gstreamer.lowlevel.GstAPI.GErrorStruct;
2323
import static org.freedesktop.gstreamer.lowlevel.GstMessageAPI.GSTMESSAGE_API;
2424

2525
/**
2626
* This message is posted by element to provide information to the application.
27+
* <p>
28+
* See upstream documentation at
29+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-info"
30+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-info</a>
31+
* <p>
2732
*/
2833
public class InfoMessage extends GErrorMessage {
2934

3035
/**
3136
* Creates a new info message.
32-
*
37+
*
3338
* @param init internal initialization data.
3439
*/
35-
public InfoMessage(Initializer init) {
40+
InfoMessage(Initializer init) {
3641
super(init);
3742
}
38-
43+
3944
/**
4045
* Retrieves the GError structure contained in this message.
41-
*
46+
*
4247
* @return the GError contained in this message.
4348
*/
4449
@Override
4550
GErrorStruct parseMessage() {
46-
GErrorStruct[] err = { null };
51+
GErrorStruct[] err = {null};
4752
GSTMESSAGE_API.gst_message_parse_info(this, err, null);
4853
return err[0];
4954
}

src/org/freedesktop/gstreamer/message/LatencyMessage.java

Lines changed: 11 additions & 5 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) 2004 Wim Taymans <[email protected]>
45
*
@@ -16,28 +17,33 @@
1617
* You should have received a copy of the GNU Lesser General Public License
1718
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
1819
*/
19-
2020
package org.freedesktop.gstreamer.message;
2121

2222
import org.freedesktop.gstreamer.GstObject;
2323
import static org.freedesktop.gstreamer.lowlevel.GstMessageAPI.GSTMESSAGE_API;
2424

2525
/**
2626
* Message posted by elements when their latency requirements have changed.
27+
* <p>
28+
* See upstream documentation at
29+
* <a href="https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-latency"
30+
* >https://gstreamer.freedesktop.org/data/doc/gstreamer/stable/gstreamer/html/GstMessage.html#gst-message-new-latency</a>
31+
* <p>
2732
*/
2833
public class LatencyMessage extends Message {
34+
2935
/**
3036
* Creates a new Latency message.
31-
*
37+
*
3238
* @param init internal initialization data.
3339
*/
34-
public LatencyMessage(Initializer init) {
40+
LatencyMessage(Initializer init) {
3541
super(init);
3642
}
37-
43+
3844
/**
3945
* Creates a new Latency message.
40-
*
46+
*
4147
* @param source the object originating the message.
4248
*/
4349
public LatencyMessage(GstObject source) {

0 commit comments

Comments
 (0)