Example usage for io.netty.handler.codec.rtsp RtspRequestEncoder RtspRequestEncoder

List of usage examples for io.netty.handler.codec.rtsp RtspRequestEncoder RtspRequestEncoder

Introduction

In this page you can find the example usage for io.netty.handler.codec.rtsp RtspRequestEncoder RtspRequestEncoder.

Prototype

RtspRequestEncoder

Source Link

Usage

From source file:org.mobicents.media.server.ctrl.rtsp.stack.RtspClientStackImpl.java

License:Open Source License

public void start() throws IOException {

    Bootstrap b = new Bootstrap();
    b.group(workerGroup);/*  w  ww. j a v  a  2s  .  c o m*/
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.SO_KEEPALIVE, true);
    b.handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            // httpResponse??HttpResponseDecoder?
            ch.pipeline().addLast(new RtspResponseDecoder());
            // ??httprequest?HttpRequestEncoder?
            ch.pipeline().addLast(new RtspRequestEncoder());
            // ch.pipeline().addLast(new HttpObjectAggregator(1024 * 64));
            ch.pipeline().addLast("handler", new RtspResponseHandler(RtspClientStackImpl.this));
        }
    });

    // Start the client.
    ChannelFuture f = b.connect(getHost(), getPort());
    try {
        f.sync();
        channel = f.channel();

        InetSocketAddress bindAddress = new InetSocketAddress(this.host, this.port);

        logger.info("Mobicents RTSP Client started and bound to " + bindAddress.toString());

    } catch (InterruptedException e) {
        throw new IOException(f.cause());
    }
}

From source file:org.mobicents.media.server.rtsp.stack.RtspClientStackImpl.java

License:Open Source License

public void connect() throws IOException {

    Bootstrap b = new Bootstrap();
    b.group(workerGroup);//from w w  w  . ja v a2 s  .  c  o  m
    b.channel(NioSocketChannel.class);
    b.option(ChannelOption.SO_KEEPALIVE, true);
    b.handler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            // ??httpResponse???HttpResponseDecoder?
            ch.pipeline().addLast(new RtspResponseDecoder());
            // ?ttprequest?HttpRequestEncoder?
            ch.pipeline().addLast(new RtspRequestEncoder());
            // ch.pipeline().addLast(new HttpObjectAggregator(1024 * 64));
            ch.pipeline().addLast("handler", new RtspResponseHandler(RtspClientStackImpl.this));
        }
    });

    // Start the client.
    ChannelFuture f = b.connect(getHost(), getPort());
    try {
        f.sync();
        channel = f.channel();

        InetSocketAddress bindAddress = new InetSocketAddress(this.host, this.port);

        logger.info("Mobicents RTSP Client started and bound to " + bindAddress.toString());

        RtspResponseHandler handler = (RtspResponseHandler) f.channel().pipeline().get("handler");
        handler.connect();
    } catch (InterruptedException e) {
        throw new IOException(f.cause());
    }
}