示例#1
0
        public static AccountConfig getBasicAccountConfig(string username, string password, string host, int port = 5060)
        {
            var acfg = new AccountConfig();

            acfg.idUri = "sip:" + username + "@" + host;
            acfg.regConfig.registrarUri = "sip:" + host + ":" + port;
            var cred = new AuthCredInfo("digest", "*", username, 0, password);

            acfg.sipConfig.authCreds.Add(cred);

            return(acfg);
        }
示例#2
0
        public void Sip()
        {
            var sipUser   = "******";
            var sipSecret = "call199";
            var sipIp     = "192.168.1.130";

            try
            {
                // Create endpoint
                var ep = new Endpoint();
                ep.libCreate();
                // Initialize endpoint
                var epConfig = new EpConfig();
                ep.libInit(epConfig);
                // Create SIP transport. Error handling sample is shown
                TransportConfig sipTpConfig = new TransportConfig();
                sipTpConfig.port = 5060;
                ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);
                // Start the library
                ep.libStart();

                AccountConfig acfg = new AccountConfig();
                acfg.idUri = $"sip:{sipUser}@{sipIp}";
                acfg.regConfig.registrarUri = $"sip:{sipIp}";
                AuthCredInfo 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);

                // 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;
            }
        }
示例#3
0
        public void Init()
        {
            //var sipUser = "******";
            //var sipSecret = "sipnetzerg";
            var sipUser   = "******";
            var sipSecret = "call199";

            Messages += $"---------------------{DateTime.Now.ToString("T")}---------------------\r";
            Messages += "Init Sip!\r";
            _endpoint = new Endpoint();
            _endpoint.libCreate();
            // Initialize endpoint
            var epConfig = new EpConfig();

            //epConfig.logConfig.consoleLevel = 4;
            _endpoint.libInit(epConfig);
            // Create SIP transport. Error handling sample is shown
            var sipTpConfig = new TransportConfig();

            sipTpConfig.port = 5060;
            //sipTpConfig.portRange = 10;
            _endpoint.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);
            // Start the library
            _endpoint.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
            _acc = new MyAccount();
            _acc.OnAccountRegState += OnAccountRegState;
            //_acc.onRegStarted(new OnRegStartedParam());
            _acc.create(acfg);


            var t = _endpoint.audDevManager().getDevCount();

            _endpoint.audDevManager().setPlaybackDev(0);
            _endpoint.audDevManager().setCaptureDev(1);
            _call              = new MyCall(_acc);
            _call.OnCallState += OnCallState;
        }
示例#4
0
        static void Main(string[] args)
        {
            Endpoint ep = new Endpoint();

            ep.libCreate();

            // Initialize endpoint
            EpConfig ep_cfg = new EpConfig();

            ep.libInit(ep_cfg);

            // Create SIP transport. Error handling sample is shown
            TransportConfig sipTpConfig = new TransportConfig();

            sipTpConfig.port = 5060;
            ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig);

            // Start the library
            ep.libStart();

            AccountConfig acfg = new AccountConfig();

            acfg.idUri = "sip:[email protected]";
            acfg.regConfig.registrarUri = "sip:ipphone.plala.or.jp";
            AuthCredInfo cred = new AuthCredInfo("digest", "*", "user_name", 0, "secret");

            acfg.sipConfig.authCreds.Add(cred);

            // Create the account
            MyAccount acc = new MyAccount();

            acc.create(acfg);

            // Here we don't have anything else to do..
            //Thread.Sleep(10000);
            Console.ReadLine();

            acc.Dispose();
            ep.libDestroy();
            ep.Dispose();
        }
示例#5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AuthCredInfo obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
示例#6
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;
            }
        }
示例#7
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AuthCredInfo obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }