Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public int transportCreate(pjsip_transport_type_e type, TransportConfig cfg)
        {
            int ret = pjsua2PINVOKE.Endpoint_transportCreate(swigCPtr, (int)type, TransportConfig.getCPtr(cfg));

            if (pjsua2PINVOKE.SWIGPendingException.Pending)
            {
                throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 3
0
        public void initTransportMode(pjsip_transport_type_e tType)
        {
            //if (transportid >= 0)
            //    ep.transportClose(transportid);

            var sipTpConfig = new TransportConfig();
            var random      = new Random();
            var randomPort  = random.Next(1025, 65534);

            sipTpConfig.port = (uint)randomPort;  //5060;
            transportid      = ep.transportCreate(tType, sipTpConfig);
        }
Exemplo n.º 4
0
        public static TransportType ToTransportType(this pjsip_transport_type_e transportType)
        {
            switch (transportType)
            {
            case pjsip_transport_type_e.PJSIP_TRANSPORT_UDP:
                return(TransportType.Udp);

            case pjsip_transport_type_e.PJSIP_TRANSPORT_TCP:
                return(TransportType.Tcp);

            case pjsip_transport_type_e.PJSIP_TRANSPORT_TLS:
                return(TransportType.Tls);

            default: throw new InvalidOperationException("There is no corresponding TransportType enum value");
            }
        }
Exemplo n.º 5
0
 public static extern int pjsua_transport_create(pjsip_transport_type_e type, [In][Out] pjsua_transport_config cfg, ref int p_id);
Exemplo n.º 6
0
 public int transportCreate(pjsip_transport_type_e type, TransportConfig cfg)
 {
     int ret = pjsua2PINVOKE.Endpoint_transportCreate(swigCPtr, (int)type, TransportConfig.getCPtr(cfg));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }