Add MultiSnapshot

This commit is contained in:
2020-05-11 21:55:34 +02:00
parent ea15817e53
commit 6afdf1a387
21 changed files with 904 additions and 714 deletions
+108 -94
View File
@@ -1,94 +1,108 @@
#include "WebAPI.h"
#include "Recorder/Recorder.h"
#include "Recorder/DigooRecorder.h"
#include "Recorder/FoscamRecorder.h"
#include "Recorder/VStarCamRecorder.h"
#include "Recorder/WatchBotRecorder.h"
#include "Recorder/ZModoRecorder.h"
#include <StringAlgorithm.h>
#include <memory>
namespace CameraRecorder {
namespace API {
// API Description
// Status Query
// Goal: Provide status information based on POST data
// Use: DomoticaSite status update
// URL: http://<ip>/API/<action>/<brand>/<ipaddress>/<port>/<username>/<password>
WebAPI::WebAPI()
{
}
WebAPI::~WebAPI()
{
}
std::string 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)
{
std::string output;
std::vector<std::string> uriTokens = StringAlgorithm::split(uri, '/');
if (uriTokens.size() < 7)
return std::string();
std::string action = uriTokens[1];
std::string brand = uriTokens[2];
Recorder::Settings settings;
settings.Path = path;
settings.IpAddress = uriTokens[3];
settings.Port = uriTokens[4];
settings.Username = uriTokens[5];
settings.Password = uriTokens[6];
if (StringAlgorithm::iequals("Digoo", brand))
{
auto recorder = Recorder::DigooRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("Foscam", brand))
{
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("VStarCam", brand))
{
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("WatchBot", brand))
{
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("ZModo", brand))
{
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
return output;
}
} // namespace API
} // namespace CameraRecorder
#include "WebAPI.h"
#include "Recorder/Recorder.h"
#include "Recorder/DigooRecorder.h"
#include "Recorder/FoscamRecorder.h"
#include "Recorder/VStarCamRecorder.h"
#include "Recorder/WatchBotRecorder.h"
#include "Recorder/ZModoRecorder.h"
#include <StringAlgorithm.h>
#include <memory>
namespace CameraRecorder {
namespace API {
// API Description
// Status Query
// Goal: Provide status information based on POST data
// Use: DomoticaSite status update
// URL: http://<ip>/API/<action>/<brand>/<ipaddress>/<port>/<username>/<password>
WebAPI::WebAPI()
{
}
WebAPI::~WebAPI()
{
}
std::string 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)
{
std::string output;
std::vector<std::string> uriTokens = StringAlgorithm::split(uri, '/');
if (uriTokens.size() < 7)
return std::string();
std::string action = uriTokens[1];
std::string brand = uriTokens[2];
Recorder::Settings settings;
settings.Path = path;
settings.IpAddress = uriTokens[3];
settings.Port = uriTokens[4];
settings.Username = uriTokens[5];
settings.Password = uriTokens[6];
int numberOfImages = 5;
if (uriTokens.size() > 7)
numberOfImages = stoi(uriTokens[7]);
if (StringAlgorithm::iequals("Digoo", brand))
{
auto recorder = Recorder::DigooRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
output = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("Foscam", brand))
{
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
output = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("VStarCam", brand))
{
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
output = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("WatchBot", brand))
{
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
output = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("ZModo", brand))
{
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
output = recorder.Snapshot(pThreadPool);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
output = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
output = recorder.Video(pThreadPool, ffmpeg);
}
return output;
}
} // namespace API
} // namespace CameraRecorder