private void onCallStateChanged(int callId) { _log.Info("Call with id '{0}' changed its state to {1}", callId, _resources.CallManager.getCall(callId).StateId); lock (_calls) { SIPCall call = FindCallById(callId); if (call == null) { _log.Info("Call with id '{0}' is not in list. Ignoring state change", callId); return; } switch (_resources.CallManager.getCall(callId).StateId) { case EStateId.ACTIVE: call.CallState = CallState.Connected; break; case EStateId.INCOMING: call.CallState = CallState.Ringing; break; case EStateId.TERMINATED: case EStateId.IDLE: call.CallState = CallState.Disconnected; call.Hangup(); break; case EStateId.RELEASED: call.CallState = CallState.HangUp; break; case EStateId.NULL: call.CallState = CallState.Disconnected; lock (_calls) { _log.Info("Removing call '{0}'", callId); _calls.Remove(call); } break; } } }
public void Initialize() { if (_resources != null) { Dispose(); } InitThread(); _initialized.WaitOne(); _dispatcher.Invoke( DispatcherPriority.Normal, (MethodInvoker) delegate { _log.Info("Initializing SIPCallProvider"); _resources = new SipekResources(); _resources.CallManager.CallStateRefresh += onCallStateChanged; _resources.CallManager.IncomingCallNotification += new DIncomingCallNotification(resources_CallManager_IncomingCallNotification); _resources.Registrar.AccountStateChanged += new DAccountStateChanged(resources_Registrar_AccountStateChanged); int status = _resources.CallManager.Initialize(); _resources.CallManager.CallLogger = _resources.CallLogger; if (status != 0) { throw new CallProviderException("Init SIP stack problem! \r\nPlease, check configuration and start again! \r\nStatus code " + status); } // initialize Stack _resources.Registrar.registerAccounts(); int noOfCodecs = _resources.StackProxy.getNoOfCodecs(); for (int i = 0; i < noOfCodecs; i++) { string codecname = _resources.StackProxy.getCodec(i); if (_resources.Configurator.CodecList.Contains(codecname)) { // leave default _resources.StackProxy.setCodecPriority(codecname, 128); } else { // disable _resources.StackProxy.setCodecPriority(codecname, 0); } } pjsipCallProxy.OnWavPlayerCompleted += delegate(int callId) { _log.Info("Wav playback for call '{0}' ended", callId); SIPCall call = FindCallById(callId); if (call != null) { call.AudioPlaybackCompleted(); } }; }); }