GetRtspRequest() static private method

Gets the Rtsp request.
static private GetRtspRequest ( string aRequestParts ) : Rtsp.Messages.RtspMessage
aRequestParts string A request parts.
return Rtsp.Messages.RtspMessage
Esempio n. 1
0
        /// <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, ILogger logger)
        {
            // We can't determine the message
            if (string.IsNullOrEmpty(aRequestLine))
            {
                return(new RtspMessage(logger));
            }
            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, logger);
                }
                else if (_rtspVersionTest.IsMatch(requestParts[0]))
                {
                    returnValue = new RtspResponse(logger);
                }
                else
                {
                    logger.Warn(CultureInfo.InvariantCulture, "Got a strange message {0}", aRequestLine);
                    returnValue = new RtspMessage(logger);
                }
            }
            else
            {
                logger.Warn(CultureInfo.InvariantCulture, "Got a strange message {0}", aRequestLine);
                returnValue = new RtspMessage(logger);
            }

            returnValue.Command = aRequestLine;
            return(returnValue);
        }
Esempio n. 2
0
        /// <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
                {
                    System.Diagnostics.Debug.WriteLine($"Got a strange message {aRequestLine}");
                    returnValue = new RtspMessage();
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Got a strange message {aRequestLine}");
                returnValue = new RtspMessage();
            }
            returnValue.Command = aRequestLine;
            return(returnValue);
        }