使用Gstreamer打开和关闭或端口

时间:2014-12-01 11:55:28

标签: java sockets gstreamer

我试图开发一个RTP proxy server并且已经完成了一半。我有一个rtpbin,我可以将文件发送到远程主机。但现在我的主管 - 说 - 应该实现一个方法来打开和关闭套接字(套接字管理),这需要使用Gstreamer完成,代码应该只在java中。

我的代码的一部分在

之下
        //send data over network via udp 

    Element udpSink_rtpout = ElementFactory.make("udpsink", "udpsink0") ; 
    udpSink_rtpout.set("host", REMOTE_HOST) ; 
    udpSink_rtpout.set("port", 5000) ;

    // rtpL16pay - payload encode raw audio over rtp packets
    Element rtpL16pay = ElementFactory.make("rtpL16pay", "rtpPay") ;
    //  rtp part ends here

    // add all elements into a pipeline 
    pipeline.addMany(source, demuxer, decoder, conv, rtpL16pay, rtpbin, udpSink_rtpout) ;

    // link all elements  
    Element.linkMany(source, demuxer) ;
    Element.linkMany(decoder, conv, rtpL16pay) ;
    // link to rtp 
    logger.info("Linking pads ....") ;
    Element.linkPads(rtpL16pay, "src", rtpbin, "send_rtp_sink_0") ;
    Element.linkPads(rtpbin, "send_rtp_src_0", udpSink_rtpout, "sink") ; 

    demuxer.connect(new PAD_ADDED() {
        public void padAdded(Element element, Pad pad) {
            logger.info("Dynamic pad added, linking demuxer/decoder") ; 
            Pad sinkPad = decoder.getStaticPad("sink") ;
            Element.linkPads(element, pad.getName(), decoder, sinkPad.getName()) ; 
        }
     });

    // set the pipeline to playing state
    logger.info(" pipeline now playing....and ") ;
    pipeline.setState(State.PLAYING) ; 
    logger.info(" Pipeline state is " + pipeline.getState()) ; 

    loop.run() ;
    logger.info(" returned ..stopping playback") ;
    pipeline.setState(State.NULL) ;      
   }
 }

任何人都可以告诉我如何使用JAVA添加一个方法来打开和关闭套接字?

0 个答案:

没有答案