Add RecorderMutex

This commit is contained in:
2023-03-16 13:41:53 +01:00
parent cacf6cfdca
commit 59f4409ab4
19 changed files with 233 additions and 35 deletions
+7 -7
View File
@@ -30,7 +30,7 @@ WebAPI::~WebAPI()
{
}
Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool, Http::HttpClient* pHttpClient, const std::string& path, const std::string& ffmpeg, const std::string& uri, const std::vector<Http::HttpPostData>& postData)
Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool, Http::HttpClient* pHttpClient, Util::RecorderMutexPointer pRecorderMutex, const std::string& path, const std::string& ffmpeg, const std::string& uri, const std::vector<Http::HttpPostData>& postData)
{
if (!StringAlgorithm::iequals(uri, "/api") && !StringAlgorithm::istarts_with(uri, "/api/"))
{
@@ -69,7 +69,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
reply.status = Http::HttpServer::HttpReply::Status::Ok;
if (StringAlgorithm::iequals("Digoo", brand))
{
auto recorder = Recorder::DigooRecorder(pHttpClient, settings);
auto recorder = Recorder::DigooRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
@@ -79,7 +79,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
}
else if (StringAlgorithm::iequals("Foscam", brand))
{
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings);
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
@@ -89,7 +89,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
}
else if (StringAlgorithm::iequals("RTSP", brand))
{
auto recorder = Recorder::RTSPRecorder(pHttpClient, settings);
auto recorder = Recorder::RTSPRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
@@ -99,7 +99,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
}
else if (StringAlgorithm::iequals("VStarCam", brand))
{
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings);
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
@@ -109,7 +109,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
}
else if (StringAlgorithm::iequals("WatchBot", brand))
{
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings);
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
@@ -119,7 +119,7 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
}
else if (StringAlgorithm::iequals("ZModo", brand))
{
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings);
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings, pRecorderMutex);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
+2 -1
View File
@@ -1,6 +1,7 @@
#ifndef API_WEBAPI_H
#define API_WEBAPI_H
#include "Util/RecorderMutex.h"
#include <HttpPostData.h>
#include <HttpServer.h>
#include <ctpl_stl.h>
@@ -23,7 +24,7 @@ public:
WebAPI();
~WebAPI();
static Http::HttpServer::HttpReply ProcessQuery(ctpl::thread_pool* pThreadPool, Http::HttpClient* pHttpClient, const std::string& path, const std::string& ffmpeg, const std::string& uri, const std::vector<Http::HttpPostData>& postData);
static Http::HttpServer::HttpReply ProcessQuery(ctpl::thread_pool* pThreadPool, Http::HttpClient* pHttpClient, Util::RecorderMutexPointer pRecorderMutex, const std::string& path, const std::string& ffmpeg, const std::string& uri, const std::vector<Http::HttpPostData>& postData);
};
} // namespace API