增加宇视分辨率设置

rtmpsuck
XI.CHEN 5 months ago
parent de288c860f
commit 5cc05c373d

@ -1589,6 +1589,11 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG(XYLOG_SEVERITY_INFO, "NetCapture %d NetHandle=%lld PHOTOID=%u", idx, netHandle, localPhotoInfo.photoId);
if(localPhotoInfo.vendor == 3)
{
UniviewResolutionSet(netPhotoInfo, localPhotoInfo.channel,localPhotoInfo.resolution);
}
img.clear();
netCaptureResult = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
if (netCaptureResult)

@ -116,7 +116,7 @@ int DoGetRequest(const char* url, int authType, const char* userName, const char
return ((0 == nRet) && (responseCode == 200)) ? 0 : 1;
}
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data)
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, char* data)
{
std::string auth;
@ -225,6 +225,46 @@ bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photo
return (0 == nRet);
}
int UniviewResolutionSet(const NET_PHOTO_INFO& photoInfo, int channel, unsigned int cmd)
{
std::string path = "/LAPI/V1.0/Channels/" + std::to_string(channel) + "/Media/Capture";
Json::Value outdata; // 创建 Json::Value 对象来存储 JSON 数据
uniview_resolution_jsoncpp_file_info(outdata, cmd);
Json::StreamWriterBuilder writer;
std::string sendbuf = Json::writeString(writer, outdata);
char respContent[1024];
DoPutRequest(path.c_str(), photoInfo.authType, photoInfo.userName, photoInfo.password, photoInfo.netHandle, sendbuf.c_str(), respContent);
XYLOG(XYLOG_SEVERITY_INFO, "sendlen= %zu, respContent=%s", sendbuf.size(), respContent);
return 0;
}
int uniview_resolution_jsoncpp_file_info(Json::Value &outdata, unsigned int cmd)
{
PIC_RESOLUTION pic_resol[] = { {352,288},{640,360},{720,576},{1280,720},{1920,1080},{2688,1520},{3072,2048},{3840,2160},{2560,1440},{704,288} };
outdata["Enable"] = 1;
Json::Value Resolution;
outdata["Resolution"] = Resolution;
if ((cmd < 1) || (cmd > 10))
{
cmd = 5;
}
Resolution["Width"] = pic_resol[cmd-1].width;
Resolution["Height"] = pic_resol[cmd-1].height;
outdata["Picturesize"] = 900;
return 0;
}
namespace nc_hk
{
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img)

@ -8,6 +8,7 @@
#include <arpa/inet.h>
#include <net/if.h>
#include <bits/ioctl.h>
#include <json/json.h>
#include <android/multinetwork.h>
#include "LogThread.h"
@ -18,6 +19,6 @@
bool setIPAddress(const char *if_name, const char *ip_addr, const char *net_mask, const char *gateway_addr);
int DoGetRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, std::vector<uint8_t>& data);
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector<uint8_t>& data);
int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, char* data);
#endif // __HTTP_CLIENT__

@ -34,10 +34,18 @@ struct NET_PHOTO_INFO
unsigned char reserved[7]; // for memory alignment
};
*/
typedef struct
{
unsigned int width;
unsigned int height;
}PIC_RESOLUTION;
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo);
bool requestCapture(uint8_t channel, uint8_t preset, const NET_PHOTO_INFO& photoInfo, std::vector<uint8_t>& img);
bool setOSD(uint8_t channel, bool status, int type, uint32_t cameraId, const NET_PHOTO_INFO& photoInfo);
int UniviewResolutionSet(const NET_PHOTO_INFO& photoInfo, int channel, unsigned int cmd);
int uniview_resolution_jsoncpp_file_info(Json::Value &outdata, unsigned int cmd);
namespace nc_hk
{

Loading…
Cancel
Save