/// <summary> /// /// </summary> /// <param name="ch"></param> /// <param name="path"></param> /// <returns></returns> protected bool TryCall(SipChannel ch, SipPath path) { string dstParams = ""; string remoteId = path.Remote.Ids[0]; if (!path.Line.centralIP) { //Estos parametros son internos, sirven para dar información a la pasarela //En encaminamiento IP no se deben usar if ((ch.Prefix != Cd40Cfg.INT_DST) && ((ch.Prefix != Cd40Cfg.PP_DST) || (string.Compare(remoteId, path.Line.Id) != 0))) { dstParams += string.Format(";cd40rs={0}", path.Line.Id); } } string dstUri = string.Format("<sip:{0}@{1}{2}>", remoteId, path.Line.Ip, dstParams); try { CORESIP_CallFlags flags = CORESIP_CallFlags.CORESIP_CALL_NO_FLAGS; if (path.ModoSinProxy == false) { flags |= CORESIP_CallFlags.CORESIP_CALL_EXTERNAL_IP; } int sipCallId = SipAgent.MakeLcCall(ch.AccId, dstUri, flags); _SipCallTx.Update(sipCallId, ch.AccId, remoteId, ch, path.Remote, path.Line); return(true); } catch (Exception ex) { ch.SetCallResult(path.Remote, path.Line, _SipCallTx.Priority, -1); _Logger.Warn("ERROR llamando a " + dstUri, ex); } return(false); }
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); }