|
|
@ -13,14 +13,75 @@ YuShiCtrl::~YuShiCtrl()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool YuShiCtrl::SetOsd()
|
|
|
|
bool YuShiCtrl::SetOsd(uint8_t channel, std::string osd, uint8_t pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// /LAPI/V1.0/Channels/<ID>/Media/OSDs/Contents
|
|
|
|
// /LAPI/V1.0/Channels/<ID>/Media/OSDs/Contents
|
|
|
|
|
|
|
|
char url[128] = { 0 };
|
|
|
|
|
|
|
|
snprintf(url, sizeof(url), "http://%s/LAPI/V1.0/Channels/%u/Media/OSDs/Contents", m_ip.c_str(), (uint32_t)channel);
|
|
|
|
|
|
|
|
std::vector<uint8_t> resData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string jsonstring;
|
|
|
|
|
|
|
|
switch (pos) {
|
|
|
|
|
|
|
|
case LEFT_TOP:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OSDJson(0, 1, osd, 0, 0, true, jsonstring);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case RIGHT_TOP:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OSDJson(1, 1, osd, 9900, 0, false, jsonstring);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case LEFT_BOTTOM:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OSDJson(2, 1, osd, 0, 9900, false, jsonstring);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case RIGHT_BOTTOM:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OSDJson(3, 1, osd, 9900, 9900, false, jsonstring);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int res = DoPutRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, jsonstring.c_str(), resData);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void YuShiCtrl::EnableOsd(bool enable)
|
|
|
|
void YuShiCtrl::EnableOsd(bool enable, uint8_t channel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// return false;
|
|
|
|
char url[128] = { 0 };
|
|
|
|
|
|
|
|
snprintf(url, sizeof(url), "http://%s/LAPI/V1.0/Channels/%u/Media/OSDs/Contents", m_ip.c_str(), (uint32_t)channel);
|
|
|
|
|
|
|
|
std::vector<uint8_t> resData;
|
|
|
|
|
|
|
|
int res =DoGetRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, resData);
|
|
|
|
|
|
|
|
std::string jsonString(resData.begin(), resData.end());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::CharReaderBuilder reader;
|
|
|
|
|
|
|
|
Json::Value root;
|
|
|
|
|
|
|
|
std::string errors;
|
|
|
|
|
|
|
|
std::istringstream s(jsonString);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Json::parseFromStream(reader, s, &root, &errors)) {
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR,"Failed to parse JSON:%s", errors);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value& data = root["Response"]["Data"];
|
|
|
|
|
|
|
|
if (data.isNull()) {
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR,"Data not found in JSON");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value& contentList = data["ContentList"];
|
|
|
|
|
|
|
|
for (auto& content : contentList) {
|
|
|
|
|
|
|
|
content["Enabled"] = enable ? 1 : 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::StreamWriterBuilder writer;
|
|
|
|
|
|
|
|
std::string putJsonString = Json::writeString(writer, data);
|
|
|
|
|
|
|
|
DoPutRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, putJsonString.c_str(), resData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string YuShiCtrl::GetStreamingUrl(uint8_t channel)
|
|
|
|
std::string YuShiCtrl::GetStreamingUrl(uint8_t channel)
|
|
|
@ -94,7 +155,73 @@ bool YuShiCtrl::TakePhoto(std::vector<uint8_t>& img)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool YuShiCtrl::TakeVideo(uint32_t duration, std::string path)
|
|
|
|
|
|
|
|
|
|
|
|
bool YuShiCtrl::TakeVideo(uint32_t duration, std::string path) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void YuShiCtrl::OSDJson(int id, bool enabled, std::string osdString, int x, int y, bool timeOn, std::string& jsonString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Json::Value root;
|
|
|
|
|
|
|
|
root["Num"] = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value contentList(Json::arrayValue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value content;
|
|
|
|
|
|
|
|
content["ID"] = id;
|
|
|
|
|
|
|
|
content["Enabled"] = enabled;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int row = 1;
|
|
|
|
|
|
|
|
for (char ch : osdString) {
|
|
|
|
|
|
|
|
if (ch == '\n') {
|
|
|
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content["Num"] = row;
|
|
|
|
|
|
|
|
Json::Value contentInfo(Json::arrayValue);
|
|
|
|
|
|
|
|
size_t start = 0;
|
|
|
|
|
|
|
|
size_t end = osdString.find('\n');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(timeOn)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//如果在此位置显示时间
|
|
|
|
|
|
|
|
Json::Value info;
|
|
|
|
|
|
|
|
info["ContentType"] = 2;
|
|
|
|
|
|
|
|
info["Value"] = "";
|
|
|
|
|
|
|
|
contentInfo.append(info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < row; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string line;
|
|
|
|
|
|
|
|
if (end == std::string::npos) {
|
|
|
|
|
|
|
|
line = osdString.substr(start);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
line = osdString.substr(start, end - start);
|
|
|
|
|
|
|
|
start = end + 1;
|
|
|
|
|
|
|
|
end = osdString.find('\n', start);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value info;
|
|
|
|
|
|
|
|
info["ContentType"] = 1;
|
|
|
|
|
|
|
|
info["Value"] = line;
|
|
|
|
|
|
|
|
contentInfo.append(info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
content["ContentInfo"] = contentInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::Value area;
|
|
|
|
|
|
|
|
Json::Value topLeft;
|
|
|
|
|
|
|
|
topLeft["X"] = x; //9900
|
|
|
|
|
|
|
|
topLeft["Y"] = y;
|
|
|
|
|
|
|
|
area["TopLeft"] = topLeft;
|
|
|
|
|
|
|
|
content["Area"] = area;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contentList.append(content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root["ContentList"] = contentList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Json::StreamWriterBuilder writer;
|
|
|
|
|
|
|
|
jsonString = Json::writeString(writer, root);
|
|
|
|
}
|
|
|
|
}
|