From c8966009b85d37c015d58cba491df5a319e44f46 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 20 Mar 2025 09:35:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=A7=86=E9=A2=91=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 24 +++++++++++++++-------- app/src/main/cpp/netcamera/HangYuCtrl.cpp | 10 +++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 26f01981..a3b7ff1b 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1936,13 +1936,12 @@ bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std: return false; } - StreamForwarder* forwarder = new StreamForwarder(); + RtspForwarder* forwarder = new RtspForwarder(streamingUrl, url); - // Initialize with RTSP input and RTMP output - if (!forwarder->initialize(streamingUrl, url)) { - std::cerr << "Failed to initialize stream forwarder" << std::endl; - delete forwarder; - return -1; + bool res = false; + if (vendorCtrl->HasAuthOnStreaming()) + { + forwarder->setAuth(photoInfo.userName, photoInfo.password); } STREAMING_CONTEXT ctx; @@ -1960,8 +1959,16 @@ bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std: #endif // Start forwarding - forwarder->start(); - + res = forwarder->start(); +#if 0 + // Initialize with RTSP input and RTMP output + if (!res) + { + XYLOG(XYLOG_SEVERITY_ERROR, "TP: Failed to open stream: %s (%u/%02X) PHOTOID=%u", streamingUrl.c_str(), (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId); + delete forwarder; + return -1; + } +#endif // Wait for user input to stop // std::cout << "Press Enter to stop streaming..." << std::endl; // std::cin.get(); @@ -2284,6 +2291,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< std::thread t([localPhotoInfo, path, pThis, osds, powerCtrlPtr]() mutable { + pThis->TakePhotoCb(1, localPhotoInfo, "", 0); pThis->StartPushStreaming(localPhotoInfo, path, osds, powerCtrlPtr); }); diff --git a/app/src/main/cpp/netcamera/HangYuCtrl.cpp b/app/src/main/cpp/netcamera/HangYuCtrl.cpp index e015bd00..d6fca518 100644 --- a/app/src/main/cpp/netcamera/HangYuCtrl.cpp +++ b/app/src/main/cpp/netcamera/HangYuCtrl.cpp @@ -32,7 +32,15 @@ std::string HangYuCtrl::GetStreamingUrl(uint8_t channel) std::vector resData; - int res = DoGetRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, resData); + int res = 0; + for (int idx = 0; idx < 10; idx++) + { + res = DoGetRequest(url, HTTP_AUTH_TYPE_BASIC, m_userName.c_str(), m_password.c_str(), m_netHandle, resData); + if (res == 0 && !resData.empty()) + { + break; + } + } if (res != 0 || resData.empty()) { return "";