Ejemplo n.º 1
0
        public void Add(IPhoneCall call)
        {
            if (call == null)
                return;

            List.Add(call.ToPhoneCallInfo());
        }
Ejemplo n.º 2
0
        public void Remove(IPhoneCall call)
        {
            if (call == null)
                return;

            List.Remove(call.ToPhoneCallInfo());
        }
Ejemplo n.º 3
0
        protected override void GivenOverride()
        {
            _call = _phone.CreateCall();
            _call.CallErrorOccured += (s, e) => _callError = e.Item;
            _call.CallStateChanged += (s, e) => _callState = e.Item;
            _call.Start(_testClientUaUri.FormatToString());
            _waitingforInviteReceived.WaitOne();

            _phone.InternalState.Should().Be(_stateProvider.GetWaitProvisional()); /*required assertion*/
        }
        public OutGoingCallEngine(string dialedNumber, ISoftPhone softPhone, IPhoneLine phoneLine)
        {
            _connector = new MediaConnector();
            _videoSender = new PhoneCallVideoSender();
            _audioSender = new PhoneCallAudioSender();

            var dial = new DialParameters(dialedNumber) { CallType = CallType.AudioVideo };
            Call = softPhone.CreateCallObject(phoneLine, dial);
            Call.CallStateChanged += _call_CallStateChanged;        

            _videoSender.AttachToCall(Call);
            _audioSender.AttachToCall(Call);
        }
Ejemplo n.º 5
0
        protected override void GivenOverride()
        {
            _call = _phone.CreateCall();
            _call.CallStateChanged += call_CallStateChanged;
            _call.Start(_testClientUaUri.FormatToString());

            _waitingforInviteReceived.WaitOne();
            _phone.InternalState.Should().Be(_stateProvider.GetWaitProvisional()); /*required assertion*/

            _toTag = SipUtil.CreateTag();
            var provResponse = CreateRingingResponse(_receivedInvite, _toTag);
            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _ringingProcessed.WaitOne();

            _phone.InternalState.Should().Be(_stateProvider.GetWaitFinal()); /*required assertion*/
        }
        private void _call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            var handler = CallStateChanged;
            if (handler != null)
                handler(sender, e);

            if (e.State.IsCallEnded())
            {
                if (Call != null)
                {
                    Call.CallStateChanged -= _call_CallStateChanged;
                    _videoSender.Detach();
                    _audioSender.Detach();
                    _connector.Dispose();
                    Call = null;
                }
            }
        }
Ejemplo n.º 7
0
        protected override void GivenOverride()
        {
            _call = _phone.CreateCall();
            _call.CallStateChanged += call_CallStateChanged;
            _call.Start(_testClientUaUri.FormatToString());

            _waitingforInviteReceived.WaitOne();
            _phone.InternalState.Should().Be(_stateProvider.GetWaitProvisional()); /*required assertion*/

            _toTag = SipUtil.CreateTag();
            var provResponse = CreateRingingResponse(_receivedInvite, _toTag);

            _network.SendTo(SipFormatter.FormatMessage(provResponse), _testClientUaEndPoint, _phoneUaEndPoint);
            _ringingProcessed.WaitOne();

            _phone.InternalState.Should().Be(_stateProvider.GetWaitFinal()); /*required assertion*/

            _call.Stop();
            _waitingforCancelReceived.Set();
        }
Ejemplo n.º 8
0
        private void StartCall(IPhoneCall call)
        {
            lock (_sync)
            {
                if (call == null)
                {
                    return;
                }

                SubscribeToCallEvents(call);
                call.Start();
                MediaHandlers.LoadSpeechToText();
                PhoneCalls.Add(call);

                if (SelectedCall == null)
                {
                    SelectedCall = call;
                }
            }
        }
		/// <summary>
		/// Occurs when the phone call state has changed.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void call_CallStateChanged(object sender, VoIPEventArgs<CallState> e)
		{
			InvokeGUIThread(() => { labelCallStateInfo.Text = e.Item.ToString(); });

			switch (e.Item)
			{
				case CallState.InCall:
					if (microphone != null)
						microphone.Start();
					connector.Connect(microphone, mediaSender);

					if (speaker != null)
						speaker.Start();
					connector.Connect(mediaReceiver, speaker);

					mediaSender.AttachToCall(call);
					mediaReceiver.AttachToCall(call);

					break;
				case CallState.Completed:
					if (microphone != null)
						microphone.Stop();
					connector.Disconnect(microphone, mediaSender);
					if (speaker != null)
						speaker.Stop();
					connector.Disconnect(mediaReceiver, speaker);

					mediaSender.Detach();
					mediaReceiver.Detach();

					WireDownCallEvents();
					call = null;

					InvokeGUIThread(() => { labelDialingNumber.Text = string.Empty; });
					break;
				case CallState.Cancelled:
					WireDownCallEvents();
					call = null;
					break;
			}
		}
Ejemplo n.º 10
0
        private void _call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            var handler = CallStateChanged;

            if (handler != null)
            {
                handler(sender, e);
            }

            if (e.State.IsCallEnded())
            {
                if (Call != null)
                {
                    Call.CallStateChanged -= _call_CallStateChanged;
                    _videoSender.Detach();
                    _audioSender.Detach();
                    _connector.Dispose();
                    Call = null;
                }
            }
        }
Ejemplo n.º 11
0
        public void Hang_Up()
        {
            if (_call != null)
            {
                if (_inComingCall && _call.CallState == CallState.Ringing)
                {
                    _call.Reject();
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call rejected."); });
                }
                else
                {
                    _call.HangUp();
                    _inComingCall = false;
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call hanged up."); });
                }

                _call = null;
            }

            //txtNumber.Text = string.Empty;
        }
Ejemplo n.º 12
0
        private void btn_HangUp_Click(object sender, EventArgs e)
        {
            if (call != null)
            {
                if (inComingCall && call.CallState == CallState.Ringing)
                {
                    call.Reject();
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call rejected."); });
                }
                else
                {
                    call.HangUp();
                    inComingCall = false;
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call hanged up."); });
                }

                call = null;
            }

            tb_Display.Text = string.Empty;
        }
Ejemplo n.º 13
0
        static void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e)
        {
            call   = e.Item;
            caller = call.DialInfo.CallerID;

            /*DialogResult dialogResult = MessageBox.Show("Chcesz odebrać połączenie od: "+caller.ToString(), "Some Title", MessageBoxButtons.YesNo);
             * if(dialogResult == DialogResult.Yes)
             * {
             *  call.CallStateChanged += call_CallStateChanged;
             *  call.Answer();
             * }
             * else if (dialogResult == DialogResult.No)
             * {
             *  MessageBox.Show("Polaczenie od: " + caller.ToString()+" odrzucone");
             *  CloseDevices();
             * }*/

            //MessageBox.Show("Chcesz odebrac polaczenie od: " + caller.ToString());
            call.CallStateChanged += call_CallStateChanged;
            call.Answer();
        }
Ejemplo n.º 14
0
        public void Pick_up(string _numberDial)
        {
            if (_inComingCall)
            {
                _inComingCall = false;
                _call.Answer();
                return;
            }
            if (_call != null)
            {
                return;
            }
            if (_phoneLineInformation != RegState.RegistrationSucceeded)
            {
                _message.Add("Registratin Failed! OFFLINE");
                return;
            }

            _call = _softPhone.CreateCallObject(_phoneLine, string.IsNullOrWhiteSpace(_numberDial) ? _reDialNumber : _numberDial);
            WireUpCallEvents();
            _call.Start();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Occurs when the phone call state has changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            Console.WriteLine("Call state changed: " + e.State);

            switch (e.State)
            {
            case CallState.InCall:
                ConnectDevicesToCall();
                break;

            case CallState.Completed:
                DisconnectDevicesFromCall();
                WireDownCallEvents();
                call = null;
                break;

            case CallState.Cancelled:
                WireDownCallEvents();
                call = null;
                break;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Create and start the call to the dialed number
        /// </summary>
        /// <param name="dialedNumber"></param>
        public void Call(string dialedNumber)
        {
            if (phoneLineInformation != RegState.RegistrationSucceeded)
            {
                Console.WriteLine("Phone line state is not valid!");
                return;
            }

            if (string.IsNullOrEmpty(dialedNumber))
            {
                return;
            }

            if (call != null)
            {
                return;
            }

            call = softPhone.CreateCallObject(phoneLine, dialedNumber);
            WireUpCallEvents();
            call.Start();
        }
Ejemplo n.º 17
0
        public void StopCall()
        {
            m_RingTimeOut = false;
            if (call != null)
            {
                if (inComingCall && call.CallState == CallState.Ringing)
                    call.Reject();
                else
                    call.HangUp();

                inComingCall = false;
                //softPhone.UnregisterPhoneLine(phoneLine);
                softPhone.Close();
                this.WireDownCallEvents();
                call = null;
            }
            else
            {
                if (CallState_Changed != null)
                {
                    CallState_Changed(this, new CallStateChangedArgs()
                    {
                        PhoneCallState =  CallState.Cancelled
                    });
                }
                m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);

            }
            m_MediaUtility.Stop();
            if (softPhone != null) {
                //softPhone.UnregisterPhoneLine(phoneLine);
                softPhone.Close();
            }
        }
Ejemplo n.º 18
0
        void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            InvokeGUIThread(() => { lbl_CallState.Text = e.State.ToString(); lblEstatusLlamada.Text = e.State.ToString(); });

            if (e.State == CallState.Answered)
            {
                InvokeGUIThread(() => {
                    wplayer.controls.stop();
                    crearFolio();
                    ALlamadaData.bCurso = true;

                    string sRuta = string.Format(@"{0}\mpy\records\nws", Path.GetTempPath());
                    if (!Directory.Exists(sRuta))
                    {
                        Directory.CreateDirectory(sRuta);
                    }
                });

                StartDevices();
                SendDTMFSingnal();

                sFechaInicio = DateTime.Now;
                sRecordName  = AProspeccionData.bCurso ? string.Format("pcll-{1}.wav", Path.GetTempPath(), AProspeccionData.iIdLlamada) : string.Format("Folio-{0}-{1}{2}{3}{4}{5}{6}.wav", iIdFolio, sFechaInicio.Day, sFechaInicio.Month, sFechaInicio.Year, sFechaInicio.Hour, sFechaInicio.Minute, sFechaInicio.Second);
                filename     = string.Format(@"{0}\mpy\records\nws\{1}", Path.GetTempPath(), sRecordName);

                recorder = new WaveStreamRecorder(filename);  // new recorder object
                _connector.Connect(_microphone, recorder);    // connects the outgoing voice to the recorder
                _connector.Connect(_mediaReceiver, recorder); // connects the incoming voice to the recorder

                _mediaSender.AttachToCall(_call);
                _mediaReceiver.AttachToCall(_call);
                recorder.Start();  // starts the recording

                InvokeGUIThread(() => {
                    timer1.Start();
                    txtDisplay.Text     = "" + ((IPhoneCall)sender).DialInfo.SIPCallerID.DisplayName;
                    lblExtEntrante.Text = "" + ((IPhoneCall)sender).DialInfo.SIPCallerID.DisplayName;

                    if (!AProspeccionData.bCurso)
                    {
                        // Valida despues de mostrar la modal para registrar la llamada
                        if (RegistrarLlamadaModal.Show(iIdFolio, filename) == DialogResult.Yes)
                        {
                            Cliente ACliente = new Cliente();
                            Caso NoCliente;
                            if (bSeguimiento)
                            {
                                NoCliente = new Caso().ClienteCaso(iIdFolioSeguimiento);
                            }
                            else
                            {
                                NoCliente = new Caso().ClienteCaso(iIdFolio);
                            }
                        }
                    }
                });
            }
            else if (e.State == CallState.InCall)
            {
                StartDevices();
            }

            if (e.State == CallState.LocalHeld || e.State == CallState.InactiveHeld)
            {
                StopDevices();
                InvokeGUIThread(() => {
                    lnkHold.Text         = "Unhold";
                    lnkHold.Image        = Properties.Resources.resume_button_48px;
                    lnkHold.NoFocusImage = Properties.Resources.resume_button_48px;
                });
            }
            else
            {
                InvokeGUIThread(() => {
                    lnkHold.Text         = "Hold";
                    lnkHold.Image        = Properties.Resources.pause_48px;
                    lnkHold.NoFocusImage = Properties.Resources.pause_48px;
                });
            }

            if (e.State.IsCallEnded())
            {
                StopDevices();

                _mediaSender.Detach();
                _mediaReceiver.Detach();

                WireDownCallEvents();

                if (recorder != null)
                {
                    recorder.Dispose();
                    recorder = null;
                }

                _call = null;

                timer1.Stop();

                InvokeGUIThread(() => {
                    wplayer.controls.stop();
                    txtDisplay.Text     = String.Empty;
                    lblExtEntrante.Text = string.Empty;
                    lblTiempo.Text      = string.Empty;

                    if (pnlLlamada.Visible == true)
                    {
                        frmTelefono.Animate2(pnlLlamada, frmTelefono.Effect.Slide, 150, 360);
                        frmTelefono.Animate(pnlKeyPad, frmTelefono.Effect.Slide, 150, 360);
                    }

                    lnkPickUpInCall.Visible      = true;
                    lnkVolverLLamada.Visible     = false;
                    pnlTransferirLlamada.Visible = false;
                    txtNoTransferir.Text         = string.Empty;
                    lnkConfigurar.Enabled        = true;
                    lnkHangUp.Location           = new Point(150, 94);
                    AProspeccionData.bCurso      = false;

                    string sFilePath = "";
                    if (bSeguimiento && iIdFolioSeguimiento != 0)
                    {
                        sFilePath = string.Format(@"{0}\mpy\records\nws\Folio-{1}-{2}{3}{4}{5}{6}{7}.wav", Path.GetTempPath(), iIdFolioSeguimiento, sFechaInicio.Day, sFechaInicio.Month, sFechaInicio.Year, sFechaInicio.Hour, sFechaInicio.Minute, sFechaInicio.Second);
                        File.Move(filename, sFilePath);
                        CasoHistorial _UpdRecord = new CasoHistorial();
                        _UpdRecord.UpdateHistorialRecord(iIdHistorialFolio, sFilePath);
                    }

                    if (ALlamadaData.bCurso)
                    {
                        if (sFilePath == "")
                        {
                            string FullPath = string.Format("{0}/{1}/Records/", FTPCredentials.Path, ConnectionString.FolderConnection);
                            FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(filename), filename);
                            File.Delete(filename);
                        }
                        else
                        {
                            string FullPath = string.Format("{0}/{1}/Records/", FTPCredentials.Path, ConnectionString.FolderConnection);
                            FTPServer.Upload(FullPath, FTPCredentials.User, FTPCredentials.Password, Path.GetFileName(sFilePath), sFilePath);
                            File.Delete(sFilePath);
                        }
                        ALlamadaData.bCurso = false;
                    }
                });
            }
        }
Ejemplo n.º 19
0
 public TransferModel(IEnumerable <IPhoneCall> phoneCalls, IPhoneCall transferee)
 {
     PhoneCalls   = phoneCalls;
     TransferMode = TransferMode.Blind;
     Transferee   = transferee;
 }
        private void Call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            IPhoneCall grCall = sender as IPhoneCall;

            _grCall = grCall;
            MyCallState tmp = MyCallState.DoNotthing;

            if (e.State == CallState.Answered)
            {
                StartDevices();
                mediaReceiver.AttachToCall(call);
                mediaSender.AttachToCall(call);
                videoReceiver.AttachToCall(call);
                videoSender.AttachToCall(call);
                tmp = MyCallState.Answered;
            }

            if (e.State == CallState.InCall)
            {
                StartDevices();
                tmp = MyCallState.InCall;
                CallDuration();
            }

            if (e.State.IsCallEnded() == true)
            {
                StopDevices();
                mediaReceiver.Detach();
                mediaSender.Detach();
                videoSender.Detach();
                videoReceiver.Detach();
                WireDownCallEvents();
                call = null;
                tmp  = MyCallState.CallEnd;
                Instance.IsLocalCameraUsed = false;
                timer.Stop();
            }

            if (e.State == CallState.LocalHeld)
            {
                StopDevices();
            }
            if (e.State == CallState.Busy)
            {
                StopDevices();
                tmp = MyCallState.Busy;
            }
            if (e.State == CallState.Cancelled)
            {
                StopDevices();
                tmp = MyCallState.Canceled;
            }
            if (e.State == CallState.Completed)
            {
                tmp = MyCallState.CallEnd;
            }

            if (CallStateChange != null)
            {
                CallStateChange.Invoke(tmp);
            }
        }
Ejemplo n.º 21
0
        private void StartCall(IPhoneCall call)
        {
            if (call == null)
                return;

            SubscribeToCallEvents(call);
            call.Start();

            PhoneCalls.Add(call);

            if (SelectedCall == null)
                SelectedCall = call;
        }
Ejemplo n.º 22
0
        private void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            try
            {
                InvokeGUIThread(() => { lb_Log.Items.Add("Callstate changed." + e.State.ToString()); });// tb_Display.Text = e.State.ToString();

                if (e.State == CallState.Answered)
                {
                    player.Stop();
                    StartDevices();

                    _mediaReceiver.AttachToCall(_call);
                    _mediaSender.AttachToCall(_call);

                    SetupAnswered();
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); });
                }

                if (e.State == CallState.InCall)
                {
                    player.Stop();
                    StartDevices();
                    InvokeGUIThread(() =>
                    {
                    });
                }

                if (e.State.IsCallEnded() || e.State == CallState.Rejected)
                {
                    StopDevices();

                    _mediaReceiver.Detach();
                    _mediaSender.Detach();

                    UnSubcribedCallEvents();
                    if (isInComingCompleted)
                    {
                        isInComingCompleted = false;
                        InvokeGUIThread(() =>
                        {
                        });
                    }
                    InvokeGUIThread(() =>
                    {
                    });
                    _call = null;
                    EndCalling();
                    InvokeGUIThread(() =>
                    {
                        lb_Log.Items.Add("Call ended.");
                        playSound(hangup);
                    });
                }

                if (e.State == CallState.LocalHeld)
                {
                    InvokeGUIThread(() => { lb_Log.Items.Add("Call Holding."); });
                    StopDevices();
                }
                if (e.State == CallState.RemoteHeld)
                {
                    InvokeGUIThread(() => { lb_Log.Items.Add("Callee Holding."); });
                    InvokeGUIThread(() => { playSound(holding); });
                }
                if (e.State == CallState.Ringing)
                {
                    InvokeGUIThread(() =>
                    {
                        if (isCalling)
                        {
                            playSound(calling);
                        }
                        else
                        {
                            playSound(ringing);
                        }
                    });
                }

                DispatchAsync(() =>
                {
                    var handler = CallStateChanged;
                    if (handler != null)
                    {
                        handler(this, e);
                    }
                });
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 23
0
 void _phoneBob_IncomingCall(object sender, VoipEventArgs <IPhoneCall> e)
 {
     _incomingCallBob = e.Item;
     WireEventsBob(_incomingCallBob);
     OnBobIncomingCallReceived();
 }
Ejemplo n.º 24
0
 void _softPhone_IncomingCall(object sender, VoipEventArgs <IPhoneCall> e)
 {
     _incomingCall = e.Item;
     WireEvents(_incomingCall);
     Log("Received incoming call");
 }
Ejemplo n.º 25
0
 private void WireEvents(IPhoneCall call)
 {
     call.CallErrorOccured += call_CallErrorOccured;
     call.CallStateChanged += call_CallStateChanged;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Attaches the media handlers to the given phone call.
 /// </summary>
 public void AttachVideo(IPhoneCall call)
 {
     if (videoCollection != null)
         videoCollection.AttachToCall(call);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Attaches the media handlers to the given phone call.
 /// </summary>
 public void AttachAudio(IPhoneCall call)
 {
     phoneCallAudioSender.AttachToCall(call);
     if (audioCollection != null)
         audioCollection.AttachToCall(call);
 }
Ejemplo n.º 28
0
 public TransferModel(IEnumerable<IPhoneCall> phoneCalls, IPhoneCall transferee)
 {
     PhoneCalls = phoneCalls;
     TransferMode = TransferMode.Blind;
     Transferee = transferee;
 }
Ejemplo n.º 29
0
        public void call_CallStateChanged(object sender, CallStateChangedArgs e)
        {
            InvokeGUIThread(() => { lb_Log.Items.Add("Callstate changed." + e.State.ToString()); }); // tb_Display.Text = e.State.ToString();

            if (e.State == CallState.Answered)
            {
                player.Stop();
                StartDevices();

                _mediaReceiver.AttachToCall(_call);
                _mediaSender.AttachToCall(_call);


                InvokeGUIThread(() => { lb_Log.Items.Add("Call started."); });
            }

            if (e.State == CallState.InCall)
            {
                isCalling = false;
                player.Stop();
                StartDevices();
                InvokeGUIThread(() => {
                    btnHangup.Enabled   = true;
                    btnHold.Enabled     = true;
                    btnHangup.BackColor = Color.Red;
                    btnHangup.ForeColor = Color.Snow;
                    btnHold.BackColor   = Color.Red;
                    btnHold.ForeColor   = Color.Snow;
                });
            }

            if (e.State.IsCallEnded())
            {
                StopDevices();

                _mediaReceiver.Detach();
                _mediaSender.Detach();

                WireDownCallEvents();
                if (isInComingCompleted)
                {
                    isInComingCompleted = false;
                    InvokeGUIThread(() =>
                    {
                        btnAccpect.Enabled   = false;
                        btnAccpect.BackColor = Color.Teal;
                        btnAccpect.ForeColor = Color.DimGray;
                        btnHold.Enabled      = false;
                        btnHangup.Enabled    = false;
                        btnHold.BackColor    = Color.Teal;
                        btnHold.ForeColor    = Color.DimGray;
                        btnHangup.BackColor  = Color.Teal;
                        btnHangup.ForeColor  = Color.DimGray;
                    });
                }
                InvokeGUIThread(() =>
                {
                    btnHold.Enabled     = false;
                    btnHangup.Enabled   = false;
                    btnHold.BackColor   = Color.Teal;
                    btnHold.ForeColor   = Color.DimGray;
                    btnHangup.BackColor = Color.Teal;
                    btnHangup.ForeColor = Color.DimGray;
                });
                _call = null;

                InvokeGUIThread(() => {
                    lb_Log.Items.Add("Call ended.");
                    playSound(hangup);
                });
            }

            if (e.State == CallState.LocalHeld)
            {
                InvokeGUIThread(() => { lb_Log.Items.Add("Call Hold."); });
                StopDevices();
            }
            if (e.State == CallState.RemoteHeld)
            {
                InvokeGUIThread(() => { playSound(holding); });
            }
            if (e.State == CallState.Ringing)
            {
                InvokeGUIThread(() => {
                    if (isCalling)
                    {
                        playSound(calling);
                    }
                    else
                    {
                        playSound(ringing);
                    }
                });
            }

            DispatchAsync(() =>
            {
                var handler = CallStateChanged;
                if (handler != null)
                {
                    handler(this, e);
                }
            });
        }
Ejemplo n.º 30
0
 private void WireEvents(IPhoneCall call)
 {
     call.CallErrorOccured += call_CallErrorOccured;
     call.CallStateChanged += call_CallStateChanged;
 }
Ejemplo n.º 31
0
        private void call_CallStateChanged(object sender, VoIPEventArgs<CallState> e)
        {
            callstate = e.Item;

                if (e.Item == CallState.Ringing)
                {
                    m_TimeStart = DateTime.Now.TimeOfDay;
                    m_StartTimeOutCounter = true;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Ring);
                }

                else if (e.Item == CallState.InCall)
                {
                    try
                    {
                        m_StartTimeOutCounter = false;
                        m_MediaUtility.Stop();
                        recorder.StartStreaming();
                        //recorder.IsStreaming = true;
                    }
                    catch (Ozeki.Common.Exceptions.MediaException me)
                    {

                        if (CallState_Changed != null)
                        {
                            AudioId = Guid.Empty;
                            CallState_Changed(this, new CallStateChangedArgs()
                            {
                                PhoneCallState = CallState.Rejected
                            });
                        }
                        if (call != null)
                            call.HangUp();

                        //softPhone.UnregisterPhoneLine(phoneLine);
                        softPhone.Close();
                        this.WireDownCallEvents();
                        call = null;

                        m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                        MessageBox.Show("Your mic or speaker is not working. Please change your mic or speaker in the Phone Settings.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }

                else if (e.Item == CallState.Completed)
                {
                    try
                    {
                        recorder.StopStreaming();
                        //recorder.IsStreaming = false;

                        EndCall();

                        if (m_RingTimeOut)
                            return;

                        this.WireDownCallEvents();
                        call = null;
                        recorder.Dispose();
                        recorder = null;
                        CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true);
                        string fileNameTmp = String.Format(@"{0}\tmpwav\{1}_.wav", commonData.ApplicationFolderPath, AudioId);
                        string fileNameCache = String.Format(@"{0}\cachewav\{1}_.wav", commonData.ApplicationFolderPath, AudioId);
                        File.Copy(fileNameTmp, fileNameCache);

                        m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);

                    }
                    catch
                    {
                        //softPhone.UnregisterPhoneLine(phoneLine);
                        softPhone.Close();
                        this.WireDownCallEvents();
                        call = null;
                    }
                }

                else if (e.Item == CallState.Cancelled)
                {
                    AudioId = Guid.Empty;
                    EndCall();
                    if (m_RingTimeOut)
                        return;

                    m_StartTimeOutCounter = false;
                    //softPhone.UnregisterPhoneLine(phoneLine);

                    this.WireDownCallEvents();
                    call = null;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                }

                else if (e.Item == CallState.Rejected)
                {
                    AudioId = Guid.Empty;
                    EndCall();
                    m_StartTimeOutCounter = false;
                    //softPhone.UnregisterPhoneLine(phoneLine);

                    this.WireDownCallEvents();
                    call = null;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                }

                else if (e.Item == CallState.Busy || e.Item == CallState.Error)
                {
                    AudioId = Guid.Empty;
                    EndCall();
                    m_RingTimeOut = true;
                    m_StartTimeOutCounter = false;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Busy);
                    //softPhone.UnregisterPhoneLine(phoneLine);
                    softPhone.Close();
                    call.HangUp();
                    call = null;
                    //MessageBox.Show("Error encountered. Please check the format of the number you are calling.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.WireDownCallEvents();
                    //call = null;
                }

                if (CallState_Changed != null)
                {
                    CallState_Changed(this, new CallStateChangedArgs()
                    {
                        PhoneCallState = e.Item,
                        AudioId = AudioId
                    });
                }
        }
Ejemplo n.º 32
0
 private void UnWireEventsBob(IPhoneCall call)
 {
     call.CallErrorOccured -= callBob_ErrorOccured;
     call.CallStateChanged -= _callBob_StateChanged;
 }
Ejemplo n.º 33
0
        /// <summary>
        /// This will be called when the state of a call has changed.
        /// </summary>
        private void Call_CallStateChanged(object sender, VoIPEventArgs <CallState> e)
        {
            IPhoneCall call = sender as IPhoneCall;

            if (call == null)
            {
                return;
            }

            CallState state = e.Item;

            OnPhoneCallStateChanged(call);
            CheckStopRingback();
            CheckStopRingtone();

            // start ringtones
            if (state.IsRinging())
            {
                if (call.IsIncoming)
                {
                    MediaHandlers.StartRingtone();
                }
                else
                {
                    MediaHandlers.StartRingback();
                }

                return;
            }

            // call has been answered
            if (state == CallState.Answered)
            {
                return;
            }

            // attach media to the selected call when the remote party sends media data
            if (state.IsRemoteMediaCommunication())
            {
                if (SelectedCall.Equals(call))
                {
                    MediaHandlers.AttachAudio(call);
                    MediaHandlers.AttachAudio(call);
                }
                return;
            }

            // detach media from the selected call in hold state or when the call has ended
            if (state == CallState.LocalHeld || state == CallState.InactiveHeld || state.IsCallEnded())
            {
                if (SelectedCall.Equals(call))
                {
                    MediaHandlers.DetachAudio();
                    MediaHandlers.DetachVideo();
                }
            }

            // call has ended, clean up
            if (state.IsCallEnded())
            {
                DisposeCall(call);

                CallHistory.Add(call);
                PhoneCalls.Remove(call);
                return;
            }
        }
Ejemplo n.º 34
0
 protected void CallAlice()
 {
     _outgoingCallAlice = _phoneBob.CreateCall();
     WireEventsBob(_outgoingCallAlice);
     _outgoingCallAlice.Start(_aliceEndPoint.ToString());
 }
        /// <summary>
        /// Call event subscriptions.
        /// </summary>
        private void SubscribeToCallEvents(IPhoneCall call)
        {
            if (call == null)
                return;

            call.CallStateChanged += (Call_CallStateChanged);
            call.DtmfReceived += (Call_DtmfReceived);
            call.DtmfStarted += (Call_DtmfStarted);
            call.InstantMessageReceived += (Call_InstantMessageReceived);
        }
Ejemplo n.º 36
0
 void _softPhone_IncomingCall(object sender, VoipEventArgs<IPhoneCall> e)
 {
     _incomingCall = e.Item;
     WireEvents(_incomingCall);
     Log("Received incoming call");
 }
Ejemplo n.º 37
0
 private void WireEventsAlice(IPhoneCall call)
 {
     call.CallErrorOccured += callAlice_ErrorOccured;
     call.CallStateChanged += _callAlice_StateChanged;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Call event unsubscriptions.
        /// </summary>
        private void UnsubscribeFromCallEvents(IPhoneCall call)
        {
            if (call == null)
                return;

            call.CallStateChanged -= (Call_CallStateChanged);
            call.CallErrorOccured -= (Call_CallErrorOccured);
            call.DtmfReceived -= (Call_DtmfReceived);
            call.DtmfStarted -= (Call_DtmfStarted);
            call.InstantMessageDataReceived -= (Call_InstantMessageDataReceived);
        }
Ejemplo n.º 39
0
 private void WireEventsBob(IPhoneCall call)
 {
     call.CallErrorOccured += callBob_ErrorOccured;
     call.CallStateChanged += _callBob_StateChanged;
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Hangs up the current call.
 /// </summary>
 public void HangUp()
 {
     _call?.Reject();
     _call?.HangUp();
     _call = null;
 }
 public PhoneCallInstantMessageArgs(IPhoneCall phoneCall, InstantMessage message)
 {
     PhoneCall = phoneCall;
     Message   = message;
 }
 private void SoftPhone_IncomingCall(object sender, global::Ozeki.Media.VoIPEventArgs <IPhoneCall> e)
 {
     call = e.Item;
     call.Answer();
     AttachSendCall();
 }
Ejemplo n.º 43
0
 protected void CallAlice()
 {
     _outgoingCallAlice = _phoneBob.CreateCall();
     WireEventsBob(_outgoingCallAlice);
     _outgoingCallAlice.Start(_aliceEndPoint.ToString());
 }
Ejemplo n.º 44
0
        public void CreateCall(string pPhoneNo, int pPhoneRingTimeOut = 30)
        {
            if (pPhoneRingTimeOut > 0)
                m_RingingTimeOut = pPhoneRingTimeOut;

            m_RingTimeOut = false;
            m_PhoneNo = pPhoneNo;

            m_UserMicrophone.Start();
            connector.Connect(m_UserMicrophone, mediaSender);

            AudioId = Guid.NewGuid();
            CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true);
            m_UserMicrophone.Start();
            string fileNameTmp = String.Format(@"{0}\tmpwav\{1}_.wav", commonData.ApplicationFolderPath, AudioId);
            recorder = new WaveStreamRecorder(fileNameTmp);
            recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped);

            connector.Connect(m_UserMicrophone, mixer);
            connector.Connect(mediaReceiver, mixer);
            connector.Connect(mixer, recorder);
            m_UserSpeaker.Start();
            connector.Connect(mediaReceiver, m_UserSpeaker);

            call = softPhone.CreateCallObject(phoneLine, m_PhoneNo);
            mediaSender.AttachToCall(call);
            mediaReceiver.AttachToCall(call);

            this.WireUpCallEvents();
            //System.Threading.Thread.Sleep(1500);
            call.Start();
            //softPhone.RegisterPhoneLine(phoneLine);
            //this.InitializeSoftPhone();
        }
Ejemplo n.º 45
0
 protected void CallBob()
 {
     _outgoingCallBob = _phoneAlice.CreateCall();
     WireEventsAlice(_outgoingCallBob);
     _outgoingCallBob.Start(_bobEndPoint.ToString());
 }
Ejemplo n.º 46
0
        public void UnRegisterPhone()
        {
            if (softPhone != null)
            {
                if(phoneLine != null)
                    softPhone.UnregisterPhoneLine(phoneLine);

                softPhone.Close();
            }
            this.WireDownCallEvents();
            call = null;
        }
Ejemplo n.º 47
0
 /// <summary>
 /// Attaches the media handlers to the given phone call.
 /// </summary>
 public void AttachVideo(IPhoneCall call)
 {
     _phoneCallVideoReceiver.AttachToCall(call);
     _phoneCallVideoSender.AttachToCall(call);
 }
Ejemplo n.º 48
0
        /// <summary>
        /// Occurs when the phone call state has changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void call_CallStateChanged1(object sender, VoIPEventArgs<CallState> e)
        {
            this.InvokeGUIThread(() => {
                if (e.Item == CallState.Ringing) {
                    m_TimeStart = DateTime.Now.TimeOfDay;
                    m_StartTimeOutCounter = true;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Ring);
                }

                else if (e.Item == CallState.InCall) {
                    try
                    {
                        m_StartTimeOutCounter = false;
                        mixer = new AudioMixerMediaHandler();
                        mixerMic = new AudioMixerMediaHandler();
                        mixerReceiver = new AudioMixerMediaHandler();
                        AudioId = Guid.NewGuid();
                        CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true);
                        if (m_UserMicrophone != null)
                            m_UserMicrophone.Start();

                        if (m_UserSpeaker != null)
                            m_UserSpeaker.Start();

                        connector.Connect(m_UserMicrophone, mediaSender);
                        connector.Connect(mediaReceiver, m_UserSpeaker);
                        m_MediaUtility.Stop();
                        //m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);

                        mediaSender.AttachToCall(call);
                        mediaReceiver.AttachToCall(call);

                        #region combine mic and receiver in record
                        string fileName = String.Format(@"{0}\\tmpwav\\{1}_.wav", commonData.ApplicationFolderPath, AudioId);
                        recorder = new WaveStreamRecorder(fileName);
                        recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped);
                        connector.Connect(m_UserMicrophone, mixer);
                        connector.Connect(mediaReceiver, mixer);
                        connector.Connect(mixer, recorder);
                        #endregion

                        #region record mic
                        fileName = String.Format(@"{0}\\tmpwav\\{1}_mic.wav", commonData.ApplicationFolderPath, AudioId);
                        recorderMic = new WaveStreamRecorder(fileName);
                        recorderMic.Stopped += new EventHandler<EventArgs>(recorder_Stopped1);
                        connector.Connect(m_UserMicrophone, mixerMic);
                        connector.Connect(mixerMic, recorderMic);
                        #endregion

                        #region record receiver
                        fileName = String.Format(@"{0}\\tmpwav\\{1}_receiver.wav", commonData.ApplicationFolderPath, AudioId);
                        recorderReceiver = new WaveStreamRecorder(fileName);
                        recorderReceiver.Stopped += new EventHandler<EventArgs>(recorder_Stopped2);
                        connector.Connect(mediaReceiver, mixerReceiver);
                        connector.Connect(mixerReceiver, recorderReceiver);
                        #endregion

                        recorder.StartStreaming();
                        //recorder.IsStreaming = true;
                        recorderReceiver.StartStreaming();
                        //recorderReceiver.IsStreaming = true;
                        recorderMic.StartStreaming();
                        //recorderMic.IsStreaming = true;
                    }
                    catch(Ozeki.Common.Exceptions.MediaException me) {
                        if (CallState_Changed != null)
                        {
                            CallState_Changed(this, new CallStateChangedArgs()
                            {
                                PhoneCallState = CallState.Rejected
                            });
                        }
                        if (call != null)
                            call.HangUp();

                        //softPhone.UnregisterPhoneLine(phoneLine);
                        softPhone.Close();
                        this.WireDownCallEvents();
                        call = null;

                        m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                        MessageBox.Show("Your mic or speaker is not working. Please change your mic or speaker in the Phone Settings.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }

                else if (e.Item == CallState.Completed) {
                    try
                    {

                        if (m_UserMicrophone != null)
                            m_UserMicrophone.Stop();
                        if (m_UserSpeaker != null)
                            m_UserSpeaker.Stop();

                        connector.Disconnect(m_UserMicrophone, mediaSender);
                        connector.Disconnect(mediaReceiver, m_UserSpeaker);

                        if (recorder != null)
                        {
                            recorder.StopStreaming();
                            //recorder.IsStreaming = false;
                        }
                        if (recorderMic != null)
                        {
                            recorderMic.StopStreaming();
                            //recorderMic.IsStreaming = false;
                        }
                        if (recorderReceiver != null)
                        {
                            recorderReceiver.StopStreaming();
                            //recorderReceiver.IsStreaming = false;
                        }

                        connector.Disconnect(m_UserMicrophone, mixer);
                        connector.Disconnect(mediaReceiver, mixer);
                        connector.Disconnect(mixer, recorder);

                        connector.Disconnect(m_UserSpeaker, mixerMic);
                        connector.Disconnect(mixerMic, recorderMic);

                        connector.Disconnect(mixerMic, recorderMic);
                        connector.Disconnect(mixerReceiver, recorderReceiver);

                        mediaSender.Detach();
                        mediaReceiver.Detach();
                        if (m_RingTimeOut)
                            return;

                        //softPhone.UnregisterPhoneLine(phoneLine);
                        softPhone.Close();

                        this.WireDownCallEvents();
                        //call.HangUp();
                        call = null;
                        m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                        recorder.Dispose();
                        mixer.Dispose();
                        recorder = null;
                        mixer = null;
                        recorderMic.Dispose();
                        mixerMic.Dispose();
                        recorderMic = null;
                        mixerMic = null;
                        mixerReceiver.Dispose();
                        recorderReceiver.Dispose();
                        mixerReceiver = null;
                        recorderReceiver = null;
                        WaitUntilTheRecordEndProcess();

                    }
                    catch {
                        //softPhone.UnregisterPhoneLine(phoneLine);
                        softPhone.Close();
                        this.WireDownCallEvents();
                        call = null;
                    }
                }

                else if (e.Item == CallState.Cancelled) {
                    if (m_RingTimeOut)
                        return;

                    m_StartTimeOutCounter = false;
                    //softPhone.UnregisterPhoneLine(phoneLine);
                    softPhone.Close();
                    this.WireDownCallEvents();
                    call = null;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                }

                else if (e.Item == CallState.Rejected) {
                    m_StartTimeOutCounter = false;
                    //softPhone.UnregisterPhoneLine(phoneLine);
                    softPhone.Close();
                    this.WireDownCallEvents();
                    call = null;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp);
                }

                else if (e.Item == CallState.Busy || e.Item == CallState.Error) {
                    m_RingTimeOut = true;
                    m_StartTimeOutCounter = false;
                    m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Busy);
                    //softPhone.UnregisterPhoneLine(phoneLine);
                    softPhone.Close();
                    call.HangUp();
                    call = null;
                    //MessageBox.Show("Error encountered. Please check the format of the number you are calling.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.WireDownCallEvents();
                    //call = null;
                }

                if (CallState_Changed != null)
                    CallState_Changed(this, new CallStateChangedArgs() {
                        PhoneCallState = e.Item,
                        AudioId = AudioId
                    });
            });
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Routes the selected call to another.
        /// </summary>
        public void AttendedTransfer(IPhoneCall targetCall)
        {
            if (SelectedCall == null)
                return;

            if (targetCall == null)
                return;

            SelectedCall.AttendedTransfer(targetCall);
        }
Ejemplo n.º 50
0
 private void UnWireEventsAlice(IPhoneCall call)
 {
     call.CallErrorOccured -= callAlice_ErrorOccured;
     call.CallStateChanged -= _callAlice_StateChanged;
 }
Ejemplo n.º 51
0
        private void DisposeCall(IPhoneCall call)
        {
            UnsubscribeFromCallEvents(call);

            if (call.Equals(SelectedCall))
                SelectedCall = null;
        }
Ejemplo n.º 52
0
 void _phoneAlice_IncomingCall(object sender, VoipEventArgs <IPhoneCall> e)
 {
     _incomingCallAlice = e.Item;
     WireEventsAlice(_incomingCallAlice);
     OnAliceIncomingCallReceived();
 }
Ejemplo n.º 53
0
 private void OnIncomingCall(IPhoneCall call)
 {
     var handler = IncomingCall;
     if (handler != null)
         handler(this, new GEventArgs<IPhoneCall>(call));
 }
Ejemplo n.º 54
0
 protected void CallBob()
 {
     _outgoingCallBob = _phoneAlice.CreateCall();
     WireEventsAlice(_outgoingCallBob);
     _outgoingCallBob.Start(_bobEndPoint.ToString());
 }
Ejemplo n.º 55
0
 private void OnPhoneCallStateChanged(IPhoneCall call)
 {
     var handler = PhoneCallStateChanged;
     if (handler != null)
         handler(this, new GEventArgs<IPhoneCall>(call));
 }
Ejemplo n.º 56
0
 void _phoneAlice_IncomingCall(object sender, VoipEventArgs<IPhoneCall> e)
 {
     _incomingCallAlice = e.Item;
     WireEventsAlice(_incomingCallAlice);
     OnAliceIncomingCallReceived();
 }
Ejemplo n.º 57
0
        private void _btnPhone_Click(object sender, EventArgs e)
        {
            if (!_callState.HasValue || _callState.Value == CallState.Completed)
            {
                FormHelper.ValidateCondition(SipUtil.IsSipUri(_txtToUri.Text), "To-uri");

                _outgoingCall = _softPhone.CreateCall();
                WireEvents(_outgoingCall);
                _outgoingCall.Start(_txtToUri.Text);
                Log("Call started");
            }
            else if (_callState.Value == CallState.Ringing)
            {
                _incomingCall.Accept();
            }
            else if (_callState.Value == CallState.Ringback || _callState.Value == CallState.InCall)
            {
                _outgoingCall.Stop();
            }
        }
Ejemplo n.º 58
0
 void softphone_IncomingCall(object sender, VoIPEventArgs <IPhoneCall> e)
 {
     call = e.Item;
     call.CallStateChanged += call_CallStateChanged;
     call.Answer();
 }
Ejemplo n.º 59
0
 void _phoneBob_IncomingCall(object sender, VoipEventArgs<IPhoneCall> e)
 {
     _incomingCallBob = e.Item;
     WireEventsBob(_incomingCallBob);
     OnBobIncomingCallReceived();
 }