From ee00935cfc82be1f496710d9802c2fe925ed972a Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 19 Apr 2020 17:21:30 +0200 Subject: [PATCH] Fixed WebRTC stuff --- server/src/client/web/VoiceBridge.cpp | 9 +++++---- server/src/client/web/VoiceBridge.h | 2 +- server/src/client/web/WebClient.cpp | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/server/src/client/web/VoiceBridge.cpp b/server/src/client/web/VoiceBridge.cpp index 8561eec..3b220d8 100644 --- a/server/src/client/web/VoiceBridge.cpp +++ b/server/src/client/web/VoiceBridge.cpp @@ -80,17 +80,18 @@ VoiceBridge::VoiceBridge(const shared_ptr& owner) : _owner(owner) { port = "19302"; /* fix for the invalid config value until 1.3.14beta1 :) */ try { - config->nice_config->ice_servers.push_back({host,(uint16_t) stoi(port)}); + config->nice_config->stun_server = {host,(uint16_t) stoi(port)}; } catch(std::exception& ex) {} } - config->nice_config->ice_servers.push_back({"stun.l.google.com", 19302}); + if(config::web::ice_servers.empty()) + config->nice_config->stun_server = {"stun.l.google.com", 19302}; config->nice_config->allow_ice_udp = true; config->nice_config->allow_ice_tcp = false; config->nice_config->use_upnp = config::web::enable_upnp; gioloop::initialize(); - config->nice_config->main_loop = gioloop::loop(); + config->event_loop = gioloop::loop(); /* config->nice_config->main_loop = std::shared_ptr(g_main_loop_new(nullptr, false), g_main_loop_unref); std::thread(g_main_loop_run, config->nice_config->main_loop.get()).detach(); @@ -126,7 +127,7 @@ bool VoiceBridge::initialize(std::string &error) { callback(candidate); } else { if(auto callback{this->callback_ice_candidate_finished}; callback) - callback(); + callback(candidate.sdpMid, candidate.sdpMLineIndex); } }; diff --git a/server/src/client/web/VoiceBridge.h b/server/src/client/web/VoiceBridge.h index 41ae577..1fd3c56 100644 --- a/server/src/client/web/VoiceBridge.h +++ b/server/src/client/web/VoiceBridge.h @@ -13,7 +13,7 @@ namespace ts { public: typedef std::function cb_voice_data; typedef std::function cb_ice_candidate; - typedef std::function cb_ice_candidate_finish; + typedef std::function cb_ice_candidate_finish; typedef std::function cb_initialized; typedef std::function cb_failed; diff --git a/server/src/client/web/WebClient.cpp b/server/src/client/web/WebClient.cpp index 9ccf464..b864cab 100644 --- a/server/src/client/web/WebClient.cpp +++ b/server/src/client/web/WebClient.cpp @@ -505,10 +505,13 @@ void WebClient::handleMessage(const std::string &message) { this->sendJson(jsonCandidate); }; - this->voice_bridge->callback_ice_candidate_finished = [&]{ + this->voice_bridge->callback_ice_candidate_finished = [&](const std::string& sdpMid, int sdpMLineIndex){ Json::Value jsonCandidate; jsonCandidate["type"] = "WebRTC"; jsonCandidate["request"] = "ice_finish"; + jsonCandidate["msg"]["candidate"] = ""; + jsonCandidate["msg"]["sdpMid"] = sdpMid; + jsonCandidate["msg"]["sdpMLineIndex"] = sdpMLineIndex; this->sendJson(jsonCandidate); };