From 2d67c94bc9cc4785ee621769c0575d96da47b09e Mon Sep 17 00:00:00 2001 From: "XI.CHEN" <2311041011@qq.com> Date: Wed, 23 Apr 2025 11:56:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=AA=E7=85=9C=E8=A7=86=E9=A2=91=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0=E6=A0=B9=E6=8D=AE=E6=97=B6=E9=97=B4=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 7 +++++++ app/src/main/cpp/netcamera/HangYuCtrl.cpp | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index f1e1c5c1..b3635549 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1653,6 +1653,9 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c // SetStaticIp(); std::this_thread::sleep_for(std::chrono::milliseconds(256)); + std::string ip = GetIpStr(localPhotoInfo.ip); + VendorCtrl* vendorCtrl = MakeVendorCtrl(localPhotoInfo.vendor, localPhotoInfo.channel, ip, localPhotoInfo.userName, localPhotoInfo.password, netHandle); + NET_PHOTO_INFO netPhotoInfo = { netHandle, 0 }; if (localPhotoInfo.vendor == 1) { @@ -1664,6 +1667,7 @@ 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) { @@ -1861,6 +1865,9 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c return false; } + if(localPhotoInfo.vendor == 5) + vendorCtrl->SetOsd(localPhotoInfo.channel, osds[0].text, 0); + std::string streamingUrl = vendorCtrl->GetStreamingUrl(localPhotoInfo.cameraId); if (streamingUrl.empty()) diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.cpp b/app/src/main/cpp/netcamera/HangYuCtrl.cpp index 2bd71214..539a2e72 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.cpp +++ b/app/src/main/cpp/netcamera/HangYuCtrl.cpp @@ -56,11 +56,22 @@ bool HangYuCtrl::SetOsd(uint8_t channel, std::string osdstring, uint8_t pos) { // /LAPI/V1.0/Channels//Media/OSDs/Contents //左上OSD + + bool hasDateTime = (osdstring.find("$$DATETIME$$") != std::string::npos); + size_t posi = osdstring.find("$$DATETIME$$"); + if (posi != std::string::npos) { + size_t endPos = posi + 12; + while (endPos < osdstring.size() && osdstring[endPos] == ' ') { + endPos++; + } + osdstring.erase(posi, endPos - posi); + } + char url[128] = { 0 }; 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 = "true801true"+ osdstring+ "824"; + 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; }