Skip to content

Commit

Permalink
Set Turn from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
reitowo committed May 13, 2024
1 parent 62380e9 commit a1eca66
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QTimer>
#include <utility>
#include "util.h"
#include "QCommandLineParser"
#include <QSettings>

Peer::Peer(CollabRoom *room, QString id) {
Expand All @@ -10,6 +11,10 @@ Peer::Peer(CollabRoom *room, QString id) {

QSettings s;
forceRelay = s.value("forceRelay").toBool();
if (vts::info::OverrideForceUseTurn) {
forceRelay = true;
qDebug() << "Use force turn server from command line";
}

dcThreadAlive = true;
dcThread = std::unique_ptr<QThread>(QThread::create([=, this]() {
Expand Down
2 changes: 2 additions & 0 deletions core/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace vts::info {
QString BuildId = "debug";
bool OverrideForceUseTurn = true;
QString OverrideTurnServer = "";
}

#ifdef HAS_DIRECTXTK
Expand Down
2 changes: 2 additions & 0 deletions core/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace vts::info {
extern QString BuildId;
extern bool OverrideForceUseTurn;
extern QString OverrideTurnServer;
}

class Elapsed {
Expand Down
9 changes: 9 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,19 @@ int main(int argc, char *argv[]) {

QCommandLineParser parser;
parser.addOption(QCommandLineOption("build-id", QString(), "build-id", "Debug"));
parser.addOption(QCommandLineOption("turn-server", QString(), "turn-server"));
parser.addOption(QCommandLineOption("force-use-turn", QString()));
parser.process(app);

vts::info::BuildId = parser.value("build-id");

if (parser.isSet("turn-server")) {
vts::info::OverrideTurnServer = parser.value("turn-server");
}
if (parser.isSet("force-use-turn")) {
vts::info::OverrideForceUseTurn = true;
}

std::vector<int> fonts;
fonts.push_back(QFontDatabase::addApplicationFont(":/fonts/SmileySans-Oblique.ttf"));
fonts.push_back(QFontDatabase::addApplicationFont(":/fonts/MiSans-Demibold.ttf"));
Expand Down
7 changes: 6 additions & 1 deletion ui/windows/collabroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,13 @@ CollabRoom::CollabRoom(bool isServer, QString roomId, QWidget *parent) :
}

turnServer = settings.value("turnServer", QString()).toString();
ui->relayInput->setText(turnServer);
qDebug() << "Turn server" << turnServer;
if (!vts::info::OverrideTurnServer.isEmpty()) {
turnServer = vts::info::OverrideTurnServer;
qDebug() << "Use turn server from command line " << turnServer;
}

ui->relayInput->setText(turnServer);
}

roomOpenWaiting = new QMessageBox(this);
Expand Down

0 comments on commit a1eca66

Please sign in to comment.