mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
EventHandler: Add more code
This commit is contained in:
parent
c0accd9cde
commit
5157134b02
@ -1 +1,20 @@
|
|||||||
#include "EventHandler.h"
|
#include "EventHandler.h"
|
||||||
|
|
||||||
|
EventHandler::EventHandler(WebSocketServerPtr webSocketServer) :
|
||||||
|
_webSocketServer(webSocketServer)
|
||||||
|
{
|
||||||
|
_cpuUsageInfo = os_cpu_usage_info_start();
|
||||||
|
|
||||||
|
obs_frontend_add_event_callback(EventHandler::OnFrontendEvent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHandler::~EventHandler()
|
||||||
|
{
|
||||||
|
os_cpu_usage_info_destroy(_cpuUsageInfo);
|
||||||
|
|
||||||
|
obs_frontend_remove_event_callback(EventHandler::OnFrontendEvent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_data) {
|
||||||
|
auto owner = reinterpret_cast<EventHandler*>(private_data);
|
||||||
|
}
|
||||||
|
@ -1 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <obs.hpp>
|
||||||
|
#include <obs-frontend-api.h>
|
||||||
|
#include <util/platform.h>
|
||||||
|
|
||||||
|
#include "../obs-websocket.h"
|
||||||
|
#include "../WebSocketServer.h"
|
||||||
|
|
||||||
|
class EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EventHandler(WebSocketServerPtr webSocketServer);
|
||||||
|
~EventHandler();
|
||||||
|
|
||||||
|
private:
|
||||||
|
WebSocketServerPtr _webSocketServer;
|
||||||
|
os_cpu_usage_info_t *_cpuUsageInfo;
|
||||||
|
|
||||||
|
static void OnFrontendEvent(enum obs_frontend_event event, void *private_data);
|
||||||
|
};
|
||||||
|
@ -21,7 +21,6 @@ void ___sceneitem_dummy_addref(obs_sceneitem_t*) {}
|
|||||||
void ___data_dummy_addref(obs_data_t*) {}
|
void ___data_dummy_addref(obs_data_t*) {}
|
||||||
void ___data_array_dummy_addref(obs_data_array_t*) {}
|
void ___data_array_dummy_addref(obs_data_array_t*) {}
|
||||||
void ___output_dummy_addref(obs_output_t*) {}
|
void ___output_dummy_addref(obs_output_t*) {}
|
||||||
|
|
||||||
void ___data_item_dummy_addref(obs_data_item_t*) {}
|
void ___data_item_dummy_addref(obs_data_item_t*) {}
|
||||||
void ___data_item_release(obs_data_item_t* dataItem)
|
void ___data_item_release(obs_data_item_t* dataItem)
|
||||||
{
|
{
|
||||||
@ -34,6 +33,7 @@ OBS_MODULE_USE_DEFAULT_LOCALE("obs-websocket", "en-US")
|
|||||||
|
|
||||||
ConfigPtr _config;
|
ConfigPtr _config;
|
||||||
WebSocketServerPtr _webSocketServer;
|
WebSocketServerPtr _webSocketServer;
|
||||||
|
EventHandlerPtr _eventHandler;
|
||||||
SettingsDialog *_settingsDialog = nullptr;
|
SettingsDialog *_settingsDialog = nullptr;
|
||||||
|
|
||||||
bool obs_module_load(void)
|
bool obs_module_load(void)
|
||||||
@ -51,6 +51,8 @@ bool obs_module_load(void)
|
|||||||
|
|
||||||
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
||||||
|
|
||||||
|
_eventHandler = EventHandlerPtr(new EventHandler(_webSocketServer));
|
||||||
|
|
||||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||||
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
||||||
_settingsDialog = new SettingsDialog(mainWindow);
|
_settingsDialog = new SettingsDialog(mainWindow);
|
||||||
@ -73,16 +75,18 @@ void obs_module_unload()
|
|||||||
{
|
{
|
||||||
blog(LOG_INFO, "[obs_module_unload] Shutting down...");
|
blog(LOG_INFO, "[obs_module_unload] Shutting down...");
|
||||||
|
|
||||||
_config->FirstLoad = false;
|
|
||||||
_config->Save();
|
|
||||||
|
|
||||||
if (_webSocketServer->IsListening()) {
|
if (_webSocketServer->IsListening()) {
|
||||||
blog(LOG_INFO, "[obs_module_unload] WebSocket server is running. Stopping...");
|
blog(LOG_INFO, "[obs_module_unload] WebSocket server is running. Stopping...");
|
||||||
_webSocketServer->Stop();
|
_webSocketServer->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
_config.reset();
|
|
||||||
_webSocketServer.reset();
|
_webSocketServer.reset();
|
||||||
|
|
||||||
|
_eventHandler.reset();
|
||||||
|
|
||||||
|
_config->FirstLoad = false;
|
||||||
|
_config->Save();
|
||||||
|
_config.reset();
|
||||||
|
|
||||||
blog(LOG_INFO, "[obs_module_unload] Finished shutting down.");
|
blog(LOG_INFO, "[obs_module_unload] Finished shutting down.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,3 +99,8 @@ WebSocketServerPtr GetWebSocketServer()
|
|||||||
{
|
{
|
||||||
return _webSocketServer;
|
return _webSocketServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventHandlerPtr GetEventHandler()
|
||||||
|
{
|
||||||
|
return _eventHandler;
|
||||||
|
}
|
||||||
|
@ -9,6 +9,8 @@ void ___sceneitem_dummy_addref(obs_sceneitem_t*);
|
|||||||
void ___data_dummy_addref(obs_data_t*);
|
void ___data_dummy_addref(obs_data_t*);
|
||||||
void ___data_array_dummy_addref(obs_data_array_t*);
|
void ___data_array_dummy_addref(obs_data_array_t*);
|
||||||
void ___output_dummy_addref(obs_output_t*);
|
void ___output_dummy_addref(obs_output_t*);
|
||||||
|
void ___data_item_dummy_addref(obs_data_item_t*);
|
||||||
|
void ___data_item_release(obs_data_item_t*);
|
||||||
|
|
||||||
using OBSSourceAutoRelease =
|
using OBSSourceAutoRelease =
|
||||||
OBSRef<obs_source_t*, ___source_dummy_addref, obs_source_release>;
|
OBSRef<obs_source_t*, ___source_dummy_addref, obs_source_release>;
|
||||||
@ -20,9 +22,6 @@ using OBSDataArrayAutoRelease =
|
|||||||
OBSRef<obs_data_array_t*, ___data_array_dummy_addref, obs_data_array_release>;
|
OBSRef<obs_data_array_t*, ___data_array_dummy_addref, obs_data_array_release>;
|
||||||
using OBSOutputAutoRelease =
|
using OBSOutputAutoRelease =
|
||||||
OBSRef<obs_output_t*, ___output_dummy_addref, obs_output_release>;
|
OBSRef<obs_output_t*, ___output_dummy_addref, obs_output_release>;
|
||||||
|
|
||||||
void ___data_item_dummy_addref(obs_data_item_t*);
|
|
||||||
void ___data_item_release(obs_data_item_t*);
|
|
||||||
using OBSDataItemAutoRelease =
|
using OBSDataItemAutoRelease =
|
||||||
OBSRef<obs_data_item_t*, ___data_item_dummy_addref, ___data_item_release>;
|
OBSRef<obs_data_item_t*, ___data_item_dummy_addref, ___data_item_release>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user