Ejemplo n.º 1
0
        public void NewCall()
        {
            _audioChannel = new AudioChannel();
            _audioChannel.SampleReady += AudioChannelSampleReady;

            _rtpManager = new RTPManager(true, true);
            _rtpManager = new RTPManager(true, false);
            _rtpManager.OnRemoteVideoSampleReady += EncodedVideoSampleReceived;
            _rtpManager.OnRemoteAudioSampleReady += RemoteAudioSampleReceived;

            if (_audioChannel != null)
            {
                _audioChannel.StartRecording();
            }
        }
Ejemplo n.º 2
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(string destination)
        {
            // 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;

            _audioChannel = new AudioChannel();

            // 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 = _audioChannel.GetSDP(!(IPSocket.IsIPAddress(callURI.Host) && IPSocket.IsPrivateAddress(callURI.Host)));
            SIPCallDescriptor callDescriptor = new SIPCallDescriptor(sipUsername, sipPassword, callURI.ToString(), fromHeader, null, null, null, null, SIPCallDirection.Out, SDP.SDP_MIME_CONTENTTYPE, sdp.ToString(), null);
            m_uac.Call(callDescriptor);
        }
Ejemplo n.º 3
0
        public void EndCall()
        {
            if (_audioChannel != null)
            {
                _audioChannel.SampleReady -= AudioChannelSampleReady;
                _audioChannel.Close();
                _audioChannel = null;
            }

            _rtpManager.OnRemoteVideoSampleReady -= EncodedVideoSampleReceived;
            _rtpManager.OnRemoteAudioSampleReady -= RemoteAudioSampleReceived;
            _rtpManager.Close();
        }
Ejemplo n.º 4
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(string destination)
        {
            if (!_isBound)
            {
                throw new ApplicationException("The Google Voice call could not proceed as the XMPP client is not bound.");
            }
            else
            {
                _audioChannel = new AudioChannel();

                // 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 = _audioChannel.GetSDP(true);
                xmppSDP.IcePwd = Crypto.GetRandomString(12);
                m_localSTUNUFrag = Crypto.GetRandomString(8);
                xmppSDP.IceUfrag = m_localSTUNUFrag;

                m_xmppCall.PlaceCall(destination + "@" + GOOGLE_VOICE_HOST, xmppSDP);
            }
        }