diff --git a/Utils.cpp b/Utils.cpp index da2f82a6..c477d6ac 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -#include "Utils.h" #include #include #include -#include +#include +#include "Utils.h" #include "obs-websocket.h" Q_DECLARE_METATYPE(OBSScene); @@ -351,6 +351,8 @@ bool Utils::SetPreviewScene(const char* name) return false; } } + + return false; } void Utils::TransitionToProgram() @@ -407,4 +409,52 @@ void Utils::SysTrayNotify(QString &text, QSystemTrayIcon::MessageIcon icon, QStr if (trayIcon) trayIcon->showMessage(title, text, icon); +} + +QString Utils::FormatIPAddress(QHostAddress &addr) +{ + if (addr.protocol() == QAbstractSocket::IPv4Protocol) + { + QString v4addr = addr.toString().replace("::fff:", ""); + } + + return addr.toString(); +} + +const char* Utils::GetRecordingFolder() +{ + config_t* profile = obs_frontend_get_profile_config(); + const char* outputMode = config_get_string(profile, "Output", "Mode"); + + if (strcmp(outputMode, "Advanced") == 0) + { + // Advanced mode + return config_get_string(profile, "AdvOut", "RecFilePath"); + } + else + { + // Simple mode + return config_get_string(profile, "SimpleOutput", "FilePath"); + } +} + +bool Utils::SetRecordingFolder(const char* path) +{ + if (!QDir(path).exists()) + return false; + + config_t* profile = obs_frontend_get_profile_config(); + const char* outputMode = config_get_string(profile, "Output", "Mode"); + + if (strcmp(outputMode, "Advanced") == 0) + { + config_set_string(profile, "AdvOut", "RecFilePath", path); + } + else + { + config_set_string(profile, "SimpleOutput", "FilePath", path); + } + + config_save(profile); + return true; } \ No newline at end of file diff --git a/Utils.h b/Utils.h index 7e52faa4..232095af 100644 --- a/Utils.h +++ b/Utils.h @@ -24,8 +24,10 @@ with this program. If not, see #include #include #include +#include #include #include +#include class Utils { @@ -66,6 +68,10 @@ class Utils static QSystemTrayIcon* GetTrayIcon(); static void SysTrayNotify(QString &text, QSystemTrayIcon::MessageIcon n, QString title = QString("obs-websocket")); + + static QString FormatIPAddress(QHostAddress &addr); + static const char* GetRecordingFolder(); + static bool SetRecordingFolder(const char* path); }; #endif // UTILS_H diff --git a/WSServer.cpp b/WSServer.cpp index c65cb570..9997529b 100644 --- a/WSServer.cpp +++ b/WSServer.cpp @@ -114,7 +114,7 @@ void WSServer::onNewConnection() _clMutex.unlock(); QHostAddress clientAddr = pSocket->peerAddress(); - QString clientIp = clientAddr.toString(); + QString clientIp = Utils::FormatIPAddress(clientAddr); blog(LOG_INFO, "new client connection from %s:%d", clientIp.toUtf8().constData(), pSocket->peerPort());