Changeset 162 for pjproject/trunk
- Timestamp:
- Feb 9, 2006 12:13:40 AM (19 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia.h
r129 r162 24 24 #include <pjmedia/codec.h> 25 25 #include <pjmedia/jbuf.h> 26 #include <pjmedia/ mediamgr.h>26 #include <pjmedia/endpoint.h> 27 27 #include <pjmedia/rtcp.h> 28 28 #include <pjmedia/rtp.h> 29 //#include <pjmedia/session.h>29 #include <pjmedia/session.h> 30 30 #include <pjmedia/sound.h> 31 31 #include <pjmedia/sdp.h> -
pjproject/trunk/pjmedia/include/pjmedia/errno.h
r159 r162 26 26 27 27 /** 28 * Guidelines on error message length.29 */30 #define PJMEDIA_ERR_MSG_SIZE 6431 32 /**33 * Get error message for the specified error code.34 *35 * @param status The error code.36 * @param buffer The buffer where to put the error message.37 * @param bufsize Size of the buffer.38 *39 * @return The error message as NULL terminated string,40 * wrapped with pj_str_t.41 */42 PJ_DECL(pj_str_t) pjmedia_strerror( pj_status_t status, char *buffer,43 pj_size_t bufsize);44 45 46 /**47 28 * Start of error code relative to PJ_ERRNO_START_USER. 48 29 */ -
pjproject/trunk/pjmedia/include/pjmedia/session.h
r159 r162 41 41 /** 42 42 * Create new session offering based on the local and remote SDP. 43 * The session initially will be inactive.43 * The session will start immediately. 44 44 * 45 45 * @param endpt The PJMEDIA endpoint instance. -
pjproject/trunk/pjmedia/include/pjmedia/types.h
r159 r162 134 134 135 135 pj_sock_t rtp_sock; 136 pj_sockaddr_in rtp_addr_name; 136 137 pj_sock_t rtcp_sock; 137 pj_sockaddr_in rt p_addr_name;138 pj_sockaddr_in rtcp_addr_name; 138 139 139 140 } pjmedia_sock_info; -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r159 r162 41 41 PJ_DECL(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory); 42 42 43 /* Flag to indicate whether pjmedia error subsystem has been registered 44 * to pjlib. 45 */ 46 static int error_subsys_registered; 47 48 49 /** 50 * Defined in pjmedia/errno.c 51 * 52 * Get error message for the specified error code. Note that this 53 * function is only able to decode PJMEDIA specific error code. 54 * Application should use pj_strerror(), which should be able to 55 * decode all error codes belonging to all subsystems (e.g. pjlib, 56 * pjmedia, pjsip, etc). 57 * 58 * @param status The error code. 59 * @param buffer The buffer where to put the error message. 60 * @param bufsize Size of the buffer. 61 * 62 * @return The error message as NULL terminated string, 63 * wrapped with pj_str_t. 64 */ 65 PJ_DECL(pj_str_t) pjmedia_strerror( pj_status_t status, char *buffer, 66 pj_size_t bufsize); 67 68 43 69 44 70 /** Concrete declaration of media endpoint. */ … … 65 91 pjmedia_codec_factory *factory; 66 92 pj_status_t status; 93 94 if (!error_subsys_registered) { 95 pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 96 &pjmedia_strerror); 97 error_subsys_registered = 1; 98 } 67 99 68 100 PJ_ASSERT_RETURN(pf && p_endpt, PJ_EINVAL); -
pjproject/trunk/pjmedia/src/pjmedia/errno.c
r159 r162 133 133 return errstr; 134 134 135 } else { 136 /* Error not found. */ 137 errstr.ptr = buf; 138 errstr.slen = pj_snprintf(buf, bufsize, 139 "Unknown error %d", 140 statcode); 141 142 return errstr; 143 } 144 } 145 else { 146 /* Not our code. Give it to PJLIB. */ 147 return pj_strerror(statcode, buf, bufsize); 135 } 148 136 } 149 137 138 /* Error not found. */ 139 errstr.ptr = buf; 140 errstr.slen = pj_snprintf(buf, bufsize, 141 "Unknown error %d", 142 statcode); 143 144 return errstr; 150 145 } 151 146 -
pjproject/trunk/pjmedia/src/pjmedia/sdp.c
r140 r162 990 990 PJ_CATCH(SYNTAX_ERROR) { 991 991 992 char errmsg[PJ MEDIA_ERR_MSG_SIZE];993 pj media_strerror(ctx.last_error, errmsg, sizeof(errmsg));992 char errmsg[PJ_ERR_MSG_SIZE]; 993 pj_strerror(ctx.last_error, errmsg, sizeof(errmsg)); 994 994 995 995 PJ_LOG(4, (THIS_FILE, "Error parsing SDP in line %d col %d: %s", -
pjproject/trunk/pjsip/include/pjsip/sip_errno.h
r127 r162 24 24 PJ_BEGIN_DECL 25 25 26 /**27 * Guidelines on error message length.28 */29 #define PJSIP_ERR_MSG_SIZE 6430 31 26 /* 32 27 * PJSIP error codes occupies 170000 - 219000, and mapped as follows: … … 34 29 * - 171000 - 171999: mapped to errors generated from PJSIP core. 35 30 */ 36 37 /**38 * Get error message for the specified error code.39 *40 * @param status The error code.41 * @param buffer The buffer where to put the error message.42 * @param bufsize Size of the buffer.43 *44 * @return The error message as NULL terminated string,45 * wrapped with pj_str_t.46 */47 PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer,48 pj_size_t bufsize);49 31 50 32 /** -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r160 r162 24 24 #include <pjmedia/sdp.h> 25 25 #include <pjmedia/sdp_neg.h> 26 #include <pjmedia/errno.h> 26 27 #include <pj/string.h> 27 28 #include <pj/pool.h> … … 761 762 &inv->neg); 762 763 } else { 763 pj_assert(!"UAS dialog without remote and local offer is not supported!"); 764 PJ_TODO(IMPLEMENT_DELAYED_UAS_OFFER); 765 status = PJ_ENOTSUP; 764 status = PJ_SUCCESS; 766 765 } 767 766 … … 874 873 } 875 874 875 876 /* 877 * Negotiate SDP. 878 */ 879 static pj_status_t inv_negotiate_sdp( pjsip_inv_session *inv ) 880 { 881 pj_status_t status; 882 883 PJ_ASSERT_RETURN(pjmedia_sdp_neg_get_state(inv->neg) == 884 PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, 885 PJMEDIA_SDPNEG_EINSTATE); 886 887 status = pjmedia_sdp_neg_negotiate(inv->pool, inv->neg, 0); 888 889 if (mod_inv.cb.on_media_update) 890 (*mod_inv.cb.on_media_update)(inv, status); 891 892 return status; 893 } 876 894 877 895 /* … … 899 917 * offer before. 900 918 */ 901 PJ_ASSERT_RETURN(!local_sdp ||902 (pjmedia_sdp_neg_get_state(inv->neg)==PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER),903 PJ_EINVALIDOP);904 919 if (local_sdp) { 905 status = pjmedia_sdp_neg_set_local_answer(inv->pool, inv->neg, 906 local_sdp); 920 921 if (inv->neg == NULL) { 922 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, local_sdp, 923 &inv->neg); 924 } else if (pjmedia_sdp_neg_get_state(inv->neg)== 925 PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) 926 { 927 status = pjmedia_sdp_neg_set_local_answer(inv->pool, inv->neg, 928 local_sdp); 929 } else { 930 931 /* Can not specify local SDP at this state. */ 932 pj_assert(0); 933 status = PJMEDIA_SDPNEG_EINSTATE; 934 } 935 907 936 if (status != PJ_SUCCESS) 908 937 return status; … … 916 945 return status; 917 946 918 /* Include SDP for 18x and 2xx response. */ 947 /* Include SDP for 18x and 2xx response. 948 * Also if SDP negotiator is ready, start negotiation. 949 */ 919 950 if (st_code/10 == 18 || st_code/10 == 20) { 920 951 const pjmedia_sdp_session *local; … … 923 954 if (status == PJ_SUCCESS) 924 955 last_res->msg->body = create_sdp_body(last_res->pool, local); 925 ; 926 } 927 928 /* Do we need to increment tdata'inv reference counter? */ 929 PJ_TODO(INV_ANSWER_MAY_HAVE_TO_INCREMENT_REF_COUNTER); 956 957 /* Start negotiation, if ready. */ 958 if (pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) { 959 status = inv_negotiate_sdp(inv); 960 if (status != PJ_SUCCESS) { 961 pjsip_tx_data_dec_ref(last_res); 962 return status; 963 } 964 } 965 } 966 930 967 931 968 *p_tdata = last_res; -
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r145 r162 107 107 extern pjsip_module mod_stateful_util; 108 108 109 110 /* Specifies whether error subsystem has been registered to pjlib. */ 111 static int error_subsys_initialized; 112 113 /** 114 * Defined in sip_errno.c 115 * 116 * Get error message for the specified error code. This can only get 117 * PJSIP specific error message. To get all types of error message, 118 * use pj_strerror() instead. 119 * 120 * @param status The error code. 121 * @param buffer The buffer where to put the error message. 122 * @param bufsize Size of the buffer. 123 * 124 * @return The error message as NULL terminated string, 125 * wrapped with pj_str_t. 126 */ 127 PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer, 128 pj_size_t bufsize); 129 130 109 131 /* 110 132 * This is the global handler for memory allocation failure, for pools that … … 394 416 pjsip_max_fwd_hdr *mf_hdr; 395 417 pj_lock_t *lock = NULL; 418 419 420 if (!error_subsys_initialized) { 421 pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 422 &pjsip_strerror); 423 error_subsys_initialized = 1; 424 } 396 425 397 426 PJ_LOG(5, (THIS_FILE, "Creating endpoint instance...")); -
pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
r109 r162 130 130 131 131 if (status != PJ_SUCCESS) { 132 char errmsg[PJ SIP_ERR_MSG_SIZE];132 char errmsg[PJ_ERR_MSG_SIZE]; 133 133 PJ_LOG(4,(THIS_FILE, "Failed to resolve '%.*s'. Err=%d (%s)", 134 134 target->addr.host.slen, 135 135 target->addr.host.ptr, 136 136 status, 137 pj sip_strerror(status,errmsg,sizeof(errmsg)).ptr));137 pj_strerror(status,errmsg,sizeof(errmsg)).ptr)); 138 138 (*cb)(status, token, &svr_addr); 139 139 return; -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r160 r162 1443 1443 1444 1444 if (!*cont) { 1445 char errmsg[PJ SIP_ERR_MSG_SIZE];1445 char errmsg[PJ_ERR_MSG_SIZE]; 1446 1446 1447 1447 PJ_LOG(4,(tsx->obj_name, 1448 1448 "Failed to send %s! err=%d (%s)", 1449 1449 pjsip_tx_data_get_info(send_state->tdata), -sent, 1450 pj sip_strerror(-sent, errmsg, sizeof(errmsg)).ptr));1450 pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 1451 1451 1452 1452 /* Clear pending transport flag. */ … … 1466 1466 1467 1467 } else { 1468 char errmsg[PJ SIP_ERR_MSG_SIZE];1468 char errmsg[PJ_ERR_MSG_SIZE]; 1469 1469 1470 1470 PJ_LOG(4,(tsx->obj_name, … … 1472 1472 "will try next server. Err=%d (%s)", 1473 1473 pjsip_tx_data_get_info(send_state->tdata), -sent, 1474 pj sip_strerror(-sent, errmsg, sizeof(errmsg)).ptr));1474 pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 1475 1475 } 1476 1476 } … … 1487 1487 pjsip_transaction *tsx = token; 1488 1488 struct tsx_lock_data lck; 1489 char errmsg[PJ SIP_ERR_MSG_SIZE];1489 char errmsg[PJ_ERR_MSG_SIZE]; 1490 1490 1491 1491 PJ_LOG(4,(tsx->obj_name, "Transport failed to send %s! Err=%d (%s)", 1492 1492 pjsip_tx_data_get_info(tdata), -sent, 1493 pj sip_strerror(-sent, errmsg, sizeof(errmsg)).ptr));1493 pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 1494 1494 1495 1495 lock_tsx(tsx, &lck); … … 1535 1535 1536 1536 if (status != PJ_SUCCESS) { 1537 char errmsg[PJ SIP_ERR_MSG_SIZE];1537 char errmsg[PJ_ERR_MSG_SIZE]; 1538 1538 1539 1539 PJ_LOG(4,(tsx->obj_name, 1540 1540 "Error sending %s: Err=%d (%s)", 1541 1541 pjsip_tx_data_get_info(tdata), status, 1542 pj sip_strerror(status, errmsg, sizeof(errmsg)).ptr));1542 pj_strerror(status, errmsg, sizeof(errmsg)).ptr)); 1543 1543 1544 1544 /* On error, release transport to force using full transport … … 1569 1569 if (tsx->transport_flag & TSX_HAS_RESOLVED_SERVER) { 1570 1570 1571 char errmsg[PJ SIP_ERR_MSG_SIZE];1571 char errmsg[PJ_ERR_MSG_SIZE]; 1572 1572 1573 1573 if (status == PJ_SUCCESS) { … … 1583 1583 "Err=%d (%s)", 1584 1584 status, 1585 pj sip_strerror(status, errmsg, sizeof(errmsg)).ptr));1585 pj_strerror(status, errmsg, sizeof(errmsg)).ptr)); 1586 1586 1587 1587 tsx->status_code = PJSIP_SC_TSX_TRANSPORT_ERROR; -
pjproject/trunk/pjsip/src/pjsua/pjsua.h
r147 r162 39 39 40 40 /* PJSUA application variables. */ 41 struct pjsua _t41 struct pjsua 42 42 { 43 43 /* Control: */ 44 44 45 pj_caching_pool 46 pjsip_endpoint 47 pj_pool_t 48 pjsip_module 45 pj_caching_pool cp; /**< Global pool factory. */ 46 pjsip_endpoint *endpt; /**< Global endpoint. */ 47 pj_pool_t *pool; /**< pjsua's private pool. */ 48 pjsip_module mod; /**< pjsua's PJSIP module. */ 49 49 50 51 /* Media: */ 52 53 pjmedia_endpt *med_endpt; /**< Media endpoint. */ 54 pj_bool_t null_audio; 55 pjmedia_sock_info med_skinfo; 50 56 51 57 /* User info: */ … … 58 64 pj_str_t proxy; 59 65 pj_str_t outbound_proxy; 66 pjsip_route_hdr route_set; 67 60 68 61 69 /* Registration: */ … … 84 92 pj_sock_t sip_sock; /**< SIP UDP socket. */ 85 93 pj_sockaddr_in sip_sock_name; /**< Public/STUN UDP socket addr. */ 86 pj_sock_t rtp_sock; /**< RTP socket. */87 pj_sockaddr_in rtp_sock_name; /**< Public/STUN UDP socket addr. */88 pj_sock_t rtcp_sock; /**< RTCP socket. */89 pj_sockaddr_in rtcp_sock_name;/**< Public/STUN UDP socket addr. */90 94 91 95 … … 97 101 pj_str_t stun_srv2; 98 102 int stun_port2; 99 100 101 /* Media stack: */102 103 pj_bool_t null_audio;104 pj_med_mgr_t *mmgr;105 103 106 104 … … 114 112 }; 115 113 116 extern struct pjsua_t pjsua; 114 115 /** PJSUA instance. */ 116 extern struct pjsua pjsua; 117 118 119 /** 120 * Structure to be attached to all dialog. 121 * Given a dialog "dlg", application can retrieve this structure 122 * by accessing dlg->mod_data[pjsua.mod.id]. 123 */ 124 struct pjsua_inv_data 125 { 126 pjmedia_session *session; 127 }; 128 117 129 118 130 /***************************************************************************** -
pjproject/trunk/pjsip/src/pjsua/pjsua_core.c
r160 r162 22 22 #define THIS_FILE "pjsua.c" 23 23 24 struct pjsua_t pjsua; 25 24 struct pjsua pjsua; 25 26 /* 27 * Default local URI, if not specified in cmd-line 28 */ 26 29 #define PJSUA_LOCAL_URI "<sip:user@127.0.0.1>" 27 30 28 static char *PJSUA_DUMMY_SDP_OFFER = 29 "v=0\r\n" 30 "o=offer 2890844526 2890844526 IN IP4 127.0.0.1\r\n" 31 "s= \r\n" 32 "c=IN IP4 127.0.0.1\r\n" 33 "t=0 0\r\n" 34 "m=audio 49170 RTP/AVP 0\r\n" 35 "a=rtpmap:0 PCMU/8000\r\n"; 36 37 static char *PJSUA_DUMMY_SDP_ANSWER = 38 "v=0\r\n" 39 "o=answer 2890844730 2890844730 IN IP4 127.0.0.1\r\n" 40 "s= \r\n" 41 "c=IN IP4 127.0.0.1\r\n" 42 "t=0 0\r\n" 43 "m=audio 49920 RTP/AVP 0\r\n" 44 "a=rtpmap:0 PCMU/8000\r\n"; 31 45 32 46 33 /* … … 75 62 76 63 pjsua.local_uri = pj_str(PJSUA_LOCAL_URI); 64 65 /* Init route set list: */ 66 67 pj_list_init(&pjsua.route_set); 77 68 } 78 69 … … 144 135 */ 145 136 pjsip_inv_session *inv; 137 struct pjsua_inv_data *inv_data; 146 138 pjmedia_sdp_session *answer; 147 139 148 /* Create dummy SDP answer: */ 149 150 151 status = pjmedia_sdp_parse(pjsua.pool, PJSUA_DUMMY_SDP_ANSWER, 152 pj_native_strlen(PJSUA_DUMMY_SDP_ANSWER), 153 &answer); 140 141 /* Get media capability from media endpoint: */ 142 143 status = pjmedia_endpt_create_sdp( pjsua.med_endpt, rdata->tp_info.pool, 144 1, &pjsua.med_skinfo, &answer ); 154 145 if (status != PJ_SUCCESS) { 155 146 … … 181 172 182 173 } 174 175 176 /* Create and attach pjsua data to the dialog: */ 177 178 inv_data = pj_pool_zalloc(dlg->pool, sizeof(struct pjsua_inv_data)); 179 dlg->mod_data[pjsua.mod.id] = inv_data; 180 183 181 184 182 /* Answer with 100 (using the dialog, not invite): */ … … 223 221 static void pjsua_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) 224 222 { 223 224 /* Destroy media session when invite session is disconnected. */ 225 if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { 226 struct pjsua_inv_data *inv_data; 227 228 inv_data = inv->dlg->mod_data[pjsua.mod.id]; 229 if (inv_data && inv_data->session) { 230 pjmedia_session_destroy(inv_data->session); 231 inv_data->session = NULL; 232 } 233 234 } 235 225 236 pjsua_ui_inv_on_state_changed(inv, e); 226 237 } … … 237 248 238 249 PJ_TODO(HANDLE_FORKED_DIALOG); 250 } 251 252 /* 253 * 254 */ 255 static void pjsua_inv_on_media_update(pjsip_inv_session *inv, 256 pj_status_t status) 257 { 258 struct pjsua_inv_data *inv_data; 259 const pjmedia_sdp_session *local_sdp; 260 const pjmedia_sdp_session *remote_sdp; 261 262 if (status != PJ_SUCCESS) { 263 264 pjsua_perror("SDP negotiation has failed", status); 265 return; 266 267 } 268 269 /* Destroy existing media session, if any. */ 270 271 inv_data = inv->dlg->mod_data[pjsua.mod.id]; 272 if (inv_data && inv_data->session) { 273 pjmedia_session_destroy(inv_data->session); 274 inv_data->session = NULL; 275 } 276 277 /* Get local and remote SDP */ 278 279 status = pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp); 280 if (status != PJ_SUCCESS) { 281 pjsua_perror("Unable to retrieve currently active local SDP", status); 282 return; 283 } 284 285 286 status = pjmedia_sdp_neg_get_active_remote(inv->neg, &remote_sdp); 287 if (status != PJ_SUCCESS) { 288 pjsua_perror("Unable to retrieve currently active remote SDP", status); 289 return; 290 } 291 292 293 /* Create new media session. 294 * The media session is active immediately. 295 */ 296 297 status = pjmedia_session_create( pjsua.med_endpt, 1, &pjsua.med_skinfo, 298 local_sdp, remote_sdp, &inv_data->session ); 299 if (status != PJ_SUCCESS) { 300 pjsua_perror("Unable to create media session", status); 301 return; 302 } 303 239 304 } 240 305 … … 364 429 pjsua.sip_sock = sock[SIP_SOCK]; 365 430 pj_memcpy(&pjsua.sip_sock_name, &mapped_addr[SIP_SOCK], sizeof(pj_sockaddr_in)); 366 pjsua.rtp_sock = sock[RTP_SOCK]; 367 pj_memcpy(&pjsua.rtp_sock_name, &mapped_addr[RTP_SOCK], sizeof(pj_sockaddr_in)); 368 pjsua.rtcp_sock = sock[RTCP_SOCK]; 369 pj_memcpy(&pjsua.rtcp_sock_name, &mapped_addr[RTCP_SOCK], sizeof(pj_sockaddr_in)); 431 432 pjsua.med_skinfo.rtp_sock = sock[RTP_SOCK]; 433 pj_memcpy(&pjsua.med_skinfo.rtp_addr_name, 434 &mapped_addr[RTP_SOCK], sizeof(pj_sockaddr_in)); 435 436 pjsua.med_skinfo.rtcp_sock = sock[RTCP_SOCK]; 437 pj_memcpy(&pjsua.med_skinfo.rtcp_addr_name, 438 &mapped_addr[RTCP_SOCK], sizeof(pj_sockaddr_in)); 370 439 371 440 PJ_LOG(4,(THIS_FILE, "SIP UDP socket reachable at %s:%d", … … 373 442 pj_ntohs(pjsua.sip_sock_name.sin_port))); 374 443 PJ_LOG(4,(THIS_FILE, "RTP socket reachable at %s:%d", 375 pj_inet_ntoa(pjsua. rtp_sock_name.sin_addr),376 pj_ntohs(pjsua. rtp_sock_name.sin_port)));444 pj_inet_ntoa(pjsua.med_skinfo.rtp_addr_name.sin_addr), 445 pj_ntohs(pjsua.med_skinfo.rtp_addr_name.sin_port))); 377 446 PJ_LOG(4,(THIS_FILE, "RTCP UDP socket reachable at %s:%d", 378 pj_inet_ntoa(pjsua. rtcp_sock_name.sin_addr),379 pj_ntohs(pjsua. rtcp_sock_name.sin_port)));447 pj_inet_ntoa(pjsua.med_skinfo.rtcp_addr_name.sin_addr), 448 pj_ntohs(pjsua.med_skinfo.rtcp_addr_name.sin_port))); 380 449 381 450 return PJ_SUCCESS; … … 479 548 inv_cb.on_state_changed = &pjsua_inv_on_state_changed; 480 549 inv_cb.on_new_session = &pjsua_inv_on_new_session; 550 inv_cb.on_media_update = &pjsua_inv_on_media_update; 481 551 482 552 /* Initialize invite session module: */ … … 552 622 pj_caching_pool_destroy(&pjsua.cp); 553 623 pjsua_perror("Stack initialization has returned error", status); 624 return status; 625 } 626 627 628 /* Init media endpoint: */ 629 630 status = pjmedia_endpt_create(&pjsua.cp.factory, &pjsua.med_endpt); 631 if (status != PJ_SUCCESS) { 632 pj_caching_pool_destroy(&pjsua.cp); 633 pjsua_perror("Media stack initialization has returned error", status); 554 634 return status; 555 635 } … … 677 757 } 678 758 679 /* Initialize global route_set: */ 680 681 PJ_TODO(INIT_GLOBAL_ROUTE_SET); 759 /* If outbound_proxy is specified, put it in the route_set: */ 760 761 if (pjsua.outbound_proxy.slen) { 762 763 pjsip_route_hdr *route; 764 const pj_str_t hname = { "Route", 5 }; 765 int parsed_len; 766 767 route = pjsip_parse_hdr( pjsua.pool, &hname, 768 pjsua.outbound_proxy.ptr, 769 pjsua.outbound_proxy.slen, 770 &parsed_len); 771 if (route == NULL) { 772 pjsua_perror("Invalid outbound proxy URL", PJSIP_EINVALIDURI); 773 return PJSIP_EINVALIDURI; 774 } 775 776 pj_list_push_back(&pjsua.route_set, route); 777 } 682 778 683 779 … … 770 866 pjmedia_sdp_session *offer; 771 867 pjsip_inv_session *inv; 868 struct pjsua_inv_data *inv_data; 772 869 pjsip_tx_data *tdata; 773 870 pj_status_t status; … … 787 884 } 788 885 789 /* Create dummy SDP for offer: */ 790 791 status = pjmedia_sdp_parse(dlg->pool, PJSUA_DUMMY_SDP_OFFER, 792 pj_native_strlen(PJSUA_DUMMY_SDP_OFFER), 793 &offer); 794 if (status != PJ_SUCCESS) { 795 pjsua_perror("Dummy SDP offer parsing failed", status); 886 /* Get media capability from media endpoint: */ 887 888 status = pjmedia_endpt_create_sdp( pjsua.med_endpt, dlg->pool, 889 1, &pjsua.med_skinfo, &offer); 890 if (status != PJ_SUCCESS) { 891 pjsua_perror("pjmedia unable to create SDP", status); 796 892 goto on_error; 797 893 } … … 806 902 807 903 904 /* Create and associate our data in the session. */ 905 906 inv_data = pj_pool_zalloc( dlg->pool, sizeof(struct pjsua_inv_data)); 907 dlg->mod_data[pjsua.mod.id] = inv_data; 908 909 808 910 /* Set dialog Route-Set: */ 809 911 810 PJ_TODO(INIT_DIALOG_ROUTE_SET); 912 if (!pj_list_empty(&pjsua.route_set)) 913 pjsip_dlg_set_route_set(dlg, &pjsua.route_set); 914 811 915 812 916 /* Set credentials: */
Note: See TracChangeset
for help on using the changeset viewer.