|
|
|
@ -257,7 +257,6 @@ void CPhoneDevice::CPhoneCamera::onDisconnected(ACameraDevice* device)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CPhoneDevice::CJpegCamera::CJpegCamera(CPhoneDevice* dev, int32_t width, int32_t height, const std::string& path, const NdkCamera::CAMERA_PARAMS& params) : CPhoneDevice::CPhoneCamera(dev, width, height, params), m_path(path)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
@ -391,7 +390,8 @@ std::mutex CPhoneDevice::m_powerLocker;
|
|
|
|
|
long CPhoneDevice::mCameraPowerCount = 0;
|
|
|
|
|
long CPhoneDevice::mOtgCount = 0;
|
|
|
|
|
|
|
|
|
|
CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir) : mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL)
|
|
|
|
|
CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPath, unsigned int netId, unsigned int versionCode, const std::string& nativeLibDir)
|
|
|
|
|
: mVersionCode(versionCode), m_nativeLibraryDir(nativeLibDir), m_network(NULL), m_netHandle(NETWORK_UNSPECIFIED)
|
|
|
|
|
{
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
m_listener = NULL;
|
|
|
|
@ -1418,17 +1418,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
mPath = path;
|
|
|
|
|
mOsds = osds;
|
|
|
|
|
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
if (photoInfo.mediaType == 0) {
|
|
|
|
|
// CameraPhotoCmd(time(NULL), channel, MOVE_PRESETNO, 0, type);
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
|
|
|
time_t ts = time(NULL);
|
|
|
|
|
CameraPhotoCmd(ts, photoInfo.channel, 0, 6, 0);
|
|
|
|
|
TakePTZPhotoCb(3, photoInfo);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
|
|
if (photoInfo.cameraType == CAM_TYPE_USB || photoInfo.cameraType == CAM_TYPE_NET)
|
|
|
|
@ -1519,18 +1508,64 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
{
|
|
|
|
|
pThis->SetStaticIp();
|
|
|
|
|
|
|
|
|
|
net_handle_t netHandle = pThis->GetNetHandle();
|
|
|
|
|
|
|
|
|
|
if (netHandle == 0)
|
|
|
|
|
{
|
|
|
|
|
// Wait about 10s
|
|
|
|
|
for (int idx = 0; idx < 84; idx++)
|
|
|
|
|
{
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(128));
|
|
|
|
|
netHandle = pThis->GetNetHandle();
|
|
|
|
|
|
|
|
|
|
NET_PHOTO_INFO netPhotoInfo = { 0 };
|
|
|
|
|
if (netHandle != 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (netHandle == 0)
|
|
|
|
|
{
|
|
|
|
|
// timeout
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Ethernet not existing CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.channel, (uint32_t)photoInfo.preset, photoInfo.photoId);
|
|
|
|
|
pThis->TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NET_PHOTO_INFO netPhotoInfo = { netHandle, 0 };
|
|
|
|
|
if (localPhotoInfo.vendor == 1)
|
|
|
|
|
{
|
|
|
|
|
// Hai Kang
|
|
|
|
|
snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/ISAPI/Streaming/channels/%u/picture", (uint32_t)localPhotoInfo.channel);
|
|
|
|
|
}
|
|
|
|
|
else if (localPhotoInfo.vendor == 2)
|
|
|
|
|
{
|
|
|
|
|
// Hang Yu
|
|
|
|
|
strcpy(netPhotoInfo.url, "/cgi-bin/snapshot.cgi");
|
|
|
|
|
}
|
|
|
|
|
else if (localPhotoInfo.vendor == 3)
|
|
|
|
|
{
|
|
|
|
|
// Yu Shi
|
|
|
|
|
int streamSid = 0; // should put into config
|
|
|
|
|
snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/LAPI/V1.0/Channels/%u/Media/Video/Streams/%d/Snapshot", (uint32_t)localPhotoInfo.channel, streamSid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Vendor(%u) not Supported CH=%u PR=%X PHOTOID=%u", (uint32_t)localPhotoInfo.vendor, (uint32_t)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
|
pThis->TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
addr.s_addr = localPhotoInfo.ip;
|
|
|
|
|
strcpy(netPhotoInfo.ip, inet_ntoa(addr));
|
|
|
|
|
strcpy(netPhotoInfo.url, "/cgi-bin/snapshot.cgi");
|
|
|
|
|
strcpy(netPhotoInfo.outputPath, path.c_str());
|
|
|
|
|
|
|
|
|
|
// strcpy(netPhotoInfo.interface, "eth0");
|
|
|
|
|
|
|
|
|
|
std::vector<uint8_t> img;
|
|
|
|
|
bool res = nc_hy::requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
|
|
|
|
|
bool res = requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
|
|
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
|
{
|
|
|
|
@ -1552,7 +1587,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
|
|
|
|
|
cv::Mat rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb);
|
|
|
|
|
// cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
res = pThis->PostProcessPhoto(localPhotoInfo, osds, path, "", rgb);
|
|
|
|
@ -1567,7 +1602,13 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
}
|
|
|
|
|
else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// if (photoInfo.mediaType == 0) {
|
|
|
|
|
// CameraPhotoCmd(time(NULL), channel, MOVE_PRESETNO, 0, type);
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::seconds(2));
|
|
|
|
|
time_t ts = time(NULL);
|
|
|
|
|
CameraPhotoCmd(ts, photoInfo.channel, 0, 6, 0);
|
|
|
|
|
TakePTZPhotoCb(3, photoInfo);
|
|
|
|
|
res = true;
|
|
|
|
|
}
|
|
|
|
|
else if (mPhotoInfo.usingSysCamera == 1)
|
|
|
|
|
{
|
|
|
|
@ -1648,7 +1689,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::CloseCamera()
|
|
|
|
@ -3260,6 +3300,23 @@ void CPhoneDevice::UpdateSimcard(const std::string& simcard)
|
|
|
|
|
m_simcard = simcard;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::UpdateEthernet(net_handle_t nethandle, bool available)
|
|
|
|
|
{
|
|
|
|
|
m_devLocker.lock();
|
|
|
|
|
m_netHandle = available ? nethandle : NETWORK_UNSPECIFIED;
|
|
|
|
|
m_devLocker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
net_handle_t CPhoneDevice::GetNetHandle() const
|
|
|
|
|
{
|
|
|
|
|
net_handle_t nethandle = NETWORK_UNSPECIFIED;
|
|
|
|
|
m_devLocker.lock();
|
|
|
|
|
nethandle = m_netHandle;
|
|
|
|
|
m_devLocker.unlock();
|
|
|
|
|
return nethandle;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip, const std::string& netmask, const std::string& gateway)
|
|
|
|
|
{
|
|
|
|
|
JNIEnv* env = NULL;
|
|
|
|
@ -3276,10 +3333,10 @@ void CPhoneDevice::SetStaticIp(const std::string& iface, const std::string& ip,
|
|
|
|
|
jstring jnetmask = env->NewStringUTF(netmask.c_str());
|
|
|
|
|
jstring jgw = env->NewStringUTF(gateway.c_str());
|
|
|
|
|
env->CallVoidMethod(m_javaService, mSetStaticIpMid, jiface, jip, jnetmask, jgw);
|
|
|
|
|
env->DeleteLocalRef(jgw);
|
|
|
|
|
env->DeleteLocalRef(jnetmask);
|
|
|
|
|
env->DeleteLocalRef(jip);
|
|
|
|
|
env->DeleteLocalRef(jiface);
|
|
|
|
|
// env->DeleteLocalRef(jgw);
|
|
|
|
|
// env->DeleteLocalRef(jnetmask);
|
|
|
|
|
// env->DeleteLocalRef(jip);
|
|
|
|
|
// env->DeleteLocalRef(jiface);
|
|
|
|
|
|
|
|
|
|
if (didAttachThread)
|
|
|
|
|
{
|
|
|
|
|