Skip to content

Instantly share code, notes, and snippets.

Created March 22, 2020 17:39
What would you like to do?
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.freedesktop.gstreamer.Element;
import org.freedesktop.gstreamer.Gst;
import org.freedesktop.gstreamer.Pad;
import org.freedesktop.gstreamer.Pipeline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main {
private static final Logger log = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException {
Pipeline pipeline = (Pipeline) Gst
.parseLaunch("audiotestsrc name=src ! fakesink sync=false");;
Element src = pipeline.getElementByName("src");
Pad srcPad = src.getStaticPad("src");
//noinspection InfiniteLoopStatement
while (true) {"> blocking");
CompletableFuture<Void> future = new CompletableFuture<>();
srcPad.block(() -> {"= blocked");
future.complete(null);"= completed");
});"< getting");
future.get(10, TimeUnit.SECONDS);"< got");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment