List of usage examples for io.netty.handler.codec.rtsp RtspResponseStatuses BAD_REQUEST
HttpResponseStatus BAD_REQUEST
To view the source code for io.netty.handler.codec.rtsp RtspResponseStatuses BAD_REQUEST.
Click Source Link
From source file:org.mobicents.media.server.ctrl.rtsp.PlayAction.java
License:Open Source License
public FullHttpResponse call() throws Exception { FullHttpResponse response = null;/* www . ja va 2 s. co m*/ String sessionId = this.request.headers().get(RtspHeaders.Names.SESSION); String absolutePath = this.request.getUri(); URI uri = new URI(absolutePath); String path = uri.getPath(); String filePath = null; String trackID = null; int pos = path.indexOf("/trackID"); if (pos > 0) { filePath = path.substring(0, pos); trackID = path.substring(pos + 1); } else { filePath = path; } File f = new File(filePath); if (f.isDirectory() || !f.exists()) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } String sessionID = this.request.headers().get(RtspHeaders.Names.SESSION); if (sessionID == null) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.BAD_REQUEST); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } // determine session RtspSession session = rtspController.getSession(this.request.headers().get(RtspHeaders.Names.SESSION), false); if (session == null) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.SESSION_NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } Endpoint endpoint = (Endpoint) session.getAttribute("endpoint"); Player player = null;//(Player) endpoint.getComponent("player"); String rtpInfo = ""; double npt = 0; if (trackID != null) { // player.getMediaSource(trackID).start(); //TODO Add rtp-info field } else { List<String> trackIds = (List<String>) session.getAttribute("trackIds"); boolean first = true; for (String trackId : trackIds) { int rtpTime = 268435456 + (int) (Math.random() * (Integer.MAX_VALUE - 268435456)); // player.setRtpTime(trackId, rtpTime); if (first) { rtpInfo += "url=" + absolutePath + "/" + trackId + ";seq=1;rtptime=" + rtpTime; first = false; // npt = player.getNPT(trackId); } else { rtpInfo += ",url=" + absolutePath + "/" + trackId + ";seq=1;rtptime=" + rtpTime; } } //System.out.println("RTP-INfo = "+ rtpInfo+ " NPT = "+ npt); // player.start(); } response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.OK); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, session.getId()); response.headers().add(RtspHeaders.Names.RTP_INFO, rtpInfo); response.headers().add("Range", "npt=0.00000-" + npt); session.setState(SessionState.PLAYING); return response; }
From source file:org.mobicents.media.server.ctrl.rtsp.TeardownAction.java
License:Open Source License
public FullHttpResponse call() throws Exception { FullHttpResponse response = null;// www.ja v a 2s .co m String sessionId = this.request.headers().get(RtspHeaders.Names.SESSION); if (sessionId != null) { RtspSession session = this.rtspController.getSession(sessionId, false); if (session != null) { Endpoint endpoint = (Endpoint) session.getAttribute("endpoint"); if (endpoint != null) { endpoint.deleteAllConnections(); } response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.OK); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, session.getId()); session = null; return response; } else { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.SESSION_NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, sessionId); return response; } } else { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.BAD_REQUEST); response.headers().add(HttpHeaders.Names.SERVER, RtspController.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } }
From source file:org.mobicents.media.server.rtsp.action.DescribeAction.java
License:Open Source License
public FullHttpResponse call() throws Exception { FullHttpResponse response = null;/* www. ja v a2s .co m*/ URI objUri = new URI(this.request.getUri()); String srcUri = objUri.getPath(); SessionDescription sd = rtspProvider.getRtspManager().describe(srcUri); if (null == sd) { logger.warn("No srcUrl passed in request " + srcUri); response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.NOT_FOUND); response.headers().set(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().set(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } List<MediaDescription> mds = sd.getMediaDescriptions(false); if (null == mds || mds.isEmpty()) { logger.warn("No Media passed in request " + srcUri); response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.BAD_REQUEST); response.headers().set(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().set(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } //we hard-code here // sdp = "v=0\n" + // "o=- 3776780 3776780 IN IP4 127.0.0.1\n" + // "s=Mobicents Media Server\n" + // "c=IN IP4 127.0.0.1\n" + // "t=0 0\n" + // "m=audio 0 RTP/AVP 0 2 3 97 8\n" + // "b=AS:20\n"+ // "a=rtpmap:0 pcmu/8000\n" + // "a=rtpmap:2 g729/8000\n" + // "a=rtpmap:3 gsm/8000\n" + // "a=rtpmap:97 speex/8000\n" + // "a=rtpmap:8 pcma/8000\n" + // "a=control:audio\n"; // sdp = "v=0\n" + // "o=MobicentsMediaServer 6732605 6732605 IN IP4 127.0.0.1\n"+ // "s=session\n"+ // "c=IN IP4 127.0.0.1\n"+ // "t=0 0\n"+ // "m=audio 0 RTP/AVP 97\n"+ // "b=AS:20\n"+ // "a=rtpmap:97 mpeg4-generic/8000/2\n"+ // "a=control:trackID=4\n"+ // "a=fmtp:97 profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1590\n"+ // "a=mpeg4-esid:101\n"+ // "m=video 0 RTP/AVP 96\n"+ // "b=AS:76\n"+ // "a=rtpmap:96 MP4V-ES/90000\n"+ // "a=control:trackID=3\n"+ // "a=cliprect:0,0,242,192\n"+ // "a=framesize:96 192-242\n"+ // "a=fmtp:96 profile-level-id=1;config=000001B0F3000001B50EE040C0CF0000010000000120008440FA283020F2A21F\n"+ // "a=mpeg4-esid:201\n"; StringBuilder sdp = new StringBuilder(); try { // v=0\n sdp.append("v=").append("0").append("\n"); // o=- 3776780 3776780 IN IP4 127.0.0.1\n long randomSessionId = RandomUtils.nextLong(); sdp.append("o=").append("- ").append(randomSessionId).append(" ").append(randomSessionId).append(" ") .append(connection.getNetworkType()).append(" ").append(connection.getAddressType()).append(" ") .append(connection.getAddress()).append(" ").append("\n"); // s=Mobicents Media Server\n sdp.append("s=").append("Mobiecnts Rtsp Media Server").append("\n"); // c=IN IP4 127.0.0.1\n sdp.append("c=").append(connection.getNetworkType()).append(" ").append(connection.getAddressType()) .append(" ").append(connection.getAddress()).append(" ").append("\n"); // "t=0 0\n" sdp.append("t=").append("0 0").append("\n"); int mediaIndex = -1; for (MediaDescription md : mds) { mediaIndex++; Media media = md.getMedia(); String rtpmap = md.getAttribute("rtpmap"); String fmtp = md.getAttribute("fmtp"); String control = request.getUri() + "/trackID=" + mediaIndex; // m=audio 0 RTP/AVP 97\n sdp.append("m=").append(media.getMediaType()).append(" ").append("0 ").append("RTP/AVP"); List<Object> formats = media.getMediaFormats(true); for (Object format : formats) { sdp.append(" ").append(format); } sdp.append("\n"); // a=rtpmap:97 mpeg4-generic/8000/2\n sdp.append("a=").append(rtpmap).append("\n"); // a=control:trackID=4\n sdp.append("a=").append("control:").append(control).append("\n"); // a=rtpmap:96 MP4V-ES/90000\n sdp.append("a=").append("rtpmap:").append(rtpmap).append("\n"); // a=fmtp:97 profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1590\n sdp.append("a=").append("fmtp:").append(fmtp).append("\n"); } } catch (RuntimeException e) { logger.warn("There is no free endpoint: " + srcUri); response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.SERVICE_UNAVAILABLE); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } byte[] bytes = sdp.toString().getBytes("UTF-8"); response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.OK, Unpooled.copiedBuffer(bytes)); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(HttpHeaders.Names.CONTENT_TYPE, "application/sdp"); response.headers().add(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(bytes.length)); return response; }
From source file:org.mobicents.media.server.rtsp.action.PlayAction.java
License:Open Source License
public FullHttpResponse call() throws Exception { FullHttpResponse response = null;// www .j a v a 2 s . c o m String sessionId = this.request.headers().get(RtspHeaders.Names.SESSION); String absolutePath = this.request.getUri(); URI uri = new URI(absolutePath); String path = uri.getPath(); String filePath = null; String trackID = null; int pos = path.indexOf("/trackID"); if (pos > 0) { filePath = path.substring(0, pos); trackID = path.substring(pos + 1); } else { filePath = path; } File f = new File(filePath); if (f.isDirectory() || !f.exists()) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } String sessionID = this.request.headers().get(RtspHeaders.Names.SESSION); if (sessionID == null) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.BAD_REQUEST); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } // determine session RtspSession session = rtspController.getSession(this.request.headers().get(RtspHeaders.Names.SESSION), false); if (session == null) { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.SESSION_NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } Endpoint endpoint = (Endpoint) session.getAttribute("endpoint"); Player player = null;//(Player) endpoint.getComponent("player"); String rtpInfo = ""; double npt = 0; if (trackID != null) { // player.getMediaSource(trackID).start(); //TODO Add rtp-info field } else { List<String> trackIds = (List<String>) session.getAttribute("trackIds"); boolean first = true; for (String trackId : trackIds) { int rtpTime = 268435456 + (int) (Math.random() * (Integer.MAX_VALUE - 268435456)); // player.setRtpTime(trackId, rtpTime); if (first) { rtpInfo += "url=" + absolutePath + "/" + trackId + ";seq=1;rtptime=" + rtpTime; first = false; // npt = player.getNPT(trackId); } else { rtpInfo += ",url=" + absolutePath + "/" + trackId + ";seq=1;rtptime=" + rtpTime; } } //System.out.println("RTP-INfo = "+ rtpInfo+ " NPT = "+ npt); // player.start(); } response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.OK); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, session.getId()); response.headers().add(RtspHeaders.Names.RTP_INFO, rtpInfo); response.headers().add("Range", "npt=0.00000-" + npt); session.setState(SessionState.PLAYING); return response; }
From source file:org.mobicents.media.server.rtsp.action.TeardownAction.java
License:Open Source License
public FullHttpResponse call() throws Exception { FullHttpResponse response = null;/*from w ww.jav a 2 s .c om*/ String sessionId = this.request.headers().get(RtspHeaders.Names.SESSION); if (sessionId != null) { RtspSession session = this.rtspController.getSession(sessionId, false); if (session != null) { Endpoint endpoint = (Endpoint) session.getAttribute("endpoint"); if (endpoint != null) { endpoint.deleteAllConnections(); } response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.OK); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, session.getId()); session = null; return response; } else { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.SESSION_NOT_FOUND); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); response.headers().add(RtspHeaders.Names.SESSION, sessionId); return response; } } else { response = new DefaultFullHttpResponse(RtspVersions.RTSP_1_0, RtspResponseStatuses.BAD_REQUEST); response.headers().add(HttpHeaders.Names.SERVER, RtspProvider.SERVER); response.headers().add(RtspHeaders.Names.CSEQ, this.request.headers().get(RtspHeaders.Names.CSEQ)); return response; } }
From source file:sas.systems.imflux.session.rtsp.SimpleRtspSession.java
License:Apache License
/** * Handles a SETUP request by checking the specified headers and sending a corresponding response. * There is no logic for setting up the the RTP stream or something else, because we do not know the details * about it./*from w w w. j a v a 2 s.c o m*/ * * @param channel * @param request */ private void handleSetupRequest(Channel channel, HttpRequest request) { if (!automatedRtspHandling) { // forward messages for (RtspRequestListener listener : this.requestListener) { listener.setupRequestReceived(request, RtspParticipant.newInstance(channel)); } return; } // handle setup request RtspParticipant participant; final HttpHeaders reqHeaders = request.headers(); final String cseq = reqHeaders.get(RtspHeaders.Names.CSEQ); final String transport = reqHeaders.get(RtspHeaders.Names.TRANSPORT); // if client already has a session id, this server does not allow aggregation final String session = reqHeaders.get(RtspHeaders.Names.SESSION); if (session != null) { sendResponse(RtspResponseStatuses.AGGREGATE_OPERATION_NOT_ALLOWED, cseq, channel); return; } // create participant and session id participant = RtspParticipant.newInstance(channel); final String sessionId = participant.setup(); this.participantSessions.put(sessionId, participant); // parse transport header and validate entries boolean validationError = false; final String[] entries = transport.split(";"); /* * this server expects at least 3 information strings: * - underlying streaming protocol: RTP * - a unicast connection * - the client ports for the data and control information */ if (entries.length < 3) { validationError = true; } if (!entries[0].contains("RTP")) { validationError = true; } if (!"unicast".equals(entries[1])) { validationError = true; } final int iOfEQ = entries[2].indexOf("="); final int iOfMin = entries[2].indexOf("-"); final int iEnd = entries[2].length(); final String dataPortString = entries[2].substring(iOfEQ + 1, iOfMin); final String controlPortString = entries[2].substring(iOfMin + 1, iEnd); int clientDataPort = 0, clientControlPort = 0; try { clientDataPort = Integer.valueOf(dataPortString); clientControlPort = Integer.valueOf(controlPortString); } catch (NumberFormatException e) { validationError = true; } if (validationError) { sendResponse(RtspResponseStatuses.BAD_REQUEST, cseq, channel); // or: // participant.sendMessage(aggOpNotAllowed); return; } // create transport string for response final int rtpDataPort = ((InetSocketAddress) localRtpParticipant.getDataDestination()).getPort(); final int rtpControlPort = ((InetSocketAddress) localRtpParticipant.getControlDestination()).getPort(); final StringBuilder transportResponse = new StringBuilder(); transportResponse.append(entries[0]).append(";").append(entries[1]).append(";") .append(RtspHeaders.Values.CLIENT_PORT + "=").append(clientDataPort).append("-") .append(clientControlPort).append(";").append(RtspHeaders.Values.SERVER_PORT + "=") .append(rtpDataPort).append("-").append(rtpControlPort); // send response final HttpResponse response = new DefaultHttpResponse(rtspVersion, RtspResponseStatuses.OK); final HttpHeaders headers = response.headers(); headers.add(RtspHeaders.Names.CSEQ, cseq); headers.add(RtspHeaders.Names.SESSION, sessionId); headers.add(RtspHeaders.Names.TRANSPORT, transportResponse.toString()); headers.add(RtspHeaders.Names.DATE, new Date()); // HttpHeaders takes care of formatting the date sendResponse(response, channel); }
From source file:sas.systems.unveiled.server.RtspMessageHandler.java
License:Apache License
@Override public void optionsRequestReceived(HttpRequest message, RtspParticipant participant) { final String seq = message.headers().get(RtspHeaders.Names.CSEQ); System.out.println(message);//from ww w .ja va 2s .co m if (seq != null) { try { final int cseq = Integer.valueOf(seq); participant.sendMessage(createOptionsResponse(cseq, this.optionsString)); return; } catch (NumberFormatException e) { // also send a 400 bad request (see below } } participant.sendMessage(createErrorResponse(RtspResponseStatuses.BAD_REQUEST, message.headers())); }
From source file:sas.systems.unveiled.server.RtspMessageHandler.java
License:Apache License
@Override public void announceRequestReceived(HttpRequest message, RtspParticipant participant) { final String seq = message.headers().get(RtspHeaders.Names.CSEQ); final String contentType = message.headers().get(RtspHeaders.Names.CONTENT_TYPE); final String authorization = message.headers().get(RtspHeaders.Names.AUTHORIZATION); System.out.println(message);//from w w w .j ava2 s . com if (authorization == null) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } else { if (!isAuthorized(authorization)) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } } if (message instanceof FullHttpRequest) { final FullHttpRequest fullResponse = (FullHttpRequest) message; final ByteBuf content = fullResponse.content(); if (seq != null && contentType != null && contentType.contains("sdp") && content != null) { // parse announce content final String fileName = retrieveFileName(fullResponse.getUri()); final SdpParser parser = new SdpParser(content); final String sessionId = participant.setup(); // setup stream handler with content of announce request final FileStreamHandler streamHandler = new FileStreamHandler(this.sm, participant); streamHandler.setFileName(fileName); streamHandler.setPayloadType(parser.getMediaType()); streamHandler.setAuthor(retrieveUsername(authorization)); streamHandler.setMediaType("video/mp4"); // save session info this.sessions.put(sessionId, streamHandler); // send response try { int cseq = Integer.valueOf(seq); participant.sendMessage(createAnnounceResponse(cseq, sessionId)); return; } catch (NumberFormatException e) { // send error message participant.sendMessage( createErrorResponse(RtspResponseStatuses.HEADER_FIELD_NOT_VALID, message.headers())); return; } } } // otherwise send error message participant.sendMessage(createErrorResponse(RtspResponseStatuses.BAD_REQUEST, message.headers())); }
From source file:sas.systems.unveiled.server.RtspMessageHandler.java
License:Apache License
@Override public void setupRequestReceived(HttpRequest message, RtspParticipant participant) { final String seq = message.headers().get(RtspHeaders.Names.CSEQ); final String session = message.headers().get(RtspHeaders.Names.SESSION); final String authorization = message.headers().get(RtspHeaders.Names.AUTHORIZATION); final String transport = message.headers().get(RtspHeaders.Names.TRANSPORT); System.out.println(message);// w w w. j a va 2s .c o m // check authorization if (authorization == null) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } else { if (!isAuthorized(authorization)) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } } // extract transport information if (seq != null && session != null && transport != null) { int cseq = 0; try { cseq = Integer.valueOf(seq); } catch (NumberFormatException e) { participant.sendMessage( createErrorResponse(RtspResponseStatuses.HEADER_FIELD_NOT_VALID, message.headers())); return; } FileStreamHandler handler = this.sessions.get(session); if (handler == null) { participant.sendMessage( createErrorResponse(RtspResponseStatuses.SESSION_NOT_FOUND, message.headers())); return; } // parse transport header and validate entries final InetSocketAddress remote = (InetSocketAddress) participant.getRemoteAddress(); final boolean validationError = parseTransportHeader(transport, handler.getParticipant(), remote.getHostName()); if (!validationError) { participant.sendMessage( createErrorResponse(RtspResponseStatuses.HEADER_FIELD_NOT_VALID, message.headers())); return; } participant.sendMessage( createSetupResponse(cseq, session, buildTransportString(transport, handler.getSsrc() + ""))); } // send error message participant.sendMessage(createErrorResponse(RtspResponseStatuses.BAD_REQUEST, message.headers())); }
From source file:sas.systems.unveiled.server.RtspMessageHandler.java
License:Apache License
@Override public void teardownRequestReceived(HttpRequest message, RtspParticipant participant) { final String seq = message.headers().get(RtspHeaders.Names.CSEQ); final String session = message.headers().get(RtspHeaders.Names.SESSION); final String authorization = message.headers().get(RtspHeaders.Names.AUTHORIZATION); System.out.println(message);//from w w w. j a v a2 s. c o m // check authorization if (authorization == null) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } else { if (!isAuthorized(authorization)) { participant.sendMessage(createErrorResponse(RtspResponseStatuses.UNAUTHORIZED, message.headers())); return; } } // extract transport information if (seq != null && session != null) { int cseq = 0; try { cseq = Integer.valueOf(seq); } catch (NumberFormatException e) { participant.sendMessage( createErrorResponse(RtspResponseStatuses.HEADER_FIELD_NOT_VALID, message.headers())); return; } FileStreamHandler handler = this.sessions.get(session); if (handler == null) { participant.sendMessage( createErrorResponse(RtspResponseStatuses.SESSION_NOT_FOUND, message.headers())); return; } // stop receiving data and close all resources handler.tieUp(); // send response participant.sendMessage(createTeardownResponse(cseq, session)); } participant.sendMessage(createErrorResponse(RtspResponseStatuses.BAD_REQUEST, message.headers())); }