From 5cc05c373d2b909f0f433ade1eff0bf2a6cea604 Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Mon, 13 Jan 2025 17:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=87=E8=A7=86=E5=88=86?= =?UTF-8?q?=E8=BE=A8=E7=8E=87=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 5 +++ app/src/main/cpp/netcamera/httpclient.cpp | 42 ++++++++++++++++++++++- app/src/main/cpp/netcamera/httpclient.h | 3 +- app/src/main/cpp/netcamera/netcamera.h | 8 +++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 70ea89ce..70f4c731 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -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) diff --git a/app/src/main/cpp/netcamera/httpclient.cpp b/app/src/main/cpp/netcamera/httpclient.cpp index 042d1a33..20b3142d 100644 --- a/app/src/main/cpp/netcamera/httpclient.cpp +++ b/app/src/main/cpp/netcamera/httpclient.cpp @@ -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& 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& img) diff --git a/app/src/main/cpp/netcamera/httpclient.h b/app/src/main/cpp/netcamera/httpclient.h index 6f8c3186..496c8515 100644 --- a/app/src/main/cpp/netcamera/httpclient.h +++ b/app/src/main/cpp/netcamera/httpclient.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #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& data); -int DoPutRequest(const char* url, int authType, const char* userName, const char* password, net_handle_t netHandle, const char* contents, std::vector& 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__ \ No newline at end of file diff --git a/app/src/main/cpp/netcamera/netcamera.h b/app/src/main/cpp/netcamera/netcamera.h index 9f0ab52e..1c6cab76 100644 --- a/app/src/main/cpp/netcamera/netcamera.h +++ b/app/src/main/cpp/netcamera/netcamera.h @@ -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& 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 {