Changeset 2568 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Apr 5, 2009 6:30:45 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2566 r2568 59 59 pjsua_media_config media_cfg; 60 60 pj_bool_t no_refersub; 61 pj_bool_t ipv6; 61 62 pj_bool_t no_tcp; 62 63 pj_bool_t no_udp; … … 139 140 static pj_status_t transport_adapter_sample(void); 140 141 #endif 142 static pj_status_t create_ipv6_media_transports(void); 141 143 pj_status_t app_destroy(void); 142 144 … … 196 198 puts (""); 197 199 puts ("Transport Options:"); 200 #if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 201 puts (" --ipv6 Use IPv6 instead for SIP and media."); 202 #endif 198 203 puts (" --local-port=port Set TCP/UDP port. This implicitly enables both "); 199 204 puts (" TCP and UDP transports on the specified port, unless"); … … 201 206 puts (" --ip-addr=IP Use the specifed address as SIP and RTP addresses."); 202 207 puts (" (Hint: the IP may be the public IP of the NAT/router)"); 208 puts (" --bound-addr=IP Bind transports to this IP interface"); 203 209 puts (" --no-tcp Disable TCP transport."); 204 210 puts (" --no-udp Disable UDP transport."); … … 465 471 OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 466 472 OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT, 467 OPT_ CONTACT_PARAMS,473 OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, 468 474 OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 469 475 OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV, … … 486 492 OPT_CAPTURE_DEV, OPT_PLAYBACK_DEV, 487 493 OPT_CAPTURE_LAT, OPT_PLAYBACK_LAT, OPT_NO_TONES, OPT_JB_MAX_SIZE, 488 OPT_STDOUT_REFRESH, OPT_STDOUT_REFRESH_TEXT, 494 OPT_STDOUT_REFRESH, OPT_STDOUT_REFRESH_TEXT, OPT_IPV6, 489 495 #ifdef _IONBF 490 496 OPT_STDOUT_NO_BUF, … … 509 515 { "local-port", 1, 0, OPT_LOCAL_PORT}, 510 516 { "ip-addr", 1, 0, OPT_IP_ADDR}, 517 { "bound-addr", 1, 0, OPT_BOUND_ADDR}, 511 518 { "no-tcp", 0, 0, OPT_NO_TCP}, 512 519 { "no-udp", 0, 0, OPT_NO_UDP}, … … 596 603 { "no-tones", 0, 0, OPT_NO_TONES}, 597 604 { "jb-max-size", 1, 0, OPT_JB_MAX_SIZE}, 605 #if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 606 { "ipv6", 0, 0, OPT_IPV6}, 607 #endif 598 608 { NULL, 0, 0, 0} 599 609 }; … … 736 746 break; 737 747 748 case OPT_BOUND_ADDR: /* bound-addr */ 749 cfg->udp_cfg.bound_addr = pj_str(pj_optarg); 750 cfg->rtp_cfg.bound_addr = pj_str(pj_optarg); 751 break; 752 738 753 case OPT_NO_UDP: /* no-udp */ 739 754 if (cfg->no_tcp) { … … 1257 1272 cfg->media_cfg.jb_max = atoi(pj_optarg); 1258 1273 break; 1274 1275 #if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6 1276 case OPT_IPV6: 1277 cfg->ipv6 = PJ_TRUE; 1278 break; 1279 #endif 1259 1280 1260 1281 default: … … 1505 1526 } 1506 1527 1528 /* Transport options */ 1529 if (config->ipv6) { 1530 pj_strcat2(&cfg, "--ipv6\n"); 1531 } 1507 1532 1508 1533 /* UDP Transport. */ … … 1515 1540 (int)config->udp_cfg.public_addr.slen, 1516 1541 config->udp_cfg.public_addr.ptr); 1542 pj_strcat2(&cfg, line); 1543 } 1544 1545 /* Bound IP address, if any. */ 1546 if (config->udp_cfg.bound_addr.slen) { 1547 pj_ansi_sprintf(line, "--bound-addr %.*s\n", 1548 (int)config->udp_cfg.bound_addr.slen, 1549 config->udp_cfg.bound_addr.ptr); 1517 1550 pj_strcat2(&cfg, line); 1518 1551 } … … 4334 4367 if (!app_config.no_udp) { 4335 4368 pjsua_acc_id aid; 4336 4337 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, 4369 pjsip_transport_type_e type = PJSIP_TRANSPORT_UDP; 4370 4371 if (app_config.ipv6) 4372 type = PJSIP_TRANSPORT_UDP6; 4373 4374 status = pjsua_transport_create(type, 4338 4375 &app_config.udp_cfg, 4339 4376 &transport_id); … … 4431 4468 4432 4469 #else 4433 status = pjsua_media_transports_create(&app_config.rtp_cfg); 4470 if (app_config.ipv6) 4471 status = create_ipv6_media_transports(); 4472 else 4473 status = pjsua_media_transports_create(&app_config.rtp_cfg); 4434 4474 #endif 4435 4475 if (status != PJ_SUCCESS) … … 4655 4695 #endif 4656 4696 4697 static pj_status_t create_ipv6_media_transports(void) 4698 { 4699 pjsua_media_transport tp[PJSUA_MAX_CALLS]; 4700 pj_status_t status; 4701 int port = app_config.rtp_cfg.port; 4702 unsigned i; 4703 4704 for (i=0; i<app_config.cfg.max_calls; ++i) { 4705 enum { MAX_RETRY = 10 }; 4706 unsigned j; 4707 4708 /* Get rid of uninitialized var compiler warning with MSVC */ 4709 status = PJ_SUCCESS; 4710 4711 for (j=0; j<MAX_RETRY; ++j) { 4712 status = pjmedia_transport_udp_create3(pjsua_get_pjmedia_endpt(), 4713 pj_AF_INET6(), 4714 NULL, 4715 &app_config.rtp_cfg.bound_addr, 4716 port, 4717 0, &tp[i].transport); 4718 4719 if (port != 0) 4720 port += 10; 4721 else 4722 break; 4723 4724 if (status == PJ_SUCCESS) 4725 break; 4726 } 4727 4728 if (status != PJ_SUCCESS) { 4729 pjsua_perror(THIS_FILE, "Error creating IPv6 UDP media transport", 4730 status); 4731 for (j=0; j<i; ++j) { 4732 pjmedia_transport_close(tp[j].transport); 4733 } 4734 return status; 4735 } 4736 } 4737 4738 return pjsua_media_transports_attach(tp, i, PJ_TRUE); 4739 }
Note: See TracChangeset
for help on using the changeset viewer.