コード例 #1
0
        public void CreatePhone(LinphoneConnectionParams connectionParams)
        {
            IsRunning = true;

            registration_state_changed = new LinphoneDelegates.LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged);
            call_state_changed         = new LinphoneDelegates.LinphoneCoreCallStateChangedCb(OnCallStateChanged);
            message_received           = new LinphoneDelegates.LinphoneCoreCbsMessageReceivedCb(OnMessageReceived);

            VTable    = CreateDefaultLinphoneCoreVTable();
            VTablePtr = VTable.ToIntPtr();

            LinphoneCore = CoreModule.linphone_core_new(VTablePtr, null, null, IntPtr.Zero);

            coreLoop = new Thread(LinphoneMainLoopHandler);
            coreLoop.IsBackground = false;
            coreLoop.Start();

            TransportConfig    = CreateTransportConfig();
            TransportConfigPtr = TransportConfig.ToIntPtr();
            NetworkModule.linphone_core_set_sip_transports(LinphoneCore, TransportConfigPtr);

            GenericModules.linphone_core_set_user_agent(LinphoneCore, connectionParams.Agent, connectionParams.Version);

            Identity = string.IsNullOrEmpty(connectionParams.AccountAlias)
                ? $"sip:{connectionParams.Username}@{connectionParams.Host}"
                : $"\"{connectionParams.AccountAlias}\" sip:{connectionParams.Username}@{connectionParams.Host}";

            ServerHost = $"sip:{connectionParams.Host}:{connectionParams.Port}";

            AuthInfo = GenericModules.linphone_auth_info_new(connectionParams.Username, null, connectionParams.Password, null, null, null);
            GenericModules.linphone_core_add_auth_info(LinphoneCore, AuthInfo);

            NatPolicy = CreateNatPolicy(connectionParams.NatPolicy);

            ProxyCfg = CreateProxyCfg();

            CallParamsBuilder = new CallParamsBuilder(LinphoneCore);
        }