An Rtsp Request
Inheritance: Rtsp.Messages.RtspMessage
Ejemplo n.º 1
0
        public void GetRtspMessageRequest(string requestLine, RtspRequest.RequestType requestType)
        {
            RtspMessage oneMessage = RtspMessage.GetRtspMessage(requestLine);
            Assert.IsInstanceOf<RtspRequest>(oneMessage);

            RtspRequest oneRequest = oneMessage as RtspRequest;
            Assert.AreEqual(requestType, oneRequest.RequestTyped);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the Rtsp request.
        /// </summary>
        /// <param name="aRequestParts">A request parts.</param>
        /// <returns>the parsed request</returns>
        internal static RtspMessage GetRtspRequest(string[] aRequestParts)
        {
            // <pex>
            Debug.Assert(aRequestParts != (string[])null, "aRequestParts");
            Debug.Assert(aRequestParts.Length != 0, "aRequestParts.Length == 0");
            // </pex>
            // we already know this is a Request
            RtspRequest returnValue;

            switch (ParseRequest(aRequestParts[0]))
            {
            case RequestType.OPTIONS:
                returnValue = new RtspRequestOptions();
                break;

            case RequestType.SETUP:
                returnValue = new RtspRequestSetup();
                break;

            case RequestType.PLAY:
                returnValue = new RtspRequestPlay();
                break;

            /*
             * case RequestType.DESCRIBE:
             * break;
             * case RequestType.ANNOUNCE:
             * break;
             * case RequestType.GET_PARAMETER:
             * break;
             *
             * case RequestType.PAUSE:
             * break;
             *
             * case RequestType.RECORD:
             * break;
             * case RequestType.REDIRECT:
             * break;
             *
             * case RequestType.SET_PARAMETER:
             * break;
             * case RequestType.TEARDOWN:
             * break;
             */
            case RequestType.UNKNOWN:
            default:
                returnValue = new RtspRequest();
                break;
            }



            return(returnValue);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the Rtsp request.
        /// </summary>
        /// <param name="aRequestParts">A request parts.</param>
        /// <returns>the parsed request</returns>
        internal static RtspMessage GetRtspRequest(string[] aRequestParts, ILogger logger)
        {
            // <pex>
            Debug.Assert(aRequestParts != (string[])null, "aRequestParts");
            Debug.Assert(aRequestParts.Length != 0, "aRequestParts.Length == 0");
            // </pex>
            // we already know this is a Request
            RtspRequest returnValue;

            switch (ParseRequest(aRequestParts[0]))
            {
            case RequestType.OPTIONS:
                returnValue = new RtspRequestOptions(logger);
                break;

            case RequestType.DESCRIBE:
                returnValue = new RtspRequestDescribe(logger);
                break;

            case RequestType.SETUP:
                returnValue = new RtspRequestSetup(logger);
                break;

            case RequestType.PLAY:
                returnValue = new RtspRequestPlay(logger);
                break;

            case RequestType.PAUSE:
                returnValue = new RtspRequestPause(logger);
                break;

            case RequestType.TEARDOWN:
                returnValue = new RtspRequestTeardown(logger);
                break;

            case RequestType.GET_PARAMETER:
                returnValue = new RtspRequestGetParameter(logger);
                break;

            case RequestType.ANNOUNCE:
                returnValue = new RtspRequestAnnounce(logger);
                break;

            case RequestType.RECORD:
                returnValue = new RtspRequestRecord(logger);
                break;

            /*
             * case RequestType.REDIRECT:
             * break;
             *
             * case RequestType.SET_PARAMETER:
             * break;
             */
            case RequestType.UNKNOWN:
            default:
                returnValue = new RtspRequest(logger);
                break;
            }



            return(returnValue);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the Rtsp request.
        /// </summary>
        /// <param name="aRequestParts">A request parts.</param>
        /// <returns>the parsed request</returns>
        internal static RtspMessage GetRtspRequest(string[] aRequestParts)
        {
            // <pex>
            Debug.Assert(aRequestParts != (string[])null, "aRequestParts");
            Debug.Assert(aRequestParts.Length != 0, "aRequestParts.Length == 0");
            // </pex>
            // we already know this is a Request
            RtspRequest returnValue;
            switch (ParseRequest(aRequestParts[0]))
            {
                case RequestType.OPTIONS:
                    returnValue = new RtspRequestOptions();
                    break;
                case RequestType.SETUP:
                    returnValue = new RtspRequestSetup();
                    break;
                case RequestType.PLAY:
                    returnValue = new RtspRequestPlay();
                    break;
                    /*
                case RequestType.DESCRIBE:
                    break;
                case RequestType.ANNOUNCE:
                    break;
                case RequestType.GET_PARAMETER:
                    break;

                case RequestType.PAUSE:
                    break;

                case RequestType.RECORD:
                    break;
                case RequestType.REDIRECT:
                    break;

                case RequestType.SET_PARAMETER:
                    break;
                case RequestType.TEARDOWN:
                    break;
                     */
                case RequestType.UNKNOWN:
                default:
                    returnValue = new RtspRequest();
                    break;
            }

            return returnValue;
        }