供应商接口封装
parent
28a09335f5
commit
e9a5df4b5a
@ -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);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Created by Matthew on 2025/3/4.
|
||||
//
|
||||
|
||||
#ifndef MICROPHOTO_VENDORCTRL_H
|
||||
#define MICROPHOTO_VENDORCTRL_H
|
||||
|
||||
#include <string>
|
||||
#include <json/json.h>
|
||||
|
||||
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<uint8_t>& 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
|
@ -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/<ID>/Media/OSDs/Contents
|
||||
}
|
||||
|
||||
void YuShiCtrl::EnableOsd(bool enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string GetStreamingUrl(uint8_t channel)
|
||||
{
|
||||
// /LAPI/V1.0/Channels/<ID>/Media/Video/Streams/<ID>/LiveStreamURL?TransType=<Tran
|
||||
// sType>&TransProtocol=<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<uint8_t>& img)
|
||||
{
|
||||
return false;
|
||||
}
|
@ -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<uint8_t>& img);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //MICROPHOTO_YUSHICTRL_H
|
Loading…
Reference in New Issue