diff --git a/src/mix.c b/src/mix.c index a7ceb12..4885e99 100644 --- a/src/mix.c +++ b/src/mix.c @@ -127,20 +127,6 @@ int slmix_update_room(void) int slmix_init(void) { int err; -#if 1 - struct pl srv; - pl_set_str(&srv, "turn:167.235.37.175:3478"); - - err = stunuri_decode(&mix.pc_config.ice_server, &srv); - if (err) { - warning("mix: invalid iceserver '%r' (%m)\n", &srv, err); - return err; - } - - mix.pc_config.stun_user = "turn200301"; - mix.pc_config.credential = "choh4zeem3foh1"; - -#endif mix.mnat = mnat_find(baresip_mnatl(), "ice"); if (!mix.mnat) { @@ -223,6 +209,26 @@ int slmix_config(char *file) err = 0; } + struct pl tmp; + err = conf_get(conf, "mix_turn_server", &tmp); + if (err) { + err = 0; + goto without_turn; + } + + err = stunuri_decode(&mix.pc_config.ice_server, &tmp); + if (err) { + warning("mix: invalid mix_turn_server '%r' (%m)\n", &tmp, err); + goto out; + } + + conf_get(conf, "mix_turn_user", &tmp); + pl_strdup((char **)&mix.pc_config.stun_user, &tmp); + + conf_get(conf, "mix_turn_password", &tmp); + pl_strdup((char **)&mix.pc_config.credential, &tmp); + +without_turn: info("slmix_config path: %s\n", mix.path); out: @@ -255,6 +261,8 @@ void slmix_close(void) mix.httpsock = mem_deref(mix.httpsock); mix.pc_config.ice_server = mem_deref(mix.pc_config.ice_server); + mix.pc_config.stun_user = mem_deref((char *)mix.pc_config.stun_user); + mix.pc_config.credential = mem_deref((char *)mix.pc_config.credential); slmix_db_close(); sl_httpc_close();