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; }
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; } }