优化错误处理

rtmpsuck
Matthew 5 months ago
parent 5d318b62c8
commit dfd970d1a9

@ -1589,18 +1589,28 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG(XYLOG_SEVERITY_INFO, "NetCapture %d NetHandle=%lld PHOTOID=%u", idx, netHandle, localPhotoInfo.photoId); XYLOG(XYLOG_SEVERITY_INFO, "NetCapture %d NetHandle=%lld PHOTOID=%u", idx, netHandle, localPhotoInfo.photoId);
img.clear();
netCaptureResult = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img); netCaptureResult = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
if (netCaptureResult) if (netCaptureResult)
{ {
XYLOG(XYLOG_SEVERITY_INFO, "NetCapture Succeeded PHOTOID=%u Img Size=%u", localPhotoInfo.photoId, (uint32_t)img.size());
break; break;
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
} }
if (netCaptureResult) cv::Mat rgb;
if (netCaptureResult && !img.empty())
{
rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
}
if (!rgb.empty())
{ {
time_t takingTime = ts; time_t takingTime = ts;
if(localPhotoInfo.scheduleTime != 0) if(localPhotoInfo.scheduleTime != 0)
{
takingTime = localPhotoInfo.scheduleTime; takingTime = localPhotoInfo.scheduleTime;
}
if (localPhotoInfo.remedy != 0) if (localPhotoInfo.remedy != 0)
{ {
if ((takingTime - localPhotoInfo.scheduleTime) > 30) if ((takingTime - localPhotoInfo.scheduleTime) > 30)
@ -1614,7 +1624,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// Notify to take next photo // Notify to take next photo
TakePhotoCb(1, localPhotoInfo, "", takingTime); TakePhotoCb(1, localPhotoInfo, "", takingTime);
cv::Mat rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
#ifdef _DEBUG #ifdef _DEBUG
// cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb); // cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb);
#endif #endif

@ -1,6 +1,8 @@
#include "httpclient.h" #include "httpclient.h"
#include "netcamera.h" #include "netcamera.h"
#include <LogThread.h>
#include <errno.h> #include <errno.h>
static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid) static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
@ -86,13 +88,20 @@ int DoGetRequest(const char* url, int authType, const char* userName, const char
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
if (responseCode != 200) if (responseCode != 200)
{ {
#ifdef _DEBUG // #ifdef _DEBUG
char * log = new char[data.size() + 1];
log[data.size()] = 0; char * log = new char[data.size() + 16];
memcpy(log, &data[0], data.size()); memset(&log[0], 0, data.size());
printf("%s", log); snprintf(log, data.size() + 16, "%d", (int)responseCode);
if (!data.empty())
{
strcat(log, " ");
memcpy(&log[strlen(log)], &data[0], data.size());
}
// printf("%s", log);
XYLOG(XYLOG_SEVERITY_ERROR, log);
delete[] log; delete[] log;
#endif // #endif
} }
} }
else else

Loading…
Cancel
Save