Changeset 657 for pjproject/trunk
- Timestamp:
- Aug 6, 2006 11:07:25 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r651 r657 140 140 puts (" --auto-answer=code Automatically answer incoming calls with code (e.g. 200)"); 141 141 puts (" --max-calls=N Maximum number of concurrent calls (default:4, max:255)"); 142 puts (" --thread-cnt=N Number of worker threads (default:1)"); 142 143 /* 143 144 puts (" --duration=SEC Set maximum call duration (default:no limit)"); … … 265 266 OPT_RX_DROP_PCT, OPT_TX_DROP_PCT, OPT_EC_TAIL, 266 267 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 267 OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, 268 OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, OPT_THREAD_CNT, 268 269 }; 269 270 struct pj_getopt_option long_options[] = { … … 312 313 { "next-cred", 0, 0, OPT_NEXT_CRED}, 313 314 { "max-calls", 1, 0, OPT_MAX_CALLS}, 314 { "duration",1,0, OPT_DURATION}, 315 { "duration", 1, 0, OPT_DURATION}, 316 { "thread-cnt", 1, 0, OPT_THREAD_CNT}, 315 317 { NULL, 0, 0, 0} 316 318 }; … … 612 614 break; 613 615 */ 616 617 case OPT_THREAD_CNT: 618 cfg->cfg.thread_cnt = my_atoi(pj_optarg); 619 if (cfg->cfg.thread_cnt > 128) { 620 PJ_LOG(1,(THIS_FILE, 621 "Error: invalid --thread-cnt option")); 622 return -1; 623 } 624 break; 614 625 615 626 case OPT_PTIME: -
pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
r624 r657 159 159 160 160 struct { 161 pj_bool_t send_trying; 162 pj_bool_t send_ringing; 163 unsigned delay; 161 164 struct srv_state prev_state; 162 165 struct srv_state cur_state; … … 169 172 { 170 173 pjsip_inv_session *inv; 171 pj_timer_entry timer;174 pj_timer_entry ans_timer; 172 175 }; 173 176 … … 344 347 345 348 349 static pj_status_t send_response(pjsip_inv_session *inv, 350 pjsip_rx_data *rdata, 351 int code, 352 pj_bool_t *has_initial) 353 { 354 pjsip_tx_data *tdata; 355 pj_status_t status; 356 357 if (*has_initial) { 358 status = pjsip_inv_answer(inv, code, NULL, NULL, &tdata); 359 } else { 360 status = pjsip_inv_initial_answer(inv, rdata, code, 361 NULL, NULL, &tdata); 362 } 363 364 if (status != PJ_SUCCESS) { 365 if (*has_initial) { 366 status = pjsip_inv_answer(inv, PJSIP_SC_NOT_ACCEPTABLE, 367 NULL, NULL, &tdata); 368 } else { 369 status = pjsip_inv_initial_answer(inv, rdata, 370 PJSIP_SC_NOT_ACCEPTABLE, 371 NULL, NULL, &tdata); 372 } 373 374 if (status == PJ_SUCCESS) { 375 *has_initial = PJ_TRUE; 376 pjsip_inv_send_msg(inv, tdata); 377 } else { 378 pjsip_inv_terminate(inv, 500, PJ_FALSE); 379 return -1; 380 } 381 } else { 382 *has_initial = PJ_TRUE; 383 384 status = pjsip_inv_send_msg(inv, tdata); 385 if (status != PJ_SUCCESS) { 386 pjsip_tx_data_dec_ref(tdata); 387 return status; 388 } 389 } 390 391 return status; 392 } 393 394 static void answer_timer_cb(pj_timer_heap_t *h, pj_timer_entry *entry) 395 { 396 struct call *call = entry->user_data; 397 pj_bool_t has_initial = PJ_TRUE; 398 399 entry->id = 0; 400 send_response(call->inv, NULL, 200, &has_initial); 401 } 402 346 403 static pj_bool_t mod_call_on_rx_request(pjsip_rx_data *rdata) 347 404 { … … 353 410 pjmedia_sdp_session *sdp; 354 411 pjsip_tx_data *tdata; 412 pj_bool_t has_initial = PJ_FALSE; 355 413 pj_status_t status; 356 414 … … 445 503 } 446 504 447 448 /* Create 200 response .*/ 449 status = pjsip_inv_initial_answer(call->inv, rdata, 200, 450 NULL, NULL, &tdata); 451 if (status != PJ_SUCCESS) { 452 status = pjsip_inv_initial_answer(call->inv, rdata, 453 PJSIP_SC_NOT_ACCEPTABLE, 454 NULL, NULL, &tdata); 455 if (status == PJ_SUCCESS) 456 pjsip_inv_send_msg(call->inv, tdata); 457 else 458 pjsip_inv_terminate(call->inv, 500, PJ_FALSE); 459 return PJ_TRUE; 460 } 461 462 463 /* Send the 200 response. */ 464 status = pjsip_inv_send_msg(call->inv, tdata); 465 PJ_ASSERT_ON_FAIL(status == PJ_SUCCESS, return PJ_TRUE); 466 505 /* Send 100/Trying if needed */ 506 if (app.server.send_trying) { 507 status = send_response(call->inv, rdata, 100, &has_initial); 508 if (status != PJ_SUCCESS) 509 return PJ_TRUE; 510 } 511 512 /* Send 180/Ringing if needed */ 513 if (app.server.send_ringing) { 514 status = send_response(call->inv, rdata, 180, &has_initial); 515 if (status != PJ_SUCCESS) 516 return PJ_TRUE; 517 } 518 519 /* Simulate call processing delay */ 520 if (app.server.delay) { 521 pj_time_val delay; 522 523 call->ans_timer.id = 1; 524 call->ans_timer.user_data = call; 525 call->ans_timer.cb = &answer_timer_cb; 526 527 delay.sec = 0; 528 delay.msec = app.server.delay; 529 pj_time_val_normalize(&delay); 530 531 pjsip_endpt_schedule_timer(app.sip_endpt, &call->ans_timer, &delay); 532 533 } else { 534 /* Send the 200 response immediately . */ 535 status = pjsip_inv_send_msg(call->inv, tdata); 536 PJ_ASSERT_ON_FAIL(status == PJ_SUCCESS, return PJ_TRUE); 537 } 467 538 468 539 /* Done */ … … 1063 1134 " [default: no]\n" 1064 1135 " --thread-count=N Set number of worker threads [default=1]\n" 1136 " --trying Send 100/Trying response (server, default no)\n" 1137 " --ringing Send 180/Ringing response (server, default no)\n" 1138 " --delay=MS, -d Delay answering call by MS (server, default no)\n" 1065 1139 "\n" 1066 1140 "Misc options:\n" … … 1085 1159 static pj_status_t init_options(int argc, char *argv[]) 1086 1160 { 1087 enum { OPT_THREAD_COUNT = 1, OPT_REAL_SDP };1161 enum { OPT_THREAD_COUNT = 1, OPT_REAL_SDP, OPT_TRYING, OPT_RINGING }; 1088 1162 struct pj_getopt_option long_options[] = { 1089 1163 { "local-port", 1, 0, 'p' }, … … 1098 1172 { "use-tcp", 0, 0, 'T' }, 1099 1173 { "window", 1, 0, 'w' }, 1174 { "delay", 1, 0, 'd' }, 1175 { "trying", 0, 0, OPT_TRYING}, 1176 { "ringing", 0, 0, OPT_RINGING}, 1100 1177 { NULL, 0, 0, 0 }, 1101 1178 }; … … 1115 1192 /* Parse options */ 1116 1193 pj_optind = 0; 1117 while((c=pj_getopt_long(argc,argv, "p:c:m:t:w: hsv",1194 while((c=pj_getopt_long(argc,argv, "p:c:m:t:w:d:hsv", 1118 1195 long_options, &option_index))!=-1) 1119 1196 { … … 1189 1266 case 'T': 1190 1267 app.use_tcp = PJ_TRUE; 1268 break; 1269 1270 case 'd': 1271 app.server.delay = my_atoi(pj_optarg); 1272 if (app.server.delay > 3600) { 1273 PJ_LOG(3,(THIS_FILE, "I think --delay %s is too long", 1274 pj_optarg)); 1275 return -1; 1276 } 1277 break; 1278 1279 case OPT_TRYING: 1280 app.server.send_trying = 1; 1281 break; 1282 1283 case OPT_RINGING: 1284 app.server.send_ringing = 1; 1191 1285 break; 1192 1286 -
pjproject/trunk/pjsip-apps/src/samples/siprtp.c
r639 r657 1062 1062 { 1063 1063 #define POLICY SCHED_FIFO 1064 pthread_t thread;1065 1064 struct sched_param tp; 1066 1065 int max_prio; -
pjproject/trunk/pjsip-apps/src/samples/sndinfo.c
r445 r657 118 118 119 119 static pj_status_t rec_cb(void *user_data, pj_uint32_t timestamp, 120 constvoid *input, unsigned size)120 void *input, unsigned size) 121 121 { 122 122 -
pjproject/trunk/pjsip-apps/src/samples/sndtest.c
r582 r657 199 199 200 200 static pj_status_t rec_cb(void *user_data, pj_uint32_t timestamp, 201 constvoid *input, unsigned size)201 void *input, unsigned size) 202 202 { 203 203 -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r612 r657 257 257 if (method->id == PJSIP_ACK_METHOD && inv) { 258 258 259 /* Ignore ACK if pending INVITE transaction has not finished. */ 260 if (inv->invite_tsx && 261 inv->invite_tsx->state < PJSIP_TSX_STATE_COMPLETED) 262 { 263 return PJ_TRUE; 264 } 265 259 266 /* Terminate INVITE transaction, if it's still present. */ 260 267 if (inv->invite_tsx && 261 268 inv->invite_tsx->state <= PJSIP_TSX_STATE_COMPLETED) 262 269 { 270 pj_assert(inv->invite_tsx->status_code >= 200); 263 271 pjsip_tsx_terminate(inv->invite_tsx, 264 272 inv->invite_tsx->status_code); -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r635 r657 1010 1010 pjsip_tsx_state_e prev_state = tsx->state; 1011 1011 1012 /* New state must be greater than previous state */ 1013 pj_assert(state >= tsx->state); 1014 1012 1015 PJ_LOG(5, (tsx->obj_name, "State changed from %s to %s, event=%s", 1013 1016 state_str[tsx->state], state_str[state], -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r637 r657 553 553 goto on_error; 554 554 } 555 PJ_LOG(4,(THIS_FILE, "%d SIP worker threads created", 556 pjsua_var.ua_cfg.thread_cnt)); 557 } else { 558 PJ_LOG(4,(THIS_FILE, "No SIP worker threads created")); 555 559 } 556 560
Note: See TracChangeset
for help on using the changeset viewer.