user3399262
user3399262

Reputation: 5

Get caps from pipeline

I am new to GStreamer and I try to get Caps property from pipeline in Java. If i try in command line this pipeline

gst-launch-0.10 -v --gst-debug-level=2 filesrc location="C:/Dokumenty/Eclipse/rtsp_test/trailer.mp4" ! decodebin2 ! queue ! jpegenc ! rtpjpegpay ! udpsink host=::1 port=5000 sync=true

it works fine and return this caps, which I needed

/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)JPEG, payload=(int)96, ssrc=(uint)3175930633, clock-base=(uint)3850186239, seqnum-base=(uint)8531

But I dont know, how to get this caps in Java from pipeline

pipe = Pipeline.launch("filesrc location="C:/Dokumenty/Eclipse/rtsp_test/trailer.mp4" ! decodebin2 ! queue ! jpegenc ! rtpjpegpay ! udpsink host=::1 port=5000 sync=true");

Are there any methods how to get udpsink0 from pipeline?

Thank you

Upvotes: 0

Views: 2878

Answers (1)

Mark Tolley
Mark Tolley

Reputation: 1418

If you look at the documentation for Bin (the parent class of Pipeline), you'll see there are a few ways to get individual elements. The most simple way is to use: Bin.getElementByName("udpsink0").

A more generic way would be to call Bin.getSinks() and then grab the first result from the list. This way the code will still work even if you use a different type of sink.

Once you have the Element object you can get the pad using Element.getStaticPad("sink") and then finally you can get the Caps object with Pad.getNegotiatedCaps().

For more information check out the javadocs, which can be found at: https://code.google.com/p/gstreamer-java/downloads/list

In short:

Element sink = pipe.getElementByName("udpsink0");
Pad pad = sink.getStaticPad("sink");
Caps caps = pad.getNegotiatedCaps();

Upvotes: 1

Related Questions