/// <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; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCallTimeout(object sender, ElapsedEventArgs e) { Top.WorkingThread.Enqueue("OnLcCallTimeout", delegate() { if (_TxState == LcTxState.Out) { Debug.Assert((_SipCallTx != null) && _SipCallTx.IsActive); Debug.Assert(_ActiveTx == this); SipAgent.HangupCall(_SipCallTx.Id); _SipCallTx.Id = -1; TxState = LcTxState.Congestion; } }); }
/// <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; } }
//private object locker = new object(); public UCMainViewModel() { //lock (locker) { _uiContext = System.Threading.SynchronizationContext.Current; Load(); SipAgentInitAndStart(); SnmpAgentInitAndStart(); Title = String.Format("Simulador de Equipos Radio Voip. Nucleo 2018. [{0}:{1}]", Config.VoipAgentIP, Config.VoipAgentPort); Btn01Text = "Config"; Btn02Text = "Salir"; ForceSquelchCmd = new DelegateCommandBase((obj) => { if (obj is SimulatedRadioEquipment) { var ses = (obj as SimulatedRadioEquipment); if (ses.Habilitado == true && ses.IsTx == false) { ses.AircrafSquelch = !ses.AircrafSquelch; if (ses.CallId != -1) { if (LocalAudioPlayer != -1 && !ses.ScvSquelch) { if (ses.AircrafSquelch) { SipAgent.MixerLink(LocalAudioPlayer, ses.CallId); } else if (!ses.AircrafSquelch) { SipAgent.MixerUnlink(LocalAudioPlayer, ses.CallId); } } SipAgent.SquelchSet(ses.CallId, ses.Squelch); } } } if (obj is SimulatedFrequecy) { var frequency = obj as SimulatedFrequecy; //var receivers = frequency.Equipments.Where(eq => eq.Habilitado == true && eq.IsTx == false).ToList(); var receivers = AllEquipments.Where(eq => eq.FreqObject == frequency && eq.Habilitado == true && eq.IsTx == false).ToList(); receivers.ForEach(receiver => { receiver.AircrafSquelch = !receiver.AircrafSquelch; if (receiver.CallId != -1) { if (LocalAudioPlayer != -1 && !receiver.ScvSquelch) { if (receiver.AircrafSquelch) { SipAgent.MixerLink(LocalAudioPlayer, receiver.CallId); } else if (!receiver.AircrafSquelch) { SipAgent.MixerUnlink(LocalAudioPlayer, receiver.CallId); } } SipAgent.SquelchSet(receiver.CallId, receiver.Squelch); } }); frequency.AircrafSquelch = !frequency.AircrafSquelch; } }); EnableDisableCmd = new DelegateCommandBase((obj) => { if (obj is SimulatedRadioEquipment) { var ses = (obj as SimulatedRadioEquipment); if (ses.CallId != -1) { SipAgent.HangupCall(ses.CallId, SipAgentNet.SIP_OK); ses.Reset(); } ses.Habilitado = !ses.Habilitado; } }); } }
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); }
/// <summary> /// /// </summary> /// <param name="sender"></param> private void OnRsChanged(object sender) { Resource rs = (Resource)sender; if (rs.Content is GwTlfRs) { //Este tipo de recurso son los creados por la 19+1 de telefonía, //no vienen del Tifx y no deben afectar a las LC if (((GwTlfRs)rs.Content).Type == (uint)RsChangeInfo.RsTypeInfo.NoType) { return; } } if (!rs.IsValid) { LcRxState rxSt; LcTxState txSt; GetState(out rxSt, out txSt); if (rxSt == LcRxState.Unavailable) { Debug.Assert(txSt == LcTxState.Unavailable); MakeHangUpRx(); MakeHangUpTx(); } else { if (_SipCallRx != null) { if (_SipCallRx.IsActive && (_SipCallRx.Line.RsLine == rs)) { MakeHangUpRx(); } else { rxSt = _RxState; } } if (_SipCallTx != null) { if (_TxState == LcTxState.Out) { if (_SipCallTx.Line.RsLine == rs) { _SipCallTx.Ch.ResetCallResults(rs); } else { foreach (SipChannel ch in _Channels) { if (ch.ResetCallResults(rs)) { break; } } } } if (_SipCallTx.IsActive && (_SipCallTx.Line.RsLine == rs)) { if (_TxState == LcTxState.Out) { SipAgent.HangupCall(_SipCallTx.Id); _SipCallTx.Id = -1; txSt = (_CallTout.Enabled ? TryCall() : LcTxState.Congestion); } else { MakeHangUpTx(); } } else { txSt = _TxState; } } } SetState(rxSt, txSt); } else { //Esto es para cambiar la IP del proxy vivo (es de tipo GwTflRs y no de GwLcRs) if (rs.Content is GwTlfRs) { ResetIpLinesOfChannels(rs.Id, ((GwTlfRs)rs.Content).GwIp); } else if (rs.Content is GwLcRs) { ResetIpLinesOfChannels(rs.Id, ((GwLcRs)rs.Content).GwIp); } if (_SipCallTx != null) { if ((_TxState == LcTxState.Out) && (_SipCallTx.Line.RsLine != rs)) { foreach (SipChannel ch in _Channels) { if (ch.ResetCallResults(rs)) { break; } } } } else { if (_RxState == LcRxState.Unavailable) { Debug.Assert(_TxState == LcTxState.Unavailable); //Pone a idle la tecla sin tener en cuenta todos sus canales y recursos //No funciona LC con recurso IP sólo //SetState(LcRxState.Idle, LcTxState.Idle); LcRxState rxSt = _RxState; LcTxState txSt = _TxState; GetState(out rxSt, out txSt); SetState(rxSt, txSt); } } } }