Example #1
0
        public RTSPRequest(RTSPMethodsEnum method, string url)
        {
            RTSPHeaderParserError urlParserError = RTSPHeaderParserError.None;

            try
            {
                Method = method;

                URL = RTSPURL.ParseRTSPURL(url, out urlParserError);
                if (urlParserError != RTSPHeaderParserError.None)
                {
                    throw new ApplicationException("Error parsing RTSP URL, " + urlParserError.ToString() + ".");
                }

                RTSPVersion = m_rtspFullVersion;
            }
            catch (Exception excp)
            {
                Logger.Logger.Error("Exception RTSPRequest Ctor. ->" + excp.Message + ".");
            }
        }
Example #2
0
        public static RTSPURL ParseRTSPURL(string url, out RTSPHeaderParserError parserError)
        {
            try
            {
                parserError = RTSPHeaderParserError.None;

                RTSPURL rtspURL = new RTSPURL();

                if (url == null || url.Trim().Length == 0)
                {
                    throw new ApplicationException("An RTSP URI cannot be parsed from an empty string.");
                }
                else
                {
                     int transAddrPosn = url.IndexOf(TRANSPORT_ADDR_SEPARATOR);

                     if (transAddrPosn == -1)
                     {
                         parserError = RTSPHeaderParserError.MandatoryColonMissing;
                         return null;
                     }
                     else
                     {
                         rtspURL.URLTransport = url.Substring(0, transAddrPosn);
                         string urlHostPortion = url.Substring(transAddrPosn + TRANSPORT_ADDR_SEPARATOR.Length);

                         int hostDelimIndex = urlHostPortion.IndexOf(HOST_ADDR_DELIMITER);
                         if (hostDelimIndex != -1)
                         {
                             rtspURL.Host = urlHostPortion.Substring(0, hostDelimIndex);
                             rtspURL.Path = urlHostPortion.Substring(hostDelimIndex);
                         }
                         else
                         {
                             rtspURL.Host = urlHostPortion;
                         }
                     }

                    return rtspURL;
                }
            }
            catch (ApplicationException appExcp)
            {
                throw appExcp;
            }
            catch (Exception excp)
            {
                throw new ApplicationException("There was an exception parsing an RTSP URL. " + excp.Message + " url=" + url);
            }
        }