Basic RTSP in Netty example?
aamir
aamir at aamirvirani.com
Thu Nov 25 14:38:48 EST 2010
My biggest question is whether there are any actual examples of the new RTSP
support in Netty. I found Mobicents but little documentation is there wrt
Netty's version.
I would like to connect to a server talking RTSP. The basic code is as
follows. Note the bottom. This fails with:
java.lang.IllegalArgumentException: unsupported message type: class
org.jboss.netty.handler.codec.http.DefaultHttpRequest
Here is the code I have.
ChannelFactory factory =
new NioClientSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
ClientBootstrap bootstrap = new ClientBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
ChannelPipeline result = Channels.pipeline(new
RtspRequestDecoder());
return result;
}
});
bootstrap.setOption("tcpNoDelay", true);
bootstrap.setOption("keepAlive", true);
int port = 554;
if (uri.getPort() != -1) {
port = uri.getPort();
}
ChannelFuture channelAfterConnect = bootstrap.connect(new
InetSocketAddress(uri.getHost(), port));
// Wait until the connection attempt succeeds or fails.
Channel channel =
channelAfterConnect.awaitUninterruptibly().getChannel();
if (!channelAfterConnect.isSuccess()) {
bootstrap.releaseExternalResources();
return;
}
HttpRequest request = new DefaultHttpRequest(RtspVersions.RTSP_1_0,
RtspMethods.SETUP, uri.toString());
request.setHeader(RtspHeaders.Names.HOST, uri.getHost());
request.setHeader(RtspHeaders.Names.CONNECTION,
RtspHeaders.Values.CLOSE);
channel.write(request);
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Basic-RTSP-in-Netty-example-tp5775338p5775338.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list