优化错误处理

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);
img.clear();
netCaptureResult = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
if (netCaptureResult)
{
XYLOG(XYLOG_SEVERITY_INFO, "NetCapture Succeeded PHOTOID=%u Img Size=%u", localPhotoInfo.photoId, (uint32_t)img.size());
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;
if(localPhotoInfo.scheduleTime != 0)
{
takingTime = localPhotoInfo.scheduleTime;
}
if (localPhotoInfo.remedy != 0)
{
if ((takingTime - localPhotoInfo.scheduleTime) > 30)
@ -1614,7 +1624,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// Notify to take next photo
TakePhotoCb(1, localPhotoInfo, "", takingTime);
cv::Mat rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
#ifdef _DEBUG
// cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb);
#endif

@ -1,6 +1,8 @@
#include "httpclient.h"
#include "netcamera.h"
#include <LogThread.h>
#include <errno.h>
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);
if (responseCode != 200)
{
#ifdef _DEBUG
char * log = new char[data.size() + 1];
log[data.size()] = 0;
memcpy(log, &data[0], data.size());
printf("%s", log);
// #ifdef _DEBUG
char * log = new char[data.size() + 16];
memset(&log[0], 0, data.size());
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;
#endif
// #endif
}
}
else

Loading…
Cancel
Save