Changeset 284 for pjproject/trunk
- Timestamp:
- Mar 5, 2006 11:54:02 AM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r278 r284 186 186 pj_bool_t auto_loop; /**< Auto loop RTP stream? */ 187 187 pj_bool_t auto_conf; /**< Auto put to conference? */ 188 int complexity; /**< Codec complexity. */ 189 int quality; /**< Codec quality. */ 190 188 191 189 192 /* Codec arguments: */ … … 338 341 * Hangup call. 339 342 */ 340 void pjsua_call_hangup(int call_index , int code);343 void pjsua_call_hangup(int call_index); 341 344 342 345 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r268 r284 38 38 { 39 39 pj_str_t dest_uri; 40 pjsip_dialog *dlg ;40 pjsip_dialog *dlg = NULL; 41 41 pjmedia_sdp_session *offer; 42 pjsip_inv_session *inv ;42 pjsip_inv_session *inv = NULL; 43 43 int call_index = -1; 44 44 pjsip_tx_data *tdata; … … 142 142 143 143 on_error: 144 PJ_TODO(DESTROY_DIALOG_ON_FAIL); 144 if (inv != NULL) { 145 pjsip_inv_terminate(inv, PJSIP_SC_OK, PJ_FALSE); 146 } else { 147 pjsip_dlg_terminate(dlg); 148 } 149 145 150 if (call_index != -1) { 146 151 pjsua.calls[call_index].inv = NULL; … … 160 165 pjsip_tx_data *response = NULL; 161 166 unsigned options = 0; 162 pjsip_inv_session *inv ;167 pjsip_inv_session *inv = NULL; 163 168 int acc_index; 164 169 int call_index = -1; … … 261 266 262 267 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 263 264 // TODO: Need to delete dialog 268 pjsip_dlg_terminate(dlg); 265 269 return PJ_TRUE; 266 270 } … … 287 291 288 292 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 289 290 // TODO: Need to delete dialog 293 pjsip_inv_terminate(inv, 500, PJ_FALSE); 291 294 292 295 } else { … … 723 726 } 724 727 728 /* Disconnect call */ 729 static void call_disconnect(pjsip_inv_session *inv, 730 int st_code) 731 { 732 pjsip_tx_data *tdata; 733 pj_status_t status; 734 735 status = pjsip_inv_end_session(inv, st_code, NULL, &tdata); 736 if (status == PJ_SUCCESS) 737 status = pjsip_inv_send_msg(inv, tdata, NULL); 738 739 if (status != PJ_SUCCESS) { 740 pjsua_perror(THIS_FILE, "Unable to disconnect call", status); 741 } 742 } 725 743 726 744 /* … … 744 762 745 763 pjsua_perror(THIS_FILE, "SDP negotiation has failed", status); 764 765 /* Disconnect call if this is not a re-INVITE */ 766 if (inv->state != PJSIP_INV_STATE_CONFIRMED) { 767 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 768 } 746 769 return; 747 770 … … 763 786 "Unable to retrieve currently active local SDP", 764 787 status); 788 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 765 789 return; 766 790 } … … 772 796 "Unable to retrieve currently active remote SDP", 773 797 status); 798 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 774 799 return; 775 800 } … … 789 814 pjsua_perror(THIS_FILE, "Unable to create media session", 790 815 status); 816 call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE); 791 817 return; 792 818 } … … 818 844 pjmedia_session_destroy(call->session); 819 845 call->session = NULL; 846 call_disconnect(inv, PJSIP_SC_INTERNAL_SERVER_ERROR); 820 847 return; 821 848 } … … 910 937 * Hangup call. 911 938 */ 912 void pjsua_call_hangup(int call_index , int code)939 void pjsua_call_hangup(int call_index) 913 940 { 914 941 pjsua_call *call; 942 int code; 915 943 pj_status_t status; 916 944 pjsip_tx_data *tdata; … … 923 951 return; 924 952 } 953 954 if (call->inv->state == PJSIP_INV_STATE_CONFIRMED) 955 code = PJSIP_SC_OK; 956 else if (call->inv->role == PJSIP_ROLE_UAS) 957 code = PJSIP_SC_DECLINE; 958 else 959 code = PJSIP_SC_REQUEST_TERMINATED; 925 960 926 961 status = pjsip_inv_end_session(call->inv, code, NULL, &tdata); … … 1190 1225 * Terminate all calls. 1191 1226 */ 1192 void pjsua_call_hangup_all( )1227 void pjsua_call_hangup_all(void) 1193 1228 { 1194 1229 int i; … … 1196 1231 for (i=0; i<pjsua.max_calls; ++i) { 1197 1232 pjsip_tx_data *tdata; 1233 int st_code; 1198 1234 pjsua_call *call; 1199 1235 … … 1203 1239 call = &pjsua.calls[i]; 1204 1240 1205 if (pjsip_inv_end_session(call->inv, 410, NULL, &tdata)==0) { 1241 if (call->inv->state == PJSIP_INV_STATE_CONFIRMED) { 1242 st_code = 200; 1243 } else { 1244 st_code = PJSIP_SC_GONE; 1245 } 1246 1247 if (pjsip_inv_end_session(call->inv, st_code, NULL, &tdata)==0) { 1206 1248 if (tdata) 1207 1249 pjsip_inv_send_msg(call->inv, tdata, NULL); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r278 r284 73 73 pjsua.stun_port1 = pjsua.stun_port2 = 0; 74 74 75 /* Default : sampling rate is 8000*/75 /* Default for media: */ 76 76 pjsua.clock_rate = 8000; 77 pjsua.complexity = 4; 78 pjsua.quality = 4; 79 77 80 78 81 /* Init accounts: */ … … 615 618 option &= ~(PJMEDIA_SPEEX_NO_UWB); 616 619 617 status = pjmedia_codec_speex_init(pjsua.med_endpt, option, -1, -1); 620 status = pjmedia_codec_speex_init(pjsua.med_endpt, option, 621 pjsua.quality, pjsua.complexity ); 618 622 if (status != PJ_SUCCESS) { 619 623 pjsua_perror(THIS_FILE, "Error initializing Speex codec", -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r255 r284 116 116 status = pjsip_pres_create_uas( dlg, &pres_cb, rdata, &sub); 117 117 if (status != PJ_SUCCESS) { 118 PJ_TODO(DESTROY_DIALOG);118 pjsip_dlg_terminate(dlg); 119 119 pjsua_perror(THIS_FILE, "Unable to create server subscription", 120 120 status); … … 145 145 status); 146 146 pj_list_erase(uapres); 147 pjsip_pres_terminate(sub, PJ_FALSE); 147 148 return PJ_FALSE; 148 149 } … … 169 170 status); 170 171 pj_list_erase(uapres); 172 pjsip_pres_terminate(sub, PJ_FALSE); 171 173 return PJ_FALSE; 172 174 } … … 328 330 pjsua_perror(THIS_FILE, "Unable to create presence client", 329 331 status); 332 pjsip_dlg_terminate(dlg); 330 333 return; 331 334 } … … 336 339 status = pjsip_pres_initiate(pjsua.buddies[index].sub, -1, &tdata); 337 340 if (status != PJ_SUCCESS) { 341 pjsip_pres_terminate(pjsua.buddies[index].sub, PJ_FALSE); 338 342 pjsua.buddies[index].sub = NULL; 339 343 pjsua_perror(THIS_FILE, "Unable to create initial SUBSCRIBE", … … 344 348 status = pjsip_pres_send_request(pjsua.buddies[index].sub, tdata); 345 349 if (status != PJ_SUCCESS) { 350 pjsip_pres_terminate(pjsua.buddies[index].sub, PJ_FALSE); 346 351 pjsua.buddies[index].sub = NULL; 347 352 pjsua_perror(THIS_FILE, "Unable to send initial SUBSCRIBE", … … 349 354 return; 350 355 } 351 352 PJ_TODO(DESTROY_DIALOG_ON_ERROR);353 356 } 354 357 … … 374 377 status = pjsip_pres_send_request( pjsua.buddies[index].sub, tdata ); 375 378 376 if (status == PJ_SUCCESS) { 377 378 //pjsip_evsub_set_mod_data(pjsua.buddies[index].sub, pjsua.mod.id, 379 // NULL); 380 //pjsua.buddies[index].sub = NULL; 381 382 } else { 379 if (status != PJ_SUCCESS) { 380 381 pjsip_pres_terminate(pjsua.buddies[index].sub, PJ_FALSE); 382 pjsua.buddies[index].sub = NULL; 383 383 pjsua_perror(THIS_FILE, "Unable to unsubscribe presence", 384 384 status); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r278 r284 46 46 static void usage(void) 47 47 { 48 puts("Usage:"); 49 puts(" pjsua [options]"); 50 puts(""); 51 puts("General options:"); 52 puts(" --help Display this help screen"); 53 puts(" --version Display version info"); 54 puts(""); 55 puts("Logging options:"); 56 puts(" --config-file=file Read the config/arguments from file."); 57 puts(" --log-file=fname Log to filename (default stderr)"); 58 puts(" --log-level=N Set log max level to N (0(none) to 6(trace))"); 59 puts(" --app-log-level=N Set log max level for stdout display to N"); 60 puts(""); 61 puts("SIP Account options:"); 62 puts(" --id=url Set the URL of local ID (used in From header)"); 63 puts(" --contact=url Override the Contact information"); 64 puts(" --proxy=url Set the URL of proxy server"); 65 puts(""); 66 puts("SIP Account Registration Options:"); 67 puts(" --registrar=url Set the URL of registrar server"); 68 puts(" --reg-timeout=secs Set registration interval to secs (default 3600)"); 69 puts(""); 70 puts("SIP Account Control:"); 71 puts(" --next-account Add more account"); 72 puts(""); 73 puts("Authentication options:"); 74 puts(" --realm=string Set realm"); 75 puts(" --username=string Set authentication username"); 76 puts(" --password=string Set authentication password"); 77 puts(" --next-cred Add more credential"); 78 puts(""); 79 puts("Transport Options:"); 80 puts(" --local-port=port Set TCP/UDP port"); 81 puts(" --outbound=url Set the URL of outbound proxy server"); 82 puts(" --use-stun1=host[:port]"); 83 puts(" --use-stun2=host[:port] Resolve local IP with the specified STUN servers"); 84 puts(""); 85 puts("Media Options:"); 86 puts(" --wb Enable wideband codecs (16KHz)"); 87 puts(" --uwb Enable ultra-wideband codecs (32KHz)"); 88 puts(" --null-audio Use NULL audio device"); 89 puts(" --play-file=file Play WAV file in conference bridge"); 90 puts(" --auto-play Automatically play the file (to incoming calls only)"); 91 puts(" --auto-loop Automatically loop incoming RTP to outgoing RTP"); 92 puts(" --auto-conf Automatically put incoming calls to conference"); 93 puts(" --rtp-port=N Base port to try for RTP"); 94 puts(" --add-codec=name Specify alternate codec order"); 95 puts(""); 96 puts("Buddy List (can be more than one):"); 97 puts(" --add-buddy url Add the specified URL to the buddy list."); 98 puts(""); 99 puts("User Agent options:"); 100 puts(" --auto-answer=code Automatically answer incoming calls with code (e.g. 200)"); 101 puts(" --max-calls=N Maximum number of concurrent calls (default:4, max:255)"); 102 puts(""); 48 puts ("Usage:"); 49 puts (" pjsua [options]"); 50 puts (""); 51 puts ("General options:"); 52 puts (" --help Display this help screen"); 53 puts (" --version Display version info"); 54 puts (""); 55 puts ("Logging options:"); 56 puts (" --config-file=file Read the config/arguments from file."); 57 puts (" --log-file=fname Log to filename (default stderr)"); 58 puts (" --log-level=N Set log max level to N (0(none) to 6(trace)) (default=5)"); 59 puts (" --app-log-level=N Set log max level for stdout display (default=4)"); 60 puts (""); 61 puts ("SIP Account options:"); 62 puts (" --id=url Set the URL of local ID (used in From header)"); 63 puts (" --contact=url Override the Contact information"); 64 puts (" --proxy=url Set the URL of proxy server"); 65 puts (""); 66 puts ("SIP Account Registration Options:"); 67 puts (" --registrar=url Set the URL of registrar server"); 68 puts (" --reg-timeout=secs Set registration interval to secs (default 3600)"); 69 puts (""); 70 puts ("SIP Account Control:"); 71 puts (" --next-account Add more account"); 72 puts (""); 73 puts ("Authentication options:"); 74 puts (" --realm=string Set realm"); 75 puts (" --username=string Set authentication username"); 76 puts (" --password=string Set authentication password"); 77 puts (" --next-cred Add more credential"); 78 puts (""); 79 puts ("Transport Options:"); 80 puts (" --local-port=port Set TCP/UDP port"); 81 puts (" --outbound=url Set the URL of outbound proxy server"); 82 puts (" --use-stun1=host[:port]"); 83 puts (" --use-stun2=host[:port] Resolve local IP with the specified STUN servers"); 84 puts (""); 85 puts ("Media Options:"); 86 puts (" --wb Enable wideband codecs and set clock-rate to 16KHz"); 87 puts (" --uwb Enable ultra-wideband codecs and set clock-rate to 32KHz"); 88 puts (" --null-audio Use NULL audio device"); 89 puts (" --play-file=file Play WAV file in conference bridge"); 90 puts (" --auto-play Automatically play the file (to incoming calls only)"); 91 puts (" --auto-loop Automatically loop incoming RTP to outgoing RTP"); 92 puts (" --auto-conf Automatically put incoming calls to conference"); 93 puts (" --rtp-port=N Base port to try for RTP (default=4000)"); 94 puts (" --add-codec=name Specify alternate codec order"); 95 puts (" --complexity=N Specify encoding complexity (0-10, default=4)"); 96 puts (" --quality=N Specify encoding quality (0-10, default=4)"); 97 puts (""); 98 puts ("Buddy List (can be more than one):"); 99 puts (" --add-buddy url Add the specified URL to the buddy list."); 100 puts (""); 101 puts ("User Agent options:"); 102 puts (" --auto-answer=code Automatically answer incoming calls with code (e.g. 200)"); 103 puts (" --max-calls=N Maximum number of concurrent calls (default:4, max:255)"); 104 puts (""); 103 105 fflush(stdout); 104 106 } … … 223 225 OPT_AUTO_CONF, 224 226 OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, OPT_ADD_CODEC, 227 OPT_COMPLEXITY, OPT_QUALITY, 225 228 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 226 229 }; … … 258 261 { "rtp-port", 1, 0, OPT_RTP_PORT}, 259 262 { "add-codec", 1, 0, OPT_ADD_CODEC}, 263 { "complexity", 1, 0, OPT_COMPLEXITY}, 264 { "quality", 1, 0, OPT_QUALITY}, 260 265 { "next-account",0,0, OPT_NEXT_ACCOUNT}, 261 266 { "next-cred", 0, 0, OPT_NEXT_CRED}, … … 495 500 case OPT_ADD_CODEC: 496 501 pjsua.codec_arg[pjsua.codec_cnt++] = pj_str(optarg); 502 break; 503 504 case OPT_COMPLEXITY: 505 pjsua.complexity = my_atoi(optarg); 506 if (pjsua.complexity < 0 || pjsua.complexity > 10) { 507 PJ_LOG(1,(THIS_FILE, 508 "Error: invalid --complexity (expecting 0-10")); 509 return -1; 510 } 511 break; 512 513 case OPT_QUALITY: 514 pjsua.quality = my_atoi(optarg); 515 if (pjsua.quality < 0 || pjsua.quality > 10) { 516 PJ_LOG(1,(THIS_FILE, 517 "Error: invalid --quality (expecting 0-10")); 518 return -1; 519 } 497 520 break; 498 521
Note: See TracChangeset
for help on using the changeset viewer.