Windows phone 8 Windows phone 8 pjsip库集成

Windows phone 8 Windows phone 8 pjsip库集成,windows-phone-8,sip,pjsip,windows-phone-voip,Windows Phone 8,Sip,Pjsip,Windows Phone Voip,我是sip开发方面的新手,正在尝试使用pjsip实现WindowsPhone8客户端 我从pjsip构建示例应用程序,它创建了具有telnet连接的pjsua应用程序 现在,我不明白的是,如果没有telnet,我将如何使用这个库并集成到我的应用程序中 我只需要放一个手动拨号盘,然后从那里打电话,要完成这项工作,程序是什么 android或iphone的pjsip有两个示例应用程序,csipsimple和虹吸,但WindowsPhone8的pjsip没有这样的应用程序 关于前进道路的任何帮助都将非

我是sip开发方面的新手,正在尝试使用pjsip实现WindowsPhone8客户端

我从pjsip构建示例应用程序,它创建了具有telnet连接的pjsua应用程序

现在,我不明白的是,如果没有telnet,我将如何使用这个库并集成到我的应用程序中

我只需要放一个手动拨号盘,然后从那里打电话,要完成这项工作,程序是什么

android或iphone的pjsip有两个示例应用程序,csipsimple和虹吸,但WindowsPhone8的pjsip没有这样的应用程序

关于前进道路的任何帮助都将非常有用


谢谢,您的问题似乎与PJSip无关,而是与UI开发有关。 我建议您创建UI(使用XAML/C#或XAML/C++并且不要忘记它必须是Windows Phone 8.0 Silverlight项目)。然后开始引用PJSip库


希望有帮助

您的问题似乎与PJSip无关,而是与UI开发有关。 我建议您创建UI(使用XAML/C#或XAML/C++并且不要忘记它必须是Windows Phone 8.0 Silverlight项目)。然后开始引用PJSip库


希望有帮助

既然您提到您已经尝试了windows phone telnet应用程序示例,我假设您已经下载了他们的示例中提到的PJSIP winphone源代码。要创建一个简单的应用程序,如您所述执行传出和接收传入呼叫,您只需重用此winphone项目即可

打开winphone项目并执行以下操作:

  • 创建新的Windows Phone项目并将其设置为启动项目(我们将此项目称为SIP_UI)。这将用作用户界面。您只需创建一个“呼叫按钮”,稍后将执行传出呼叫
  • 遵循此SIP_UI的现有pjsua_wp WMAppManifest.xml设置。特别是能力部分。如果只使用默认设置,应用程序将无法运行
  • 创建新的Windows Phone运行时项目(我们称之为SIP_WINPRT)。在此类中创建一个类和一个方法,该类将在以后执行实际调用
  • 通过遵循现有pjsua\U wp\U后端更改SIP\U WINPRT的属性设置(右键单击SIP\U WINPRT项目->属性)。特别是在引用、附加的include目录和预处理器定义上进行更改。相应地调整路径
  • 在winphone示例中搜索simple_pjsua.c。并尝试在您在SIP_WINPRT中创建的类中实现它。我创建的示例:

    #include "pch.h"
    #include "backend.h"
    #include "pjsua.h"
    
    #define SIP_DOMAIN  "dogdomain"
    #define SIP_USER    "dog"
    #define SIP_PASSWD  "dog"
    
    using namespace backend;
    using namespace Platform;
    
    SipletRuntimeComponent::SipletRuntimeComponent()
    {
    }
    
    /* Display error and exit application */
    static void error_exit(const char *title, pj_status_t status)
    {
        //pjsua_perror(THIS_FILE, title, status);
        pjsua_destroy();
        exit(1);
    }
    
    /* Callback called by the library upon receiving incoming call */
    static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
                     pjsip_rx_data *rdata)
    {
        pjsua_call_info ci;
    
        PJ_UNUSED_ARG(acc_id);
        PJ_UNUSED_ARG(rdata);
    
        pjsua_call_get_info(call_id, &ci);
    
        //PJ_LOG(3,(THIS_FILE, "Incoming call from %.*s!!",
        //       (int)ci.remote_info.slen,
        //       ci.remote_info.ptr));
    
        /* Automatically answer incoming calls with 200/OK */
        pjsua_call_answer(call_id, 200, NULL, NULL);
    }
    
    /* Callback called by the library when call's media state has changed */
    static void on_call_media_state(pjsua_call_id call_id)
    {
        pjsua_call_info ci;
    
        pjsua_call_get_info(call_id, &ci);
    
        if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
        // When media is active, connect call to sound device.
        pjsua_conf_connect(ci.conf_slot, 0);
        pjsua_conf_connect(0, ci.conf_slot);
        }
    }
    
    /* Callback called by the library when call's state has changed */
    static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
    {
        pjsua_call_info ci;
    
        PJ_UNUSED_ARG(e);
    
        pjsua_call_get_info(call_id, &ci);
        //PJ_LOG(3,(THIS_FILE, "Call %d state=%.*s", call_id,
        //       (int)ci.state_text.slen,
        //       ci.state_text.ptr));
    }
    
    
    int SipletRuntimeComponent::SipCall(int address)
    {
        /* Create pjsua */
        pj_status_t status;
        status = pjsua_create();
        if (status != PJ_SUCCESS){
            //Error in pjsua_create()
            return -1;
        }
    
        /* Validate the URL*/
        char url[50] = "sip:cat:cat@catdomain:5060";
        status = pjsua_verify_url(url);
        if (status != PJ_SUCCESS){
            //Invalid URL given
            return -1;
        }
    
        /* Init pjsua */
        {
            pjsua_config cfg;
            pjsua_logging_config log_cfg;
    
            pjsua_config_default(&cfg);
            cfg.cb.on_incoming_call = &on_incoming_call;
            cfg.cb.on_call_media_state = &on_call_media_state;
            cfg.cb.on_call_state = &on_call_state;
    
            pjsua_logging_config_default(&log_cfg);
            log_cfg.console_level = 4;
    
            status = pjsua_init(&cfg, &log_cfg, NULL);
            if (status != PJ_SUCCESS){
                //Error in pjsua_init()
                pjsua_destroy();
                return -1;
            }
        }
    
        /* Add UDP transport. */
        {
            pjsua_transport_config cfg;
    
            pjsua_transport_config_default(&cfg);
            cfg.port = 5060;
            status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
            if (status != PJ_SUCCESS){
                //Error creating transport
                pjsua_destroy();
                return -1;
            }
        }
    
        /* Initialization is done, now start pjsua */
        status = pjsua_start();
        if (status != PJ_SUCCESS){
            //Error starting pjsua
            pjsua_destroy();
            return -1;
        }
    
        /* Register to SIP server by creating SIP account. */
        pjsua_acc_id acc_id;
        {
            pjsua_acc_config cfg;
    
            pjsua_acc_config_default(&cfg);
            cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN);
            cfg.reg_uri = pj_str("sip:" SIP_DOMAIN);
            cfg.cred_count = 1;
            cfg.cred_info[0].realm = pj_str(SIP_DOMAIN);
            cfg.cred_info[0].scheme = pj_str("digest");
            cfg.cred_info[0].username = pj_str(SIP_USER);
            cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
            cfg.cred_info[0].data = pj_str(SIP_PASSWD);
    
            status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
    
            if (status != PJ_SUCCESS){          
                //Error adding account
                pjsua_destroy();
                return -1;
            }
        }
    
        /* make call to the URL. */
        pj_str_t uri = pj_str(url);
        status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
        if (status != PJ_SUCCESS){
            //Error making call
            pjsua_destroy();
            return -1;
        }
    
        return address + 1;
    }
    
  • 添加SIP_WINPRT作为SIP_UI项目中的引用

  • 按下呼叫按钮时,呼叫SIP_WINPRT

  • 既然您提到您已经尝试了windows phone telnet应用程序示例,我假设您已经下载了他们的示例中提到的PJSIP winphone源代码。要创建一个简单的应用程序,如您所述执行传出和接收传入呼叫,您只需重用此winphone项目即可

    打开winphone项目并执行以下操作:

  • 创建新的Windows Phone项目并将其设置为启动项目(我们将此项目称为SIP_UI)。这将用作用户界面。您只需创建一个“呼叫按钮”,稍后将执行传出呼叫
  • 遵循此SIP_UI的现有pjsua_wp WMAppManifest.xml设置。特别是能力部分。如果只使用默认设置,应用程序将无法运行
  • 创建新的Windows Phone运行时项目(我们称之为SIP_WINPRT)。在此类中创建一个类和一个方法,该类将在以后执行实际调用
  • 通过遵循现有pjsua\U wp\U后端更改SIP\U WINPRT的属性设置(右键单击SIP\U WINPRT项目->属性)。特别是在引用、附加的include目录和预处理器定义上进行更改。相应地调整路径
  • 在winphone示例中搜索simple_pjsua.c。并尝试在您在SIP_WINPRT中创建的类中实现它。我创建的示例:

    #include "pch.h"
    #include "backend.h"
    #include "pjsua.h"
    
    #define SIP_DOMAIN  "dogdomain"
    #define SIP_USER    "dog"
    #define SIP_PASSWD  "dog"
    
    using namespace backend;
    using namespace Platform;
    
    SipletRuntimeComponent::SipletRuntimeComponent()
    {
    }
    
    /* Display error and exit application */
    static void error_exit(const char *title, pj_status_t status)
    {
        //pjsua_perror(THIS_FILE, title, status);
        pjsua_destroy();
        exit(1);
    }
    
    /* Callback called by the library upon receiving incoming call */
    static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
                     pjsip_rx_data *rdata)
    {
        pjsua_call_info ci;
    
        PJ_UNUSED_ARG(acc_id);
        PJ_UNUSED_ARG(rdata);
    
        pjsua_call_get_info(call_id, &ci);
    
        //PJ_LOG(3,(THIS_FILE, "Incoming call from %.*s!!",
        //       (int)ci.remote_info.slen,
        //       ci.remote_info.ptr));
    
        /* Automatically answer incoming calls with 200/OK */
        pjsua_call_answer(call_id, 200, NULL, NULL);
    }
    
    /* Callback called by the library when call's media state has changed */
    static void on_call_media_state(pjsua_call_id call_id)
    {
        pjsua_call_info ci;
    
        pjsua_call_get_info(call_id, &ci);
    
        if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
        // When media is active, connect call to sound device.
        pjsua_conf_connect(ci.conf_slot, 0);
        pjsua_conf_connect(0, ci.conf_slot);
        }
    }
    
    /* Callback called by the library when call's state has changed */
    static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
    {
        pjsua_call_info ci;
    
        PJ_UNUSED_ARG(e);
    
        pjsua_call_get_info(call_id, &ci);
        //PJ_LOG(3,(THIS_FILE, "Call %d state=%.*s", call_id,
        //       (int)ci.state_text.slen,
        //       ci.state_text.ptr));
    }
    
    
    int SipletRuntimeComponent::SipCall(int address)
    {
        /* Create pjsua */
        pj_status_t status;
        status = pjsua_create();
        if (status != PJ_SUCCESS){
            //Error in pjsua_create()
            return -1;
        }
    
        /* Validate the URL*/
        char url[50] = "sip:cat:cat@catdomain:5060";
        status = pjsua_verify_url(url);
        if (status != PJ_SUCCESS){
            //Invalid URL given
            return -1;
        }
    
        /* Init pjsua */
        {
            pjsua_config cfg;
            pjsua_logging_config log_cfg;
    
            pjsua_config_default(&cfg);
            cfg.cb.on_incoming_call = &on_incoming_call;
            cfg.cb.on_call_media_state = &on_call_media_state;
            cfg.cb.on_call_state = &on_call_state;
    
            pjsua_logging_config_default(&log_cfg);
            log_cfg.console_level = 4;
    
            status = pjsua_init(&cfg, &log_cfg, NULL);
            if (status != PJ_SUCCESS){
                //Error in pjsua_init()
                pjsua_destroy();
                return -1;
            }
        }
    
        /* Add UDP transport. */
        {
            pjsua_transport_config cfg;
    
            pjsua_transport_config_default(&cfg);
            cfg.port = 5060;
            status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
            if (status != PJ_SUCCESS){
                //Error creating transport
                pjsua_destroy();
                return -1;
            }
        }
    
        /* Initialization is done, now start pjsua */
        status = pjsua_start();
        if (status != PJ_SUCCESS){
            //Error starting pjsua
            pjsua_destroy();
            return -1;
        }
    
        /* Register to SIP server by creating SIP account. */
        pjsua_acc_id acc_id;
        {
            pjsua_acc_config cfg;
    
            pjsua_acc_config_default(&cfg);
            cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN);
            cfg.reg_uri = pj_str("sip:" SIP_DOMAIN);
            cfg.cred_count = 1;
            cfg.cred_info[0].realm = pj_str(SIP_DOMAIN);
            cfg.cred_info[0].scheme = pj_str("digest");
            cfg.cred_info[0].username = pj_str(SIP_USER);
            cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
            cfg.cred_info[0].data = pj_str(SIP_PASSWD);
    
            status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
    
            if (status != PJ_SUCCESS){          
                //Error adding account
                pjsua_destroy();
                return -1;
            }
        }
    
        /* make call to the URL. */
        pj_str_t uri = pj_str(url);
        status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
        if (status != PJ_SUCCESS){
            //Error making call
            pjsua_destroy();
            return -1;
        }
    
        return address + 1;
    }
    
  • 添加SIP_WINPRT作为SIP_UI项目中的引用

  • 按下呼叫按钮时,呼叫SIP_WINPRT

  • 这是非常有帮助的,雷扎,是的,这是前进的道路,不幸的是,qus是旧的,我已经明白了这一点。现在,当应用程序存在时,我被困在来电管理中,我们有没有办法在没有推送通知系统的情况下处理来电?还有,您是否已将音频传送到耳机而不是扬声器?谢谢。我也在几周前开始做这件事,现在看来你比我领先了很多。我对windows phone开发也很陌生,所以现在无法真正帮助您。但这可能是因为PJSIP不能使用后台代理。参考答案中的注释,实际上微软有一个voip chatterbox示例应用程序,文档非常糟糕,pjsip有自己的客户端,需要与chatterbox应用程序集成。但由于chatterbox应用程序的文档记录非常糟糕,现在不可能将pjsip与之集成。我仍然不清楚这一点,你能给我提供你创建的示例项目吗?我正在WP8上开发一个应用程序,它使用SIP来聊天,但我不知道如何使用PJSIP大型项目T_TShofiqul Alam,你能和我们分享你所做的winrt实现吗。这将对愿意使用pjsip在Windows phone上开发应用程序的人非常有帮助。:)这是非常有帮助的,雷扎,是的,这是前进的道路,不幸的是,qus是旧的,我已经明白了这一点。现在,当应用程序存在时,我被困在来电管理中,我们有没有办法在没有推送通知系统的情况下处理来电?还有,您是否已将音频传送到耳机而不是扬声器?谢谢。我也在几周前开始做这件事,现在看来你比我领先了很多。我对windows phone开发也很陌生,所以现在无法真正帮助您。但它可能是到期的