public void Dispose() { if (rtspSession != null) { rtspSession.Dispose(); rtspSession = null; } }
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(); }
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(); }