2021-03-08 11:56:43 +00:00
|
|
|
#include <obs-module.h>
|
|
|
|
#include <obs-frontend-api.h>
|
|
|
|
#include <obs-data.h>
|
|
|
|
|
|
|
|
#include <QtCore/QTimer>
|
|
|
|
#include <QtWidgets/QAction>
|
|
|
|
#include <QtWidgets/QMainWindow>
|
|
|
|
|
|
|
|
#include "obs-websocket.h"
|
2021-04-27 02:59:50 +00:00
|
|
|
#include "Config.h"
|
2021-04-27 16:18:06 +00:00
|
|
|
#include "WebSocketServer.h"
|
2021-04-27 02:59:50 +00:00
|
|
|
#include "forms/SettingsDialog.h"
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
// Auto release definitions
|
2021-03-08 11:56:43 +00:00
|
|
|
void ___source_dummy_addref(obs_source_t*) {}
|
|
|
|
void ___sceneitem_dummy_addref(obs_sceneitem_t*) {}
|
|
|
|
void ___data_dummy_addref(obs_data_t*) {}
|
|
|
|
void ___data_array_dummy_addref(obs_data_array_t*) {}
|
|
|
|
void ___output_dummy_addref(obs_output_t*) {}
|
|
|
|
|
|
|
|
void ___data_item_dummy_addref(obs_data_item_t*) {}
|
2021-04-27 16:18:06 +00:00
|
|
|
void ___data_item_release(obs_data_item_t* dataItem)
|
|
|
|
{
|
2021-03-08 11:56:43 +00:00
|
|
|
obs_data_item_release(&dataItem);
|
|
|
|
}
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
|
2021-03-08 11:56:43 +00:00
|
|
|
OBS_DECLARE_MODULE()
|
|
|
|
OBS_MODULE_USE_DEFAULT_LOCALE("obs-websocket", "en-US")
|
|
|
|
|
2021-04-27 02:59:50 +00:00
|
|
|
ConfigPtr _config;
|
2021-04-27 16:18:06 +00:00
|
|
|
WebSocketServerPtr _webSocketServer;
|
2021-04-27 03:55:18 +00:00
|
|
|
SettingsDialog *_settingsDialog = nullptr;
|
2021-04-27 02:59:50 +00:00
|
|
|
|
2021-04-27 16:18:06 +00:00
|
|
|
bool obs_module_load(void)
|
|
|
|
{
|
2021-03-08 11:56:43 +00:00
|
|
|
blog(LOG_INFO, "you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
|
2021-04-26 15:46:11 +00:00
|
|
|
blog(LOG_INFO, "Qt version (compile-time): %s | Qt version (run-time): %s",
|
2021-03-08 11:56:43 +00:00
|
|
|
QT_VERSION_STR, qVersion());
|
|
|
|
|
2021-04-27 03:55:18 +00:00
|
|
|
_config = ConfigPtr(new Config());
|
|
|
|
_config->Load();
|
|
|
|
|
2021-04-27 16:18:06 +00:00
|
|
|
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
|
|
|
|
2021-04-27 03:55:18 +00:00
|
|
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
|
|
|
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
|
|
|
_settingsDialog = new SettingsDialog(mainWindow);
|
|
|
|
obs_frontend_pop_ui_translation();
|
|
|
|
|
|
|
|
const char* menuActionText = obs_module_text("OBSWebSocket.Settings.DialogTitle");
|
|
|
|
QAction* menuAction = (QAction*)obs_frontend_add_tools_menu_qaction(menuActionText);
|
|
|
|
QObject::connect(menuAction, &QAction::triggered, [] { _settingsDialog->ToggleShowHide(); });
|
|
|
|
|
2021-03-08 11:56:43 +00:00
|
|
|
// Loading finished
|
2021-04-26 15:46:11 +00:00
|
|
|
blog(LOG_INFO, "Module loaded.");
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-04-27 16:18:06 +00:00
|
|
|
void obs_module_unload()
|
|
|
|
{
|
2021-04-27 03:55:18 +00:00
|
|
|
_config.reset();
|
2021-04-26 15:46:11 +00:00
|
|
|
blog(LOG_INFO, "Finished shutting down.");
|
2021-04-27 02:59:50 +00:00
|
|
|
}
|
|
|
|
|
2021-04-27 16:18:06 +00:00
|
|
|
ConfigPtr GetConfig()
|
|
|
|
{
|
2021-04-27 02:59:50 +00:00
|
|
|
return _config;
|
2021-04-27 16:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WebSocketServerPtr GetWebSocketServer()
|
|
|
|
{
|
|
|
|
return _webSocketServer;
|
2021-03-08 11:56:43 +00:00
|
|
|
}
|