/// <summary> /// Gets the assiociate OK response with the request. /// </summary> /// <returns>an Rtsp response correcponding to request.</returns> public virtual RtspResponse CreateResponse() { RtspResponse returnValue = new RtspResponse(); returnValue.ReturnCode = 200; returnValue.CSeq = this.CSeq; if (this.Headers.ContainsKey(RtspHeaderNames.Session)) { returnValue.Headers [RtspHeaderNames.Session] = this.Headers [RtspHeaderNames.Session]; } return(returnValue); }
/// <summary> /// Create the good type of Rtsp Message from the header. /// </summary> /// <param name="aRequestLine">A request line.</param> /// <returns>An Rtsp message</returns> public static RtspMessage GetRtspMessage(string aRequestLine) { // We can't determine the message if (string.IsNullOrEmpty(aRequestLine)) { return(new RtspMessage()); } string [] requestParts = aRequestLine.Split(new char [] { ' ' }, 3); RtspMessage returnValue; if (requestParts.Length == 3) { // A request is : Method SP Request-URI SP RTSP-Version // A response is : RTSP-Version SP Status-Code SP Reason-Phrase // RTSP-Version = "RTSP" "/" 1*DIGIT "." 1*DIGIT if (_rtspVersionTest.IsMatch(requestParts [2])) { returnValue = RtspRequest.GetRtspRequest(requestParts); } else if (_rtspVersionTest.IsMatch(requestParts [0])) { returnValue = new RtspResponse(); } else { _logger.Warn(CultureInfo.InvariantCulture, "Got a strange message {0}", aRequestLine); returnValue = new RtspMessage(); } } else { _logger.Warn(CultureInfo.InvariantCulture, "Got a strange message {0}", aRequestLine); returnValue = new RtspMessage(); } returnValue.Command = aRequestLine; return(returnValue); }