Changeset 487 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
- Timestamp:
- Jun 1, 2006 12:28:44 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r482 r487 52 52 53 53 cfg->thread_cnt = 1; 54 cfg->media_has_ioqueue = 1; 55 cfg->media_thread_cnt = 1; 54 56 cfg->udp_port = 5060; 55 57 cfg->start_rtp_port = 4000; … … 247 249 } 248 250 251 /** 252 * Poll pjsua. 253 */ 254 PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout) 255 { 256 unsigned count = 0; 257 pj_time_val tv; 258 pj_status_t status; 259 260 tv.sec = 0; 261 tv.msec = msec_timeout; 262 pj_time_val_normalize(&tv); 263 264 status = pjsip_endpt_handle_events2(pjsua.endpt, &tv, &count); 265 if (status != PJ_SUCCESS) 266 return -status; 267 268 return count; 269 } 249 270 250 271 … … 505 526 /* Must create media endpoint too */ 506 527 status = pjmedia_endpt_create(&pjsua.cp.factory, 507 pjsip_endpt_get_ioqueue(pjsua.endpt), 0, 528 pjsua.config.media_has_ioqueue? NULL : 529 pjsip_endpt_get_ioqueue(pjsua.endpt), 530 pjsua.config.media_thread_cnt, 508 531 &pjsua.med_endpt); 509 532 if (status != PJ_SUCCESS) { … … 755 778 756 779 780 /***************************************************************************** 781 * Console application custom logging: 782 */ 783 784 785 static void log_writer(int level, const char *buffer, int len) 786 { 787 /* Write to both stdout and file. */ 788 789 if (level <= (int)pjsua.config.app_log_level) 790 pj_log_write(level, buffer, len); 791 792 if (pjsua.log_file) { 793 fwrite(buffer, len, 1, pjsua.log_file); 794 fflush(pjsua.log_file); 795 } 796 } 797 798 799 static pj_status_t logging_init() 800 { 801 /* Redirect log function to ours */ 802 803 pj_log_set_log_func( &log_writer ); 804 805 /* If output log file is desired, create the file: */ 806 807 if (pjsua.config.log_filename.slen) { 808 pjsua.log_file = fopen(pjsua.config.log_filename.ptr, "wt"); 809 if (pjsua.log_file == NULL) { 810 PJ_LOG(1,(THIS_FILE, "Unable to open log file %s", 811 pjsua.config.log_filename.ptr)); 812 return -1; 813 } 814 } 815 816 return PJ_SUCCESS; 817 } 818 819 820 static void logging_shutdown(void) 821 { 822 /* Close logging file, if any: */ 823 824 if (pjsua.log_file) { 825 fclose(pjsua.log_file); 826 pjsua.log_file = NULL; 827 } 828 } 829 830 757 831 /* 758 832 * Initialize pjsua application. … … 807 881 pj_log_set_level(pjsua.config.log_level); 808 882 pj_log_set_decor(pjsua.config.log_decor); 883 884 status = logging_init(); 885 if (status != PJ_SUCCESS) 886 goto on_error; 809 887 810 888 … … 854 932 } 855 933 status = pjmedia_transport_udp_attach(pjsua.med_endpt, NULL, 856 &pjsua.calls[i].skinfo, 934 &pjsua.calls[i].skinfo, 0, 857 935 &pjsua.calls[i].med_tp); 858 936 } … … 1369 1447 * Get conference port associated with player. 1370 1448 */ 1371 PJ_DEF( unsigned) pjsua_player_get_conf_port(pjsua_player_id id)1449 PJ_DEF(int) pjsua_player_get_conf_port(pjsua_player_id id) 1372 1450 { 1373 1451 PJ_ASSERT_RETURN(id>=0 && id < PJ_ARRAY_SIZE(pjsua.player), PJ_EINVAL); … … 1453 1531 * Get conference port associated with recorder. 1454 1532 */ 1455 PJ_DEF( unsigned) pjsua_recorder_get_conf_port(pjsua_recorder_id id)1533 PJ_DEF(int) pjsua_recorder_get_conf_port(pjsua_recorder_id id) 1456 1534 { 1457 1535 PJ_ASSERT_RETURN(id>=0 && id < PJ_ARRAY_SIZE(pjsua.recorder), PJ_EINVAL); … … 1521 1599 /* Signal threads to quit: */ 1522 1600 pjsua.quit_flag = 1; 1523 1524 /* Terminate all calls. */1525 pjsua_call_hangup_all();1526 1527 /* Terminate all presence subscriptions. */1528 pjsua_pres_shutdown();1529 1530 /* Unregister, if required: */1531 for (i=0; i<(int)pjsua.config.acc_cnt; ++i) {1532 if (pjsua.acc[i].regc) {1533 pjsua_acc_set_registration(i, PJ_FALSE);1534 }1535 }1536 1601 1537 1602 /* Wait worker threads to quit: */ … … 1545 1610 } 1546 1611 1547 1548 /* Wait for some time to allow unregistration to complete: */ 1612 1549 1613 if (pjsua.endpt) { 1614 /* Terminate all calls. */ 1615 pjsua_call_hangup_all(); 1616 1617 /* Terminate all presence subscriptions. */ 1618 pjsua_pres_shutdown(); 1619 1620 /* Unregister, if required: */ 1621 for (i=0; i<(int)pjsua.config.acc_cnt; ++i) { 1622 if (pjsua.acc[i].regc) { 1623 pjsua_acc_set_registration(i, PJ_FALSE); 1624 } 1625 } 1626 1627 /* Wait for some time to allow unregistration to complete: */ 1550 1628 PJ_LOG(4,(THIS_FILE, "Shutting down...")); 1551 1629 busy_sleep(1000); … … 1630 1708 1631 1709 1710 PJ_LOG(4,(THIS_FILE, "PJSUA destroyed...")); 1711 1712 /* End logging */ 1713 logging_shutdown(); 1714 1632 1715 /* Done. */ 1633 1716
Note: See TracChangeset
for help on using the changeset viewer.