I am not an expert on this but i think The Gst.init()
, Gst.main()
, and Gst.quit()
methods in your code are static because they are part of the GStreamer Java bindings library, which is a Java wrapper around the GStreamer multimedia framework. These methods initialize and run the GStreamer pipeline, and are designed to be used in a static context, meaning they are independent of any specific instance of a pipeline.
I believe, when you run the code, each customer will have their own instance of a pipeline running, but they will all share the same GStreamer runtime environment. The Gst.init() method initializes the GStreamer runtime environment, and the Gst.quit() method shuts it down. The Gst.main() method starts the GStreamer main loop, which processes events such as EOS (end-of-stream) messages.
To avoid conflicts between the EOS callbacks of multiple pipelines running concurrently, you can use the source parameter of the connect() method to distinguish between the EOS messages of different pipelines. For example, you can assign a unique identifier to each pipeline, and use that identifier in the EOS callback to determine which pipeline has reached the end of the stream.
Something similar to this:
String pipelineName = "myPipeline-" + UUID.randomUUID().toString();
Gst.init(Version.BASELINE, pipelineName);
Pipeline pipeline = (Pipeline) Gst.parseLaunch("videotestsrc ! autovideosink");
pipeline.play();
// Use a lambda expression to handle the EOS message for this pipeline
pipeline.getBus().connect((Bus.EOS) (source) -> {
String pipelineName = source.getName();
System.out.println("Pipeline " + pipelineName + " reached end of stream");
});
Gst.main();
Gst.quit();
I hope this helps!