简体   繁体   中英

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM