Example #1
0
 public SIPClient(SIPTransport sipTransport, RTPMediaSessionManager rtpMediaSessionManager)
 {
     m_sipTransport           = sipTransport;
     m_rtpMediaSessionManager = rtpMediaSessionManager;
     m_userAgent = new SIPUserAgent(m_sipTransport, null);
     m_userAgent.ClientCallTrying    += CallTrying;
     m_userAgent.ClientCallRinging   += CallRinging;
     m_userAgent.ClientCallAnswered  += CallAnswered;
     m_userAgent.ClientCallFailed    += CallFailed;
     m_userAgent.OnCallHungup        += CallFinished;
     m_userAgent.ServerCallCancelled += IncomingCallCancelled;
     m_userAgent.OnTransferNotify    += OnTransferNotify;
 }
Example #2
0
        private async Task Initialize()
        {
            await _sipTransportManager.InitialiseSIP();

            var mediaSessionFactory = new RTPMediaSessionManager(_mediaManager, _musicOnHold);
            var sipClient           = new SIPClient(_sipTransportManager.SIPTransport, mediaSessionFactory);

            sipClient.CallAnswer        += SIPCallAnswered;
            sipClient.CallEnded         += ResetToCallStartState;
            sipClient.StatusMessage     += (client, message) => { SetStatusText(lbl_status, message); };
            sipClient.RemotePutOnHold   += RemotePutOnHold;
            sipClient.RemoteTookOffHold += RemoteTookOffHold;

            _sipClients = sipClient;

            string listeningEndPoints = null;

            foreach (var sipChannel in _sipTransportManager.SIPTransport.GetSIPChannels())
            {
                SIPEndPoint sipChannelEP = sipChannel.ListeningSIPEndPoint.CopyOf();
                sipChannelEP.ChannelID = null;
                listeningEndPoints    += (listeningEndPoints == null) ? sipChannelEP.ToString() : $", {sipChannelEP}";
            }

            _sipRegistrationClient = new SIPRegistrationUserAgent(
                _sipTransportManager.SIPTransport,
                null,
                null,
                new SIPURI(m_sipUsername, m_sipServer, null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp),
                m_sipUsername,
                m_sipPassword,
                null,
                m_sipServer,
                new SIPURI(m_sipUsername, IPAddress.Any.ToString(), null),
                180,
                null,
                null,
                (message) => { logger.Debug(message); });

            _sipRegistrationClient.Start();
        }