Beispiel #1
0
        public void CreatePlayRequest_ValidProperties()
        {
            var factory = new RtspRequestMessageFactory(FakeUri, UserAgent);

            RtspRequestMessage request = factory.CreatePlayRequest();

            Assert.AreEqual(RtspMethod.PLAY, request.Method);
            Assert.AreEqual(FakeUri, request.ConnectionUri);
            Assert.AreEqual(UserAgent, request.UserAgent);
        }
Beispiel #2
0
        public void CreateGetParameterRequest_ValidProperties()
        {
            var factory = new RtspRequestMessageFactory(FakeUri, UserAgent);

            RtspRequestMessage request = factory.CreateGetParameterRequest();

            Assert.AreEqual(RtspMethod.GET_PARAMETER, request.Method);
            Assert.AreEqual(FakeUri, request.ConnectionUri);
            Assert.AreEqual(UserAgent, request.UserAgent);
        }
Beispiel #3
0
        public void EnsureCSeqIncreasesAfterEveryCreatedRequest()
        {
            var factory = new RtspRequestMessageFactory(FakeUri, null);

            RtspRequestMessage request1 = factory.CreateOptionsRequest();
            RtspRequestMessage request2 = factory.CreateDescribeRequest();

            Assert.AreEqual(1u, request1.CSeq);
            Assert.AreEqual(2u, request2.CSeq);
        }
Beispiel #4
0
        public void CreatePlayRequest_ContentBaseAndSessionAreSet_ValidProperties()
        {
            var factory = new RtspRequestMessageFactory(FakeUri, UserAgent)
            {
                SessionId   = "testSessionId",
                ContentBase = new Uri("http://127.0.0.1/base")
            };

            RtspRequestMessage request = factory.CreatePlayRequest();

            Assert.AreEqual(factory.SessionId, request.Headers.Get("Session"));
            Assert.AreEqual(factory.ContentBase, request.ConnectionUri);
        }
Beispiel #5
0
        public void CreateSetupUdpUnicastRequest_ValidProperties()
        {
            const string testTrackName = "testTrack";
            var          factory       = new RtspRequestMessageFactory(FakeUri, UserAgent);

            RtspRequestMessage request = factory.CreateSetupUdpUnicastRequest(testTrackName, 1, 2);

            Assert.AreEqual(RtspMethod.SETUP, request.Method);
            Assert.AreEqual(FakeUri + "testTrack", request.ConnectionUri.ToString());
            Assert.AreEqual(UserAgent, request.UserAgent);
            string transportHeaderValue = request.Headers.Get("Transport");

            Assert.IsTrue(transportHeaderValue.Contains("unicast"));
            Assert.IsTrue(transportHeaderValue.Contains($"{1}-{2}"));
        }
Beispiel #6
0
        public Task <RtspResponseMessage> ExecuteRequest(RtspRequestMessage requestMessage, CancellationToken token,
                                                         int responseReadPortionSize = 0)
        {
            token.ThrowIfCancellationRequested();

            switch (requestMessage.Method)
            {
            case RtspMethod.OPTIONS:
                return(Task.FromResult(OptionsResponse));

            case RtspMethod.DESCRIBE:
                return(Task.FromResult(DescribeResponse));

            case RtspMethod.SETUP:
                return(Task.FromResult(SetupInterleavedResponse));

            case RtspMethod.PLAY:
                return(Task.FromResult(PlayResponse));

            default:
                throw new ArgumentException($"Method \"{requestMessage.Method}\" is not supported",
                                            nameof(requestMessage));
            }
        }
Beispiel #7
0
 public Task <RtspResponseMessage> EnsureExecuteRequest(RtspRequestMessage requestMessage,
                                                        CancellationToken token, int responseReadPortionSize = 0)
 {
     return(ExecuteRequest(requestMessage, token, responseReadPortionSize));
 }
Beispiel #8
0
 public Task SendRequestAsync(RtspRequestMessage requestMessage, CancellationToken token)
 {
     return(Task.CompletedTask);
 }