Exemple #1
0
        private void SIPCallAnswered(SIPClient client)
        {
            _mediaManager.StartAudio();

            this.Invoke(new MethodInvoker(delegate
            {
                btn_call.Enabled = !btn_call.Enabled;
            }));
        }
Exemple #2
0
        /// Answer an incoming call on the SipClient
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        private async Task AnswerCallAsync(SIPClient client)
        {
            await client.Answer();

            _mediaManager.StartAudio();
            //m_answerButton.Visibility = Visibility.Collapsed;
            //m_rejectButton.Visibility = Visibility.Collapsed;
            //m_redirectButton.Visibility = Visibility.Collapsed;
            //m_byeButton.Visibility = Visibility.Visible;
            //m_transferButton.Visibility = Visibility.Visible;
            //m_holdButton.Visibility = Visibility.Visible;

            //m_call2ActionsGrid.IsEnabled = true;
        }
Exemple #3
0
        private void ResetToCallStartState(SIPClient sipClient)
        {
            if (sipClient == null)
            {
                if (IsHandleCreated)
                {
                    this.Invoke((MethodInvoker) delegate()

                    {
                        SetStatusText(lbl_status, "Ready");
                    });
                }
                else
                {
                    SetStatusText(lbl_status, "Ready");
                }
            }
        }
Exemple #4
0
        /// The remote call party has taken us off hold.
        /// </summary>
        private void RemoteTookOffHold(SIPClient sipClient)
        {
            SetStatusText(lbl_status, "Taken off hold by remote party.");

            //if (sipClient == _sipClients[0])
            //{
            //    Dispatcher.DoOnUIThread(() =>
            //    {
            //        m_holdButton.Visibility = Visibility.Visible;
            //    });
            //}
            //else if (sipClient == _sipClients[1])
            //{
            //    Dispatcher.DoOnUIThread(() =>
            //    {
            //        m_hold2Button.Visibility = Visibility.Visible;
            //    });
            //}
        }
Exemple #5
0
        /// <summary>
        /// The button to initiate an attended transfer request between the two in active calls.
        /// </summary>
        //private async void AttendedTransferButton_Click(object sender, System.Windows.RoutedEventArgs e)
        //{
        //    bool wasAccepted = await _sipClients[1].AttendedTransfer(_sipClients[0].Dialogue);

        //    if (!wasAccepted)
        //    {
        //        SetStatusText(m_signallingStatus, "The remote call party did not accept the transfer request.");
        //    }
        //}

        //private void RedirectButton_Click(object sender, System.Windows.RoutedEventArgs e)
        //{
        //    ResetToCallStartState(_sipClients);
        //}

        /// <summary>
        /// The button to send a blind transfer request to the remote call party.
        /// </summary>
        //private async void BlindTransferButton_Click(object sender, System.Windows.RoutedEventArgs e)
        //{
        //    var client = (sender == m_transferButton) ? _sipClients[0] : _sipClients[1];
        //    bool wasAccepted = await client.BlindTransfer(m_uriEntryTextBox.Text);

        //    if (wasAccepted)
        //    {
        //        //TODO: We need to the end the call

        //        ResetToCallStartState(client);
        //    }
        //    else
        //    {
        //        SetStatusText(m_signallingStatus, "The remote call party did not accept the transfer request.");
        //    }
        //}

        private void RemotePutOnHold(SIPClient sipClient)
        {
            // We can't put them on hold if they've already put us on hold.
            SetStatusText(lbl_status, "Put on hold by remote party.");

            //if (sipClient == _sipClients[0])
            //{
            //    Dispatcher.DoOnUIThread(() =>
            //    {
            //        m_holdButton.Visibility = Visibility.Collapsed;
            //    });
            //}
            //else if (sipClient == _sipClients[1])
            //{
            //    Dispatcher.DoOnUIThread(() =>
            //    {
            //        m_hold2Button.Visibility = Visibility.Collapsed;
            //    });
            //}
        }
Exemple #6
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();
        }