2014-08-27 10 views
0

나는 pjsua를 기반으로하는 VoIP 응용 프로그램을 가지고 있습니다. STUN 설정을 올바르게 설정하는 방법을 모르겠다는 것 외에는 잘 작동합니다.PJSIP ios 응용 프로그램에서 STUN 설정을 설정하는 방법은 무엇입니까?

는 지금은 pjsua 초기화하기 전에 STUN 연결 -

cfg.stun_host = pj_str(&stunAdr); 

을 그 후 모두가 잘 작동하지 않을 경우 동일한 네트워크에있는 클라이언트. 하지만 같은 네트워크에있을 때는 NAT를 사용하지 않으므로 STUN은 필요하지 않지만 STUN은 연결되어 사용되고 클라이언트는 서로를 듣지 않습니다.

그래서 필요할 때만 STUN을 사용하여 설정하는 방법은 무엇입니까? NAT가 아닌 클라이언트간에 존재 하는가? 나는

도와주세요 NAT 그러나 그것을 사용하는 방법 ..

cfg.cb.on_nat_detect = &on_nat; 

static void on_nat(const pj_stun_nat_detect_result *result) { 
    if (result->status != PJ_SUCCESS) { 
     pjsua_perror(THIS_FILE, "NAT detection failed", result->status); 


    } else { 

     PJ_LOG(3, (THIS_FILE, "NAT detected as %s", result->nat_type_name)); 

    } 
} 
  • 는 잘 동작도 감지 연결 해요!

답변

1
 // Disable STUN for a new config obtained from the old one, where acc_id is 
     // old config id 

     // declare a new account config 
     pjsua_acc_config acc_cfg_new; 

     // create a new pj pool used when copying the existing config 
     pj_pool_t *pool = pjsua_pool_create("tmp-pjsua", 1000, 1000); 

     // default the new account configuration 
     pjsua_acc_config_default(&acc_cfg_new); 

     // now copy the existing account config - if you already have one 
     pjsua_acc_get_config(acc_id, pool, &acc_cfg_new); 

     // disable all stun on new account config 
     acc_cfg_new.sip_stun_use = PJSUA_STUN_USE_DISABLED; 
     acc_cfg_new.media_stun_use = PJSUA_STUN_USE_DISABLED; 


     // Now apply the new config without STUN to the current config 
     pjsua_acc_modify(acc_id, &acc_cfg_new); 

     // and make a call 
+0

설명과 설명을 추가하여 답변을 확장하십시오. 코드 내 주석을 호출하면 가독성이 향상됩니다. – Ajean

관련 문제