Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void MakeHangUpTx()
        {
            if (_SipCallTx != null)
            {
                if (_SipCallTx.IsActive)
                {
                    Debug.Assert(_ActiveTx == this);

                    switch (_TxState)
                    {
                    case LcTxState.Out:
                        _CallTout.Enabled = false;
                        break;

                    case LcTxState.Tx:
                        Top.Mixer.Unlink(_SipCallTx.Id);
                        break;
                    }

                    SipAgent.HangupCall(_SipCallTx.Id);
                }
                else
                {
                    Debug.Assert((_TxState == LcTxState.Congestion) || (_TxState == LcTxState.Busy));
                }

                // Top.Recorder.Rec(CORESIP_CallType.CORESIP_CALL_IA, false);

                _SipCallTx       = null;
                _ActiveTx        = null;
                Top.Lc.HoldedTlf = false;
            }
        }
Exemplo n.º 2
0
        public static SipCallInfo NewMonitoringCall(IEnumerable <SipChannel> channels)
        {
            SipCallInfo info = NewCall(channels);

            info._Monitoring = true;

            return(info);
        }
Exemplo n.º 3
0
        public static SipCallInfo NewReplacesCall(IEnumerable <SipChannel> channels, TlfPickUp.DialogData dialog)
        {
            SipCallInfo info = NewCall(channels);

            info._Dialog = dialog;

            return(info);
        }
Exemplo n.º 4
0
        public static SipCallInfo NewLcCall(IEnumerable <SipChannel> channels)
        {
            SipCallInfo info = NewCall(channels);

            info._Priority = CORESIP_Priority.CORESIP_PR_URGENT;

            return(info);
        }
Exemplo n.º 5
0
        public static SipCallInfo NewTlfCall(IEnumerable <SipChannel> channels, CORESIP_Priority priority, string referBy)
        {
            SipCallInfo info = NewCall(channels);

            info._Priority = priority;
            info._ReferBy  = referBy;

            return(info);
        }
Exemplo n.º 6
0
        public static SipCallInfo NewRedirectCall(IEnumerable <SipChannel> channels, CORESIP_Priority priority, int callId)
        {
            SipCallInfo info = NewCall(channels);

            info._Redirect = true;
            info._Id       = callId;
            info._Priority = priority;

            return(info);
        }
Exemplo n.º 7
0
        private static SipCallInfo NewCall(IEnumerable <SipChannel> channels)
        {
            foreach (SipChannel ch in channels)
            {
                ch.ResetCallResults(true);
            }

            SipCallInfo info = new SipCallInfo();

            return(info);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sipCallId"></param>
        /// <param name="info"></param>
        /// <param name="inInfo"></param>
        /// <returns></returns>
        public int HandleIncomingCall(int sipCallId, CORESIP_CallInfo info, CORESIP_CallInInfo inInfo)
        {
            SipCallInfo inCall = SipCallInfo.NewIncommingCall(_Channels, sipCallId, info, inInfo, false);

            if (inCall != null)
            {
                if ((Top.ScreenSaverEnabled) || Top.Hw.LCSpeaker == false)
                {
                    return(SipAgent.SIP_DECLINE);
                }
                // Si la telefonía va por altavoz y hay llamada de LC se quita
                // el estado "en espera de cuelgue"
                if (Top.Mixer.RxTlfAudioVia == TlfRxAudioVia.Speaker)
                {
                    Top.Tlf.SetHangToneOff();
                }
                MakeHangUpRx();
                RxState = LcRxState.Idle;

                if ((_ActiveRx != null) || ((_ActiveTx != null) && (_ActiveTx != this)))
                {
                    // Notificamos el Mem y lo borramos
                    _OldRxState = _RxState;
                    RxState     = LcRxState.Mem;
                    _RxState    = LcRxState.Idle;

                    return(SipAgent.SIP_BUSY);
                }
                else
                {
                    _SipCallRx = inCall;
                    _ActiveRx  = this;

                    _Channels.Sort(delegate(SipChannel a, SipChannel b)
                    {
                        return(b.First.CompareTo(a.First));
                    }
                                   );

                    return(SipAgent.SIP_OK);
                }
            }

            return(SipAgent.SIP_DECLINE);
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        public void Call()
        {
            if ((_ActiveTx == null) && (_TxState == LcTxState.Idle))
            {
                Debug.Assert(_SipCallTx == null);
                _SipCallTx = SipCallInfo.NewLcCall(_Channels);

                TxState   = TryCall();
                _ActiveTx = this;

                if (_TxState == LcTxState.Out)
                {
                    _CallTout.Enabled = true;

                    // Top.Recorder.Rec(CORESIP_CallType.CORESIP_CALL_IA, true);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        private void MakeHangUpRx()
        {
            if (_SipCallRx != null)
            {
                Debug.Assert(_SipCallRx.IsActive);
                Debug.Assert(_ActiveRx == this);

                if (_RxState == LcRxState.Rx)
                {
                    Top.Mixer.Unlink(_SipCallRx.Id);
                }

                SipAgent.HangupCall(_SipCallRx.Id);

                _ActiveRx        = null;
                _SipCallRx       = null;
                Top.Lc.HoldedTlf = false;
            }
        }
Exemplo n.º 11
0
        public override int HandleIncomingCall(int sipCallId, int call2replace, CORESIP_CallInfo info, CORESIP_CallInInfo inInfo)
        {
            bool replacedCall = false;

            if ((Top.ScreenSaverEnabled) || (Top.Mixer.RxTlfAudioVia == TlfRxAudioVia.Speaker && !Top.Hw.LCSpeaker))
            {
                return(SipAgent.SIP_DECLINE);
            }

            if ((call2replace >= 0) && (CallId == call2replace))
            {
                MakeHangUp(SipAgent.SIP_GONE);
                replacedCall = true;
            }

            if ((info.Priority == CORESIP_Priority.CORESIP_PR_EMERGENCY) &&
                ((Top.Cfg.Permissions & Permissions.Intruded) == Permissions.Intruded) && (_SipCall != null))
            {
                if (_State == TlfState.Out)
                {
                    //En teclas de 19+1,  se admiten llamada con los datos que no coincidan con configuracion
                    SipCallInfo inCall = SipCallInfo.NewIncommingCall(_Channels, sipCallId, info, inInfo, true);

                    if (inCall != null)
                    {
                        if (((int)inCall.Priority < (int)_SipCall.Priority) ||
                            ((inCall.Priority == _SipCall.Priority) && (string.Compare(inInfo.SrcIp, Top.SipIp) < 0)))
                        {
                            _CallTout.Enabled = false;
                            SipAgent.HangupCall(_SipCall.Id);

                            _SipCall = inCall;
                            CORESIP_CallFlags flags = Settings.Default.EnableEchoCanceller &&
                                                      (_SipCall.Ch.Prefix == Cd40Cfg.PP_DST || (_SipCall.Ch.Prefix >= Cd40Cfg.RTB_DST && _SipCall.Ch.Prefix < Cd40Cfg.EyM_DEST)) ?
                                                      CORESIP_CallFlags.CORESIP_CALL_EC : CORESIP_CallFlags.CORESIP_CALL_NO_FLAGS;

                            return(SipAgent.SIP_OK | ((int)flags << 16));
                        }
                    }
                }

                if (EfectivePriority != CORESIP_Priority.CORESIP_PR_EMERGENCY && info.Priority != CORESIP_Priority.CORESIP_PR_EMERGENCY)
                {
                    MakeHangUp(0);
                }
            }

            if ((_SipCall == null) && !InOperation())                   // && PermisoRed((uint)(((SipChannel)inCall.Ch).Type),true))
            {
                if (FillData(info, inInfo) == false)
                {
                    return(SipAgent.SIP_DECLINE);
                }
            }
            int result = base.HandleIncomingCall(sipCallId, call2replace, info, inInfo);

            //Si no se acepta llamada entrante y se trataba de un replace que ya se ha colgado, se señaliza con error
            if (replacedCall &&
                ((result == SipAgent.SIP_DECLINE) || (result == SipAgent.SIP_BUSY)))
            {
                State = TlfState.Busy;
            }
            return(result);
        }
Exemplo n.º 12
0
        ///Tests para probar cuando se corta la llamada y pasa la tecla a reposo
        ///por una sectorización con cambios.
        ///La llamada no tiene canal
        public void ChangeConfig1()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);

            //Give it an incomplete call, , no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //1.Cambio configuracion origen R2
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002"; // Cambio
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //2.Cambio configuracion Prioridad, literal
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1_"; //Cambio
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;     // Cambio
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);

            //3.Cambio configuracion prefijo recurso, nombre rec
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1_";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 3;     // Cambio
            rec.NombreRecurso = "S1_"; //Cambio
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No Se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
        }
Exemplo n.º 13
0
        ///Tests para probar cuando se corta la llamada y pasa la tecla a reposo
        ///por una sectorización con cambios.
        ///Hay una llamada con canal, pero sin callId
        public void ChangeConfig3()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "BL";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);

            //Give it an incomplete call, no callID
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            SipRemote remote = new SipRemote(rec.NombreRecurso);

            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            Assert.IsNotNull(tlfTest._SipCall);

            //1.Cambio configuracion origen R2
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218002"; // Cambio
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);

            //Give it an incomplete call, no callID
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            remote           = new SipRemote(rec.NombreRecurso);
            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            tlfTest.State = TlfState.Busy;

            //2.Cambio configuracion Prioridad, literal
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL_"; //Cambio
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 3;     // Cambio
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "prubl";
            rec.Interface     = TipoInterface.TI_BL;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada porque no esta disponible la linea
            Assert.IsNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //Give it an incomplete call, no channel
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            remote           = new SipRemote(rec.NombreRecurso);
            tlfTest._SipCall.Update(-1, link.OrigenR2, rec.NombreRecurso, tlfTest.Channels[0], remote, tlfTest.Channels[0].ListLines[0]);
            tlfTest.State = TlfState.Busy;
            Assert.IsNotNull(tlfTest._SipCall);

            //3.Cambio configuracion prefijo recurso, nombre rec
            link                   = new CfgEnlaceInterno();
            link.Literal           = "BL_";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 3;
            link.OrigenR2          = "218002";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 0;         // Cambio
            rec.NombreRecurso = "S4_SCV2"; //Cambio
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //Se corta la llamada
            Assert.IsNull(tlfTest._SipCall);
        }
Exemplo n.º 14
0
        ///Tests para probar que no se corta la llamada ni cambia de estado
        ///por una sectorización sin cambios
        public void ChangeConfig2()
        {
            //Initial configuration
            TlfPosition      tlfTest = new TlfPosition(12);
            CfgEnlaceInterno link    = new CfgEnlaceInterno();

            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            CfgRecursoEnlaceInterno rec = new CfgRecursoEnlaceInterno();

            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);

            tlfTest.Reset(link);
            //Give it an incomplete call, estado unavailable
            tlfTest._SipCall = SipCallInfo.NewTlfCall(tlfTest.Channels, CORESIP_Priority.CORESIP_PR_NORMAL, null);
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //1.sin cambios, en estado unavailable
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Unavailable);

            //2. Tecla en congestion, no cambia
            tlfTest.State          = TlfState.Congestion;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Congestion);

            //3. Tecla en busy, no cambia
            tlfTest.State          = TlfState.Busy;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.Busy);

            //3. Tecla en InProcess, no cambia
            tlfTest.State          = TlfState.InProcess;
            link                   = new CfgEnlaceInterno();
            link.Literal           = "S1";
            link.TipoEnlaceInterno = "DA";
            link.Prioridad         = 4;
            link.OrigenR2          = "218001";
            rec               = new CfgRecursoEnlaceInterno();
            rec.Prefijo       = 2;
            rec.NombreRecurso = "S1";
            rec.Interface     = TipoInterface.TI_Radio;
            link.ListaRecursos.Add(rec);
            tlfTest.Reset(link);
            //No se corta la llamada
            Assert.IsNotNull(tlfTest._SipCall);
            Assert.AreEqual(tlfTest.State, TlfState.InProcess);
        }