Changeset 1501 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
- Timestamp:
- Oct 16, 2007 1:34:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1495 r1501 52 52 53 53 pjsua_var.stun_status = PJ_EUNKNOWN; 54 pjsua_var.nat_status = PJ_EPENDING; 54 55 } 55 56 … … 80 81 cfg->max_calls = 4; 81 82 cfg->thread_cnt = 1; 83 cfg->nat_type_in_sdp = 2; 82 84 } 83 85 … … 1859 1861 1860 1862 1863 /* Callback upon NAT detection completion */ 1864 static void nat_detect_cb(void *user_data, 1865 const pj_stun_nat_detect_result *res) 1866 { 1867 PJ_UNUSED_ARG(user_data); 1868 1869 pjsua_var.nat_in_progress = PJ_FALSE; 1870 pjsua_var.nat_status = res->status; 1871 pjsua_var.nat_type = res->nat_type; 1872 1873 if (pjsua_var.ua_cfg.cb.on_nat_detect) { 1874 (*pjsua_var.ua_cfg.cb.on_nat_detect)(res); 1875 } 1876 } 1877 1878 1861 1879 /* 1862 1880 * Detect NAT type. 1863 1881 */ 1864 PJ_DEF(pj_status_t) pjsua_detect_nat_type( void *user_data, 1865 pj_stun_nat_detect_cb *cb) 1882 PJ_DEF(pj_status_t) pjsua_detect_nat_type() 1866 1883 { 1867 1884 pj_status_t status; 1885 1886 if (pjsua_var.nat_in_progress) 1887 return PJ_SUCCESS; 1868 1888 1869 1889 /* Make sure STUN server resolution has completed */ 1870 1890 status = pjsua_resolve_stun_server(PJ_TRUE); 1871 1891 if (status != PJ_SUCCESS) { 1892 pjsua_var.nat_status = status; 1893 pjsua_var.nat_type = PJ_STUN_NAT_TYPE_ERR_UNKNOWN; 1872 1894 return status; 1873 1895 } … … 1875 1897 /* Make sure we have STUN */ 1876 1898 if (pjsua_var.stun_srv.ipv4.sin_family == 0) { 1877 return PJ_EINVALIDOP; 1878 } 1879 1880 return pj_stun_detect_nat_type(&pjsua_var.stun_srv.ipv4, 1881 &pjsua_var.stun_cfg, 1882 user_data, cb); 1899 pjsua_var.nat_status = PJNATH_ESTUNINSERVER; 1900 return PJNATH_ESTUNINSERVER; 1901 } 1902 1903 status = pj_stun_detect_nat_type(&pjsua_var.stun_srv.ipv4, 1904 &pjsua_var.stun_cfg, 1905 NULL, &nat_detect_cb); 1906 1907 if (status != PJ_SUCCESS) { 1908 pjsua_var.nat_status = status; 1909 pjsua_var.nat_type = PJ_STUN_NAT_TYPE_ERR_UNKNOWN; 1910 return status; 1911 } 1912 1913 pjsua_var.nat_in_progress = PJ_TRUE; 1914 1915 return PJ_SUCCESS; 1916 } 1917 1918 1919 /* 1920 * Get NAT type. 1921 */ 1922 PJ_DEF(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type) 1923 { 1924 *type = pjsua_var.nat_type; 1925 return pjsua_var.nat_status; 1883 1926 } 1884 1927
Note: See TracChangeset
for help on using the changeset viewer.