コード例 #1
0
        private void ProcessSetupRequest(RtspResponse message)
        {
            // If we get a reply to SETUP (which was our third command), then process then send PLAY

            // Got Reply to SETUP
            Logger.Info("Got reply from Setup. Session is " + message.Session);

            session = message.Session; // Session value used with Play, Pause, Teardown

            // Check the Transport header
            if (message.Headers.ContainsKey(RtspHeaderNames.Transport))
            {
                RtspTransport transport = RtspTransport.Parse(message.Headers[RtspHeaderNames.Transport]);
                // Check if Transport header includes Multicast
                if (transport.IsMulticast)
                {
                    String multicastAddress = transport.Destination;
                    videoDataChannel = transport.Port.First;
                    videoRTCPChannel = transport.Port.Second;

                    // Create the Pair of UDP Sockets in Multicast mode
                    udpPair = new UDPSocketPair(multicastAddress, videoDataChannel, multicastAddress, videoRTCPChannel);
                    udpPair.DataReceived += RtpDataReceived;
                    udpPair.Start();
                }
            }

            RtspRequest play_message = new RtspRequestPlay
            {
                RtspUri = new Uri(url),
                Session = session
            };

            rtspListener.SendMessage(play_message);
        }
コード例 #2
0
        private void ProcessSetupResponse(RtspResponse message)
        {
            rtspSession = message.Session; // Session value used with Play, Pause, Teardown
            Logger.Info($"RTSP session: {rtspSession}");

            if (message.Headers.ContainsKey(RtspHeaderNames.Transport))
            {
                RtspTransport transport = RtspTransport.Parse(message.Headers[RtspHeaderNames.Transport]);

                if (transport.IsMulticast)
                {
                    string multicastAddress = transport.Destination;
                    videoDataChannel = transport.Port.First;
                    videoRTCPChannel = transport.Port.Second;

                    // Create the Pair of UDP Sockets in Multicast mode
                    udpSocketPair = new UDPSocketPair(multicastAddress, videoDataChannel, multicastAddress, videoRTCPChannel);
                    udpSocketPair.DataReceived += RtpDataReceived;
                    udpSocketPair.Start();
                }
            }

            if (_suspendTransfer)
            {
                // Transfer suspended. Set state to playing but do not issue play request.
                // Play request will be sent upon resume.
                _currentState = State.Playing;
                return;
            }
            _currentState = State.Paused;
            PostRequest(new RtspRequestPlay
            {
                RtspUri = new Uri(rtspUrl),
                Session = rtspSession
            });
        }