Changeset 580
- Timestamp:
- Jul 3, 2006 2:31:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsip-perf.c
r579 r580 112 112 pj_caching_pool cp; 113 113 pj_pool_t *pool; 114 pj_bool_t use_tcp; 114 115 pj_str_t local_addr; 115 116 int local_port; … … 609 610 pj_status_t status; 610 611 611 /* Add UDP transport. */612 /* Add UDP/TCP transport. */ 612 613 { 613 614 pj_sockaddr_in addr; 614 615 pjsip_host_port addrname; 615 pjsip_transport *tp;616 const char *transport_type; 616 617 617 618 pj_memset(&addr, 0, sizeof(addr)); … … 623 624 addrname.host = app.local_addr; 624 625 addrname.port = 5060; 625 } 626 } 626 627 if (app.local_port != 0) 627 628 addrname.port = app.local_port; 628 629 629 status = pjsip_udp_transport_start( app.sip_endpt, &addr, 630 (app.local_addr.slen ? &addrname:NULL), 631 1, &tp); 630 if (app.use_tcp) { 631 pj_sockaddr_in local_addr; 632 pjsip_tpfactory *tpfactory; 633 634 transport_type = "tcp"; 635 pj_sockaddr_in_init(&local_addr, 0, app.local_port); 636 status = pjsip_tcp_transport_start(app.sip_endpt, &local_addr, 637 app.thread_count, &tpfactory); 638 if (status == PJ_SUCCESS) { 639 app.local_addr = tpfactory->addr_name.host; 640 app.local_port = tpfactory->addr_name.port; 641 } 642 } else { 643 pjsip_transport *tp; 644 645 transport_type = "udp"; 646 status = pjsip_udp_transport_start(app.sip_endpt, &addr, 647 (app.local_addr.slen ? &addrname:NULL), 648 app.thread_count, &tp); 649 if (status == PJ_SUCCESS) { 650 app.local_addr = tp->local_name.host; 651 app.local_port = tp->local_name.port; 652 } 653 654 } 632 655 if (status != PJ_SUCCESS) { 633 app_perror(THIS_FILE, "Unable to start UDPtransport", status);656 app_perror(THIS_FILE, "Unable to start transport", status); 634 657 return status; 635 658 } 636 637 app.local_addr = tp->local_name.host;638 app.local_port = tp->local_name.port;639 659 640 660 app.local_uri.ptr = pj_pool_alloc(app.pool, 128); 641 661 app.local_uri.slen = pj_ansi_sprintf(app.local_uri.ptr, 642 "<sip:pjsip-perf@%.*s:%d>", 643 (int)tp->local_name.host.slen, 644 tp->local_name.host.ptr, 645 tp->local_name.port); 662 "<sip:pjsip-perf@%.*s:%d;transport=%s>", 663 (int)app.local_addr.slen, 664 app.local_addr.ptr, 665 app.local_port, 666 transport_type); 646 667 647 668 app.local_contact = app.local_uri; … … 951 972 " --method=METHOD, -m Set the test method (default: OPTIONS)\n" 952 973 " --local-port=PORT, -p Set local port [default: 5060]\n" 974 " --use-tcp, -T Use TCP instead of UDP (default: no)\n" 953 975 " --thread-count=N Set number of worker threads (default=1)\n" 954 976 " --stateless, -s Set client to operate in stateless mode\n" … … 988 1010 { "real-sdp", 0, 0, OPT_REAL_SDP }, 989 1011 { "verbose", 0, 0, 'v' }, 1012 { "use-tcp", 0, 0, 'T' }, 990 1013 { NULL, 0, 0, 0 }, 991 1014 }; … … 1068 1091 break; 1069 1092 1093 case 'T': 1094 app.use_tcp = PJ_TRUE; 1095 break; 1096 1070 1097 default: 1071 1098 PJ_LOG(1,(THIS_FILE, … … 1342 1369 int main(int argc, char *argv[]) 1343 1370 { 1344 pj_log_set_level(3);1345 1371 1346 1372 if (create_app() != 0) … … 1359 1385 pj_log_set_level(4); 1360 1386 pjsip_endpt_register_module(app.sip_endpt, &msg_logger); 1387 } else { 1388 pj_log_set_level(3); 1361 1389 } 1362 1390 … … 1367 1395 app.client.stateless) 1368 1396 { 1369 PJ_LOG(3,(THIS_FILE, "Info: --stateless option makes no sense for INVITE, ignored.")); 1397 PJ_LOG(3,(THIS_FILE, 1398 "Info: --stateless option makes no sense for INVITE, " 1399 "ignored.")); 1370 1400 } 1371 1401 } 1372 1402 1373 1403 if (app.real_sdp) { 1374 PJ_LOG(3,(THIS_FILE, "Info: client/server using real SDP from PJMEDIA")); 1404 PJ_LOG(3,(THIS_FILE, 1405 "Info: client/server using real SDP from PJMEDIA")); 1375 1406 } else { 1376 1407 PJ_LOG(3,(THIS_FILE, "Info: client/server using dummy SDP")); … … 1399 1430 1400 1431 1401 PJ_LOG(3,(THIS_FILE, "Starting %d %s, please wait..", 1402 app.client.job_count, test_type)); 1432 PJ_LOG(3,(THIS_FILE, "Sending %d %s to %.*s, please wait..", 1433 app.client.job_count, test_type, 1434 (int)app.client.dst_uri.slen, app.client.dst_uri.ptr)); 1403 1435 1404 1436 for (i=0; i<app.thread_count; ++i) { … … 1456 1488 1457 1489 printf("Receiving requests on the following URIs:\n" 1458 " sip:0@%.*s:%d for stateless handling (non-INVITE only)\n"1459 " sip:1@%.*s:%d for stateful handling (INVITE and non-INVITE)\n"1460 " sip:2@%.*s:%d for call handling (INVITE only)\n",1490 " sip:0@%.*s:%d;transport=%s for stateless handling (non-INVITE only)\n" 1491 " sip:1@%.*s:%d;transport=%s for stateful handling (INVITE and non-INVITE)\n" 1492 " sip:2@%.*s:%d;transport=%s for call handling (INVITE only)\n", 1461 1493 (int)app.local_addr.slen, 1462 1494 app.local_addr.ptr, 1463 1495 app.local_port, 1496 (app.use_tcp ? "tcp" : "udp"), 1464 1497 (int)app.local_addr.slen, 1465 1498 app.local_addr.ptr, 1466 1499 app.local_port, 1500 (app.use_tcp ? "tcp" : "udp"), 1467 1501 (int)app.local_addr.slen, 1468 1502 app.local_addr.ptr, 1469 app.local_port); 1503 app.local_port, 1504 (app.use_tcp ? "tcp" : "udp")); 1470 1505 1471 1506 for (i=0; i<app.thread_count; ++i) {
Note: See TracChangeset
for help on using the changeset viewer.