mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-18 16:17:23 -05:00
Disable Network tab functionality on macOS (#155)
The asio library ran into issues when the obs-websocket plugin was also running leading to a crash in the obs-websocket's listen() calls. As the use obs-websocket plugin is more widespread than the use of the advanced scene switcher the network tab functionality will be disabled for macOS for the time being.
This commit is contained in:
parent
e561d378dd
commit
beb482bd5a
|
|
@ -219,6 +219,7 @@ AdvSceneSwitcher.videoTab.help="<html><head/><body><p>Dieser Tab ermöglicht es
|
|||
; Network Tab
|
||||
AdvSceneSwitcher.networkTab.title="Netzwerk"
|
||||
AdvSceneSwitcher.networkTab.warning="Die Verwendung des Servers außerhalb eines lokalen Netzwerks kann dazu führen, dass die aktive Szene von dritten Personen ausgelesen werden kann."
|
||||
AdvSceneSwitcher.networkTab.Disabledwarning="Diese Funktionalität musste unter macOS leider aufgrund von Bibliotheksinkompatibilitäten mit dem obs-websocket plugin deaktiviert werden."
|
||||
AdvSceneSwitcher.networkTab.server="Server starten (Sendet Szenenwechselnachrichten zu allen verbundenen Clients)"
|
||||
AdvSceneSwitcher.networkTab.server.port="Port"
|
||||
AdvSceneSwitcher.networkTab.server.lockToIPv4="Nur IPv4 verwenden (deaktiviert IPv6)"
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ AdvSceneSwitcher.videoTab.help="<html><head/><body><p>This tab will allow you to
|
|||
; Network Tab
|
||||
AdvSceneSwitcher.networkTab.title="Network"
|
||||
AdvSceneSwitcher.networkTab.warning="Running the server outside of a local network will allow third parties to read the active scene."
|
||||
AdvSceneSwitcher.networkTab.DisabledWarning="This functionality unfortunately had to be disabled on macOS due to library incompatibilities when running the obs-websocket plugin in parallel."
|
||||
AdvSceneSwitcher.networkTab.server="Start server (Sends scene switch messages to all connected clients)"
|
||||
AdvSceneSwitcher.networkTab.server.port="Port"
|
||||
AdvSceneSwitcher.networkTab.server.lockToIPv4="Lock server to only using IPv4"
|
||||
|
|
|
|||
|
|
@ -3302,7 +3302,7 @@
|
|||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_30">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<widget class="QLabel" name="networkTabWarningLabel">
|
||||
<property name="text">
|
||||
<string>AdvSceneSwitcher.networkTab.warning</string>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ Most of this code is based on https://github.com/Palakis/obs-websocket
|
|||
|
||||
#pragma once
|
||||
|
||||
// Due to iussues with asio the network functionality will be disabled on macOS
|
||||
#if !(__APPLE__)
|
||||
|
||||
#include <set>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMutex>
|
||||
|
|
@ -13,36 +16,16 @@ Most of this code is based on https://github.com/Palakis/obs-websocket
|
|||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <websocketpp/config/asio_no_tls_client.hpp>
|
||||
#include <websocketpp/config/asio_no_tls.hpp>
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
#include <websocketpp/config/asio_no_tls_client.hpp>
|
||||
#include <websocketpp/client.hpp>
|
||||
|
||||
using websocketpp::connection_hdl;
|
||||
typedef websocketpp::server<websocketpp::config::asio> server;
|
||||
typedef websocketpp::client<websocketpp::config::asio_client> client;
|
||||
|
||||
class NetworkConfig {
|
||||
public:
|
||||
NetworkConfig();
|
||||
void Load(obs_data_t *obj);
|
||||
void Save(obs_data_t *obj);
|
||||
void SetDefaults(obs_data_t *obj);
|
||||
|
||||
std::string GetClientUri();
|
||||
|
||||
// Server
|
||||
bool ServerEnabled;
|
||||
uint64_t ServerPort;
|
||||
bool LockToIPv4;
|
||||
|
||||
// Client
|
||||
bool ClientEnabled;
|
||||
std::string Address;
|
||||
uint64_t ClientPort;
|
||||
bool SendAll;
|
||||
};
|
||||
|
||||
class WSServer : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -69,12 +52,6 @@ private:
|
|||
QThreadPool _threadPool;
|
||||
};
|
||||
|
||||
enum class ServerStatus {
|
||||
NOT_RUNNING,
|
||||
STARTING,
|
||||
RUNNING,
|
||||
};
|
||||
|
||||
class WSClient : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -103,6 +80,62 @@ private:
|
|||
std::string _failMsg;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class WSServer : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WSServer(){};
|
||||
virtual ~WSServer(){};
|
||||
void start(quint16 port, bool lockToIPv4){};
|
||||
void stop(){};
|
||||
void sendMessage(OBSWeakSource scene, OBSWeakSource transition){};
|
||||
};
|
||||
|
||||
class WSClient : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WSClient(){};
|
||||
virtual ~WSClient(){};
|
||||
void connect(std::string uri){};
|
||||
void disconnect(){};
|
||||
std::string getFail() { return _failMsg; }
|
||||
|
||||
private:
|
||||
std::string _failMsg;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class NetworkConfig {
|
||||
public:
|
||||
NetworkConfig();
|
||||
void Load(obs_data_t *obj);
|
||||
void Save(obs_data_t *obj);
|
||||
void SetDefaults(obs_data_t *obj);
|
||||
|
||||
std::string GetClientUri();
|
||||
|
||||
// Server
|
||||
bool ServerEnabled;
|
||||
uint64_t ServerPort;
|
||||
bool LockToIPv4;
|
||||
|
||||
// Client
|
||||
bool ClientEnabled;
|
||||
std::string Address;
|
||||
uint64_t ClientPort;
|
||||
bool SendAll;
|
||||
};
|
||||
|
||||
enum class ServerStatus {
|
||||
NOT_RUNNING,
|
||||
STARTING,
|
||||
RUNNING,
|
||||
};
|
||||
|
||||
enum class ClientStatus {
|
||||
DISCONNECTED,
|
||||
CONNECTING,
|
||||
|
|
|
|||
|
|
@ -24,64 +24,12 @@ Most of this code is based on https://github.com/Palakis/obs-websocket
|
|||
#define SCENE_ENTRY "scene"
|
||||
#define TRANSITION_ENTRY "transition"
|
||||
|
||||
#if !(__APPLE__)
|
||||
|
||||
using websocketpp::lib::placeholders::_1;
|
||||
using websocketpp::lib::placeholders::_2;
|
||||
using websocketpp::lib::bind;
|
||||
|
||||
NetworkConfig::NetworkConfig()
|
||||
: ServerEnabled(false),
|
||||
ServerPort(55555),
|
||||
LockToIPv4(false),
|
||||
ClientEnabled(false),
|
||||
Address(""),
|
||||
ClientPort(55555),
|
||||
SendAll(true)
|
||||
{
|
||||
}
|
||||
|
||||
void NetworkConfig::Load(obs_data_t *obj)
|
||||
{
|
||||
SetDefaults(obj);
|
||||
|
||||
ServerEnabled = obs_data_get_bool(obj, PARAM_SERVER_ENABLE);
|
||||
ServerPort = obs_data_get_int(obj, PARAM_SERVER_PORT);
|
||||
LockToIPv4 = obs_data_get_bool(obj, PARAM_LOCKTOIPV4);
|
||||
|
||||
ClientEnabled = obs_data_get_bool(obj, PARAM_CLIENT_ENABLE);
|
||||
Address = obs_data_get_string(obj, PARAM_ADDRESS);
|
||||
ClientPort = obs_data_get_int(obj, PARAM_CLIENT_PORT);
|
||||
SendAll = obs_data_get_bool(obj, PARAM_CLIENT_SENDALL);
|
||||
}
|
||||
|
||||
void NetworkConfig::Save(obs_data_t *obj)
|
||||
{
|
||||
obs_data_set_bool(obj, PARAM_SERVER_ENABLE, ServerEnabled);
|
||||
obs_data_set_int(obj, PARAM_SERVER_PORT, ServerPort);
|
||||
obs_data_set_bool(obj, PARAM_LOCKTOIPV4, LockToIPv4);
|
||||
|
||||
obs_data_set_bool(obj, PARAM_CLIENT_ENABLE, ClientEnabled);
|
||||
obs_data_set_string(obj, PARAM_ADDRESS, Address.c_str());
|
||||
obs_data_set_int(obj, PARAM_CLIENT_PORT, ClientPort);
|
||||
obs_data_set_bool(obj, PARAM_CLIENT_SENDALL, SendAll);
|
||||
}
|
||||
|
||||
void NetworkConfig::SetDefaults(obs_data_t *obj)
|
||||
{
|
||||
obs_data_set_default_bool(obj, PARAM_SERVER_ENABLE, ServerEnabled);
|
||||
obs_data_set_default_int(obj, PARAM_SERVER_PORT, ServerPort);
|
||||
obs_data_set_default_bool(obj, PARAM_LOCKTOIPV4, LockToIPv4);
|
||||
|
||||
obs_data_set_default_bool(obj, PARAM_CLIENT_ENABLE, ClientEnabled);
|
||||
obs_data_set_default_string(obj, PARAM_ADDRESS, Address.c_str());
|
||||
obs_data_set_default_int(obj, PARAM_CLIENT_PORT, ClientPort);
|
||||
obs_data_set_default_bool(obj, PARAM_CLIENT_SENDALL, SendAll);
|
||||
}
|
||||
|
||||
std::string NetworkConfig::GetClientUri()
|
||||
{
|
||||
return "ws://" + Address + ":" + std::to_string(ClientPort);
|
||||
}
|
||||
|
||||
WSServer::WSServer()
|
||||
: QObject(nullptr), _connections(), _clMutex(QMutex::Recursive)
|
||||
{
|
||||
|
|
@ -452,6 +400,62 @@ void WSClient::onClose(connection_hdl hdl)
|
|||
switcher->clientStatus = ClientStatus::DISCONNECTED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NetworkConfig::NetworkConfig()
|
||||
: ServerEnabled(false),
|
||||
ServerPort(55555),
|
||||
LockToIPv4(false),
|
||||
ClientEnabled(false),
|
||||
Address(""),
|
||||
ClientPort(55555),
|
||||
SendAll(true)
|
||||
{
|
||||
}
|
||||
|
||||
void NetworkConfig::Load(obs_data_t *obj)
|
||||
{
|
||||
SetDefaults(obj);
|
||||
|
||||
ServerEnabled = obs_data_get_bool(obj, PARAM_SERVER_ENABLE);
|
||||
ServerPort = obs_data_get_int(obj, PARAM_SERVER_PORT);
|
||||
LockToIPv4 = obs_data_get_bool(obj, PARAM_LOCKTOIPV4);
|
||||
|
||||
ClientEnabled = obs_data_get_bool(obj, PARAM_CLIENT_ENABLE);
|
||||
Address = obs_data_get_string(obj, PARAM_ADDRESS);
|
||||
ClientPort = obs_data_get_int(obj, PARAM_CLIENT_PORT);
|
||||
SendAll = obs_data_get_bool(obj, PARAM_CLIENT_SENDALL);
|
||||
}
|
||||
|
||||
void NetworkConfig::Save(obs_data_t *obj)
|
||||
{
|
||||
obs_data_set_bool(obj, PARAM_SERVER_ENABLE, ServerEnabled);
|
||||
obs_data_set_int(obj, PARAM_SERVER_PORT, ServerPort);
|
||||
obs_data_set_bool(obj, PARAM_LOCKTOIPV4, LockToIPv4);
|
||||
|
||||
obs_data_set_bool(obj, PARAM_CLIENT_ENABLE, ClientEnabled);
|
||||
obs_data_set_string(obj, PARAM_ADDRESS, Address.c_str());
|
||||
obs_data_set_int(obj, PARAM_CLIENT_PORT, ClientPort);
|
||||
obs_data_set_bool(obj, PARAM_CLIENT_SENDALL, SendAll);
|
||||
}
|
||||
|
||||
void NetworkConfig::SetDefaults(obs_data_t *obj)
|
||||
{
|
||||
obs_data_set_default_bool(obj, PARAM_SERVER_ENABLE, ServerEnabled);
|
||||
obs_data_set_default_int(obj, PARAM_SERVER_PORT, ServerPort);
|
||||
obs_data_set_default_bool(obj, PARAM_LOCKTOIPV4, LockToIPv4);
|
||||
|
||||
obs_data_set_default_bool(obj, PARAM_CLIENT_ENABLE, ClientEnabled);
|
||||
obs_data_set_default_string(obj, PARAM_ADDRESS, Address.c_str());
|
||||
obs_data_set_default_int(obj, PARAM_CLIENT_PORT, ClientPort);
|
||||
obs_data_set_default_bool(obj, PARAM_CLIENT_SENDALL, SendAll);
|
||||
}
|
||||
|
||||
std::string NetworkConfig::GetClientUri()
|
||||
{
|
||||
return "ws://" + Address + ":" + std::to_string(ClientPort);
|
||||
}
|
||||
|
||||
void SwitcherData::loadNetworkSettings(obs_data_t *obj)
|
||||
{
|
||||
networkConfig.Load(obj);
|
||||
|
|
@ -467,6 +471,13 @@ void SwitcherData::saveNetworkSwitches(obs_data_t *obj)
|
|||
|
||||
void AdvSceneSwitcher::setupNetworkTab()
|
||||
{
|
||||
#if __APPLE__
|
||||
ui->clientSettings->setDisabled(true);
|
||||
ui->serverSettings->setDisabled(true);
|
||||
ui->networkTabWarningLabel->setText(
|
||||
obs_module_text("AdvSceneSwitcher.networkTab.DisabledWarning"));
|
||||
#endif
|
||||
|
||||
ui->serverSettings->setChecked(switcher->networkConfig.ServerEnabled);
|
||||
ui->serverPort->setValue(switcher->networkConfig.ServerPort);
|
||||
ui->lockToIPv4->setChecked(switcher->networkConfig.LockToIPv4);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user