Exemple #1
0
 /// <summary>
 /// Forwards media from the SIP session to the WebRTC session.
 /// </summary>
 /// <param name="mediaType">The type of media.</param>
 /// <param name="rtpPacket">The RTP packet received on the SIP session.</param>
 private static void ForwardMedia(SDPMediaTypesEnum mediaType, RTPPacket rtpPacket)
 {
     if (_webRtcSession != null)
     {
         _webRtcSession.SendMedia(mediaType, (uint)rtpPacket.Payload.Length, rtpPacket.Payload);
     }
 }
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);
            }
        }