- Timestamp:
- Oct 19, 2011 12:45:05 PM (13 years ago)
- Location:
- pjproject/branches/1.x
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c
r3804 r3829 5119 5119 } 5120 5120 5121 status = pjsua_destroy ();5121 status = pjsua_destroy2(1); 5122 5122 5123 5123 pj_bzero(&app_config, sizeof(app_config)); -
pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h
r3762 r3829 1295 1295 1296 1296 /** 1297 * Flags to be given to pjsua_destroy2() 1298 */ 1299 typedef enum pjsua_destroy_flag 1300 { 1301 /** 1302 * Do not invoke any networking functions. 1303 */ 1304 PJSUA_DESTROY_NO_NETWORK = 1 1305 1306 } pjsua_destroy_flag; 1307 1308 /** 1297 1309 * Use this function to initialize pjsua config. 1298 1310 * … … 1430 1442 * keep track of it's state. 1431 1443 * 1444 * @see pjsua_destroy2() 1445 * 1432 1446 * @return PJ_SUCCESS on success, or the appropriate error code. 1433 1447 */ 1434 1448 PJ_DECL(pj_status_t) pjsua_destroy(void); 1449 1450 1451 /** 1452 * Variant of destroy with additional flags. 1453 * 1454 * @param flags Combination of pjsua_destroy_flag enumeration. 1455 * 1456 * @return PJ_SUCCESS on success, or the appropriate error code. 1457 */ 1458 PJ_DECL(pj_status_t) pjsua_destroy2(unsigned flags); 1435 1459 1436 1460 -
pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua_internal.h
r3749 r3829 464 464 * Shutdown presence. 465 465 */ 466 void pjsua_pres_shutdown( void);466 void pjsua_pres_shutdown(unsigned flags); 467 467 468 468 /** … … 479 479 * Send un-PUBLISH 480 480 */ 481 void pjsua_pres_unpublish(pjsua_acc *acc );481 void pjsua_pres_unpublish(pjsua_acc *acc, unsigned flags); 482 482 483 483 /** 484 484 * Terminate server subscription for the account 485 485 */ 486 void pjsua_pres_delete_acc(int acc_id );486 void pjsua_pres_delete_acc(int acc_id, unsigned flags); 487 487 488 488 /** … … 519 519 * Destroy pjsua media subsystem. 520 520 */ 521 pj_status_t pjsua_media_subsys_destroy( void);521 pj_status_t pjsua_media_subsys_destroy(unsigned flags); 522 522 523 523 /** -
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_acc.c
r3770 r3829 583 583 584 584 /* Delete server presence subscription */ 585 pjsua_pres_delete_acc(acc_id );585 pjsua_pres_delete_acc(acc_id, 0); 586 586 587 587 /* Release account pool */ … … 802 802 acc->cfg.publish_enabled = cfg->publish_enabled; 803 803 if (!acc->cfg.publish_enabled) 804 pjsua_pres_unpublish(acc );804 pjsua_pres_unpublish(acc, 0); 805 805 else 806 806 update_reg = PJ_TRUE; … … 1996 1996 } 1997 1997 1998 pjsua_pres_unpublish(&pjsua_var.acc[acc_id] );1998 pjsua_pres_unpublish(&pjsua_var.acc[acc_id], 0); 1999 1999 2000 2000 status = pjsip_regc_unregister(pjsua_var.acc[acc_id].regc, &tdata); -
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_core.c
r3594 r3829 1284 1284 * Destroy pjsua. 1285 1285 */ 1286 PJ_DEF(pj_status_t) pjsua_destroy (void)1286 PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) 1287 1287 { 1288 1288 int i; /* Must be signed */ … … 1303 1303 unsigned max_wait; 1304 1304 1305 PJ_LOG(4,(THIS_FILE, "Shutting down ..."));1305 PJ_LOG(4,(THIS_FILE, "Shutting down, flags=%d...", flags)); 1306 1306 1307 1307 /* Terminate all calls. */ 1308 pjsua_call_hangup_all(); 1308 if ((flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 1309 pjsua_call_hangup_all(); 1310 } 1309 1311 1310 1312 /* Set all accounts to offline */ … … 1317 1319 1318 1320 /* Terminate all presence subscriptions. */ 1319 pjsua_pres_shutdown( );1321 pjsua_pres_shutdown(flags); 1320 1322 1321 1323 /* Destroy media (to shutdown media transports etc) */ 1322 pjsua_media_subsys_destroy( );1324 pjsua_media_subsys_destroy(flags); 1323 1325 1324 1326 /* Wait for sometime until all publish client sessions are done … … 1334 1336 } 1335 1337 1338 /* No need to wait if we didn't send anything */ 1339 if (flags & PJSUA_DESTROY_NO_NETWORK) { 1340 max_wait = 0; 1341 } 1342 1336 1343 /* Second stage, wait for unpublications to complete */ 1337 1344 for (i=0; i<(int)(max_wait/50); ++i) { … … 1363 1370 continue; 1364 1371 1365 if (pjsua_var.acc[i].regc) { 1372 if (pjsua_var.acc[i].regc && (flags & PJSUA_DESTROY_NO_NETWORK)==0) 1373 { 1366 1374 pjsua_acc_set_registration(i, PJ_FALSE); 1367 1375 } … … 1388 1396 } 1389 1397 1398 /* No need to wait if we didn't send anything */ 1399 if (flags & PJSUA_DESTROY_NO_NETWORK) { 1400 max_wait = 0; 1401 } 1402 1390 1403 /* Second stage, wait for unregistrations to complete */ 1391 1404 for (i=0; i<(int)(max_wait/50); ++i) { … … 1408 1421 * transports shutdown to complete: 1409 1422 */ 1410 if (i < 20 )1423 if (i < 20 && (flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 1411 1424 busy_sleep(1000 - i*50); 1425 } 1412 1426 1413 1427 PJ_LOG(4,(THIS_FILE, "Destroying...")); … … 1467 1481 /* Done. */ 1468 1482 return PJ_SUCCESS; 1483 } 1484 1485 1486 PJ_DEF(pj_status_t) pjsua_destroy(void) 1487 { 1488 return pjsua_destroy2(0); 1469 1489 } 1470 1490 -
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c
r3816 r3829 659 659 * Destroy pjsua media subsystem. 660 660 */ 661 pj_status_t pjsua_media_subsys_destroy( void)661 pj_status_t pjsua_media_subsys_destroy(unsigned flags) 662 662 { 663 663 unsigned i; … … 699 699 } 700 700 if (pjsua_var.calls[i].med_tp && pjsua_var.calls[i].med_tp_auto_del) { 701 /* TODO: check if we're not allowed to send to network in the 702 * "flags", and if so do not do TURN allocation... 703 */ 704 PJ_UNUSED_ARG(flags); 701 705 pjmedia_transport_close(pjsua_var.calls[i].med_tp); 702 706 } -
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_pres.c
r3604 r3829 1278 1278 1279 1279 /* Unpublish presence publication */ 1280 void pjsua_pres_unpublish(pjsua_acc *acc )1280 void pjsua_pres_unpublish(pjsua_acc *acc, unsigned flags) 1281 1281 { 1282 1282 if (acc->publish_sess) { … … 1284 1284 1285 1285 acc->online_status = PJ_FALSE; 1286 send_publish(acc->index, PJ_FALSE); 1286 1287 if ((flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 1288 send_publish(acc->index, PJ_FALSE); 1289 } 1290 1287 1291 /* By ticket #364, don't destroy the session yet (let the callback 1288 1292 destroy it) … … 1297 1301 1298 1302 /* Terminate server subscription for the account */ 1299 void pjsua_pres_delete_acc(int acc_id )1303 void pjsua_pres_delete_acc(int acc_id, unsigned flags) 1300 1304 { 1301 1305 pjsua_acc *acc = &pjsua_var.acc[acc_id]; … … 1319 1323 pjsip_pres_set_status(uapres->sub, &pres_status); 1320 1324 1321 if (pjsip_pres_notify(uapres->sub, 1322 PJSIP_EVSUB_STATE_TERMINATED, NULL, 1323 &reason, &tdata)==PJ_SUCCESS) 1324 { 1325 pjsip_pres_send_request(uapres->sub, tdata); 1325 if ((flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 1326 if (pjsip_pres_notify(uapres->sub, 1327 PJSIP_EVSUB_STATE_TERMINATED, NULL, 1328 &reason, &tdata)==PJ_SUCCESS) 1329 { 1330 pjsip_pres_send_request(uapres->sub, tdata); 1331 } 1332 } else { 1333 pjsip_pres_terminate(uapres->sub, PJ_FALSE); 1326 1334 } 1327 1335 … … 1334 1342 1335 1343 /* Terminate presence publication, if any */ 1336 pjsua_pres_unpublish(acc );1344 pjsua_pres_unpublish(acc, flags); 1337 1345 } 1338 1346 … … 2253 2261 * Shutdown presence. 2254 2262 */ 2255 void pjsua_pres_shutdown( void)2263 void pjsua_pres_shutdown(unsigned flags) 2256 2264 { 2257 2265 unsigned i; … … 2267 2275 if (!pjsua_var.acc[i].valid) 2268 2276 continue; 2269 pjsua_pres_delete_acc(i );2277 pjsua_pres_delete_acc(i, flags); 2270 2278 } 2271 2279 … … 2274 2282 } 2275 2283 2276 refresh_client_subscriptions(); 2277 2278 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 2279 if (pjsua_var.acc[i].valid) 2280 pjsua_pres_update_acc(i, PJ_FALSE); 2281 } 2282 } 2284 if ((flags & PJSUA_DESTROY_NO_NETWORK) == 0) { 2285 refresh_client_subscriptions(); 2286 2287 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 2288 if (pjsua_var.acc[i].valid) 2289 pjsua_pres_update_acc(i, PJ_FALSE); 2290 } 2291 } 2292 }
Note: See TracChangeset
for help on using the changeset viewer.