- Timestamp:
- Aug 12, 2009 5:53:47 PM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h
r2858 r2869 319 319 /** 320 320 * This structure describes the invite session. 321 * 322 * Note regarding the invite session's pools. The inv_sess used to have 323 * only one pool, which is just a pointer to the dialog's pool. Ticket 324 * http://trac.pjsip.org/repos/ticket/877 has found that the memory 325 * usage will grow considerably everytime re-INVITE or UPDATE is 326 * performed. 327 * 328 * Ticket #877 then created two more memory pools for the inv_sess, so 329 * now we have three memory pools: 330 * - pool: to be used to allocate long term data for the session 331 * - pool_prov and pool_active: this is a flip-flop pools to be used 332 * interchangably during re-INVITE and UPDATE. pool_prov is 333 * "provisional" pool, used to allocate SDP offer or answer for 334 * the re-INVITE and UPDATE. Once SDP negotiation is done, the 335 * provisional pool will be made as the active pool, then the 336 * existing active pool will be reset, to release the memory 337 * back to the OS. So these pool's lifetime is synchronized to 338 * the SDP offer-answer negotiation. 339 * 340 * Higher level application such as PJSUA-LIB has been modified to 341 * make use of these flip-flop pools, i.e. by creating media objects 342 * from the provisional pool rather than from the long term pool. 343 * 344 * Other applications that want to use these pools must understand 345 * that the flip-flop pool's lifetimes are synchronized to the 346 * SDP offer-answer negotiation. 321 347 */ 322 348 struct pjsip_inv_session 323 349 { 324 350 char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification */ 325 pj_pool_t *pool; /**< Dialog's pool. */ 351 pj_pool_t *pool; /**< Long term pool. */ 352 pj_pool_t *pool_prov; /**< Provisional pool */ 353 pj_pool_t *pool_active; /**< Active/current pool*/ 326 354 pjsip_inv_state state; /**< Invite sess state. */ 327 355 pj_bool_t cancelling; /**< CANCEL requested */ -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r2861 r2869 78 78 }; 79 79 80 #define POOL_INIT_SIZE 256 81 #define POOL_INC_SIZE 256 82 80 83 /* 81 84 * Static prototypes. … … 235 238 pjsip_timer_end_session(inv); 236 239 pjsip_dlg_dec_session(inv->dlg, &mod_inv.mod); 240 241 /* Release the flip-flop pools */ 242 pj_pool_release(inv->pool_prov); 243 pj_pool_release(inv->pool_active); 237 244 } 238 245 } … … 670 677 inv->cause = (pjsip_status_code) 0; 671 678 679 /* Create flip-flop pool (see ticket #877) */ 680 /* (using inv->obj_name as temporary variable for pool names */ 681 pj_ansi_snprintf(inv->obj_name, PJ_MAX_OBJ_NAME, "inv%p", dlg->pool); 682 inv->pool_prov = pjsip_endpt_create_pool(dlg->endpt, inv->obj_name, 683 POOL_INIT_SIZE, POOL_INC_SIZE); 684 inv->pool_active = pjsip_endpt_create_pool(dlg->endpt, inv->obj_name, 685 POOL_INIT_SIZE, POOL_INC_SIZE); 686 672 687 /* Object name will use the same dialog pointer. */ 673 688 pj_ansi_snprintf(inv->obj_name, PJ_MAX_OBJ_NAME, "inv%p", dlg); … … 675 690 /* Create negotiator if local_sdp is specified. */ 676 691 if (local_sdp) { 677 status = pjmedia_sdp_neg_create_w_local_offer( dlg->pool, local_sdp,678 &inv->neg);692 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, 693 local_sdp, &inv->neg); 679 694 if (status != PJ_SUCCESS) { 680 695 pjsip_dlg_dec_lock(dlg); … … 1130 1145 inv->cause = (pjsip_status_code) 0; 1131 1146 1147 /* Create flip-flop pool (see ticket #877) */ 1148 /* (using inv->obj_name as temporary variable for pool names */ 1149 pj_ansi_snprintf(inv->obj_name, PJ_MAX_OBJ_NAME, "inv%p", dlg->pool); 1150 inv->pool_prov = pjsip_endpt_create_pool(dlg->endpt, inv->obj_name, 1151 POOL_INIT_SIZE, POOL_INC_SIZE); 1152 inv->pool_active = pjsip_endpt_create_pool(dlg->endpt, inv->obj_name, 1153 POOL_INIT_SIZE, POOL_INC_SIZE); 1154 1132 1155 /* Object name will use the same dialog pointer. */ 1133 1156 pj_ansi_snprintf(inv->obj_name, PJ_MAX_OBJ_NAME, "inv%p", dlg); … … 1151 1174 /* Create negotiator. */ 1152 1175 if (rem_sdp) { 1153 status = pjmedia_sdp_neg_create_w_remote_offer(inv->pool, local_sdp, 1154 rem_sdp, &inv->neg); 1176 status = pjmedia_sdp_neg_create_w_remote_offer(inv->pool, 1177 local_sdp, rem_sdp, 1178 &inv->neg); 1155 1179 1156 1180 } else if (local_sdp) { 1157 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, local_sdp,1158 &inv->neg);1181 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, 1182 local_sdp, &inv->neg); 1159 1183 } else { 1160 1184 status = PJ_SUCCESS; … … 1440 1464 1441 1465 1466 /* Util: swap pool */ 1467 static void swap_pool(pj_pool_t **p1, pj_pool_t **p2) 1468 { 1469 pj_pool_t *tmp = *p1; 1470 *p1 = *p2; 1471 *p2 = tmp; 1472 } 1473 1442 1474 /* 1443 1475 * Initiate SDP negotiation in the SDP negotiator. … … 1451 1483 PJMEDIA_SDPNEG_EINSTATE); 1452 1484 1453 status = pjmedia_sdp_neg_negotiate(inv->pool , inv->neg, 0);1485 status = pjmedia_sdp_neg_negotiate(inv->pool_prov, inv->neg, 0); 1454 1486 1455 1487 PJ_LOG(5,(inv->obj_name, "SDP negotiation done, status=%d", status)); … … 1457 1489 if (mod_inv.cb.on_media_update && inv->notify) 1458 1490 (*mod_inv.cb.on_media_update)(inv, status); 1491 1492 /* Swap the flip-flop pool, and reset the new provisional pool */ 1493 swap_pool(&inv->pool_prov, &inv->pool_active); 1494 pj_pool_reset(inv->pool_prov); 1459 1495 1460 1496 return status; … … 1535 1571 1536 1572 /* Feed the original offer to negotiator */ 1537 status = pjmedia_sdp_neg_modify_local_offer(inv->pool, inv->neg, 1573 status = pjmedia_sdp_neg_modify_local_offer(inv->pool_prov, 1574 inv->neg, 1538 1575 reoffer_sdp); 1539 1576 if (status != PJ_SUCCESS) { … … 1581 1618 1582 1619 if (inv->neg == NULL) { 1583 status=pjmedia_sdp_neg_create_w_remote_offer(inv->pool, NULL, 1620 status=pjmedia_sdp_neg_create_w_remote_offer(inv->pool, NULL, 1584 1621 rem_sdp, &inv->neg); 1585 1622 } else { 1586 status=pjmedia_sdp_neg_set_remote_offer(inv->pool , inv->neg,1623 status=pjmedia_sdp_neg_set_remote_offer(inv->pool_prov, inv->neg, 1587 1624 rem_sdp); 1588 1625 } … … 1616 1653 pjsip_rx_data_get_info(rdata))); 1617 1654 1618 status = pjmedia_sdp_neg_set_remote_answer(inv->pool , inv->neg,1655 status = pjmedia_sdp_neg_set_remote_answer(inv->pool_prov, inv->neg, 1619 1656 rem_sdp); 1620 1657 … … 1669 1706 1670 1707 if (inv->neg == NULL) { 1671 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, local_sdp, 1708 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, 1709 local_sdp, 1672 1710 &inv->neg); 1673 1711 } else if (pjmedia_sdp_neg_get_state(inv->neg)== 1674 1712 PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) 1675 1713 { 1676 status = pjmedia_sdp_neg_set_local_answer(inv->pool , inv->neg,1714 status = pjmedia_sdp_neg_set_local_answer(inv->pool_prov, inv->neg, 1677 1715 local_sdp); 1678 1716 } else { … … 1879 1917 1880 1918 pjsip_dlg_inc_lock(inv->dlg); 1881 status = pjmedia_sdp_neg_set_local_answer( inv->pool , inv->neg, sdp);1919 status = pjmedia_sdp_neg_set_local_answer( inv->pool_prov, inv->neg, sdp); 1882 1920 pjsip_dlg_dec_lock(inv->dlg); 1883 1921 … … 2228 2266 if (new_offer) { 2229 2267 if (!inv->neg) { 2230 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, new_offer, 2268 status = pjmedia_sdp_neg_create_w_local_offer(inv->pool, 2269 new_offer, 2231 2270 &inv->neg); 2232 2271 if (status != PJ_SUCCESS) … … 2247 2286 2248 2287 case PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER: 2249 status = pjmedia_sdp_neg_set_local_answer(inv->pool, inv->neg, 2288 status = pjmedia_sdp_neg_set_local_answer(inv->pool_prov, 2289 inv->neg, 2250 2290 new_offer); 2251 2291 if (status != PJ_SUCCESS) … … 2260 2300 2261 2301 case PJMEDIA_SDP_NEG_STATE_DONE: 2262 status = pjmedia_sdp_neg_modify_local_offer(inv->pool,inv->neg, 2302 status = pjmedia_sdp_neg_modify_local_offer(inv->pool_prov, 2303 inv->neg, 2263 2304 new_offer); 2264 2305 if (status != PJ_SUCCESS) … … 2316 2357 * with correct SDP origin. 2317 2358 */ 2318 status = pjmedia_sdp_neg_modify_local_offer(inv->pool ,inv->neg,2359 status = pjmedia_sdp_neg_modify_local_offer(inv->pool_prov, inv->neg, 2319 2360 offer); 2320 2361 if (status != PJ_SUCCESS) … … 3745 3786 * fix the offer with correct SDP origin. 3746 3787 */ 3747 status = pjmedia_sdp_neg_modify_local_offer(dlg->pool, 3748 inv->neg, 3749 sdp); 3788 status = 3789 pjmedia_sdp_neg_modify_local_offer(inv->pool_prov, 3790 inv->neg, 3791 sdp); 3750 3792 3751 3793 /* Retrieve the "fixed" offer from negotiator */ … … 3760 3802 if (sdp == NULL) { 3761 3803 const pjmedia_sdp_session *active_sdp = NULL; 3762 status = pjmedia_sdp_neg_send_local_offer( dlg->pool,3804 status = pjmedia_sdp_neg_send_local_offer(inv->pool_prov, 3763 3805 inv->neg, 3764 3806 &active_sdp); -
pjproject/trunk/pjsip/src/pjsip-ua/sip_timer.c
r2865 r2869 360 360 status = pjsip_inv_invite(inv, &tdata); 361 361 if (status == PJ_SUCCESS) 362 status = pjmedia_sdp_neg_send_local_offer(inv->pool ,362 status = pjmedia_sdp_neg_send_local_offer(inv->pool_prov, 363 363 inv->neg, &offer); 364 364 if (status == PJ_SUCCESS) -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2859 r2869 1597 1597 status = create_sdp_of_call_hold(call, &sdp); 1598 1598 } else { 1599 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1599 status = pjsua_media_channel_create_sdp(call->index, 1600 call->inv->pool_prov, 1600 1601 NULL, &sdp, NULL); 1601 1602 call->local_hold = PJ_FALSE; … … 1656 1657 1657 1658 /* Create SDP */ 1658 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1659 status = pjsua_media_channel_create_sdp(call->index, 1660 call->inv->pool_prov, 1659 1661 NULL, &sdp, NULL); 1660 1662 if (status != PJ_SUCCESS) { … … 3201 3203 pjmedia_sdp_session *sdp; 3202 3204 3203 /* Use call's p ool */3204 pool = call->inv->pool ;3205 /* Use call's provisional pool */ 3206 pool = call->inv->pool_prov; 3205 3207 3206 3208 /* Create new offer */ … … 3268 3270 call->index)); 3269 3271 3270 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 3272 status = pjsua_media_channel_create_sdp(call->index, 3273 call->inv->pool_prov, 3271 3274 offer, &answer, NULL); 3272 3275 if (status != PJ_SUCCESS) { … … 3297 3300 * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1) 3298 3301 */ 3299 attr = pjmedia_sdp_attr_create(call->inv->pool , "sendonly", NULL);3302 attr = pjmedia_sdp_attr_create(call->inv->pool_prov, "sendonly", NULL); 3300 3303 pjmedia_sdp_media_add_attr(answer->media[0], attr); 3301 3304 } … … 3335 3338 call->index)); 3336 3339 3337 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 3340 status = pjsua_media_channel_create_sdp(call->index, 3341 call->inv->pool_prov, 3338 3342 NULL, offer, NULL); 3339 3343 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r2864 r2869 1427 1427 /* Create media session info based on SDP parameters. 1428 1428 */ 1429 status = pjmedia_session_info_from_sdp( call->inv-> dlg->pool,1429 status = pjmedia_session_info_from_sdp( call->inv->pool_prov, 1430 1430 pjsua_var.med_endpt, 1431 1431 PJMEDIA_MAX_SDP_MEDIA, &sess_info, … … 1470 1470 /* Start/restart media transport */ 1471 1471 status = pjmedia_transport_media_start(call->med_tp, 1472 call->inv->pool ,1472 call->inv->pool_prov, 1473 1473 local_sdp, remote_sdp, 0); 1474 1474 if (status != PJ_SUCCESS) … … 1573 1573 port_name = pj_str("call"); 1574 1574 } 1575 status = pjmedia_conf_add_port( pjsua_var.mconf, call->inv->pool, 1575 status = pjmedia_conf_add_port( pjsua_var.mconf, 1576 call->inv->pool_prov, 1576 1577 media_port, 1577 1578 &port_name,
Note: See TracChangeset
for help on using the changeset viewer.