Beispiel #1
0
        public override void onCallState(OnCallStateParam prm)
        {
            base.onCallState(prm);
            //lock (locker)
            {
                var ci = getInfo();

                if (ci == null)
                {
                    return;
                }

                if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_INCOMING ||
                    LastState == pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
                {
                    CallType = Type.INBOUND;
                }
                if (ci.state.In(pjsip_inv_state.PJSIP_INV_STATE_EARLY, pjsip_inv_state.PJSIP_INV_STATE_CALLING))
                {
                    CallType = Type.OUTBOUND;
                }

                NotifyCallState(ci.state);
                if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED)
                {
                    if (LastState == pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
                    {
                        CallType = Type.MISSED;
                    }
                    /* Delete the call */
                    Dispose();
                }
                LastState = ci.state;
            }
        }
Beispiel #2
0
 public void processStateChange(OnCallStateParam prm)
 {
     pjsua2PINVOKE.Call_processStateChange(swigCPtr, OnCallStateParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #3
0
 public virtual void onCallState(OnCallStateParam prm)
 {
     pjsua2PINVOKE.Call_onCallState(swigCPtr, OnCallStateParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #4
0
        public override void onCallState(OnCallStateParam prm)
        {
            base.onCallState(prm);
            var ci = this.getInfo();

            if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED)
            {
                Dispose();
            }
        }
Beispiel #5
0
        private void OnCallState(object sender, CallInfo info, OnCallStateParam prm, MyAccount account)
        {
            var      call = (MyCall)sender;
            CallInfo ci   = call.getInfo();

            if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED)
            {
                account.Calls.Remove(call);
                /* Delete the call */
                call.Dispose();
            }
        }
Beispiel #6
0
 public virtual void onCallState(OnCallStateParam prm)
 {
     if (SwigDerivedClassHasMethod("onCallState", swigMethodTypes0))
     {
         pjsua2PINVOKE.Call_onCallStateSwigExplicitCall(swigCPtr, OnCallStateParam.getCPtr(prm));
     }
     else
     {
         pjsua2PINVOKE.Call_onCallState(swigCPtr, OnCallStateParam.getCPtr(prm));
     }
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #7
0
        private void OnCallState(object sender, CallInfo info, OnCallStateParam prm, MyAccount account)
        {
            Messages += $"---------------------{DateTime.Now.ToString("T")}---------------------\r";
            Messages += "CallStateParam:\r" + JsonConvert.SerializeObject(prm) + "\r";
            Messages += "CallInfo:\r" + JsonConvert.SerializeObject(info) + "\r";
            var      call = (MyCall)sender;
            CallInfo ci   = call.getInfo();

            if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED)
            {
                account.Calls.Remove(call);
                /* Delete the call */
                call.Dispose();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Обрабатываем событие изменения статуса звонка
        /// </summary>
        /// <param name="prm"></param>
        public override void onCallState(OnCallStateParam prm)
        {
            CallInfo ci = getInfo();

            isOnLine = isActive();

            if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
            {
                if (onCallIncoming != null)
                {
                    onCallIncoming(ci.remoteUri);
                }
            }

            if (ci.state == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED)
            {
                if (onCallDisconnected != null)
                {
                    onCallDisconnected(this);
                }
            }
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(OnCallStateParam obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #10
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(OnCallStateParam obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Beispiel #11
0
        /// <summary>
        /// Notify application when call state has changed.
        /// Application may then query the call info to get the
        /// detail call states by calling getInfo() function.
        /// </summary>
        /// <param name="sender">The current sender.</param>
        /// <param name="e">The event parameter.</param>
        private void _call_OnCallState(object sender, OnCallStateParam e)
        {
            Nequeo.Net.PjSip.CallInfo ci = e.Info;
            if (ci != null)
            {
                _info = null;
                try
                {
                    // Create the call info.
                    _info                 = new CallInfoParam();
                    _info.CallID          = ci.Id;
                    _info.Guid            = _guid;
                    _info.Contact         = ci.RemoteContact;
                    _info.FromTo          = ci.RemoteUri;
                    _info.Date            = DateTime.Now;
                    _info.ConnectDuration = new TimeSpan(0, 0, 0, ci.ConnectDuration.Seconds, ci.ConnectDuration.Milliseconds);
                    _info.TotalDuration   = new TimeSpan(0, 0, 0, ci.TotalDuration.Seconds, ci.TotalDuration.Milliseconds);
                }
                catch { _info = null; }

                Param.CallStateParam callState = new CallStateParam();
                callState.CallID   = ci.Id;
                callState.State    = ci.State;
                callState.CallInfo = _info;

                try
                {
                    // Handle the event.
                    OnCallState?.Invoke(this, callState);

                    // Set the contact name.
                    _info.ContactName = callState.ContactName;
                }
                catch { }

                // If call is disconnected.
                if ((ci.State == InviteSessionState.PJSIP_INV_STATE_DISCONNECTED) ||
                    (ci.State == InviteSessionState.PJSIP_INV_STATE_NULL))
                {
                    // If current call.
                    if (e.CurrentCall != null)
                    {
                        try
                        {
                            // Cleanup the call.
                            e.CurrentCall.Dispose();
                            e.CurrentCall = null;
                        }
                        catch { }
                    }

                    // If recoder.
                    if (_recorder != null)
                    {
                        try
                        {
                            // Stop the recorder.
                            AudioMedia audioMedia = _mediaManager.GetCaptureDeviceMedia();
                            _recorder.Stop(audioMedia);
                        }
                        catch { }

                        try
                        {
                            // Cleanup the recoder.
                            _recorder.Dispose();
                            _recorder = null;
                        }
                        catch { }
                    }

                    // If auto answer recoder.
                    if (_recorderAutoAnswer != null)
                    {
                        try
                        {
                            // Cleanup the recoder.
                            _recorderAutoAnswer.Dispose();
                            _recorderAutoAnswer = null;
                        }
                        catch { }
                    }

                    // If sound player.
                    if (_player != null)
                    {
                        try
                        {
                            // Cleanup the recoder.
                            _player.Dispose();
                            _player = null;
                        }
                        catch { }
                    }

                    // If video window.
                    if (_videoWindow != null)
                    {
                        try
                        {
                            _hasVideo = false;

                            // Cleanup the video window.
                            _videoWindow.Dispose();
                            _videoWindow = null;
                        }
                        catch { }
                    }

                    // Cleanup the audio media.
                    if (_audioMedias != null)
                    {
                        _audioMedias.Clear();
                        _audioMedias = null;
                    }
                }

                // If call is disconnected.
                if ((ci.State == InviteSessionState.PJSIP_INV_STATE_DISCONNECTED) ||
                    (ci.State == InviteSessionState.PJSIP_INV_STATE_NULL))
                {
                    try
                    {
                        // Handle the event.
                        OnCallDisconnected?.Invoke(this, _info);
                    }
                    catch { }
                }
            }
        }
Beispiel #12
0
 public void processStateChange(OnCallStateParam prm)
 {
     pjsua2PINVOKE.Call_processStateChange(swigCPtr, OnCallStateParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #13
0
 public virtual void onCallState(OnCallStateParam prm)
 {
     if (SwigDerivedClassHasMethod("onCallState", swigMethodTypes0)) pjsua2PINVOKE.Call_onCallStateSwigExplicitCall(swigCPtr, OnCallStateParam.getCPtr(prm)); else pjsua2PINVOKE.Call_onCallState(swigCPtr, OnCallStateParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #14
0
        public override void onCallState(OnCallStateParam prm)
        {
            var info = getInfo();

            OnCallState?.Invoke(this, info, prm, _account);
        }