Example usage for io.netty.handler.codec.rtsp RtspMethods ANNOUNCE

List of usage examples for io.netty.handler.codec.rtsp RtspMethods ANNOUNCE

Introduction

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

Prototype

HttpMethod ANNOUNCE

To view the source code for io.netty.handler.codec.rtsp RtspMethods ANNOUNCE.

Click Source Link

Document

The ANNOUNCE posts the description of a presentation or media object identified by the request URL to a server, or updates the client-side session description in real-time.

Usage

From source file:sas.systems.imflux.session.rtsp.SimpleRtspSession.java

License:Apache License

/**
 * {@inheritDoc}//from  w  w w.j a va  2s .  co m
 */
@Override
public void requestReceived(Channel channel, HttpRequest request) {
    if (!request.getDecoderResult().isSuccess())
        return;

    LOG.debug("RTSP request received: {}", request);

    if (request.getMethod().equals(RtspMethods.OPTIONS)) {
        handleOptionsRequest(channel, request);
    }
    if (request.getMethod().equals(RtspMethods.DESCRIBE)) {
        if (this.requestListener.isEmpty()) {
            LOG.warn(
                    "No requestListener registered, sending NOT_IMPLEMENTED as response of a DESCRIBE request!");
            sendNotImplemented(channel, request);
        }
        // forward message (resource description is application specific)
        for (RtspRequestListener listener : this.requestListener) {
            listener.describeRequestReceived(request, RtspParticipant.newInstance(channel));
        }
    }
    if (request.getMethod().equals(RtspMethods.ANNOUNCE)) {
        if (this.requestListener.isEmpty()) {
            LOG.warn(
                    "No requestListener registered, sending NOT_IMPLEMENTED as response of an ANNOUNCE request!");
            sendNotImplemented(channel, request);
        }
        // forward message (resource description is again application specific)
        for (RtspRequestListener listener : this.requestListener) {
            listener.announceRequestReceived(request, RtspParticipant.newInstance(channel));
        }
    }
    if (request.getMethod().equals(RtspMethods.SETUP)) {
        handleSetupRequest(channel, request);
    }
    if (request.getMethod().equals(RtspMethods.PLAY)) {
        if (!automatedRtspHandling) {
            // forward message
            for (RtspRequestListener listener : this.requestListener) {
                listener.playRequestReceived(request, RtspParticipant.newInstance(channel));
            }
        } else {
            sendNotImplemented(channel, request);
        }
    }
    if (request.getMethod().equals(RtspMethods.PAUSE)) {
        if (!automatedRtspHandling) {
            // forward message
            for (RtspRequestListener listener : this.requestListener) {
                listener.pauseRequestReceived(request, RtspParticipant.newInstance(channel));
            }
        } else {
            sendNotImplemented(channel, request);
        }
    }
    if (request.getMethod().equals(RtspMethods.TEARDOWN)) {
        handleTeardownRequest(channel, request);
    }
    if (request.getMethod().equals(RtspMethods.GET_PARAMETER)) {
        if (this.requestListener.isEmpty()) {
            // RTSP assumes an empty body if content-length header is missing
            if (!request.headers().contains(RtspHeaders.Names.CONTENT_LENGTH)) {
                // assume this is a ping 
                HttpResponse response = new DefaultHttpResponse(rtspVersion, RtspResponseStatuses.OK);
                response.headers().add(RtspHeaders.Names.CSEQ, request.headers().get(RtspHeaders.Names.CSEQ));
                sendResponse(response, channel);
            }
            LOG.warn(
                    "No requestListener registered, sending NOT_IMPLEMENTED as response of a GET_PARAMETER request!");
            sendNotImplemented(channel, request);
        }
        // forward message (GET_PARAMETER is application specific)
        for (RtspRequestListener listener : this.requestListener) {
            listener.getParameterRequestReceived(request, RtspParticipant.newInstance(channel));
        }
    }
    if (request.getMethod().equals(RtspMethods.SET_PARAMETER)) {
        if (this.requestListener.isEmpty()) {
            LOG.warn(
                    "No requestListener registered, sending NOT_IMPLEMENTED as response of a SET_PARAMETER request!");
            sendNotImplemented(channel, request);
        }
        // forward message (SET_PARAMETER is application specific)
        for (RtspRequestListener listener : this.requestListener) {
            listener.setParameterRequestReceived(request, RtspParticipant.newInstance(channel));
        }
    }
    if (request.getMethod().equals(RtspMethods.REDIRECT)) {
        if (!automatedRtspHandling) {
            // forward message 
            for (RtspRequestListener listener : this.requestListener) {
                listener.redirectRequestReceived(request, RtspParticipant.newInstance(channel));
            }
        } else {
            sendNotImplemented(channel, request);
        }
    }
    if (request.getMethod().equals(RtspMethods.RECORD)) {
        if (!automatedRtspHandling) {
            // forward message 
            for (RtspRequestListener listener : this.requestListener) {
                listener.recordRequestReceived(request, RtspParticipant.newInstance(channel));
            }
        } else {
            sendNotImplemented(channel, request);
        }
    }
}