mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Preliminary work on Recording folder get/set
This commit is contained in:
parent
8dfe471ef2
commit
9de6e229d9
54
Utils.cpp
54
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 <https://www.gnu.org/licenses/>
|
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Utils.h"
|
|
||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
#include <obs.hpp>
|
#include <obs.hpp>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QPainter>
|
#include <QDir>
|
||||||
|
#include "Utils.h"
|
||||||
#include "obs-websocket.h"
|
#include "obs-websocket.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(OBSScene);
|
Q_DECLARE_METATYPE(OBSScene);
|
||||||
@ -351,6 +351,8 @@ bool Utils::SetPreviewScene(const char* name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::TransitionToProgram()
|
void Utils::TransitionToProgram()
|
||||||
@ -407,4 +409,52 @@ void Utils::SysTrayNotify(QString &text, QSystemTrayIcon::MessageIcon icon, QStr
|
|||||||
|
|
||||||
if (trayIcon)
|
if (trayIcon)
|
||||||
trayIcon->showMessage(title, text, icon);
|
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;
|
||||||
}
|
}
|
6
Utils.h
6
Utils.h
@ -24,8 +24,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QHostAddress>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <obs-module.h>
|
#include <obs-module.h>
|
||||||
|
#include <util/config-file.h>
|
||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
@ -66,6 +68,10 @@ class Utils
|
|||||||
|
|
||||||
static QSystemTrayIcon* GetTrayIcon();
|
static QSystemTrayIcon* GetTrayIcon();
|
||||||
static void SysTrayNotify(QString &text, QSystemTrayIcon::MessageIcon n, QString title = QString("obs-websocket"));
|
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
|
#endif // UTILS_H
|
||||||
|
@ -114,7 +114,7 @@ void WSServer::onNewConnection()
|
|||||||
_clMutex.unlock();
|
_clMutex.unlock();
|
||||||
|
|
||||||
QHostAddress clientAddr = pSocket->peerAddress();
|
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());
|
blog(LOG_INFO, "new client connection from %s:%d", clientIp.toUtf8().constData(), pSocket->peerPort());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user