Small performance improvements for RTSP
This commit is contained in:
parent
2f7759a264
commit
cd51674070
@ -20,12 +20,15 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||
|
||||
/**
|
||||
* Encodes an RTSP request represented in {@link FullHttpRequest} into
|
||||
* a {@link ByteBuf}.
|
||||
|
||||
*/
|
||||
public class RtspRequestEncoder extends RtspObjectEncoder<HttpRequest> {
|
||||
private static final byte[] CRLF = { CR, LF };
|
||||
|
||||
@Override
|
||||
public boolean acceptOutboundMessage(Object msg) throws Exception {
|
||||
@ -35,12 +38,11 @@ public class RtspRequestEncoder extends RtspObjectEncoder<HttpRequest> {
|
||||
@Override
|
||||
protected void encodeInitialLine(ByteBuf buf, HttpRequest request)
|
||||
throws Exception {
|
||||
buf.writeBytes(request.getMethod().toString().getBytes(CharsetUtil.US_ASCII));
|
||||
buf.writeByte((byte) ' ');
|
||||
encodeAscii(request.getMethod().toString(), buf);
|
||||
buf.writeByte(SP);
|
||||
buf.writeBytes(request.getUri().getBytes(CharsetUtil.UTF_8));
|
||||
buf.writeByte((byte) ' ');
|
||||
buf.writeBytes(request.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
|
||||
buf.writeByte((byte) '\r');
|
||||
buf.writeByte((byte) '\n');
|
||||
buf.writeByte(SP);
|
||||
encodeAscii(request.getProtocolVersion().toString(), buf);
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,15 @@ import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import io.netty.handler.codec.http.HttpResponse;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||
|
||||
/**
|
||||
* Encodes an RTSP response represented in {@link FullHttpResponse} into
|
||||
* a {@link ByteBuf}.
|
||||
|
||||
*/
|
||||
public class RtspResponseEncoder extends RtspObjectEncoder<HttpResponse> {
|
||||
private static final byte[] CRLF = { CR, LF };
|
||||
|
||||
@Override
|
||||
public boolean acceptOutboundMessage(Object msg) throws Exception {
|
||||
@ -35,12 +38,11 @@ public class RtspResponseEncoder extends RtspObjectEncoder<HttpResponse> {
|
||||
@Override
|
||||
protected void encodeInitialLine(ByteBuf buf, HttpResponse response)
|
||||
throws Exception {
|
||||
buf.writeBytes(response.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
|
||||
buf.writeByte((byte) ' ');
|
||||
encodeAscii(response.getProtocolVersion().toString(), buf);
|
||||
buf.writeByte(SP);
|
||||
buf.writeBytes(String.valueOf(response.getStatus().code()).getBytes(CharsetUtil.US_ASCII));
|
||||
buf.writeByte((byte) ' ');
|
||||
buf.writeBytes(String.valueOf(response.getStatus().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
|
||||
buf.writeByte((byte) '\r');
|
||||
buf.writeByte((byte) '\n');
|
||||
buf.writeByte(SP);
|
||||
encodeAscii(String.valueOf(response.getStatus().reasonPhrase()), buf);
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user