diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f979a0d..1d8b5c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,6 +64,7 @@ jobs: set -ex sudo apt install -y \ libopenblas-dev libopenblas0 \ + libcurl4-openssl-dev \ || true export OPENBLAS_HOME=/lib/x86_64-linux-gnu/ cmake -S . -B build \ diff --git a/CMakeLists.txt b/CMakeLists.txt index d952940..c8fa980 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ find_package(libobs REQUIRED) find_package(obs-frontend-api REQUIRED) include(cmake/ObsPluginHelpers.cmake) find_qt(VERSION ${QT_VERSION} COMPONENTS Widgets Core Gui) +find_package(CURL REQUIRED) if (WITH_DLIB_SUBMODULE) set(CMAKE_POSITION_INDEPENDENT_CODE True) @@ -123,6 +124,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME} OBS::libobs OBS::obs-frontend-api dlib + CURL::libcurl ${plugin_additional_libs} ) @@ -137,6 +139,7 @@ if(OS_WINDOWS) add_definitions("-D_USE_MATH_DEFINES") add_definitions("-D_CRT_SECURE_NO_WARNINGS") # to avoid a warning for `fopen` add_definitions("-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") # TODO: Remove once requiring OBS 30.2 or later. + target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX) endif() target_link_libraries(${CMAKE_PROJECT_NAME} OBS::w32-pthreads) diff --git a/ci/plugin.spec b/ci/plugin.spec index 44ea9fa..198c9d7 100644 --- a/ci/plugin.spec +++ b/ci/plugin.spec @@ -13,6 +13,7 @@ BuildRequires: obs-studio-devel BuildRequires: qt6-qtbase-devel qt6-qtbase-private-devel BuildRequires: dlib-devel ffmpeg-free-devel sqlite-devel blas-devel lapack-devel BuildRequires: flexiblas-devel +BuildRequires: libcurl-devel # dlib-devel requires /usr/include/ffmpeg so that install ffmpeg-free-devel %package data diff --git a/src/ptz-http-backend.cpp b/src/ptz-http-backend.cpp index 8e32ea8..49429e9 100644 --- a/src/ptz-http-backend.cpp +++ b/src/ptz-http-backend.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "plugin-macros.generated.h" #include "ptz-http-backend.hpp" @@ -185,7 +186,26 @@ void *ptz_http_backend::thread_main(void *data) static void call_url(const char *method, const char *url, const char *payload) { blog(LOG_INFO, "call_url(method='%s', url='%s', payload='%s')", method, url, payload); - // TODO: Implement + + CURL *const c = curl_easy_init(); + if (!c) + return; + + curl_easy_setopt(c, CURLOPT_URL, url); + + // TODO: Implement method, payload, etc. + + char error[CURL_ERROR_SIZE]; + curl_easy_setopt(c, CURLOPT_ERRORBUFFER, error); + + CURLcode code = curl_easy_perform(c); + if (code != CURLE_OK) { + blog(LOG_WARNING, "Failed method='%s' url='%s' %s", + method, url, + strlen(error) ? error : curl_easy_strerror(code)); + } + + curl_easy_cleanup(c); } static bool send_ptz(obs_data_t *user_data, obs_data_t *camera_settings)