Exemple #1
0
        private static void SDPAnswerReceived(WebRtcSession webRtcSession, string sdpAnswer)
        {
            try
            {
                logger.LogDebug("Answer SDP: " + sdpAnswer);

                var answerSDP = SDP.ParseSDPDescription(sdpAnswer);

                webRtcSession.SdpSessionID      = answerSDP.SessionId;
                webRtcSession.RemoteIceUser     = answerSDP.IceUfrag;
                webRtcSession.RemoteIcePassword = answerSDP.IcePwd;

                // All browsers seem to have gone to trickling ICE candidates now but just
                // in case one or more are given we can start the STUN dance immediately.
                if (answerSDP.IceCandidates != null)
                {
                    foreach (var iceCandidate in answerSDP.IceCandidates)
                    {
                        webRtcSession.AppendRemoteIceCandidate(iceCandidate);
                    }
                }

                OnMediaSampleReady += webRtcSession.SendMedia;

                if (_mfSampleGrabber.Paused)
                {
                    _mfSampleGrabber.Start();
                }
            }
            catch (Exception excp)
            {
                logger.LogError("Exception SDPAnswerReceived. " + excp.Message);
            }
        }
Exemple #2
0
        private static void SDPAnswerReceived(WebRtcSession webRtcSession, string sdpAnswer)
        {
            try
            {
                logger.LogDebug("Answer SDP: " + sdpAnswer);

                var answerSDP = SDP.ParseSDPDescription(sdpAnswer);

                webRtcSession.SdpSessionID      = answerSDP.SessionId;
                webRtcSession.RemoteIceUser     = answerSDP.IceUfrag;
                webRtcSession.RemoteIcePassword = answerSDP.IcePwd;

                // All browsers seem to have gone to trickling ICE candidates now but just
                // in case one or more are given we can start the STUN dance immediately.
                if (answerSDP.IceCandidates != null)
                {
                    foreach (var iceCandidate in answerSDP.IceCandidates)
                    {
                        webRtcSession.AppendRemoteIceCandidate(iceCandidate);
                    }
                }

                OnTestPatternSampleReady += (timestamp, sample) =>
                {
                    try
                    {
                        webRtcSession.SendMedia(SDPMediaTypesEnum.video, timestamp, sample);
                    }
                    catch (Exception sendExcp)
                    {
                        logger.LogWarning("Exception OnTestPatternSampleReady. " + sendExcp.Message);
                        webRtcSession.Close();
                    }
                };
            }
            catch (Exception excp)
            {
                logger.LogError("Exception SDPAnswerReceived. " + excp.Message);
            }
        }