Changeset 5384
- Timestamp:
- Jul 14, 2016 6:14:46 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r5342 r5384 843 843 /* Create ICE stream transport configuration */ 844 844 pj_ice_strans_cfg_default(&ice_cfg); 845 pj_bzero(&ice_cfg.stun, sizeof(ice_cfg.stun)); 846 pj_bzero(&ice_cfg.turn, sizeof(ice_cfg.turn)); 845 847 pj_stun_config_init(&ice_cfg.stun_cfg, &pjsua_var.cp.factory, 0, 846 848 pjsip_endpt_get_ioqueue(pjsua_var.endpt), … … 851 853 ice_cfg.opt = acc_cfg->ice_cfg.ice_opt; 852 854 853 /* Check if STUN transport is configured*/855 /* If STUN transport is configured, initialize STUN transport settings */ 854 856 if ((pj_sockaddr_has_addr(&pjsua_var.stun_srv) && 855 857 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) || … … 865 867 } 866 868 867 /* Configure STUN settings */ 868 if (pj_sockaddr_has_addr(&pjsua_var.stun_srv) && 869 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) 870 { 871 pj_sockaddr_print(&pjsua_var.stun_srv, stunip, sizeof(stunip), 0); 872 ice_cfg.stun_tp[0].server = pj_str(stunip); 873 ice_cfg.stun_tp[0].port = pj_sockaddr_get_port(&pjsua_var.stun_srv); 874 } 875 if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) { 876 ice_cfg.stun_tp[0].max_host_cands = 877 acc_cfg->ice_cfg.ice_max_host_cands; 878 if (use_ipv6) 879 ice_cfg.stun_tp[1].max_host_cands = 880 acc_cfg->ice_cfg.ice_max_host_cands; 881 } 882 883 /* Copy binding port setting to STUN setting */ 884 pj_sockaddr_init(ice_cfg.stun_tp[0].af, &ice_cfg.stun_tp[0].cfg.bound_addr, 885 &cfg->bound_addr, (pj_uint16_t)cfg->port); 886 ice_cfg.stun_tp[0].cfg.port_range = (pj_uint16_t)cfg->port_range; 887 if (cfg->port != 0 && ice_cfg.stun_tp[0].cfg.port_range == 0) { 888 ice_cfg.stun_tp[0].cfg.port_range = 889 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 890 } 891 if (use_ipv6) { 892 pj_str_t IN6_ADDR_ANY = {"0", 1}; 893 pj_sockaddr_init(pj_AF_INET6(), &ice_cfg.stun_tp[1].cfg.bound_addr, 894 &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 895 ice_cfg.stun_tp[1].cfg.port_range = ice_cfg.stun_tp[0].cfg.port_range; 896 } 897 898 /* Copy QoS setting to STUN setting */ 899 ice_cfg.stun_tp[0].cfg.qos_type = cfg->qos_type; 900 pj_memcpy(&ice_cfg.stun_tp[0].cfg.qos_params, &cfg->qos_params, 901 sizeof(cfg->qos_params)); 902 if (use_ipv6) { 903 ice_cfg.stun_tp[1].cfg.qos_type = cfg->qos_type; 904 pj_memcpy(&ice_cfg.stun_tp[1].cfg.qos_params, &cfg->qos_params, 869 /* Configure STUN transport settings */ 870 if (ice_cfg.stun_tp_cnt) { 871 unsigned i; 872 873 /* Configure STUN server (currently only for IPv4) */ 874 if (pj_sockaddr_has_addr(&pjsua_var.stun_srv) && 875 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) 876 { 877 pj_sockaddr_print(&pjsua_var.stun_srv, stunip, sizeof(stunip), 0); 878 ice_cfg.stun_tp[0].server = pj_str(stunip); 879 ice_cfg.stun_tp[0].port = 880 pj_sockaddr_get_port(&pjsua_var.stun_srv); 881 } 882 883 /* Configure max host candidates */ 884 if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) { 885 for (i = 0; i < ice_cfg.stun_tp_cnt; ++i) 886 ice_cfg.stun_tp[i].max_host_cands = 887 acc_cfg->ice_cfg.ice_max_host_cands; 888 } 889 890 /* Configure binding address */ 891 pj_sockaddr_init(ice_cfg.stun_tp[0].af, 892 &ice_cfg.stun_tp[0].cfg.bound_addr, 893 &cfg->bound_addr, (pj_uint16_t)cfg->port); 894 ice_cfg.stun_tp[0].cfg.port_range = (pj_uint16_t)cfg->port_range; 895 if (cfg->port != 0 && ice_cfg.stun_tp[0].cfg.port_range == 0) { 896 ice_cfg.stun_tp[0].cfg.port_range = 897 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 898 } 899 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) { 900 pj_str_t IN6_ADDR_ANY = {"0", 1}; 901 pj_sockaddr_init(pj_AF_INET6(), 902 &ice_cfg.stun_tp[1].cfg.bound_addr, 903 &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 904 ice_cfg.stun_tp[1].cfg.port_range = 905 ice_cfg.stun_tp[0].cfg.port_range; 906 } 907 908 /* Configure QoS setting */ 909 ice_cfg.stun_tp[0].cfg.qos_type = cfg->qos_type; 910 pj_memcpy(&ice_cfg.stun_tp[0].cfg.qos_params, &cfg->qos_params, 905 911 sizeof(cfg->qos_params)); 912 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) { 913 ice_cfg.stun_tp[1].cfg.qos_type = cfg->qos_type; 914 pj_memcpy(&ice_cfg.stun_tp[1].cfg.qos_params, &cfg->qos_params, 915 sizeof(cfg->qos_params)); 916 } 917 918 /* Configure max packet size */ 919 ice_cfg.stun_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 920 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) 921 ice_cfg.stun_tp[1].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 922 906 923 } 907 924 … … 936 953 ice_cfg.turn_tp[0].cfg.port_range = 937 954 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 938 } 939 940 /* Configure packet size for STUN and TURN sockets */ 941 ice_cfg.stun_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 942 ice_cfg.turn_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 943 944 if (use_ipv6) { 945 ice_cfg.stun_tp[1].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 955 956 /* Configure max packet size */ 957 ice_cfg.turn_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 946 958 } 947 959
Note: See TracChangeset
for help on using the changeset viewer.