调整网络短视频实现
parent
b82fe124d8
commit
d1298663f3
@ -0,0 +1,87 @@
|
||||
//
|
||||
// Created by Matthew on 2025/3/4.
|
||||
//
|
||||
|
||||
#include "YuShiCtrl.h"
|
||||
#include "httpclient.h"
|
||||
|
||||
HangYuCtrl::~HangYuCtrl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool HangYuCtrl::SetOsd()
|
||||
{
|
||||
// /LAPI/V1.0/Channels/<ID>/Media/OSDs/Contents
|
||||
}
|
||||
|
||||
void HangYuCtrl::EnableOsd(bool enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string HangYuCtrl::GetStreamingUrl(uint8_t channel)
|
||||
{
|
||||
// /LAPI/V1.0/Channels/<ID>/Media/Video/Streams/<ID>/LiveStreamURL?TransType=<Tran
|
||||
// sType>&TransProtocol=<TransProtocol>
|
||||
char url[128] = { 0 };
|
||||
snprintf(url, sizeof(url), "/Streams/%u/1/Transport", (uint32_t)channel);
|
||||
|
||||
std::vector<uint8_t> resData;
|
||||
int res = DoPutRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, "", resData);
|
||||
if (res != 0 || resData.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
resData.push_back(0);
|
||||
const char* start = strstr(&resData[0], "<RTSPURI>");
|
||||
if (start == NULL)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
start += 9;
|
||||
const char* end = strstr(start, "</RTSPURI>");
|
||||
if (end == NULL)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
strncpy(url, start, end - start);
|
||||
|
||||
return std::string(url);
|
||||
}
|
||||
|
||||
bool HangYuCtrl::UpdateTime(time_t ts)
|
||||
{
|
||||
// /LAPI/V1.0/System/Time
|
||||
|
||||
// <?xml version="1.0" encoding="utf-8"?>
|
||||
//<Time>
|
||||
//<DateTimeFormat>
|
||||
//<!--req,string,YYYYMMDDWhhmmss,YYYYMMDDhhmmss,MMDDYYYYWhhmmss,MMD
|
||||
// DYYYYhhmmss,DDMMYYYYWhhmmss,DDMMYYYYhhmmss-->
|
||||
//</DateTimeFormat>
|
||||
//<TimeFormat><!--req,xs:string,12hour,24hour--></TimeFormat>
|
||||
//<SystemTime><!--req,xs:datetime,” 20040503T173008+08”--></SystemTime>
|
||||
//<SyncNTPFlag><!--req,xs:string,"Sync,NoSync"--></SyncNTPFlag>
|
||||
//</Time>
|
||||
|
||||
std::string reqData = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Time><SystemTime>"
|
||||
+ FormatLocalDateTime("%d%02d%02dT%02d%02d%02d") + "+08</SystemTime></Time>";
|
||||
|
||||
std::string url = "http://" + m_ip + " /System/Time";
|
||||
std::vector<uint8_t> resData;
|
||||
int res = DoPutRequest(url.c_str(), HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, reqData.c_str(), resData);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HangYuCtrl::TakePhoto(std::vector<uint8_t>& img)
|
||||
{
|
||||
return false;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Matthew on 2025/3/4.
|
||||
//
|
||||
|
||||
#ifndef __MICROPHOTO_HANGYUCTRL_H__
|
||||
#define __MICROPHOTO_HANGYUCTRL_H__
|
||||
|
||||
#include "VendorCtrl.h"
|
||||
|
||||
class HangYuCtrl : public VendorCtrl
|
||||
{
|
||||
public:
|
||||
using VendorCtrl::VendorCtrl;
|
||||
virtual ~HangYuCtrl();
|
||||
|
||||
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);
|
||||
virtual bool TakeVideo(uint32_t duration, std::string path);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //__MICROPHOTO_HANGYUCTRL_H__
|
Loading…
Reference in New Issue