Esempio n. 1
0
        public void Connect()
        {
            Trace.WriteLine("RtspHandler::Connect()");
            _rtspClient.Connect();
            _rtspClient.SendOptions().Dispose();
            _rtspClient.SendDescribe().Dispose();

            var videoDesc = _rtspClient.SessionDescription.MediaDescriptions.First(d => d.MediaType == MediaType.video);
            var audioDesc = _rtspClient.SessionDescription.MediaDescriptions.First(d => d.MediaType == MediaType.audio);

            // a=fmtp:97 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH62EBUViuKxUdCAqKxXFYqOhAVFYrisVHQgKisVxWKjoQFRWK4rFR0ICorFcVio6ECSFITk8nyfk/k/J8nm5s00IEkKQnJ5Pk/J/J+T5PNzZprQCgC3I,aO48sA==
            _videoStreamInfo.Parameter = videoDesc.FmtpLine.Parts.ElementAt(1).Split(';').First(l => l.StartsWith(VideoParameterIdentifier)).Substring(VideoParameterIdentifier.Length);
            // a=fmtp:96 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1190
            _audioStreamInfo.Parameter = audioDesc.FmtpLine.Parts.ElementAt(1).Split(';').First(l => l.StartsWith(AudioParameterIdentifier)).Substring(AudioParameterIdentifier.Length);
            // a=rtpmap:97 H264/90000
            _videoStreamInfo.ClockRate = int.Parse(videoDesc.RtpMapLine.Parts.ElementAt(1).Split('/')[1]);
            // a=rtpmap:96 MPEG4-GENERIC/48000/2
            _audioStreamInfo.ClockRate = int.Parse(audioDesc.RtpMapLine.Parts.ElementAt(1).Split('/')[1]);
            Trace.WriteLine($"RtspHandler::Connect(): Video ClockRate={_videoStreamInfo.ClockRate} / Config={_videoStreamInfo.Parameter}");
            Trace.WriteLine($"RtspHandler::Connect(): Audio ClockRate={_audioStreamInfo.ClockRate} / Config={_audioStreamInfo.Parameter}");

            _rtspClient.Client.Logger              = _rtspClient.Logger;
            _rtspClient.Client.HandleFrameChanges  = false;
            _rtspClient.Client.RtpPacketReceieved += OnRtpPacketReceieved;
        }