public SipManager(Thread thread, EpConfig config = null, pjsip_transport_type_e tType = pjsip_transport_type_e.PJSIP_TRANSPORT_UDP) { if (thread == null) { throw new ArgumentNullException("Thread cannot be null!"); } // Create Library ep.libCreate(); // Initialize endpoint ep.libInit(config == null ? initEndpoint() : config); // Create SIP transport. initTransportMode(tType); // Start the library ep.libStart(); // Load the logger CallLogPath = Utils.UserAppDataPath + "calllog.json"; CallLogManager = new CallLogManager(); if (File.Exists(CallLogPath)) { CallLogManager.LoadFromFile(CallLogPath); } // Register Thread Endpoint.instance() .libRegisterThread(thread.Name ?? Assembly.GetEntryAssembly().FullName); //Console.WriteLine("Thread registered: " + ep.libIsThreadRegistered()); }
private void MainForm_Load(object sender, EventArgs e) { ep = new Endpoint(); ep.libCreate(); var ep_cfg = new EpConfig(); ep_cfg.uaConfig.userAgent = String.Format( "pjsip-{0} {1}-{2}.{3} dotNET-{4}", Endpoint.instance().libVersion().full, Environment.OSVersion.Platform.ToString(), Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.Version.ToString() ); ep.libInit(ep_cfg); var trans_cfg = new TransportConfig(); trans_cfg.port = 5060; ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, trans_cfg); ep.libStart(); var acc_cfg = new AccountConfig(); acc_cfg.idUri = string.Format("sip:0.0.0.0:{0}", trans_cfg.port); localAcc = new MyAccount(); localAcc.create(acc_cfg); }
/// <summary> /// Инициализация PJSIP /// </summary> private void PjsipInit() { try { ep = new Endpoint(); ep.libCreate(); EpConfig epConfig = new EpConfig(); ep.libInit(epConfig); TransportConfig tcfg = new TransportConfig(); tcfg.port = 5080; ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, tcfg); ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TCP, tcfg); ep.libStart(); AccountConfig accCfg = new AccountConfig(); accCfg.idUri = "sip:[email protected]"; defaultAcc = new Account(); defaultAcc.create(accCfg, true); } catch (Exception ex) { MessageBox.Show(string.Format("Ошибка инициализации PJSIP\r\n{0}", ex.Message)); this.Close(); } }
public void libInit(EpConfig prmEpConfig) { pjsua2PINVOKE.Endpoint_libInit(swigCPtr, EpConfig.getCPtr(prmEpConfig)); if (pjsua2PINVOKE.SWIGPendingException.Pending) { throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); } }
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; } }
public static EpConfig initEndpoint() { var epConfig = new EpConfig(); //epConfig.logConfig.filename = Utils.UserAppDataPath + "pjsip.log"; //epConfig.logConfig.consoleLevel = 6; //epConfig.logConfig.msgLogging = 6; //epConfig.logConfig.level = 6; epConfig.uaConfig.maxCalls = 6; epConfig.medConfig.sndClockRate = 16000; epConfig.medConfig.noVad = true; epConfig.medConfig.ecTailLen = 0; epConfig.medConfig.hasIoqueue = true; return(epConfig); }
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; }
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(); }
public void test1() { try { ep.libCreate(); // Init library EpConfig epConfig = new EpConfig(); epConfig.logConfig.writer = writer; ep.libInit(epConfig); // Create transport TransportConfig tcfg = new TransportConfig(); tcfg.port = 5080; ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, tcfg); ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TCP, tcfg); // Start library ep.libStart(); Console.WriteLine("*** PJSUA2 STARTED ***"); // Add account AccountConfig accCfg = new AccountConfig(); accCfg.idUri = "sip:[email protected]"; accCfg.regConfig.registrarUri = "sip:sip.pjsip.org"; accCfg.sipConfig.authCreds.Add( new AuthCredInfo("digest", "*", "test1", 0, "test1")); MyAccount acc = new MyAccount(); acc.create(accCfg); Console.WriteLine("*** DESTROYING PJSUA2 ***"); // Explicitly delete account when unused acc.Dispose(); ep.libDestroy(); } catch (Exception err) { Console.WriteLine("Exception: " + err.Message); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EpConfig obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
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; } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(EpConfig obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
public void libInit(EpConfig prmEpConfig) { pjsua2PINVOKE.Endpoint_libInit(swigCPtr, EpConfig.getCPtr(prmEpConfig)); if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); }