예제 #1
0
        public RTSPChannel(RTSPChannelParameters parameters)
        {
            Parameters = parameters;

            unicastUdpClient = new UnicastUdpClient(Parameters.RTPPort);
            rtpPacketHandler = new RtpPacketHandler(parameters.SSRT);

            unicastUdpClient.UdpPacketRecived += rtpPacketHandler.HandleRtpPacket;
            payloadHandler = PayloadHandlerFactory.Create(Parameters.Codec);

            rtpPacketHandler.RtpPacketRecieved += payloadHandler.HandleRtpPacket;
            payloadHandler.FrameReceived       += PayloadHandler_FrameRecived;

            rtcpReporter = new RtcpReporter(Parameters.RTCPPort, Parameters.SampleRate);

            rtpPacketHandler.RtpPacketRecieved += rtcpReporter.HandleRtpPacket;
            rtcpReporter.RtpTimeReporting      += videoRtcpClient_OnRtpTimeReporting;

            rtcpReporter.SessionTimeCorrecting += videoRtcpClient_OnRtpTimeCorrecting;
        }
예제 #2
0
        public RTSPChannel(RTSPChannelParameters parameters)
        {
            Parameters = parameters;

            unicastUdpClient = new UnicastUdpClient(Parameters.RTPPort);
            rtpPacketHandler = new RtpPacketHandler(parameters.SSRT);

            unicastUdpClient.UdpPacketRecived += rtpPacketHandler.HandleRtpPacket;
            payloadHandler = PayloadHandlerFactory.Create(Parameters.Codec);

            rtpPacketHandler.RtpPacketRecieved += payloadHandler.HandleRtpPacket;
            payloadHandler.FrameReceived += PayloadHandler_FrameRecived;

            rtcpReporter = new RtcpReporter(Parameters.RTCPPort, Parameters.SampleRate);

            rtpPacketHandler.RtpPacketRecieved += rtcpReporter.HandleRtpPacket;
            rtcpReporter.RtpTimeReporting += videoRtcpClient_OnRtpTimeReporting;

            rtcpReporter.SessionTimeCorrecting += videoRtcpClient_OnRtpTimeCorrecting;
        }
예제 #3
0
        public void Start()
        {
            RTSPChannelParameters videoParameters = new RTSPChannelParameters {};
            RTSPChannelParameters audioParameters = new RTSPChannelParameters {};

            rtspSession = RTSPSession.Open(this.MediaDevice.ONVIF.GetCurrentMediaProfileRtspStreamUri().AbsoluteUri);
            //rtspSession.RTSPServerResponse += new RTSPSession.RTSPResponseHandler(rtsp_RTSPServerResponse);

            // OPTIONS возвращает команды сервера
            // OPTIONS, DESCRIBE, SETUP, PLAY, PAUSE, GET_PARAMETER, TEARDOWN, SET_PARAMETER
            RTSPResponse respons = rtspSession.Options();

            // DESCRIBE возвращает SDP файл
            respons = rtspSession.Describe();

            string ContentBase = respons.ContentBase;

            // Парсим SDP пакет
            sdp = SDP.Parse(respons.Body);
            videoParameters.Codec = sdp.GetCodec(MediaType: "video");
            videoParameters.SampleRate = sdp.GetSampleRate(MediaType: "video");

            string VideoControl = sdp.GetControl(MediaType: "video");

            audioParameters.Codec = sdp.GetCodec(MediaType: "audio");
            audioParameters.SampleRate = sdp.GetSampleRate(MediaType: "audio");

            string AudioControl = sdp.GetControl(MediaType: "audio");

            string VideoSetupUri = String.Format("{0}{1}", ContentBase, VideoControl);
            string AudioSetupUri = String.Format("{0}{1}", ContentBase, AudioControl);

            int[] ports = GetPortRange(4);

            videoParameters.RTPPort = ports[0];
            videoParameters.RTCPPort = ports[1];

            audioParameters.RTPPort= ports[2];
            audioParameters.RTCPPort = ports[3];

            respons = rtspSession.Setup(VideoSetupUri, videoParameters.RTPPort, videoParameters.RTCPPort);
            rtspSession.Parameters.Session = respons.Session;

            videoParameters.SSRT = respons.SSRT;

            respons = rtspSession.Setup(AudioSetupUri, audioParameters.RTPPort, audioParameters.RTCPPort, rtspSession.Parameters.Session);

            audioParameters.SSRT = respons.SSRT;

            respons = rtspSession.Play(rtspSession.Parameters.Session);

            videoChannel = new RTSPChannel(videoParameters);
            audioChannel = new RTSPChannel(audioParameters);

            //audioChannel.DataRecieved += MediaDevice.AVProcessor.AudioDataRecieved;
            //videoChannel.DataRecieved += MediaDevice.AVProcessor.VideoDataRecieved;

            audioChannel.DataRecieved += MediaDevice.Decoder.AudioDataRecieved;
            videoChannel.DataRecieved += MediaDevice.Decoder.VideoDataRecieved;

            videoChannel.StartRecieving();
            audioChannel.StartRecieving();
        }
예제 #4
0
        public void Start()
        {
            RTSPChannelParameters videoParameters = new RTSPChannelParameters {
            };
            RTSPChannelParameters audioParameters = new RTSPChannelParameters {
            };

            rtspSession = RTSPSession.Open(this.MediaDevice.ONVIF.GetCurrentMediaProfileRtspStreamUri().AbsoluteUri);
            //rtspSession.RTSPServerResponse += new RTSPSession.RTSPResponseHandler(rtsp_RTSPServerResponse);


            // OPTIONS возвращает команды сервера
            // OPTIONS, DESCRIBE, SETUP, PLAY, PAUSE, GET_PARAMETER, TEARDOWN, SET_PARAMETER
            RTSPResponse respons = rtspSession.Options();

            // DESCRIBE возвращает SDP файл
            respons = rtspSession.Describe();

            string ContentBase = respons.ContentBase;

            // Парсим SDP пакет
            sdp = SDP.Parse(respons.Body);
            videoParameters.Codec      = sdp.GetCodec(MediaType: "video");
            videoParameters.SampleRate = sdp.GetSampleRate(MediaType: "video");

            string VideoControl = sdp.GetControl(MediaType: "video");

            audioParameters.Codec      = sdp.GetCodec(MediaType: "audio");
            audioParameters.SampleRate = sdp.GetSampleRate(MediaType: "audio");

            string AudioControl = sdp.GetControl(MediaType: "audio");

            string VideoSetupUri = String.Format("{0}{1}", ContentBase, VideoControl);
            string AudioSetupUri = String.Format("{0}{1}", ContentBase, AudioControl);

            int[] ports = GetPortRange(4);

            videoParameters.RTPPort  = ports[0];
            videoParameters.RTCPPort = ports[1];

            audioParameters.RTPPort  = ports[2];
            audioParameters.RTCPPort = ports[3];


            respons = rtspSession.Setup(VideoSetupUri, videoParameters.RTPPort, videoParameters.RTCPPort);
            rtspSession.Parameters.Session = respons.Session;

            videoParameters.SSRT = respons.SSRT;

            respons = rtspSession.Setup(AudioSetupUri, audioParameters.RTPPort, audioParameters.RTCPPort, rtspSession.Parameters.Session);

            audioParameters.SSRT = respons.SSRT;


            respons = rtspSession.Play(rtspSession.Parameters.Session);

            videoChannel = new RTSPChannel(videoParameters);
            audioChannel = new RTSPChannel(audioParameters);

            //audioChannel.DataRecieved += MediaDevice.AVProcessor.AudioDataRecieved;
            //videoChannel.DataRecieved += MediaDevice.AVProcessor.VideoDataRecieved;

            audioChannel.DataRecieved += MediaDevice.Decoder.AudioDataRecieved;
            videoChannel.DataRecieved += MediaDevice.Decoder.VideoDataRecieved;

            videoChannel.StartRecieving();
            audioChannel.StartRecieving();
        }