From ec6a27df28f55df6e218b3367a387fe492c2b718 Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Wed, 23 Apr 2025 18:53:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=88=AA=E7=85=9COSD=E5=92=8C=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 | 8 ++++++-- app/src/main/cpp/netcamera/HangYuCtrl.cpp | 4 ++-- app/src/main/cpp/netcamera/HangYuCtrl.h | 3 +-- app/src/main/cpp/netcamera/VendorCtrl.h | 1 + app/src/main/cpp/netcamera/YuShiCtrl.cpp | 5 +++++ app/src/main/cpp/netcamera/YuShiCtrl.h | 1 + 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index b3635549..4eabdb53 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1667,7 +1667,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c { // Hang Yu strcpy(netPhotoInfo.url, "/cgi-bin/snapshot.cgi"); - vendorCtrl->EnableOsd(false, localPhotoInfo.channel); } else if (localPhotoInfo.vendor == 3) { @@ -1684,6 +1683,7 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c // http://192.168.1.101/Snapshot/1/2/RemoteImageCaptureV2?ImageFormat=jpg // http://192.168.1.101/Snapshot/1/1/RemoteImageCaptureV2?ImageFormat=jpg snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/Snapshot/%u/1/RemoteImageCaptureV2?ImageFormat=jpg", (uint32_t)localPhotoInfo.cameraId); + vendorCtrl->EnableOsd(false, localPhotoInfo.cameraId); } else { @@ -1866,7 +1866,11 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c } if(localPhotoInfo.vendor == 5) - vendorCtrl->SetOsd(localPhotoInfo.channel, osds[0].text, 0); + { + vendorCtrl->SetOsd(localPhotoInfo.cameraId, osds[0].text, 0); + vendorCtrl->SetResolution(localPhotoInfo.cameraId, 1, localPhotoInfo.width, localPhotoInfo.height); + } + std::string streamingUrl = vendorCtrl->GetStreamingUrl(localPhotoInfo.cameraId); diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.cpp b/app/src/main/cpp/netcamera/HangYuCtrl.cpp index 539a2e72..6f06bbac 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.cpp +++ b/app/src/main/cpp/netcamera/HangYuCtrl.cpp @@ -17,7 +17,7 @@ bool HangYuCtrl::SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, { //流类型范围1-4,1为主流 char url[128] = { 0 }; - snprintf(url, sizeof(url), "http://%s/Streams/%u/%u", m_ip.c_str(), (uint32_t)channel, (uint32_t)streamID); + snprintf(url, sizeof(url), "http://%s/Streams/%u/1", m_ip.c_str(), (uint32_t)channel); std::vector resData; @@ -61,7 +61,7 @@ bool HangYuCtrl::SetOsd(uint8_t channel, std::string osdstring, uint8_t pos) size_t posi = osdstring.find("$$DATETIME$$"); if (posi != std::string::npos) { size_t endPos = posi + 12; - while (endPos < osdstring.size() && osdstring[endPos] == ' ') { + while (endPos < osdstring.size() && (osdstring[endPos] == ' ' || osdstring[endPos] == '\n')) { endPos++; } osdstring.erase(posi, endPos - posi); diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.h b/app/src/main/cpp/netcamera/HangYuCtrl.h index 2d02729f..1188400c 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.h +++ b/app/src/main/cpp/netcamera/HangYuCtrl.h @@ -20,9 +20,8 @@ public: virtual bool TakePhoto(std::vector& img); virtual bool TakeVideo(uint32_t duration, std::string path); virtual bool HasAuthOnStreaming() const { return true; } + virtual bool SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, uint32_t resY); -private: - bool SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, uint32_t resY); }; diff --git a/app/src/main/cpp/netcamera/VendorCtrl.h b/app/src/main/cpp/netcamera/VendorCtrl.h index 7018a21c..bb9b28f9 100644 --- a/app/src/main/cpp/netcamera/VendorCtrl.h +++ b/app/src/main/cpp/netcamera/VendorCtrl.h @@ -26,6 +26,7 @@ public: virtual bool TakePhoto(std::vector& img) = 0; virtual bool TakeVideo(uint32_t duration, std::string path) = 0; virtual bool HasAuthOnStreaming() const { return false; } + virtual bool SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, uint32_t resY) = 0; protected: diff --git a/app/src/main/cpp/netcamera/YuShiCtrl.cpp b/app/src/main/cpp/netcamera/YuShiCtrl.cpp index 1943300d..1599ee04 100644 --- a/app/src/main/cpp/netcamera/YuShiCtrl.cpp +++ b/app/src/main/cpp/netcamera/YuShiCtrl.cpp @@ -13,6 +13,11 @@ YuShiCtrl::~YuShiCtrl() } +bool YuShiCtrl::SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, uint32_t resY) +{ + return false; +} + bool YuShiCtrl::SetOsd(uint8_t channel, std::string osd, uint8_t pos) { // /LAPI/V1.0/Channels//Media/OSDs/Contents diff --git a/app/src/main/cpp/netcamera/YuShiCtrl.h b/app/src/main/cpp/netcamera/YuShiCtrl.h index 0f2d1b26..d8d17bdf 100644 --- a/app/src/main/cpp/netcamera/YuShiCtrl.h +++ b/app/src/main/cpp/netcamera/YuShiCtrl.h @@ -19,6 +19,7 @@ public: virtual bool UpdateTime(time_t ts); virtual bool TakePhoto(std::vector& img); virtual bool TakeVideo(uint32_t duration, std::string path); + virtual bool SetResolution(uint8_t channel, uint8_t streamID, uint32_t resX, uint32_t resY); private: void OSDJson(int id, bool enabled, std::string osdString, int x, int y, bool timeOn, std::string& jsonString); From 167878de1ab2a7e6137ab4d8af84015bc8021f7b Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Wed, 23 Apr 2025 19:33:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E8=88=AA=E7=85=9C=E8=A7=86=E9=A2=91=E9=99=A4=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=A4=96=E6=B0=B4=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/netcamera/HangYuCtrl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.cpp b/app/src/main/cpp/netcamera/HangYuCtrl.cpp index 6f06bbac..b90e7bfc 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.cpp +++ b/app/src/main/cpp/netcamera/HangYuCtrl.cpp @@ -71,7 +71,6 @@ bool HangYuCtrl::SetOsd(uint8_t channel, std::string osdstring, uint8_t pos) snprintf(url, sizeof(url), "http://%s/Pictures/%u/MultiOSDV2", m_ip.c_str(), (uint32_t)channel); std::vector resData; std::replace(osdstring.begin(), osdstring.end(), '\n', '^'); - string xmlString = "" + string(hasDateTime ? "true" : "false") + "801true"+ osdstring+ "8" + string(hasDateTime ? "24" : "0") + ""; int res = DoPutRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, xmlString.c_str(), resData); return res; } From cafa30c728cf0929acb0370fb6fcb1cd771916b9 Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Wed, 23 Apr 2025 19:34:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E8=88=AA=E7=85=9C=E8=A7=86=E9=A2=91=E9=99=A4=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=A4=96=E6=B0=B4=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/netcamera/HangYuCtrl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.cpp b/app/src/main/cpp/netcamera/HangYuCtrl.cpp index b90e7bfc..44effbc2 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.cpp +++ b/app/src/main/cpp/netcamera/HangYuCtrl.cpp @@ -71,6 +71,7 @@ bool HangYuCtrl::SetOsd(uint8_t channel, std::string osdstring, uint8_t pos) snprintf(url, sizeof(url), "http://%s/Pictures/%u/MultiOSDV2", m_ip.c_str(), (uint32_t)channel); std::vector resData; std::replace(osdstring.begin(), osdstring.end(), '\n', '^'); + string xmlString = "" + string(hasDateTime ? "true" : "false") + "801false"+ osdstring+ "8" + string(hasDateTime ? "24" : "0") + ""; int res = DoPutRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, xmlString.c_str(), resData); return res; }