From 8b30d2e77e8fe0f3a59bc1543813950e04c338fd Mon Sep 17 00:00:00 2001 From: tt2468 Date: Mon, 10 May 2021 18:34:27 -0700 Subject: [PATCH] EventHandler: Add some calldata helpers --- src/eventhandler/EventHandler.cpp | 7 +++++++ src/eventhandler/EventHandler.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/eventhandler/EventHandler.cpp b/src/eventhandler/EventHandler.cpp index ee5179f3..86a2c8b6 100644 --- a/src/eventhandler/EventHandler.cpp +++ b/src/eventhandler/EventHandler.cpp @@ -15,6 +15,13 @@ EventHandler::~EventHandler() obs_frontend_remove_event_callback(EventHandler::OnFrontendEvent, this); } +std::string EventHandler::GetCalldataString(const calldata_t *data, const char* name) +{ + const char* value = nullptr; + calldata_get_string(data, name, &value); + return value; +} + void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_data) { auto eventHandler = reinterpret_cast(private_data); diff --git a/src/eventhandler/EventHandler.h b/src/eventhandler/EventHandler.h index 4a535c26..240f2f35 100644 --- a/src/eventhandler/EventHandler.h +++ b/src/eventhandler/EventHandler.h @@ -13,6 +13,14 @@ class EventHandler EventHandler(WebSocketServerPtr webSocketServer); ~EventHandler(); + template T* GetCalldataPointer(const calldata_t *data, const char* name) { + void* ptr = nullptr; + calldata_get_ptr(data, name, &ptr); + return reinterpret_cast(ptr); + } + + static std::string GetCalldataString(const calldata_t *data, const char* name); + private: WebSocketServerPtr _webSocketServer; os_cpu_usage_info_t *_cpuUsageInfo;