RAW格式拍照的相关实现

TempBranch
Matthew 9 months ago
parent 4a154984f4
commit bba323a08a

@ -92,6 +92,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.MicroPhoto"
tools:targetApi="28">
<activity
android:name=".RawActivity"
android:exported="false"
android:screenOrientation="landscape" />
<activity
android:name=".StreamActivity"
android:exported="false"

@ -711,7 +711,7 @@ Java_com_xypower_mpapp_MicroPhotoService_getNextScheduleItem(
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
JNIEnv* env,
jobject pThis, jlong handler, jboolean result, jstring path, jlong videoId) {
jobject pThis, jlong handler, jboolean photoOrVideo, jboolean result, jstring path, jlong videoId) {
CTerminal* pTerminal = reinterpret_cast<CTerminal *>(handler);
if (pTerminal == NULL)
@ -730,7 +730,7 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
// camera->Open(pathStr, fileNameStr);
unsigned long photoId = videoId;
((CPhoneDevice *)dev)->OnVideoReady(result != JNI_FALSE, pathStr, photoId);
((CPhoneDevice *)dev)->OnVideoReady(photoOrVideo != JNI_FALSE, result != JNI_FALSE, pathStr, photoId);
if (path != NULL)
{
env->ReleaseStringUTFChars(path, pathStr);

@ -321,7 +321,7 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
mRegisterHeartbeatMid = env->GetMethodID(classService, "registerHeartbeatTimer", "(IJ)V");
mUpdateTimeMid = env->GetMethodID(classService, "updateTime", "(J)Z");
mUpdateCaptureScheduleMid = env->GetMethodID(classService, "updateCaptureSchedule", "(J)Z");
mStartRecordingMid = env->GetMethodID(classService, "startRecording", "(IJIIIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
mStartRecordingMid = env->GetMethodID(classService, "startRecording", "(ZIJIIIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
mRequestWakelockMid = env->GetMethodID(classService, "requestWakelock", "(Ljava/lang/String;J)V");
mReleaseWakelockMid = env->GetMethodID(classService, "releaseWakelock", "(Ljava/lang/String;)V");
@ -1395,8 +1395,10 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
}
int orientation = mPhotoInfo.orientation == 0 ? -1 : (mPhotoInfo.orientation - 1) * 90;
env->CallVoidMethod(m_javaService, mStartRecordingMid, mPhotoInfo.cameraId, (unsigned long)mPhotoInfo.photoId, mPhotoInfo.duration, mPhotoInfo.width, mPhotoInfo.height,
mPhotoInfo.duration, orientation, leftTopOSD, rightTopOSD, rightBottomOSD, leftBottomOSD);
jboolean photoOrVideo = JNI_FALSE;
env->CallVoidMethod(m_javaService, mStartRecordingMid, photoOrVideo, mPhotoInfo.cameraId, (unsigned long)mPhotoInfo.photoId,
mPhotoInfo.duration, mPhotoInfo.width, mPhotoInfo.height,mPhotoInfo.duration, orientation,
leftTopOSD, rightTopOSD, rightBottomOSD, leftBottomOSD);
if (leftTopOSD) env->DeleteLocalRef(leftTopOSD);
if (rightTopOSD) env->DeleteLocalRef(rightTopOSD);
@ -1786,7 +1788,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
return res;
}
bool CPhoneDevice::OnVideoReady(bool result, const char* path, unsigned int photoId)
bool CPhoneDevice::OnVideoReady(bool photoOrVideo, bool result, const char* path, unsigned int photoId)
{
mPhotoInfo.photoTime = time(NULL);

@ -219,7 +219,8 @@ public:
bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector<uint32_t>& items);
void UpdatePosition(double lon, double lat, double radius, time_t ts);
bool OnVideoReady(bool result, const char* path, unsigned int photoId);
bool OnVideoReady(bool photoOrVideo, bool result, const char* path, unsigned int photoId);
void UpdateSignalLevel(int signalLevel);
void UpdateTfCardPath(const std::string& tfCardPath)
{

@ -391,12 +391,13 @@ public class MicroPhotoService extends Service {
mService.reloadConfigs(mService.mNativeHandle);
}
} else if (TextUtils.equals(ACTION_VIDEO_FINISHED, action)) {
boolean photoOrVideo = intent.getBooleanExtra("photoOrVideo", false);
boolean result = intent.getBooleanExtra("result", false);
String path = intent.getStringExtra("path");
long videoId = intent.getLongExtra("videoId", 0);
Log.i(TAG, "Recording received(" + Long.toString(videoId) + "):" + path);
mService.recordingFinished(mService.mNativeHandle, result, path, videoId);
mService.recordingFinished(mService.mNativeHandle, photoOrVideo, result, path, videoId);
} else if (TextUtils.equals(ACTION_STOP, action)) {
mService.stopTerminalService();
} else if (TextUtils.equals(ACTION_IMP_PUBKRY, action)) {
@ -509,7 +510,7 @@ public class MicroPhotoService extends Service {
registerPhotoTimer(getApplicationContext(), scheduleTime, scheduleTime, timeout, schedules);
}
public void startRecording(int cameraId, long videoId, int duration, int width, int height, int quality, int orientation, String leftTopOsd, String rightTopOsd, String rightBottomOsd, String leftBottomOsd) {
public void startRecording(boolean photoOrVideo, int cameraId, long videoId, int duration, int width, int height, int quality, int orientation, String leftTopOsd, String rightTopOsd, String rightBottomOsd, String leftBottomOsd) {
Context context = getApplicationContext();
// Intent intent = new Intent(this, VideoActivity.class);
Intent intent = makeRecordingIntent(context, cameraId, videoId, duration, width, height, quality, orientation,
@ -1203,7 +1204,7 @@ cellSignalStrengthGsm.getDbm();
protected native boolean reloadConfigs(long handler);
protected native void updatePosition(long handler, double lon, double lat, double radius, long ts);
protected native boolean uninit(long handler);
protected native void recordingFinished(long handler, boolean result, String path, long videoId);
protected native void recordingFinished(long handler, boolean photoOrVideo, boolean result, String path, long videoId);
public static native long takePhoto(int channel, int preset, boolean photoOrVideo, String configFilePath, String path);
public static native void releaseDeviceHandle(long deviceHandle);
public static native boolean sendExternalPhoto(long deviceHandle, String path);

@ -838,6 +838,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
Intent intent = new Intent(ACTION_MP_VIDEO_FINISHED);
// intent.setPackage(packageName);
intent.putExtra("photoOrVideo", false);
intent.putExtra("result", result);
intent.putExtra("path", path);
intent.putExtra("videoId", mVideoId);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".video.RawActivity">
<com.xypower.mpapp.video.AutoFitTextureView
android:id="@+id/texture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save