EventHandler: Add some calldata helpers

This commit is contained in:
tt2468 2021-05-10 18:34:27 -07:00
parent 902c9dfdc5
commit 8b30d2e77e
2 changed files with 15 additions and 0 deletions

View File

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

View File

@ -13,6 +13,14 @@ class EventHandler
EventHandler(WebSocketServerPtr webSocketServer);
~EventHandler();
template <typename T> T* GetCalldataPointer(const calldata_t *data, const char* name) {
void* ptr = nullptr;
calldata_get_ptr(data, name, &ptr);
return reinterpret_cast<T*>(ptr);
}
static std::string GetCalldataString(const calldata_t *data, const char* name);
private:
WebSocketServerPtr _webSocketServer;
os_cpu_usage_info_t *_cpuUsageInfo;