Skip to content

Commit

Permalink
ptz: Add libcurl as the dependency and call it
Browse files Browse the repository at this point in the history
  • Loading branch information
norihiro committed Sep 16, 2024
1 parent 08efb0c commit 549613e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -123,6 +124,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
OBS::libobs
OBS::obs-frontend-api
dlib
CURL::libcurl
${plugin_additional_libs}
)

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ci/plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion src/ptz-http-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <obs.hpp>
#include <util/util.hpp>
#include <util/platform.h>
#include <curl/curl.h>
#include "plugin-macros.generated.h"
#include "ptz-http-backend.hpp"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 549613e

Please sign in to comment.