From e9a5df4b5a3be60098f65c23770a5f8c2a14046f Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 4 Mar 2025 22:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/netcamera/VendorCtrl.cpp | 20 ++++++++++ app/src/main/cpp/netcamera/VendorCtrl.h | 34 ++++++++++++++++ app/src/main/cpp/netcamera/YuShiCtrl.cpp | 47 +++++++++++++++++++++++ app/src/main/cpp/netcamera/YuShiCtrl.h | 27 +++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 app/src/main/cpp/netcamera/VendorCtrl.cpp create mode 100644 app/src/main/cpp/netcamera/VendorCtrl.h create mode 100644 app/src/main/cpp/netcamera/YuShiCtrl.cpp create mode 100644 app/src/main/cpp/netcamera/YuShiCtrl.h diff --git a/app/src/main/cpp/netcamera/VendorCtrl.cpp b/app/src/main/cpp/netcamera/VendorCtrl.cpp new file mode 100644 index 00000000..81f5d1c8 --- /dev/null +++ b/app/src/main/cpp/netcamera/VendorCtrl.cpp @@ -0,0 +1,20 @@ +// +// Created by Matthew on 2025/3/4. +// +#include "VendorCtrl.h" + +VendorCtrl::VendorCtrl(const std::string& ip, const std::string& userName, const std::string& password) : + m_ip(ip), m_userName(userName), m_password(password), m_channel(channel) +{ +} +std::string VendorCtrl::CvtJSONToString(const Json::Value& data) +{ + Json::StreamWriterBuilder builder; +#ifndef NDEBUG + builder["indentation"] = "\t"; // assume default for comments is None + builder["emitUTF8"] = true; +#else + builder["indentation"] = ""; +#endif + return Json::writeString(builder, data); +} \ No newline at end of file diff --git a/app/src/main/cpp/netcamera/VendorCtrl.h b/app/src/main/cpp/netcamera/VendorCtrl.h new file mode 100644 index 00000000..66a18e4a --- /dev/null +++ b/app/src/main/cpp/netcamera/VendorCtrl.h @@ -0,0 +1,34 @@ +// +// Created by Matthew on 2025/3/4. +// + +#ifndef MICROPHOTO_VENDORCTRL_H +#define MICROPHOTO_VENDORCTRL_H + +#include +#include + +class VendorCtrl { +public: + VendorCtrl(const std::string& ip, const std::string& userName, const std::string& password, uint8_t channel); + virtual ~VendorCtrl() = 0; + + virtual bool SetOsd() = 0; + virtual void EnableOsd(bool enable) = 0; + virtual std::string GetStreamingUrl(uint8_t channel) = 0; + virtual bool UpdateTime(time_t ts) = 0; + virtual bool TakePhoto(std::vector& img) = 0; + +protected: + + std::string CvtJSONToString(const Json::Value& data); + +protected: + std::string m_ip; + std::string m_userName; + std::string m_password; + uint8_t m_channel; +}; + + +#endif //MICROPHOTO_VENDORCTRL_H diff --git a/app/src/main/cpp/netcamera/YuShiCtrl.cpp b/app/src/main/cpp/netcamera/YuShiCtrl.cpp new file mode 100644 index 00000000..9c51f8f0 --- /dev/null +++ b/app/src/main/cpp/netcamera/YuShiCtrl.cpp @@ -0,0 +1,47 @@ +// +// Created by Matthew on 2025/3/4. +// + +#include "YuShiCtrl.h" +#include "httpclient.h" + +YuShiCtrl::~YuShiCtrl() +{ + +} + +bool YuShiCtrl::SetOsd() +{ + // /LAPI/V1.0/Channels//Media/OSDs/Contents +} + +void YuShiCtrl::EnableOsd(bool enable) +{ + return false; +} + +std::string GetStreamingUrl(uint8_t channel) +{ + // /LAPI/V1.0/Channels//Media/Video/Streams//LiveStreamURL?TransType=&TransProtocol= + return ""; +} + +bool YuShiCtrl::UpdateTime(time_t ts) +{ + /LAPI/V1.0/System/Time + + Json::Value jsonData(Json::objectValue); + + jsonData["TimeZone"] = "GMT+08:00"; + jsonData["DeviceTime"] = ts; + jsonData["DateFormat"] = 0; // YYYY-MM-DD + jsonData["HourFormat"] = 1; // 24H + + return false; +} + +bool YuShiCtrl::TakePhoto(std::vector& img) +{ + return false; +} \ No newline at end of file diff --git a/app/src/main/cpp/netcamera/YuShiCtrl.h b/app/src/main/cpp/netcamera/YuShiCtrl.h new file mode 100644 index 00000000..d5da62ad --- /dev/null +++ b/app/src/main/cpp/netcamera/YuShiCtrl.h @@ -0,0 +1,27 @@ +// +// Created by Matthew on 2025/3/4. +// + +#ifndef MICROPHOTO_YUSHICTRL_H +#define MICROPHOTO_YUSHICTRL_H + +#include "VendorCtrl.h" + +class YuShiCtrl : public VendorCtrl +{ +public: + using VendorCtrl::VendorCtrl; + virtual ~YuShiCtrl(); + + virtual bool SetOsd(); + virtual void EnableOsd(bool enable); + virtual std::string GetStreamingUrl(uint8_t channel); + virtual bool UpdateTime(time_t ts); + virtual bool TakePhoto(std::vector& img); + +private: + +}; + + +#endif //MICROPHOTO_YUSHICTRL_H