Skip to content

Commit 107a6d4

Browse files
Basic update of examples for v1.0.0-beta-1 release.
1 parent 75cb01a commit 107a6d4

File tree

8 files changed

+58
-49
lines changed

8 files changed

+58
-49
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.freedesktop.gstreamer</groupId>
55
<artifactId>gst1-java-examples</artifactId>
6-
<version>0.9-SNAPSHOT</version>
6+
<version>1.0.0-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<dependencies>
99
<dependency>
1010
<groupId>net.java.dev.jna</groupId>
1111
<artifactId>jna</artifactId>
12-
<version>[4.4.0,5.0)</version>
12+
<version>5.2.0</version>
1313
</dependency>
1414
<dependency>
1515
<groupId>org.freedesktop.gstreamer</groupId>
1616
<artifactId>gst1-java-core</artifactId>
17-
<version>[0.9.3,1.0)</version>
17+
<version>1.0.0-beta-1</version>
1818
</dependency>
1919
</dependencies>
2020
<properties>

src/main/java/org/freedesktop/gstreamer/examples/BatchTranscode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void main(String[] argv)
2727
"! x264enc pass=4 quantizer=21 ! queue ! mux. " +
2828
"mpegtsmux name=mux") +
2929
" ! filesink name=dst";
30-
Pipeline pipe = Pipeline.launch(pipeSpec);
30+
Pipeline pipe = (Pipeline) Gst.parseLaunch(pipeSpec);
3131

3232
pipe.getElementByName("src").set("location", srcVideo);
3333
pipe.getElementByName("dst").set("location", outFile);

src/main/java/org/freedesktop/gstreamer/examples/CameraTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright 2018 Neil C Smith.
4+
* Copyright 2019 Neil C Smith.
55
*
66
* Copying and distribution of this file, with or without modification,
77
* are permitted in any medium without royalty provided the copyright
@@ -38,7 +38,9 @@ public static void main(String[] args) {
3838
@Override
3939
public void run() {
4040
SimpleVideoComponent vc = new SimpleVideoComponent();
41-
Bin bin = Bin.launch("autovideosrc ! videoconvert ! capsfilter caps=video/x-raw,width=640,height=480", true);
41+
Bin bin = Gst.parseBinFromDescription(
42+
"autovideosrc ! videoconvert ! capsfilter caps=video/x-raw,width=640,height=480",
43+
true);
4244
pipe = new Pipeline();
4345
pipe.addMany(bin, vc.getElement());
4446
Pipeline.linkMany(bin, vc.getElement());

src/main/java/org/freedesktop/gstreamer/examples/MultiSinkExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void main(String[] args) {
4141

4242
Gst.init();
4343
EventQueue.invokeLater(() -> {
44-
Bin bin = Bin.launch("tee name=t t. ! queue ! videoconvert ! autovideosink "
44+
Bin bin = Gst.parseBinFromDescription("tee name=t t. ! queue ! videoconvert ! autovideosink "
4545
+ "t. ! queue ! videoconvert ! videoscale ! capsfilter caps=video/x-raw,width=640,height=480 ! appsink name=appsink", true);
4646

4747
SimpleVideoComponent vc = new SimpleVideoComponent((AppSink) bin.getElementByName("appsink"));

src/main/java/org/freedesktop/gstreamer/examples/PlayBinVideoPlayer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright 2018 Neil C Smith.
4+
* Copyright 2019 Neil C Smith.
55
*
66
* Copying and distribution of this file, with or without modification,
77
* are permitted in any medium without royalty provided the copyright
@@ -27,10 +27,10 @@
2727
import org.freedesktop.gstreamer.Element;
2828
import org.freedesktop.gstreamer.ElementFactory;
2929
import org.freedesktop.gstreamer.Gst;
30-
import org.freedesktop.gstreamer.Message;
31-
import org.freedesktop.gstreamer.MessageType;
3230
import org.freedesktop.gstreamer.Structure;
3331
import org.freedesktop.gstreamer.elements.PlayBin;
32+
import org.freedesktop.gstreamer.message.Message;
33+
import org.freedesktop.gstreamer.message.MessageType;
3434

3535
/**
3636
*
@@ -137,17 +137,17 @@ public void busMessage(Bus arg0, Message message) {
137137
// Calculate the time offset required to get the level
138138
// information in sync with the video display
139139
long timeDelay = getTimeOffset(struct);
140-
Gst.getScheduledExecutorService().schedule(
140+
Gst.getExecutor().schedule(
141141
() -> EventQueue.invokeLater(() -> updateLevelDisplay(levels)),
142142
timeDelay, TimeUnit.NANOSECONDS);
143143
}
144144
}
145145

146146
private long getTimeOffset(Structure struct) {
147-
long actualTime = playbin.getClock().getTime().toNanos()
148-
- playbin.getBaseTime().toNanos();
149-
long runningTime = ((Long) struct.getValue("running-time"));
150-
long duration = ((Long) struct.getValue("duration"));
147+
long actualTime = playbin.getClock().getTime()
148+
- playbin.getBaseTime();
149+
long runningTime = (long) struct.getValue("running-time");
150+
long duration = (long) struct.getValue("duration");
151151
long messageTime = runningTime + (duration / 2);
152152
return messageTime - actualTime;
153153
}

src/main/java/org/freedesktop/gstreamer/examples/TestFootageCapture.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ public static void main(String args[]) throws Exception {
6969

7070
// The time delaying queue is specified below. Specify a different value or take out the queue
7171
// completely for real time capture.
72-
Bin videoBin = Bin.launch("queue max-size-time=10000000000 min-threshold-time=5000000000 flush-on-eos=true ! appsink name=videoAppSink",true);
73-
Bin audioBin = Bin.launch("queue max-size-time=10000000000 min-threshold-time=5000000000 flush-on-eos=true ! appsink name=audioAppSink",true);
72+
Bin videoBin = Gst.parseBinFromDescription(
73+
"queue max-size-time=10000000000 min-threshold-time=5000000000 flush-on-eos=true ! appsink name=videoAppSink",
74+
true);
75+
Bin audioBin = Gst.parseBinFromDescription(
76+
"queue max-size-time=10000000000 min-threshold-time=5000000000 flush-on-eos=true ! appsink name=audioAppSink",
77+
true);
7478

7579
AppSink videoAppSink = (AppSink) videoBin.getElementByName("videoAppSink");
7680
AppSink audioAppSink = (AppSink) audioBin.getElementByName("audioAppSink");
@@ -128,7 +132,7 @@ public static void main(String args[]) throws Exception {
128132
// encodes a video only MP4 file.
129133
boolean hasAudio = (audioCaps.length()>0);
130134
if (hasAudio) {
131-
pipeline = Pipeline.launch(
135+
pipeline = (Pipeline) Gst.parseLaunch(
132136
"appsrc name=videoAppSrc "+
133137
"! rawvideoparse use-sink-caps=true "+
134138
"! videoconvert ! x264enc speed-preset=ultrafast ! h264parse "+
@@ -149,7 +153,7 @@ public static void main(String args[]) throws Exception {
149153
else {
150154
System.out.println("RTSP stream has no audio.");
151155

152-
pipeline = Pipeline.launch(
156+
pipeline = (Pipeline) Gst.parseLaunch(
153157
"appsrc name=videoAppSrc "+
154158
"! rawvideoparse use-sink-caps=true "+
155159
"! videoconvert ! x264enc speed-preset=ultrafast ! h264parse "+

src/main/java/org/freedesktop/gstreamer/examples/TestProcessVideoMP4ToMP4.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
import org.freedesktop.gstreamer.Bin;
2828
import org.freedesktop.gstreamer.Buffer;
29+
import org.freedesktop.gstreamer.BufferFlags;
2930
import org.freedesktop.gstreamer.Bus;
3031
import org.freedesktop.gstreamer.Caps;
31-
import org.freedesktop.gstreamer.ClockTime;
3232
import org.freedesktop.gstreamer.FlowReturn;
3333
import org.freedesktop.gstreamer.Gst;
3434
import org.freedesktop.gstreamer.Pipeline;
@@ -39,6 +39,7 @@
3939
import org.freedesktop.gstreamer.elements.BaseSink;
4040
import org.freedesktop.gstreamer.elements.PlayBin;
4141
import org.freedesktop.gstreamer.event.EOSEvent;
42+
import org.freedesktop.gstreamer.glib.NativeFlags;
4243

4344
/**
4445
* This example shows how to use the various gstreamer mechanisms to
@@ -73,11 +74,11 @@ public static void main(String args[]) throws Exception {
7374

7475
Scanner s = new Scanner(System.in);
7576

76-
Bin videoBin = Bin.launch("appsink name=videoAppSink", true);
77+
Bin videoBin = Gst.parseBinFromDescription("appsink name=videoAppSink", true);
7778

7879
AppSink videoAppSink = (AppSink) videoBin.getElementByName("videoAppSink");
7980
videoAppSink.set("emit-signals", true);
80-
videoAppSink.enableAsync(false);
81+
videoAppSink.set("async", true);
8182

8283
AppSinkListener videoAppSinkListener = new AppSinkListener(processingQueue,videoCaps,gotCaps);
8384
videoAppSink.connect((AppSink.NEW_SAMPLE) videoAppSinkListener);
@@ -125,7 +126,7 @@ public static void main(String args[]) throws Exception {
125126

126127
gotCaps.acquire(1);
127128

128-
pipeline = Pipeline.launch(
129+
pipeline = (Pipeline) Gst.parseLaunch(
129130
"appsrc name=videoAppSrc "+
130131
"! videoconvert ! video/x-raw,format=I420 "+
131132
"! x264enc ! h264parse "+
@@ -245,7 +246,7 @@ public FlowReturn newSample(AppSink elem) {
245246
FrameInfo info = new FrameInfo();
246247
info.setCapacity(bb.capacity());
247248
info.setPixels(pixels);
248-
info.setFlags(srcBuffer.getFlags());
249+
info.setFlags(NativeFlags.toInt(srcBuffer.getFlags()));
249250
info.setDuration(srcBuffer.getDuration());
250251
info.setOffset(srcBuffer.getOffset());
251252
info.setOffsetEnd(srcBuffer.getOffsetEnd());
@@ -299,11 +300,11 @@ private static class FrameInfo {
299300
private int[] pixels;
300301

301302
private int flags;
302-
private ClockTime duration;
303+
private long duration;
303304
private long offset;
304305
private long offsetEnd;
305-
private ClockTime decodeTimestamp;
306-
private ClockTime presentationTimestamp;
306+
private long decodeTimestamp;
307+
private long presentationTimestamp;
307308

308309
public int getCapacity() {
309310
return capacity;
@@ -323,10 +324,10 @@ public int getFlags() {
323324
public void setFlags(int flags) {
324325
this.flags = flags;
325326
}
326-
public ClockTime getDuration() {
327+
public long getDuration() {
327328
return duration;
328329
}
329-
public void setDuration(ClockTime duration) {
330+
public void setDuration(long duration) {
330331
this.duration = duration;
331332
}
332333
public long getOffset() {
@@ -341,16 +342,16 @@ public long getOffsetEnd() {
341342
public void setOffsetEnd(long offsetEnd) {
342343
this.offsetEnd = offsetEnd;
343344
}
344-
public ClockTime getDecodeTimestamp() {
345+
public long getDecodeTimestamp() {
345346
return decodeTimestamp;
346347
}
347-
public void setDecodeTimestamp(ClockTime decodeTimestamp) {
348+
public void setDecodeTimestamp(long decodeTimestamp) {
348349
this.decodeTimestamp = decodeTimestamp;
349350
}
350-
public ClockTime getPresentationTimestamp() {
351+
public long getPresentationTimestamp() {
351352
return presentationTimestamp;
352353
}
353-
public void setPresentationTimestamp(ClockTime presentationTimestamp) {
354+
public void setPresentationTimestamp(long presentationTimestamp) {
354355
this.presentationTimestamp = presentationTimestamp;
355356
}
356357
}
@@ -407,7 +408,7 @@ public void run() {
407408
dstBuffer.map(true).asIntBuffer().put(destPixels);
408409
dstBuffer.unmap();
409410

410-
dstBuffer.setFlags(info.getFlags());
411+
dstBuffer.setFlags(NativeFlags.fromInt(BufferFlags.class, info.getFlags()));
411412
dstBuffer.setDuration(info.getDuration());
412413
dstBuffer.setOffset(info.getOffset());
413414
dstBuffer.setOffsetEnd(info.getOffsetEnd());

src/main/java/org/freedesktop/gstreamer/examples/TestProcessVideoRTSPToMP4.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
import org.freedesktop.gstreamer.Bin;
2828
import org.freedesktop.gstreamer.Buffer;
29+
import org.freedesktop.gstreamer.BufferFlags;
2930
import org.freedesktop.gstreamer.Bus;
3031
import org.freedesktop.gstreamer.Caps;
31-
import org.freedesktop.gstreamer.ClockTime;
3232
import org.freedesktop.gstreamer.FlowReturn;
3333
import org.freedesktop.gstreamer.Gst;
3434
import org.freedesktop.gstreamer.Pipeline;
@@ -39,6 +39,7 @@
3939
import org.freedesktop.gstreamer.elements.BaseSink;
4040
import org.freedesktop.gstreamer.elements.PlayBin;
4141
import org.freedesktop.gstreamer.event.EOSEvent;
42+
import org.freedesktop.gstreamer.glib.NativeFlags;
4243

4344
/**
4445
* This example shows how to use the various gstreamer mechanisms to
@@ -73,11 +74,12 @@ public static void main(String args[]) throws Exception {
7374

7475
Scanner s = new Scanner(System.in);
7576

76-
Bin videoBin = Bin.launch("appsink name=videoAppSink", true);
77+
Bin videoBin = Gst.parseBinFromDescription("appsink name=videoAppSink", true);
7778

7879
AppSink videoAppSink = (AppSink) videoBin.getElementByName("videoAppSink");
7980
videoAppSink.set("emit-signals", true);
80-
videoAppSink.enableAsync(false);
81+
// videoAppSink.enableAsync(false);
82+
videoAppSink.set("async", true);
8183

8284
AppSinkListener videoAppSinkListener = new AppSinkListener(processingQueue,videoCaps,gotCaps);
8385
videoAppSink.connect((AppSink.NEW_SAMPLE) videoAppSinkListener);
@@ -125,7 +127,7 @@ public static void main(String args[]) throws Exception {
125127

126128
gotCaps.acquire(1);
127129

128-
pipeline = Pipeline.launch(
130+
pipeline = (Pipeline) Gst.parseLaunch(
129131
"appsrc name=videoAppSrc "+
130132
"! videoconvert ! video/x-raw,format=I420 "+
131133
"! x264enc ! h264parse "+
@@ -244,7 +246,7 @@ public FlowReturn newSample(AppSink elem) {
244246
FrameInfo info = new FrameInfo();
245247
info.setCapacity(bb.capacity());
246248
info.setPixels(pixels);
247-
info.setFlags(srcBuffer.getFlags());
249+
info.setFlags(NativeFlags.toInt(srcBuffer.getFlags()));
248250
info.setDuration(srcBuffer.getDuration());
249251
info.setOffset(srcBuffer.getOffset());
250252
info.setOffsetEnd(srcBuffer.getOffsetEnd());
@@ -298,11 +300,11 @@ private static class FrameInfo {
298300
private int[] pixels;
299301

300302
private int flags;
301-
private ClockTime duration;
303+
private long duration;
302304
private long offset;
303305
private long offsetEnd;
304-
private ClockTime decodeTimestamp;
305-
private ClockTime presentationTimestamp;
306+
private long decodeTimestamp;
307+
private long presentationTimestamp;
306308

307309
public int getCapacity() {
308310
return capacity;
@@ -322,10 +324,10 @@ public int getFlags() {
322324
public void setFlags(int flags) {
323325
this.flags = flags;
324326
}
325-
public ClockTime getDuration() {
327+
public long getDuration() {
326328
return duration;
327329
}
328-
public void setDuration(ClockTime duration) {
330+
public void setDuration(long duration) {
329331
this.duration = duration;
330332
}
331333
public long getOffset() {
@@ -340,16 +342,16 @@ public long getOffsetEnd() {
340342
public void setOffsetEnd(long offsetEnd) {
341343
this.offsetEnd = offsetEnd;
342344
}
343-
public ClockTime getDecodeTimestamp() {
345+
public long getDecodeTimestamp() {
344346
return decodeTimestamp;
345347
}
346-
public void setDecodeTimestamp(ClockTime decodeTimestamp) {
348+
public void setDecodeTimestamp(long decodeTimestamp) {
347349
this.decodeTimestamp = decodeTimestamp;
348350
}
349-
public ClockTime getPresentationTimestamp() {
351+
public long getPresentationTimestamp() {
350352
return presentationTimestamp;
351353
}
352-
public void setPresentationTimestamp(ClockTime presentationTimestamp) {
354+
public void setPresentationTimestamp(long presentationTimestamp) {
353355
this.presentationTimestamp = presentationTimestamp;
354356
}
355357
}
@@ -405,7 +407,7 @@ public void run() {
405407
dstBuffer.map(true).asIntBuffer().put(destPixels);
406408
dstBuffer.unmap();
407409

408-
dstBuffer.setFlags(info.getFlags());
410+
dstBuffer.setFlags(NativeFlags.fromInt(BufferFlags.class, info.getFlags()));
409411
dstBuffer.setDuration(info.getDuration());
410412
dstBuffer.setOffset(info.getOffset());
411413
dstBuffer.setOffsetEnd(info.getOffsetEnd());

0 commit comments

Comments
 (0)