Add RTSP Camera Type

This commit is contained in:
2021-07-28 15:58:51 +02:00
parent 72d4b6d4d8
commit 269b300bfa
6 changed files with 229 additions and 65 deletions
+86 -65
View File
@@ -2,10 +2,13 @@
#include "Recorder/Recorder.h"
#include "Recorder/DigooRecorder.h"
#include "Recorder/FoscamRecorder.h"
#include "Recorder/RTSPRecorder.h"
#include "Recorder/VStarCamRecorder.h"
#include "Recorder/WatchBotRecorder.h"
#include "Recorder/ZModoRecorder.h"
#include <StringAlgorithm.h>
#include <base64_url.hpp>
#include <iostream>
#include <memory>
@@ -17,7 +20,7 @@ namespace API {
// Status Query
// Goal: Provide status information based on POST data
// Use: DomoticaSite status update
// URL: http://<ip>/API/<action>/<brand>/<ipaddress>/<port>/<username>/<password>
// URL: http://<ip>/API/<action>/<brand>/<ipaddress>/<port>/<url(base64)>/<username>/<password>
WebAPI::WebAPI()
{
@@ -40,78 +43,96 @@ Http::HttpServer::HttpReply WebAPI::ProcessQuery(ctpl::thread_pool* pThreadPool,
reply.status = Http::HttpServer::HttpReply::Status::InternalServerError;
reply.content = "{\"result\": \"error\"}\r\n";
std::string apiURI = uri.substr(4);
try {
std::string apiURI = uri.substr(4);
std::vector<std::string> uriTokens = StringAlgorithm::split(apiURI, '/');
std::vector<std::string> uriTokens = StringAlgorithm::split(apiURI, '/');
if (uriTokens.size() < 7)
if (uriTokens.size() < 7)
return reply;
std::string action = uriTokens[1];
std::string brand = uriTokens[2];
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];
Recorder::Settings settings;
settings.Path = path;
settings.IpAddress = uriTokens[3];
settings.Port = uriTokens[4];
settings.URL = cppcodec::base64_url::decode<std::string>(uriTokens[5].c_str(), uriTokens[5].length());
settings.Username = uriTokens[6];
settings.Password = uriTokens[7];
int numberOfImages = 5;
if (uriTokens.size() > 7)
numberOfImages = stoi(uriTokens[7]);
int numberOfImages = 5;
if (uriTokens.size() > 8)
numberOfImages = stoi(uriTokens[8]);
reply.status = Http::HttpServer::HttpReply::Status::Ok;
if (StringAlgorithm::iequals("Digoo", brand))
{
auto recorder = Recorder::DigooRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("Foscam", brand))
{
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("VStarCam", brand))
{
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("WatchBot", brand))
{
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("ZModo", brand))
{
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
reply.status = Http::HttpServer::HttpReply::Status::Ok;
if (StringAlgorithm::iequals("Digoo", brand))
{
auto recorder = Recorder::DigooRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("Foscam", brand))
{
auto recorder = Recorder::FoscamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("RTSP", brand))
{
auto recorder = Recorder::RTSPRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("VStarCam", brand))
{
auto recorder = Recorder::VStarCamRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("WatchBot", brand))
{
auto recorder = Recorder::WatchBotRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
else if (StringAlgorithm::iequals("ZModo", brand))
{
auto recorder = Recorder::ZModoRecorder(pHttpClient, settings);
if (StringAlgorithm::iequals("Snapshot", action))
reply.content = recorder.Snapshot(pThreadPool, ffmpeg);
else if (StringAlgorithm::iequals("MultiSnapshot", action))
reply.content = recorder.MultiSnapshot(pThreadPool, ffmpeg, numberOfImages);
else if (StringAlgorithm::iequals("Video", action))
reply.content = recorder.Video(pThreadPool, ffmpeg);
}
}
catch (const std::exception& e)
{
std::cout << "WebAPI::ProcessQuery() - Error: " << e.what() << std::endl;
return reply;
}
return reply;
}