Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Netty服务器端RTSP交织RTP(解码和处理)_Java_Netty_Rtsp_Rtp - Fatal编程技术网

Java Netty服务器端RTSP交织RTP(解码和处理)

Java Netty服务器端RTSP交织RTP(解码和处理),java,netty,rtsp,rtp,Java,Netty,Rtsp,Rtp,我是netty的初学者,我需要一种方法来处理RTSP和RTP,如ED-137_4B(嵌入式交错二进制数据)规范中所述。 我目前使用的是netty framework版本4.0.24,但在更高版本(如4.0.34)中,我找不到对嵌入式交错二进制数据的RTSP支持,其中RTP在RTSP包中交错。 我尝试了很多事情,例如,我尝试用RTPServerInitilizer实现了第二个childHandler,它应该处理RTP解码,但这不能与RTSP解码器一起工作。 我也尝试过实现两条管道的连接(见下文),

我是netty的初学者,我需要一种方法来处理RTSP和RTP,如ED-137_4B(嵌入式交错二进制数据)规范中所述。 我目前使用的是netty framework版本4.0.24,但在更高版本(如4.0.34)中,我找不到对嵌入式交错二进制数据的RTSP支持,其中RTP在RTSP包中交错。 我尝试了很多事情,例如,我尝试用RTPServerInitilizer实现了第二个childHandler,它应该处理RTP解码,但这不能与RTSP解码器一起工作。 我也尝试过实现两条管道的连接(见下文),但这两条管道也不能一起工作

总之,当我一起实现RTSP解码器和RTP解码器时,例如,使用RTSP和RTP的完全独立的初始值设定项,或者使用两个独立的管道实现时,始终只有一个解码器工作。例如,如果在第一个位置设置RTSP,则仅对RTSP事件进行解码,如果RTP解码器位于第一个位置,则仅对RTP包进行解码。 如果客户端断开连接,那么我可以看到另一个解码器将尝试像队列一样解码,但是来自客户端的消息不再可用。可以在同一TCP套接字上使用“NioServerSocketChannel.class”同步处理多个不同的RTSP客户端

请,你能给我一个提示,或者你能帮我解决如何一起使用RTSP和RTP,因为我在新工作的项目中需要它,这是非常必要的

提前多谢:-)

以下是我的代码片段:

//***-->For your interest, functions that begin with HttpServer... handle the RTSP events!<--**//

public class HttpServerInitializer extends ChannelInitializer<SocketChannel>{    
    @Override
    public void initChannel(SocketChannel ch)  {

     //Handling of RTSP
         ChannelPipeline p = ch.pipeline();

       p.addLast(new RtspResponseEncoder());
       p.addFirst(new RtspRequestDecoder()); 

       p.addLast(new HttpObjectAggregator(65536));
       p.addLast(new HttpContentCompressor());        
       p.addLast(new ChunkedWriteHandler());       
       p.addLast(new HttpServerHandler());    


     //Second pipeline for handling of RTP
     ChannelPipeline pp = ch.pipeline();            
     pp.addLast(new RTPDecoder());
     pp.addLast(new RTPHandler());
    }
}


public class HttpServer {

    //static final int PORT = 554;
    public Channel ch = null;

    public void connect(int iPort) throws Exception {

        // Configure the server.
        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
        EventLoopGroup workerGroup = new NioEventLoopGroup();
        //try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup)
             .channel(NioServerSocketChannel.class)
             //.childHandler(new RtpServerInitializer())    //Second separately initializer did not worked together with initializer for RTSP
             //.handler(new LoggingHandler(LogLevel.ERROR))
             .childHandler(new HttpServerInitializer());  

            ch = b.bind(iPort).sync().channel();

        /*    ch.closeFuture().sync();
        } finally {
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }*/
    }   
} 


public class HttpServerHandler extends SimpleChannelInboundHandler <HttpObject> { 

    private HttpRequest m_request;
    /** Buffer that stores the response content for only log output**/
    private final StringBuilder buf = new StringBuilder();


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg)
            throws Exception {
        // TODO Auto-generated method stub

        if (msg instanceof HttpRequest) {
            m_request = (HttpRequest) msg;
        ....
}
...
    }
  }


public class RTPDecoder extends ByteToMessageDecoder {

private ByteBuf collector = Unpooled.buffer();

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
        throws Exception {
…
    }
   ...
  }


public class RTPHandler extends SimpleChannelInboundHandler<ByteToMessageDecoder> { 

    @Override 
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception { 

            super.exceptionCaught(ctx, e);            
    } 

    public void channelRead(ChannelHandlerContext ctx,  Object msg)
            throws Exception {
        // TODO Auto-generated method stub
    …
    }
 …
 }
/***-->出于您的兴趣,以HttpServer开头的函数。。。处理RTSP事件!