gBroutin / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

Live Streaming #48

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi All

I am new to gstreamer and i have written a pipeline that is supposed to
stream video from a v4l2src using RTP but it looks like no packets are not
actually leaving the pipeline.I have checked using wireshark but no packets
are captured. I can display the feed from the camera so i think it has
nothing to do with the source.Below is my code

public class RTPServer
{
    private Pipeline pipeline;
    private Pipeline pipe;
    private Element videosrc;
    private Element videosrc1;
    private Element videofilter;
    private Element videofilter1;
    private Element videoencoder;
    private Element videopayloader;
    private Element videosink;

    private Element rtpbin;
    private Element rtpsink;
    private Element rtcpsink;
    private Element rtcpsrc;

    private Pad srcpad;
    private Pad sinkpad;

    public RTPServer(String[] args)
    {
        Gst.init("RTPSendPipeline",args);

        //Pipeline to hold everything
        pipeline = new Pipeline("RTPSendPipeline");

        //the video capture and format conversion
        videosrc = ElementFactory.make("v4l2src","source");
        //videofilter = ElementFactory.make("capsfilter","flt");

        //encoding and payloading
        videoencoder = ElementFactory.make("ffenc_h263", "h263encoder");
        videopayloader = ElementFactory.make("rtph263ppay", "h263payloader");

        //add capture and payloading to the pipeline
        pipeline.addMany(videosrc,videoencoder,videopayloader,null);
        Element.linkMany(videosrc,videoencoder,videopayloader, null);
        //System.out.println("ghis");

        //the rtpbin element
        rtpbin = ElementFactory.make("gstrtpbin", "rtpbin");
        pipeline.add(rtpbin);

        //the udp sinks and source that we will use for RTP and RTCP
        rtpsink = ElementFactory.make("udpsink","rtpsink");
        rtpsink.set("host","127.0.0.1");
        rtpsink.set("port","5002");

        rtcpsink = ElementFactory.make("udpsink","rtcpsink");
        rtcpsink.set("host","127.0.0.1");
        rtcpsink.set("port","5003");

        //no need for synchronisation or prerollon the RTCP sink
        rtcpsink.set("async","FALSE");
        rtcpsink.set("sync","FALSE");

        rtcpsrc = ElementFactory.make("udpsrc","rtcpsrc");
        rtcpsrc.set("port","5007");

        pipeline.addMany(rtpsink,rtcpsink,rtcpsrc,null);

        //now link all to the rtpbin, start by getting an RTP sinkpad for
session 0
        sinkpad = rtpbin.getRequestPad("send_rtp_sink_0");
        srcpad = videopayloader.getStaticPad("src");
        srcpad.link(sinkpad);
        System.out.println(sinkpad.toString());
        System.out.println(srcpad.toString());
        //System.out.println(srcpad.isLinked());
        System.out.println();

        //get the RTP srcpad that was created when we requested the sinkpad
above and link
        //it to the rtpsink sinkpad
        srcpad = rtpbin.getStaticPad("send_rtp_src_0");
        sinkpad = rtpsink.getStaticPad("sink");
        srcpad.link(sinkpad);
        System.out.println(sinkpad.toString());
        System.out.println(srcpad.toString());
        System.out.println();

        //get an RTCP srcpad for sending RTCP to the receiver
        srcpad = rtpbin.getRequestPad("send_rtcp_src_0");
        sinkpad = rtcpsink.getStaticPad("sink");
        srcpad.link(sinkpad);
        System.out.println(sinkpad.toString());
        System.out.println(srcpad.toString());
        System.out.println();

        //we also want to receive RTCP, request and RTCP sinkpad for
session 0 and link
        //it to the srcpad of the udpsrc for RTCP
        srcpad = rtcpsrc.getStaticPad("src");
        sinkpad = rtpbin.getRequestPad("recv_rtcp_sink_0");
        srcpad.link(sinkpad);
        System.out.println(sinkpad.toString());
        System.out.println(srcpad.toString());

        /*we want to see what we are sending across
        pipe = new Pipeline("What we are sending");
        videosrc1 = ElementFactory.make("v4l2src","source");
        videofilter1 = ElementFactory.make("capsfilter","flt");
        videofilter1.setCaps(Caps.fromString("video/x-raw-yuv, width=640,
height=480" + ", bpp=32, depth=32, framerate=25/1"));
        SwingUtilities.invokeLater(new Runnable()
        {

            public void run()
            {
                // This gives a window with the stream from webcam
                Element videosink = ElementFactory.make("xvimagesink", "sink");

                pipe.addMany(videosrc1, videofilter1, videosink);
                Element.linkMany(videosrc1, videofilter1, videosink);

                // Start the pipeline processing
                pipe.setState(State.PLAYING);
            }

        });*/

        //set pipeline to playing state
        pipeline.setState(State.PLAYING);
        //pipeline.play();
        Gst.main();

        pipeline.setState(State.NULL);
        //pipeline.stop();

        //print stats every second

        //System.out.println("finished");
    }
    public static void main(String[] args)
    {
        new RTPServer(args);
    }

}

I am using ubuntu karmic koala, gstreamer-java-1.3.jar and jna-3.2.5.jar

Original issue reported on code.google.com by wmusw...@gmail.com on 1 Jun 2010 at 1:35

GoogleCodeExporter commented 8 years ago
Sorry for posting this in the wrong place

Original comment by wmusw...@gmail.com on 1 Jun 2010 at 1:41

GoogleCodeExporter commented 8 years ago

Original comment by lfar...@gmail.com on 7 Jun 2010 at 2:20