Exemplo n.º 1
0
 private void initVTable()
 {
     this.registration_state_changed = new LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged);
     this.call_state_changed         = new LinphoneCoreCallStateChangedCb(OnCallStateChanged);
     this.message_received           = new LinphoneCoreMessageReceivedCb(OnMessageReceived);
     this.vtable = new LinphoneCoreVTable()
     {
         global_state_changed       = IntPtr.Zero,
         registration_state_changed = Marshal.GetFunctionPointerForDelegate(registration_state_changed),
         call_state_changed         = Marshal.GetFunctionPointerForDelegate(call_state_changed),
         notify_presence_received   = IntPtr.Zero,
         new_subscription_requested = IntPtr.Zero,
         auth_info_requested        = IntPtr.Zero,
         call_log_updated           = IntPtr.Zero,
         message_received           = Marshal.GetFunctionPointerForDelegate(message_received),
         is_composing_received      = IntPtr.Zero,
         dtmf_received              = IntPtr.Zero,
         refer_received             = IntPtr.Zero,
         call_encryption_changed    = IntPtr.Zero,
         transfer_state_changed     = IntPtr.Zero,
         buddy_info_updated         = IntPtr.Zero,
         call_stats_updated         = IntPtr.Zero,
         info_received              = IntPtr.Zero,
         subscription_state_changed = IntPtr.Zero,
         notify_received            = IntPtr.Zero,
         publish_state_changed      = IntPtr.Zero,
         configuring_status         = IntPtr.Zero,
         display_status             = IntPtr.Zero,
         display_message            = IntPtr.Zero,
         display_warning            = IntPtr.Zero,
         display_url        = IntPtr.Zero,
         show               = IntPtr.Zero,
         text_received      = IntPtr.Zero,
         file_transfer_recv = IntPtr.Zero,
         file_transfer_send = IntPtr.Zero,
         file_transfer_progress_indication = IntPtr.Zero,
         network_reachable = IntPtr.Zero,
         log_collection_upload_state_changed       = IntPtr.Zero,
         log_collection_upload_progress_indication = IntPtr.Zero
     };
     this.vtablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(this.vtable));
     Marshal.StructureToPtr(vtable, this.vtablePtr, false);
 }
Exemplo n.º 2
0
        public void CreatePhone(string username, string password, string server, int port, string agent, string version)
        {
            //#if (TRACE)
            //linphone_core_enable_logs (IntPtr.Zero);
            //#else
            //linphone_core_disable_logs ();
            //#endif

            running = true;
            registration_state_changed = new LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged);
            call_state_changed         = new LinphoneCoreCallStateChangedCb(OnCallStateChanged);
            vtable = new LinphoneCoreVTable()
            {
                global_state_changed       = IntPtr.Zero,
                registration_state_changed = Marshal.GetFunctionPointerForDelegate(registration_state_changed),
                call_state_changed         = Marshal.GetFunctionPointerForDelegate(call_state_changed),
                notify_presence_received   = IntPtr.Zero,
                new_subscription_requested = IntPtr.Zero,
                auth_info_requested        = IntPtr.Zero,
                call_log_updated           = IntPtr.Zero,
                message_received           = IntPtr.Zero,
                is_composing_received      = IntPtr.Zero,
                dtmf_received              = IntPtr.Zero,
                refer_received             = IntPtr.Zero,
                call_encryption_changed    = IntPtr.Zero,
                transfer_state_changed     = IntPtr.Zero,
                buddy_info_updated         = IntPtr.Zero,
                call_stats_updated         = IntPtr.Zero,
                info_received              = IntPtr.Zero,
                subscription_state_changed = IntPtr.Zero,
                notify_received            = IntPtr.Zero,
                publish_state_changed      = IntPtr.Zero,
                configuring_status         = IntPtr.Zero,
                display_status             = IntPtr.Zero,
                display_message            = IntPtr.Zero,
                display_warning            = IntPtr.Zero,
                display_url   = IntPtr.Zero,
                show          = IntPtr.Zero,
                text_received = IntPtr.Zero,
            };
            vtablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(vtable));
            Marshal.StructureToPtr(vtable, vtablePtr, false);

            linphoneCore = linphone_core_new(vtablePtr, null, null, IntPtr.Zero);

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

            t_config = new LCSipTransports()
            {
                udp_port  = LC_SIP_TRANSPORT_RANDOM,
                tcp_port  = LC_SIP_TRANSPORT_RANDOM,
                dtls_port = LC_SIP_TRANSPORT_RANDOM,
                tls_port  = LC_SIP_TRANSPORT_RANDOM
            };
            t_configPtr = Marshal.AllocHGlobal(Marshal.SizeOf(t_config));
            Marshal.StructureToPtr(t_config, t_configPtr, false);
            linphone_core_set_sip_transports(linphoneCore, t_configPtr);

            linphone_core_set_user_agent(linphoneCore, agent, version);

            callsDefaultParams = linphone_core_create_default_call_parameters(linphoneCore);
            linphone_call_params_enable_video(callsDefaultParams, false);
            linphone_call_params_enable_early_media_sending(callsDefaultParams, true);

            identity    = "sip:" + username + "@" + server;
            server_addr = "sip:" + server + ":" + port.ToString();

            auth_info = linphone_auth_info_new(username, null, password, null, null, null);
            linphone_core_add_auth_info(linphoneCore, auth_info);

            proxy_cfg = linphone_core_create_proxy_config(linphoneCore);
            linphone_proxy_config_set_identity(proxy_cfg, identity);
            linphone_proxy_config_set_server_addr(proxy_cfg, server_addr);
            linphone_proxy_config_enable_register(proxy_cfg, true);
            linphone_core_add_proxy_config(linphoneCore, proxy_cfg);
            linphone_core_set_default_proxy(linphoneCore, proxy_cfg);
        }
Exemplo n.º 3
0
        public void CreatePhone(string username, string password, string server, int port, string agent, string version)
        {
            #if (TRACE)
            linphone_core_enable_logs (IntPtr.Zero);
            #else
            linphone_core_disable_logs ();
            #endif

            running = true;
            registration_state_changed = new LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged);
            call_state_changed = new LinphoneCoreCallStateChangedCb(OnCallStateChanged);
            vtable = new LinphoneCoreVTable()
            {
                global_state_changed = IntPtr.Zero,
                registration_state_changed = Marshal.GetFunctionPointerForDelegate(registration_state_changed),
                call_state_changed = Marshal.GetFunctionPointerForDelegate(call_state_changed),
                notify_presence_received = IntPtr.Zero,
                new_subscription_requested = IntPtr.Zero,
                auth_info_requested = IntPtr.Zero,
                call_log_updated = IntPtr.Zero,
                message_received = IntPtr.Zero,
                is_composing_received = IntPtr.Zero,
                dtmf_received = IntPtr.Zero,
                refer_received = IntPtr.Zero,
                call_encryption_changed = IntPtr.Zero,
                transfer_state_changed = IntPtr.Zero,
                buddy_info_updated = IntPtr.Zero,
                call_stats_updated = IntPtr.Zero,
                info_received = IntPtr.Zero,
                subscription_state_changed = IntPtr.Zero,
                notify_received = IntPtr.Zero,
                publish_state_changed = IntPtr.Zero,
                configuring_status = IntPtr.Zero,
                display_status = IntPtr.Zero,
                display_message = IntPtr.Zero,
                display_warning = IntPtr.Zero,
                display_url = IntPtr.Zero,
                show = IntPtr.Zero,
                text_received = IntPtr.Zero,
            };
            vtablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(vtable));
            Marshal.StructureToPtr(vtable, vtablePtr, false);

            linphoneCore = linphone_core_new(vtablePtr, null, null, IntPtr.Zero);

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

            t_config = new LCSipTransports()
            {
                udp_port = LC_SIP_TRANSPORT_RANDOM,
                tcp_port = LC_SIP_TRANSPORT_RANDOM,
                dtls_port = LC_SIP_TRANSPORT_RANDOM,
                tls_port = LC_SIP_TRANSPORT_RANDOM
            };
            t_configPtr = Marshal.AllocHGlobal(Marshal.SizeOf(t_config));
            Marshal.StructureToPtr (t_config, t_configPtr, false);
            linphone_core_set_sip_transports (linphoneCore, t_configPtr);

            linphone_core_set_user_agent (linphoneCore, agent, version);

            callsDefaultParams = linphone_core_create_default_call_parameters(linphoneCore);
            linphone_call_params_enable_video(callsDefaultParams, false);
            linphone_call_params_enable_early_media_sending(callsDefaultParams, true);

            identity = "sip:" + username + "@" + server;
            server_addr = "sip:" + server + ":" + port.ToString();

            auth_info = linphone_auth_info_new (username, null, password, null, null, null);
            linphone_core_add_auth_info (linphoneCore, auth_info);

            proxy_cfg = linphone_core_create_proxy_config(linphoneCore);
            linphone_proxy_config_set_identity (proxy_cfg, identity);
            linphone_proxy_config_set_server_addr (proxy_cfg, server_addr);
            linphone_proxy_config_enable_register (proxy_cfg, true);
            linphone_core_add_proxy_config (linphoneCore, proxy_cfg);
            linphone_core_set_default_proxy (linphoneCore, proxy_cfg);
        }