Include CxxUrl and use it to build the correct url in Amcrest API

This commit is contained in:
Isaac Connor
2025-08-31 10:08:40 -04:00
parent ed96724f54
commit 1f061c9666
5 changed files with 16 additions and 6 deletions

3
.gitmodules vendored
View File

@@ -8,3 +8,6 @@
[submodule "dep/RtspServer"]
path = dep/RtspServer
url = https://github.com/ZoneMinder/RtspServer
[submodule "dep/CxxUrl"]
path = dep/CxxUrl
url = git@github.com:chmike/CxxUrl.git

View File

@@ -363,6 +363,9 @@ else()
"ZoneMinder requires jpeg but it was not found on your system")
endif()
list(APPEND ZM_BIN_LIBS chmike::CxxUrl)
# libjwt
if (${ZM_JWT_BACKEND} STREQUAL "libjwt")
find_package(LibJWT REQUIRED COMPONENTS ${ZM_CRYPTO_BACKEND})

View File

@@ -2,3 +2,4 @@ add_subdirectory(jwt-cpp)
add_subdirectory(libbcrypt)
add_subdirectory(RtspServer)
add_subdirectory(span-lite)
add_subdirectory(CxxUrl)

1
dep/CxxUrl Submodule

Submodule dep/CxxUrl added at eaf46c0207

View File

@@ -18,6 +18,7 @@
//
#include "zm_monitor.h"
#include "dep/CxxUrl/url.hpp"
Monitor::AmcrestAPI::AmcrestAPI(Monitor *parent_) :
parent(parent_),
@@ -45,16 +46,17 @@ int Monitor::AmcrestAPI::start() {
curl_easy_cleanup(Amcrest_handle);
}
std::string full_url = parent->onvif_url;
if (full_url.back() != '/') full_url += '/';
full_url += "eventManager.cgi?action=attach&codes=[VideoMotion]";
Debug(1, "AMCREST url is %s", full_url.c_str());
Url full_url(parent->onvif_url);
//std::string full_url = parent->onvif_url;
//if (full_url.path().back() != '/') full_url += '/';
full_url.path("eventManager.cgi?action=attach&codes=[VideoMotion]");
Debug(1, "AMCREST url is %s", full_url.str().c_str());
Amcrest_handle = curl_easy_init();
if (!Amcrest_handle) {
Warning("Handle is null!");
return -1;
}
curl_easy_setopt(Amcrest_handle, CURLOPT_URL, full_url.c_str());
curl_easy_setopt(Amcrest_handle, CURLOPT_URL, full_url.str().c_str());
curl_easy_setopt(Amcrest_handle, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(Amcrest_handle, CURLOPT_WRITEDATA, &amcrest_response);
curl_easy_setopt(Amcrest_handle, CURLOPT_USERNAME, parent->onvif_username.c_str());
@@ -88,7 +90,7 @@ int Monitor::AmcrestAPI::start() {
} else {
Warning("AMCREST Response: %s", amcrest_response.c_str());
Warning("AMCREST Seeing %i streams, and error of %i, url: %s",
running_handles, curl_error, full_url.c_str());
running_handles, curl_error, full_url.str().c_str());
long response_code;
curl_easy_getinfo(Amcrest_handle, CURLINFO_OS_ERRNO, &response_code);
Warning("AMCREST Response code: %lu", response_code);