Preliminary work on Recording folder get/set

This commit is contained in:
Palakis 2017-04-23 18:54:24 +02:00
parent 8dfe471ef2
commit 9de6e229d9
3 changed files with 59 additions and 3 deletions

View File

@ -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;
} }

View File

@ -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

View File

@ -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());