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 Aug 4, 2024
1 parent ab75024 commit 4f35d49
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 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 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 4f35d49

Please sign in to comment.