コード例 #1
0
        /// <summary>
        /// Set the call on hold or re-activate.
        /// </summary>
        public void Hold()
        {
            if (_call != null)
            {
                if (_callOnHold)
                {
                    // Create the call settings.
                    CallSetting setting = new CallSetting(true);
                    CallOpParam parm    = new CallOpParam(true);
                    setting.AudioCount = (uint)1;
                    setting.VideoCount = (_hasVideo ? (uint)1 : (uint)0);
                    setting.Flag       = CallFlag.PJSUA_CALL_UNHOLD;
                    parm.Setting       = setting;
                    parm.Code          = StatusCode.SC_OK;

                    // Reinvite the call.
                    _call.Reinvite(parm);
                    _callOnHold = false;
                }
                else
                {
                    // Create the call settings.
                    CallSetting setting = new CallSetting(true);
                    CallOpParam parm    = new CallOpParam(true);
                    setting.AudioCount = (uint)1;
                    setting.VideoCount = (_hasVideo ? (uint)1 : (uint)0);
                    parm.Setting       = setting;
                    parm.Code          = StatusCode.SC_OK;

                    // Hold the call.
                    _call.SetHold(parm);
                    _callOnHold = true;
                }
            }
        }
コード例 #2
0
ファイル: VoIPManager.cs プロジェクト: waffle-iron/nequeo
        /// <summary>
        /// Make outgoing call to the specified URI.
        /// </summary>
        /// <param name="callId">An index call id (0 - 3).</param>
        /// <param name="uri">URI to be put in the To header (normally is the same as the target URI).</param>
        /// <param name="recordFilename">The path and filename where the conversation is to be recorded to. Currently ".wav" is supported on all platforms.</param>
        /// <returns>The call information.</returns>
        public Param.CallParam MakeCall(int callId, string uri, string recordFilename = null)
        {
            // If created.
            if (_created)
            {
                // Create a new call.
                Call call = new Call(_account, callId);

                // Create the call settings.
                CallSetting setting = new CallSetting(true);
                CallOpParam parm    = new CallOpParam(true);
                setting.AudioCount = 1;
                parm.Setting       = setting;

                // Make the call.
                call.MakeCall(uri, parm);

                // return the call information.
                Param.CallParam callInfo = new Param.CallParam(call, _mediaManager, recordFilename);
                return(callInfo);
            }
            else
            {
                throw new Exception("Create the account first.");
            }
        }
コード例 #3
0
        /// <summary>
        /// Notify application on incoming call.
        /// </summary>
        ///<param name="sender">The current sender.</param>
        /// <param name="e">The event parameter.</param>
        private void _voipManager_OnIncomingCall(object sender, OnIncomingCallParam e)
        {
            // Is valid call.
            if (e.CallId >= 0)
            {
                // Create a new call.
                Call            call     = _voipManager.CreateCall(e.CallId);
                Param.CallParam callInfo = new Param.CallParam(call, _voipManager.MediaManager, _recordFilename);

                // Create the call settings.
                CallSetting setting = new CallSetting(true);
                CallOpParam parm    = new CallOpParam(true);
                setting.AudioCount = 1;
                parm.Setting       = setting;

                // Continue ringing.
                parm.Code = StatusCode.SC_RINGING;
                call.Answer(parm);

                // Send a notification to the call.
                Param.OnIncomingCallParam param = new Param.OnIncomingCallParam();
                param.CallID     = e.CallId;
                param.Info       = e.RxData.Info;
                param.SrcAddress = e.RxData.SrcAddress;
                param.WholeMsg   = e.RxData.WholeMsg;
                param.Call       = callInfo;
                param.Contact    = FindContact(param);

                // Call the event handler.
                OnIncomingCall?.Invoke(this, param);
            }
        }
コード例 #4
0
ファイル: Account.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        public override void onIncomingCall(OnIncomingCallParam iprm)
        {
            base.onIncomingCall(iprm);

            var call = new Call(this, iprm.callId, Call.Type.INBOUND);

            // If Do not disturb
            if (DND)
            {
                // hangup;
                var op = new CallOpParam(true);
                op.statusCode = pjsip_status_code.PJSIP_SC_DECLINE;
                call.decline();

                // And delete the call
                //call.Dispose();
                return;
            }

            // Hook into call state
            hookCall(call);

            // Notify stack of the call
            NotifyIncomingCall(call);
        }
コード例 #5
0
 public void makeCall(string dst_uri, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_makeCall(swigCPtr, dst_uri, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #6
0
        public void Call(string phone)
        {
            var prm = new CallOpParam(true);

            //prm.opt.audioCount = 1;
            //prm.opt.videoCount = 0;
            _call.makeCall($"sip:{phone}@{_sipIp}", prm);
        }
コード例 #7
0
 public void update(CallOpParam prm)
 {
     pjsua2PINVOKE.Call_update(swigCPtr, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #8
0
 public void xfer(string dest, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_xfer(swigCPtr, dest, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #9
0
 public void xferReplaces(Call dest_call, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_xferReplaces(swigCPtr, Call.getCPtr(dest_call), CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #10
0
ファイル: MyAccount.cs プロジェクト: salihy/pjsua2-csharp
        public override void onIncomingCall(OnIncomingCallParam prm)
        {
            base.onIncomingCall(prm);
            var call        = new MyCall(this, prm.callId);
            var callOpParam = new CallOpParam();

            callOpParam.statusCode = pjsip_status_code.PJSIP_SC_OK;
            call.answer(callOpParam);
        }
コード例 #11
0
        public override void onIncomingCall(OnIncomingCallParam prm)
        {
            base.onIncomingCall(prm);
            Console.WriteLine("事件:入方向呼叫");
            var call        = new MyCall(this, prm.callId);
            var callOpParam = new CallOpParam();

            callOpParam.statusCode = pjsip_status_code.PJSIP_SC_RINGING; // pjsip_status_code.PJSIP_SC_OK;
            call.answer(callOpParam);
        }
コード例 #12
0
        private void AnswerLine0()
        {
            var info = _acc.Calls[0].getInfo();

            if (info.state == pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
            {
                var prm = new CallOpParam {
                    statusCode = (pjsip_status_code)200
                };
                _acc.Calls[0].answer(prm);
            }
        }
コード例 #13
0
ファイル: Call.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        public virtual void hangup()
        {
            //lock (locker)
            {
                if (State.In(pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED, pjsip_inv_state.PJSIP_INV_STATE_NULL))
                {
                    return;
                }

                var op = new CallOpParam(true);
                hangup(op);
            }
        }
コード例 #14
0
        public override void onIncomingCall(OnIncomingCallParam prm)
        {
            CallOpParam cprm = new CallOpParam();

            cprm.statusCode = pjsip_status_code.PJSIP_SC_RINGING;
            PjsipCall call = new PjsipCall(this, prm.callId);

            call.answer(cprm);

            if (onAccountIncomingCall != null)
            {
                onAccountIncomingCall(this, call, prm.callId);
            }
        }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: vp-altukhov/PjsipDialer
 /// <summary>
 /// Ответ на входящий вызов
 /// </summary>
 private void Answer()
 {
     if (ring != null)
     {
         ring.Stop = true;
         ring      = null;
     }
     if (currentCall != null)
     {
         CallOpParam prm = new CallOpParam();
         prm.statusCode = pjsip_status_code.PJSIP_SC_OK;
         currentCall.answer(prm);
         SetCallButtonState(CallButtonState.Hungup);
     }
 }
コード例 #16
0
ファイル: CallParam.cs プロジェクト: jamecook/projects
        /// <summary>
        /// Hangup the current call.
        /// </summary>
        public void Hangup()
        {
            // Create the call settings.
            CallSetting setting = new CallSetting(true);
            CallOpParam parm    = new CallOpParam(true);

            setting.AudioCount = 1;
            parm.Setting       = setting;
            parm.Code          = StatusCode.SC_BUSY_HERE;

            if (_call != null)
            {
                // Hangup the call.
                _call.Hangup(parm);
            }
        }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: vp-altukhov/PjsipDialer
 /// <summary>
 /// Положить трубку
 /// </summary>
 private void Hungup()
 {
     if (currentCall != null)
     {
         if (currentCall.IsOnline)
         {
             try
             {
                 CallOpParam prm = new CallOpParam();
                 prm.statusCode = pjsip_status_code.PJSIP_SC_GONE;
                 currentCall.hangup(prm);
             }
             catch { }
         }
     }
 }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: vp-altukhov/PjsipDialer
 /// <summary>
 /// Вызов на набранный номер
 /// </summary>
 private void MakeCall()
 {
     try
     {
         CallOpParam prm = new CallOpParam(true);
         currentCall = new PjsipCall(checkedAccount);
         string destUri = string.Format("sip:{0}@{1}", tbNumber.Text.Trim(), checkedAccount.Host);
         currentCall.makeCall(destUri, prm);
         currentCall.OnCallDisconnected = CallDisconnect;
         SetCallButtonState(CallButtonState.Hungup);
     }
     catch
     {
         Hungup();
     }
 }
コード例 #19
0
ファイル: CallParam.cs プロジェクト: jamecook/projects
        /// <summary>
        /// Answer the current call.
        /// </summary>
        public void Answer()
        {
            // Create the call settings.
            CallSetting setting = new CallSetting(true);
            CallOpParam parm    = new CallOpParam(true);

            setting.AudioCount = 1;
            parm.Setting       = setting;
            parm.Code          = StatusCode.SC_OK;

            if (_call != null)
            {
                // Answer the call.
                _call.Answer(parm);
            }
        }
コード例 #20
0
ファイル: CallParam.cs プロジェクト: jamecook/projects
        /// <summary>
        /// Transfer the current call.
        /// </summary>
        /// <param name="destination">The URI of new target to be contacted. The URI may be in name address or addr format.</param>
        public void Transfer(string destination)
        {
            // Create the call settings.
            CallSetting setting = new CallSetting(true);
            CallOpParam parm    = new CallOpParam(true);

            setting.AudioCount = 1;
            parm.Setting       = setting;
            parm.Code          = StatusCode.SC_OK;

            if (_call != null)
            {
                // Answer the call.
                _call.Answer(parm);
                _call.Transfer(destination, parm);
            }
        }
コード例 #21
0
ファイル: Call.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        public virtual Call answer()
        {
            //lock (locker)
            {
                if (State != pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
                {
                    return(this);
                }

                var op = new CallOpParam(true);
                op.statusCode = pjsip_status_code.PJSIP_SC_OK;
                base.answer(op);

                connectAudioDevice();
                return(this);
            }
        }
コード例 #22
0
        /// <summary>
        /// Update the call.
        /// </summary>
        public void Update()
        {
            // Create the call settings.
            CallSetting setting = new CallSetting(true);
            CallOpParam parm    = new CallOpParam(true);

            setting.AudioCount = 1;
            setting.VideoCount = (_hasVideo ? (uint)1 : (uint)0);
            parm.Setting       = setting;
            parm.Code          = StatusCode.SC_OK;

            if (_call != null)
            {
                // Update the call.
                _call.Update(parm);
            }
        }
コード例 #23
0
ファイル: CallParam.cs プロジェクト: drazenzadravec/nequeo
        /// <summary>
        /// Transfer replace the current call.
        /// </summary>
        /// <param name="call">The existing call.</param>
        public void TransferReplaces(CallParam call)
        {
            // Create the call settings.
            CallSetting setting = new CallSetting(true);
            CallOpParam parm    = new CallOpParam(true);

            setting.AudioCount = (uint)1;
            setting.VideoCount = (_hasVideo ? (uint)1 : (uint)0);
            parm.Setting       = setting;
            parm.Code          = StatusCode.SC_OK;

            if (_call != null)
            {
                // Transfer.
                _call.TransferReplaces(call.Call, parm);
            }
        }
コード例 #24
0
ファイル: Call.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        public virtual void decline()
        {
            //lock (locker)
            {
                if (State != pjsip_inv_state.PJSIP_INV_STATE_INCOMING)
                {
                    return;
                }

                CallType = Type.DECLINED;

                var op = new CallOpParam(true)
                {
                    statusCode = pjsip_status_code.PJSIP_SC_DECLINE
                };

                hangup(op);
            }
        }
コード例 #25
0
ファイル: Call.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        private new void hangup(CallOpParam op)
        {
            //lock (locker)
            {
                if (State.In(pjsip_inv_state.PJSIP_INV_STATE_NULL, pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED))
                {
                    return;
                }

                base.hangup(op);
            }

            /* If we don't dispose of the call it will notify its diconnected state */
            // Manually notify of disconnect
            //NotifyCallState(pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED);

            // And delete the call
            //Dispose();
        }
コード例 #26
0
ファイル: Call.cs プロジェクト: fanshuxian/PJSIPDotNetSDK
        public Call retrieve()
        {
            lock (locker)
            {
                if (State != pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED || IsHeld == false)
                {
                    return(this);
                }

                var op = new CallOpParam(true);
                if (op.opt != null)
                {
                    op.opt.flag |= (uint)pjsua_call_flag.PJSUA_CALL_UNHOLD;
                }

                if (IsHeld)
                {
                    reinvite(op);
                }
                return(this);
            }
        }
コード例 #27
0
ファイル: MainForm.cs プロジェクト: vp-altukhov/PjsipDialer
 /// <summary>
 /// Обработка входящего вызова
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="callId"></param>
 private void IncomingCall(PjsipAccount acc, PjsipCall call, int callId)
 {
     if (InvokeRequired)
     {
         AccountIncomingCall ic = new AccountIncomingCall(IncomingCall);
         Invoke(ic, new object[] { acc, call, callId });
     }
     else
     {
         try
         {
             if (currentCall != null && currentCall.IsOnline)
             {
                 CallOpParam prm = new CallOpParam();
                 prm.statusCode = pjsip_status_code.PJSIP_SC_BUSY_HERE;
                 call.answer(prm);
                 call.Dispose();
             }
             else
             {
                 SelectAccount(acc);
                 currentCall = call;
                 currentCall.OnCallIncoming     = CallIncomingInfo;
                 currentCall.OnCallDisconnected = CallDisconnect;
                 SetCallButtonState(CallButtonState.Ring);
                 ring = new PjsipRing();
             }
         }
         catch
         {
             if (currentCall != null)
             {
                 Hungup();
             }
         }
     }
 }
コード例 #28
0
ファイル: Call.cs プロジェクト: Reltik/PJSip-CSharp
 public void xfer(string dest, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_xfer(swigCPtr, dest, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
コード例 #29
0
        public void Transfer(string phone)
        {
            var prm = new CallOpParam(true);

            _call.xfer($"sip:{phone}@{_sipIp}", prm);
        }
コード例 #30
0
ファイル: Call.cs プロジェクト: Reltik/PJSip-CSharp
 public void makeCall(string dst_uri, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_makeCall(swigCPtr, dst_uri, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
コード例 #31
0
ファイル: Call.cs プロジェクト: Reltik/PJSip-CSharp
 public void update(CallOpParam prm)
 {
     pjsua2PINVOKE.Call_update(swigCPtr, CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
コード例 #32
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CallOpParam obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #33
0
ファイル: CallOpParam.cs プロジェクト: Jetsly/pjsip-csharp
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CallOpParam obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
コード例 #34
0
        public void Sip()
        {
            var sipUser = "******";
            var sipSecret = "call199";
            var sipIp = "192.168.1.130";
            try
            {
                // Create endpoint
                ep = new Endpoint();
                ep.libCreate();
                // Initialize endpoint
                var epConfig = new EpConfig();
                ep.libInit(epConfig);
                // Create SIP transport. Error handling sample is shown
                var sipTpConfig = new TransportConfig();
                sipTpConfig.port = 5060;
                ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);
                // Start the library
                ep.libStart();

                var acfg = new AccountConfig();
                acfg.idUri = $"sip:{sipUser}@{sipIp}";
                acfg.regConfig.registrarUri = $"sip:{sipIp}";
                var cred = new AuthCredInfo("DispexPhone", "*", sipUser, 0, sipSecret);
                acfg.sipConfig.authCreds.Add(cred);
                // Create the account
                var acc = new MyAccount();
                //acc.onRegStarted(new OnRegStartedParam());
                acc.create(acfg);

                var t = ep.audDevManager().getDevCount();
                ep.audDevManager().setPlaybackDev(0);
                var tt = ep.audDevManager().getPlaybackDevMedia();
                for (int i = 0; i < t; i++)
                {
                    Console.WriteLine("-------------------------------------");
                    Console.WriteLine(JsonConvert.SerializeObject(tt));
                    Console.WriteLine("-------------------------------------");
                }
                //ep.audDevManager().setNullDev();
                /*
                // And install sound device using Extra Audio Device 
                ExtraAudioDevice auddev2(-1, -1);
                    auddev2.open();
             

                // Create player and recorder
                {
                    var amp = new AudioMediaPlayer();
                    amp.createPlayer(filename);

                    var amr = new AudioMediaRecorder();
                    amr.createRecorder("recorder_test_output.wav");

                    amp.startTransmit(amr);
                    if (auddev2.isOpened())
                        amp.startTransmit(auddev2);
*/
                    Thread.Sleep(5000);
                var call = new MyCall(acc);
                
                var prm = new CallOpParam(true);
                //prm.opt.audioCount = 1;
                //prm.opt.videoCount = 0;
                call.makeCall($"sip:89323232177@{sipIp}", prm);

                // Hangup all calls
                Thread.Sleep(15000);
                ep.hangupAllCalls();
                Thread.Sleep(5000);
                // Here we don't have anything else to do..

                /* Explicitly delete the account.
                 * This is to avoid GC to delete the endpoint first before deleting
                 * the account.
                 */
                //acc.Dispose();

                // Explicitly destroy and delete endpoint
                //ep.libDestroy();
                //ep.Dispose();

            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
                return;
            }
        }
コード例 #35
0
ファイル: Call.cs プロジェクト: Reltik/PJSip-CSharp
 public void xferReplaces(Call dest_call, CallOpParam prm)
 {
     pjsua2PINVOKE.Call_xferReplaces(swigCPtr, Call.getCPtr(dest_call), CallOpParam.getCPtr(prm));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }