Beispiel #1
0
            public RtspRequest Build()
            {
                var request = new RtspRequest(_method, _uri);

                foreach (var entry in _headers)
                {
                    request.Headers[entry.Key] = entry.Value;
                }

                return(request);
            }
Beispiel #2
0
        public static RtspMessage CreateNewMessage(string[] parts, IPEndPoint endpoint)
        {
            if (parts == null || parts.Length < 3)
            {
                throw new RtspMessageParseException("Unable to parse invalid RtspMessage.");
            }

            try
            {
                if (StartLineTest.IsMatch(parts[2]))
                {
                    LOG.Debug($"Detected RtspRequest '{parts[0]} {parts[1]} {parts[2]}'");
                    var request = new RtspRequest(parts);
                    request.RemoteEndpoint = endpoint;

                    return(request);
                }
                else if (StartLineTest.IsMatch(parts[0]))
                {
                    LOG.Debug($"Detected RtspResponse '{parts[0]} {parts[1]} {parts[2]}'");
                    var response = new RtspResponse(parts);
                    response.RemoteEndpoint = endpoint;

                    return(response);
                }

                throw new RtspMessageParseException($"Received malformed RTSPMessage start line '{parts[0]} {parts[1]} {parts[2]}'");
            }
            catch (Exception e)
            {
                if (e is RtspMessageParseException)
                {
                    throw e;
                }

                throw new RtspMessageParseException($"Unable to parse RTSP message, reason: {e.Message}", e);
            }
        }