ios - 在 IOS 中使用 PJSIP 注册远程 VOIP 服务器

标签 ios c voip pjsip

我想制作让用户通过 ip (VOIP) 调用电话的应用程序。 我正在学习本教程 http://www.xianwenchen.com/blog/2014/06/09/how-to-make-an-ios-voip-app-with-pjsip-part-1/

但现在我想注册到像 ekiga 或 linphone.org 这样的全局服务器。

现在这是我用 C 编写的代码

#include "Pjsua.h"
#include <pjsua-lib/pjsua.h>
#define THIS_FILE "Pjsua.c"
static pjsua_acc_id acc_id;

const size_t MAX_SIP_ID_LENGTH = 50;
const size_t MAX_SIP_REG_URI_LENGTH = 50;

static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata);
static void on_call_state(pjsua_call_id call_id, pjsip_event *e);
static void on_call_media_state(pjsua_call_id call_id);
static void error_exit(const char *title, pj_status_t status);

int startPjsip(char *sipUser, char* sipDomain)
{
    pj_status_t status;

    // Create pjsua first
    status = pjsua_create();
    if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status);

    // Init pjsua
    {
        // Init the config structure
        pjsua_config 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;

        // Init the logging config structure
        pjsua_logging_config log_cfg;
        pjsua_logging_config_default(&log_cfg);
        log_cfg.console_level = 5;
        log_cfg.level = 5;

        // Init the pjsua
        status = pjsua_init(&cfg, &log_cfg, NULL);
        if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);
    }

    // Add UDP transport.
    {
        // Init transport config structure
        pjsua_transport_config cfg;
        pjsua_transport_config_default(&cfg);
        cfg.port = 5080;

        // Add TCP transport.
        status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
        if (status != PJ_SUCCESS) error_exit("Error creating transport udp", status);
    }

    // Add TCP transport.
    {
        // Init transport config structure
        pjsua_transport_config cfg;
        pjsua_transport_config_default(&cfg);
        cfg.port = 5080;

        // Add TCP transport.
        status = pjsua_transport_create(PJSIP_TRANSPORT_TCP, &cfg, NULL);
        if (status != PJ_SUCCESS) error_exit("Error creating transport tcp", status);
    }

    // Initialization is done, now start pjsua
    status = pjsua_start();
    if (status != PJ_SUCCESS) error_exit("Error starting pjsua", status);

    // Register the account on local sip server
    {
        pjsua_acc_config cfg;

        pjsua_acc_config_default(&cfg);


        cfg.id = pj_str((char *)"sip:exampleuser@sip.linphone.org");

        cfg.reg_uri = pj_str((char *)"sip:sip.linphone.org");
        cfg.proxy[0] = pj_str((char *)"sip:sip.linphone.org");
        cfg.cred_count = 1;
        cfg.cred_info[0].scheme = pj_str((char *)"digest");
        cfg.cred_info[0].realm = pj_str((char *)"*");
        cfg.cred_info[0].username = pj_str((char *)"exampleuser");
        cfg.cred_info[0].data_type = 0;
        cfg.cred_info[0].data = pj_str((char *)"examplepasswor");

        status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
        if (status != PJ_SUCCESS) error_exit("Error adding account", status);

    }

    return 0;
}

/* 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 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));
}

/* 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);
    }
}

/* 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);
}

void makeCall(char* destUri)
{
    pj_status_t status;
    pj_str_t uri = pj_str(destUri);

    status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
    if (status != PJ_SUCCESS) error_exit("Error making call", status);
}

void endCall()
{
    pjsua_call_hangup_all();
}

显示请求超时错误。

12:41:02.521 os_core_unix.c !pjlib 2.3 for POSIX initialized
12:41:02.524 sip_endpoint.c  .Creating endpoint instance...
12:41:02.528          pjlib  .select() I/O Queue created (0x7db49148)
12:41:02.528 sip_endpoint.c  .Module "mod-msg-print" registered
12:41:02.528 sip_transport.  .Transport manager created.
12:41:02.528   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
12:41:02.531 sip_endpoint.c  .Module "mod-pjsua-log" registered
12:41:02.531 sip_endpoint.c  .Module "mod-tsx-layer" registered
12:41:02.532 sip_endpoint.c  .Module "mod-stateful-util" registered
12:41:02.532 sip_endpoint.c  .Module "mod-ua" registered
12:41:02.533 sip_endpoint.c  .Module "mod-100rel" registered
12:41:02.533 sip_endpoint.c  .Module "mod-pjsua" registered
12:41:02.533 sip_endpoint.c  .Module "mod-invite" registered
12:41:02.584 coreaudio_dev.  .. dev_id 0: iPhone IO device  (in=1, out=1) 8000Hz
12:41:02.584 coreaudio_dev.  ..core audio initialized
12:41:02.584          pjlib  ..select() I/O Queue created (0x7cb38a14)
12:41:02.595 sip_endpoint.c  .Module "mod-evsub" registered
12:41:02.595 sip_endpoint.c  .Module "mod-presence" registered
12:41:02.595 sip_endpoint.c  .Module "mod-mwi" registered
12:41:02.609 sip_endpoint.c  .Module "mod-refer" registered
12:41:02.609 sip_endpoint.c  .Module "mod-pjsua-pres" registered
12:41:02.609 sip_endpoint.c  .Module "mod-pjsua-im" registered
12:41:02.609 sip_endpoint.c  .Module "mod-pjsua-options" registered
12:41:02.609   pjsua_core.c  .1 SIP worker threads created
12:41:02.609   pjsua_core.c  .pjsua version 2.3 for Darwin-15.2/x86_64 initialized
12:41:02.609   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
12:41:02.610   pjsua_core.c  SIP UDP socket reachable at 192.168.1.4:5080
12:41:02.610  udp0x7e33de00  SIP UDP transport started, published address is 192.168.1.4:5080
12:41:02.610   pjsua_core.c  PJSUA state changed: INIT --> STARTING
12:41:02.610 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
12:41:02.610   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
12:41:02.610    pjsua_acc.c  Adding account: id=sip:eslamhanafy@sip.linphone.org
12:41:02.610    pjsua_acc.c  .Account sip:eslamhanafy@sip.linphone.org added with id 0
12:41:02.662    pjsua_acc.c  .Acc 0: setting registration..
12:41:03.011   pjsua_core.c  ...TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:03.012    pjsua_acc.c  ..Acc 0: Registration sent
12:41:03.012   pjsua_call.c  Making call with acc #0 to sip:485501406065403210@sip.linphone.org
12:41:03.013    pjsua_aud.c  .Set sound device: capture=-1, playback=-2
12:41:03.014    pjsua_aud.c  ..Opening sound device PCM@16000/1/20ms
12:41:03.014 coreaudio_dev.  ...Using VoiceProcessingIO audio unit
12:41:03.082 coreaudio_dev.  ...core audio stream started
12:41:03.082  pjsua_media.c  .Call 0: initializing media..
12:41:03.083  pjsua_media.c  ..RTP socket reachable at 192.168.1.4:4000
12:41:03.083  pjsua_media.c  ..RTCP socket reachable at 192.168.1.4:4001
12:41:03.083  pjsua_media.c  ..Media index 0 selected for audio call 0
12:41:03.084   pjsua_core.c  ....TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
done
done
12:41:03.100 os_core_unix.c !Info: possibly re-registering existing thread
12:41:03.512   pjsua_core.c !.TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:03.585   pjsua_core.c  .TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
12:41:04.513   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:04.585   pjsua_core.c  .TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
12:41:06.515   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0

--end msg--
12:41:10.515   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:10.585   pjsua_core.c  .TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
12:41:14.515   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:18.518   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:18.588   pjsua_core.c  .TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
12:41:22.520   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:26.520   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:30.524   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:34.525   pjsua_core.c  .TX 513 bytes Request msg REGISTER/cseq=61350 (tdta0x7db55800) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjEqa4bpBzv-vnExngLtmsuk5iwICWQ6nq
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=6tsmpbE3RQMQYGV3V4umeMM.U78z5CLt
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: OMZHw0Zs5Yz7Yjn8qZGr3Oiy2ELIHUh2
CSeq: 61350 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
12:41:34.588   pjsua_core.c  .TX 1079 bytes Request msg INVITE/cseq=5147 (tdta0x7db57000) to UDP 91.121.209.194:5060:
INVITE sip:485501406065403210@sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwaxGhboJCF8WhuS7G6UQqXVwps0Qo3na
Max-Forwards: 70
From: sip:eslamhanafy@sip.linphone.org;tag=yRJayafQCC9ApjtJuF8-NtAmY8PquMXt
To: sip:485501406065403210@sip.linphone.org
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Call-ID: FScQI.ot3zfH6qdPis4.zQUw4g.yzDun
CSeq: 5147 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   446

v=0
o=- 3662793663 3662793663 IN IP4 192.168.1.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 98 97 99 104 3 0 8 96
c=IN IP4 192.168.1.4
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.1.4
a=sendrecv
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:99 speex/32000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

--end msg--
12:41:35.015    pjsua_acc.c  ...SIP registration failed, status=408 (Request Timeout)
12:41:35.015    pjsua_acc.c  ...Scheduling re-registration retry for acc 0 in 6 seconds..
12:41:35.086  pjsua_media.c  ....Call 0: deinitializing media..
12:41:36.087    pjsua_aud.c  Closing sound device after idle for 1 second(s)
12:41:36.088    pjsua_aud.c  .Closing iPhone IO device sound playback device and iPhone IO device sound capture device
12:41:36.097 coreaudio_dev.  .core audio stream stopped
12:41:41.818    pjsua_acc.c  Acc 0: setting registration..
12:41:41.820   pjsua_core.c  ..TX 513 bytes Request msg REGISTER/cseq=57441 (tdta0x7e343400) to UDP 91.121.209.194:5060:
REGISTER sip:sip.linphone.org SIP/2.0
Via: SIP/2.0/UDP 192.168.1.4:5080;rport;branch=z9hG4bKPjwqokNHR5QxIsPICaadyURijMJCPYMq0s
Max-Forwards: 70
From: <sip:eslamhanafy@sip.linphone.org>;tag=j5fAFvbb3pMEy4jUSE8Mvx4OdSl0LR.I
To: <sip:eslamhanafy@sip.linphone.org>
Call-ID: J4IpT-HlM8wWISM6NHokczyuNpJBZ5i.
CSeq: 57441 REGISTER
Contact: <sip:eslamhanafy@192.168.1.4:5080;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0

请帮忙。

最佳答案

检查您的日志,我发现您的手机上已经运行了一个进程,该进程已绑定(bind)到目标 UDP 端口。

15:47:04.750 Pjsua.c : Error creating transport UDP: Address already in use [status=120048]

这一行说明你的App无法分配网络资源。

解决方案 1:尝试重启您的 iOS 和/或关闭所有与 SIP 相关的应用;

解决方案 2:如果可能,更改 UDP 端口 cfg.port = 5080;

关于ios - 在 IOS 中使用 PJSIP 注册远程 VOIP 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34994308/

相关文章:

ios - NSFileManager - Swift - 文件浏览器

ios - 是否有可用于访问 SIM 工具包的私有(private) API?

ios - 如何在 UIViewcontroller 中访问已安装的 pod 库宏字符串?

asp.net-mvc - 当我在本地主机上开发时,我应该在 TwiML 应用程序设置中使用什么语音请求 URL?

ios - 使用 "Aggregate target"和 "Cocoa Touch Framework"的框架。有什么区别?

ios - ios如何更改ListView的背景颜色

c - 初学者编写makefile;检查我的 Makefile

c - 斐波那契数列计算器的问题

c++ - vector 排序和更改数据

security - 将 XMPP 用于 VoIP 的安全性如何?