Ejemplo n.º 1
0
        /// <summary>
        /// Answers an incoming SIP call.
        /// </summary>
        public void Answer(MediaManager mediaManager)
        {
            _mediaManager = mediaManager;
            _mediaManager.NewCall();

            SDP sdpAnswer = SDP.ParseSDPDescription(m_uas.CallRequest.Body);

            _mediaManager.SetRemoteSDP(sdpAnswer);

            SDP sdp = _mediaManager.GetSDP(false);

            m_uas.Answer(_sdpMimeContentType, sdp.ToString(), null, SIPDialogueTransferModesEnum.NotAllowed);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cleans up after a SIP call has completely finished.
        /// </summary>
        private void CallFinished()
        {
            if (_mediaManager != null)
            {
                _mediaManager.EndCall();
                _mediaManager = null;
            }

            m_uac = null;
            m_uas = null;

            CallEnded();
        }
Ejemplo n.º 3
0
        private void OnWindowLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Task.Run(() => {
                _mediaManager = new MediaManager();
                logger.Debug("Media Manager Initialised.");
                _mediaManager.OnLocalVideoSampleReady  += LocalVideoSampleReady;
                _mediaManager.OnRemoteVideoSampleReady += RemoteVideoSampleReady;
                _mediaManager.OnLocalVideoError        += LocalVideoError;

                if (_localVideoDevices.Items.Count == 0)
                {
                    LoadVideoDevices();
                }
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Cleans up after a SIP call has completely finished.
        /// </summary>
        private void CallFinished()
        {
            if (_mediaManager != null)
            {
                _mediaManager.EndCall();
                _mediaManager = null;
            }

            //_cancelCallTokenSource.Cancel();

            m_uac = null;
            m_uas = null;

            CallEnded();
        }
Ejemplo n.º 5
0
        private async void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            _mediaManager = new MediaManager(Dispatcher);
            logger.LogDebug("Media Manager Initialized.");
            _mediaManager.OnLocalVideoSampleReady  += LocalVideoSampleReady;
            _mediaManager.OnRemoteVideoSampleReady += RemoteVideoSampleReady;
            _mediaManager.OnLocalVideoError        += LocalVideoError;

            _musicOnHold = new MusicOnHold();

            await Initialize();

            if (_localVideoDevices.Items.Count == 0)
            {
                await Task.Run(LoadVideoDevices);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Places an outgoing SIP call.
        /// </summary>
        /// <param name="destination">The SIP URI to place a call to. The destination can be a full SIP URI in which case the all will
        /// be placed anonymously directly to that URI. Alternatively it can be just the user portion of a URI in which case it will
        /// be sent to the configured SIP server.</param>
        public void Call(MediaManager mediaManager, string destination)
        {
            //_initialisationTask.Wait(_cancelCallTokenSource.Token);

            _mediaManager = mediaManager;
            _mediaManager.NewCall();

            // Determine if this is a direct anonymous call or whether it should be placed using the pre-configured SIP server account.
            SIPURI callURI     = null;
            string sipUsername = null;
            string sipPassword = null;
            string fromHeader  = null;

            if (destination.Contains("@") || m_sipServer == null)
            {
                // Anonymous call direct to SIP server specified in the URI.
                callURI    = SIPURI.ParseSIPURIRelaxed(destination);
                fromHeader = (new SIPFromHeader(m_sipFromName, SIPURI.ParseSIPURI(SIPFromHeader.DEFAULT_FROM_URI), null)).ToString();
            }
            else
            {
                // This call will use the pre-configured SIP account.
                callURI     = SIPURI.ParseSIPURIRelaxed(destination + "@" + m_sipServer);
                sipUsername = m_sipUsername;
                sipPassword = m_sipPassword;
                fromHeader  = (new SIPFromHeader(m_sipFromName, new SIPURI(m_sipUsername, m_sipServer, null), null)).ToString();
            }

            StatusMessage("Starting call to " + callURI.ToString() + ".");

            m_uac               = new SIPClientUserAgent(m_sipTransport, null, null, null, null);
            m_uac.CallTrying   += CallTrying;
            m_uac.CallRinging  += CallRinging;
            m_uac.CallAnswered += CallAnswered;
            m_uac.CallFailed   += CallFailed;

            // Get the SDP requesting that the public IP address be used if the host on the call destination is not a private IP address.
            SDP sdp = _mediaManager.GetSDP(!(IPAddress.TryParse(callURI.Host, out _) && IPSocket.IsPrivateAddress(callURI.Host)));

            System.Diagnostics.Debug.WriteLine(sdp.ToString());
            SIPCallDescriptor callDescriptor = new SIPCallDescriptor(sipUsername, sipPassword, callURI.ToString(), fromHeader, null, null, null, null, SIPCallDirection.Out, _sdpMimeContentType, sdp.ToString(), null);

            m_uac.Call(callDescriptor);
        }
Ejemplo n.º 7
0
        private void OnWindowLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                _mediaManager = new MediaManager();
                logger.Debug("Media Manager Initialised.");
                _mediaManager.OnLocalVideoSampleReady += LocalVideoSampleReady;
                _mediaManager.OnRemoteVideoSampleReady += RemoteVideoSampleReady;
                _mediaManager.OnLocalVideoError += LocalVideoError;

                if (_localVideoDevices.Items.Count == 0)
                {
                    LoadVideoDevices();
                }
            });
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Cleans up after a SIP call has completely finished.
        /// </summary>
        private void CallFinished()
        {
            if (_mediaManager != null)
            {
                _mediaManager.EndCall();
                _mediaManager = null;
            }

            m_uac = null;
            m_uas = null;

            CallEnded();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Places an outgoing SIP call.
        /// </summary>
        /// <param name="destination">The SIP URI to place a call to. The destination can be a full SIP URI in which case the all will
        /// be placed anonymously directly to that URI. Alternatively it can be just the user portion of a URI in which case it will
        /// be sent to the configured SIP server.</param>
        public void Call(MediaManager mediaManager, string destination)
        {
            _mediaManager = mediaManager;
            _mediaManager.NewCall();

            // Determine if this is a direct anonymous call or whether it should be placed using the pre-configured SIP server account.
            SIPURI callURI = null;
            string sipUsername = null;
            string sipPassword = null;
            string fromHeader = null;

            if (destination.Contains("@") || m_sipServer == null)
            {
                // Anonymous call direct to SIP server specified in the URI.
                callURI = SIPURI.ParseSIPURIRelaxed(destination);
            }
            else
            {
                // This call will use the pre-configured SIP account.
                callURI = SIPURI.ParseSIPURIRelaxed(destination + "@" + m_sipServer);
                sipUsername = m_sipUsername;
                sipPassword = m_sipPassword;
                fromHeader = (new SIPFromHeader(m_sipFromName, new SIPURI(m_sipUsername, m_sipServer, null), null)).ToString();
            }

            StatusMessage("Starting call to " + callURI.ToString() + ".");

            m_uac = new SIPClientUserAgent(m_sipTransport, null, null, null, null);
            m_uac.CallTrying += CallTrying;
            m_uac.CallRinging += CallRinging;
            m_uac.CallAnswered += CallAnswered;
            m_uac.CallFailed += CallFailed;

            // Get the SDP requesting that the public IP address be used if the host on the call destination is not a private IP address.
            SDP sdp = _mediaManager.GetSDP(!(IPSocket.IsIPAddress(callURI.Host) && IPSocket.IsPrivateAddress(callURI.Host)));
            System.Diagnostics.Debug.WriteLine(sdp.ToString());
            SIPCallDescriptor callDescriptor = new SIPCallDescriptor(sipUsername, sipPassword, callURI.ToString(), fromHeader, null, null, null, null, SIPCallDirection.Out, _sdpMimeContentType, sdp.ToString(), null);
            m_uac.Call(callDescriptor);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Answers an incoming SIP call.
        /// </summary>
        public void Answer(MediaManager mediaManager)
        {
            _mediaManager = mediaManager;
            _mediaManager.NewCall();

            SDP sdpAnswer = SDP.ParseSDPDescription(m_uas.CallRequest.Body);
            _mediaManager.SetRemoteSDP(sdpAnswer);

            SDP sdp = _mediaManager.GetSDP(false);
            m_uas.Answer(_sdpMimeContentType, sdp.ToString(), null, SIPDialogueTransferModesEnum.NotAllowed);
        }
Ejemplo n.º 11
0
 public RTPMediaSessionManager(MediaManager mediaManager, MusicOnHold musicOnHold)
 {
     _mediaManager = mediaManager;
     _musicOnHold  = musicOnHold;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Attempts to establish a new VoIP call via the Google Voice gateway.
        /// </summary>
        /// <param name="destination">The destination number to call.</param>
        public void Call(MediaManager mediaManager, string destination)
        {
            if (!_isBound)
            {
                throw new ApplicationException("The Google Voice call could not proceed as the XMPP client is not bound.");
            }
            else
            {
                _rtpManager = new RTPManager(true, false);

                // Call to Google Voice over XMPP & Gingle (Google's version of Jingle).
                XMPPPhoneSession phoneSession = m_xmppClient.GetPhoneSession();

                m_xmppCall = m_xmppClient.GetPhoneSession();
                m_xmppCall.Accepted += XMPPAnswered;
                m_xmppCall.Rejected += XMPPCallFailed;
                m_xmppCall.Hungup += Hangup;

                // Create the SDP packet to send to GV. Customise it with the ICE credentials that GV require.
                SDP xmppSDP = null; //  _rtpManager.GetSDP(true);
                xmppSDP.IcePwd = Crypto.GetRandomString(12);
                m_localSTUNUFrag = Crypto.GetRandomString(8);
                xmppSDP.IceUfrag = m_localSTUNUFrag;

                m_xmppCall.PlaceCall(destination + "@" + GOOGLE_VOICE_HOST, xmppSDP);
            }
        }
Ejemplo n.º 13
0
 public void Answer(MediaManager mediaManager)
 {
     throw new NotSupportedException("Incoming calls are currently not supported with the Gingle client.");
 }
Ejemplo n.º 14
0
 public void Answer(MediaManager mediaManager)
 {
     throw new NotSupportedException("Incoming calls are currently not supported with the Gingle client.");
 }