Fixed WebRTC stuff

This commit is contained in:
WolverinDEV 2020-04-19 17:21:30 +02:00
parent 4de657a9a2
commit ee00935cfc
3 changed files with 10 additions and 6 deletions

View File

@ -80,17 +80,18 @@ VoiceBridge::VoiceBridge(const shared_ptr<WebClient>& owner) : _owner(owner) {
port = "19302"; /* fix for the invalid config value until 1.3.14beta1 :) */ port = "19302"; /* fix for the invalid config value until 1.3.14beta1 :) */
try { 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) {} } 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_udp = true;
config->nice_config->allow_ice_tcp = false; config->nice_config->allow_ice_tcp = false;
config->nice_config->use_upnp = config::web::enable_upnp; config->nice_config->use_upnp = config::web::enable_upnp;
gioloop::initialize(); gioloop::initialize();
config->nice_config->main_loop = gioloop::loop(); config->event_loop = gioloop::loop();
/* /*
config->nice_config->main_loop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, false), g_main_loop_unref); config->nice_config->main_loop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, false), g_main_loop_unref);
std::thread(g_main_loop_run, config->nice_config->main_loop.get()).detach(); 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); callback(candidate);
} else { } else {
if(auto callback{this->callback_ice_candidate_finished}; callback) if(auto callback{this->callback_ice_candidate_finished}; callback)
callback(); callback(candidate.sdpMid, candidate.sdpMLineIndex);
} }
}; };

View File

@ -13,7 +13,7 @@ namespace ts {
public: public:
typedef std::function<void(const pipes::buffer_view&, bool, bool)> cb_voice_data; typedef std::function<void(const pipes::buffer_view&, bool, bool)> cb_voice_data;
typedef std::function<void(const rtc::IceCandidate&)> cb_ice_candidate; typedef std::function<void(const rtc::IceCandidate&)> cb_ice_candidate;
typedef std::function<void()> cb_ice_candidate_finish; typedef std::function<void(const std::string& /* sdpMid */, int /* sdpMLineIndex */)> cb_ice_candidate_finish;
typedef std::function<void()> cb_initialized; typedef std::function<void()> cb_initialized;
typedef std::function<void()> cb_failed; typedef std::function<void()> cb_failed;

View File

@ -505,10 +505,13 @@ void WebClient::handleMessage(const std::string &message) {
this->sendJson(jsonCandidate); 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; Json::Value jsonCandidate;
jsonCandidate["type"] = "WebRTC"; jsonCandidate["type"] = "WebRTC";
jsonCandidate["request"] = "ice_finish"; jsonCandidate["request"] = "ice_finish";
jsonCandidate["msg"]["candidate"] = "";
jsonCandidate["msg"]["sdpMid"] = sdpMid;
jsonCandidate["msg"]["sdpMLineIndex"] = sdpMLineIndex;
this->sendJson(jsonCandidate); this->sendJson(jsonCandidate);
}; };