diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index b3577e12..9ba6652a 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -1362,7 +1362,6 @@ Java_com_xypower_mpapp_MicroPhotoService_updateEhernet( return JNI_TRUE; } - extern "C" JNIEXPORT jboolean JNICALL Java_com_xypower_mpapp_MicroPhotoService_updateActiveNetwork( JNIEnv* env, jobject pThis, jlong handle, jlong networkHandle, jboolean available) { @@ -1381,4 +1380,25 @@ Java_com_xypower_mpapp_MicroPhotoService_updateActiveNetwork( } return JNI_TRUE; -} \ No newline at end of file +} + + +extern "C" JNIEXPORT jlong JNICALL +Java_com_xypower_mpapp_MicroPhotoService_requestPowerControl( + JNIEnv* env, jclass cls, jint type) { + if (type == 1) // Net + { + NetCameraPowerCtrl* powerControl = new NetCameraPowerCtrl(2); + return reinterpret_cast(powerControl); + } + + return 0L; +} + +extern "C" JNIEXPORT jlong JNICALL +Java_com_xypower_mpapp_MicroPhotoService_releasePowerControl( + JNIEnv* env, jclass cls, jlong powerControlHandle) { + + PowerControl* powerControl = reinterpret_cast(powerControlHandle); + delete powerControl; +} diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 8ebaf19d..45cbe277 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1686,6 +1686,11 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c return true; } +bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& localPhotoInfo, const std::string& url, std::vector& osds, std::shared_ptr powerCtrlPtr) +{ + return true; +} + bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const std::string& path) { if (photoInfo.width == 0 || photoInfo.height == 0) @@ -1973,6 +1978,24 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< t.detach(); } + else if ((mPhotoInfo.mediaType == XY_MEDIA_TYPE_STREAM || mPhotoInfo.mediaType == XY_MEDIA_TYPE_STREAM_OFF) && (mPhotoInfo.cameraType == CAM_TYPE_NET || mPhotoInfo.cameraType == CAM_TYPE_PLZ)) + { + XYLOG(XYLOG_SEVERITY_INFO, "Start TP(Streaming) CH=%u PR=%X PHOTOID=%u", (uint32_t)mPhotoInfo.channel, (uint32_t)mPhotoInfo.preset, mPhotoInfo.photoId); + + // Start Thread + CPhoneDevice* pThis = this; + + vector osds; + osds.swap(mOsds); + IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo; + + std::thread t([localPhotoInfo, path, pThis, osds, powerCtrlPtr]() mutable + { + pThis->StartPushStreaming(localPhotoInfo, path, osds, powerCtrlPtr); + }); + + t.detach(); + } else if (mPhotoInfo.usingSysCamera == 1) { JNIEnv* env = NULL; @@ -3964,6 +3987,7 @@ int CPhoneDevice::GetSerialPhoto(int devno, D_IMAGE_DEF *photo) return GetImage(devno, (IMAGE_DEF*)photo); } + void CPhoneDevice::InitSerialComm(D_SENSOR_PARAM *sensorParam, char *filedir,const char *logpath) { Gm_InitSerialComm((SENSOR_PARAM *)sensorParam, filedir, logpath); diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index a1476058..cc9c8b23 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -273,6 +273,7 @@ protected: // bool MatchCaptureSizeRequest(ACameraManager *cameraManager, const char *selectedCameraId, unsigned int width, unsigned int height, uint32_t cameraOrientation_, bool TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, const std::string& path, std::vector& osds, std::shared_ptr powerCtrlPtr); + bool StartPushStreaming(IDevice::PHOTO_INFO& localPhotoInfo, const std::string& url, std::vector& osds, std::shared_ptr powerCtrlPtr); bool PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector& osds, const std::string& path, const std::string& cameraInfo, cv::Mat mat); inline bool TakePhotoCb(int res, const IDevice::PHOTO_INFO& photoInfo, const string& path, time_t photoTime, const std::vector& objects) const { diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 374eb8e9..f0c312e8 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -1679,6 +1679,9 @@ cellSignalStrengthGsm.getDbm(); public static native boolean exportPublicKeyFile(int index, String outputPath); public static native boolean exportPrivateFile(int index, String outputPath); + public static native long requestPowerControl(int type); + public static native long releasePowerControl(long powerControlHandle); + ////////////////////////GPS//////////////////// // private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER; private LocationManager mLocationManager;