Camera: Fix passing video native handle for 64-bit app
Add new binder calls to pass video native handle so the video native
handle can be passed between 32-bit and 64-bit processes.
Remove problematic code that used IMemory to pass video native
handle because the sizes of VideoNativeMetadata are different in
32-bit and 64-bit processes.
Bug: 28403412
Change-Id: I3341b1812ecc41d61846bb72ca926ecb1674c9ec
diff --git a/include/camera/Camera.h b/include/camera/Camera.h
index b45bbfc..be793a2 100644
--- a/include/camera/Camera.h
+++ b/include/camera/Camera.h
@@ -43,6 +43,7 @@
virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr,
camera_frame_metadata_t *metadata) = 0;
virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
+ virtual void postRecordingFrameHandleTimestamp(nsecs_t timestamp, native_handle_t* handle) = 0;
};
class Camera;
@@ -114,6 +115,9 @@
// release a recording frame
void releaseRecordingFrame(const sp<IMemory>& mem);
+ // release a recording frame handle
+ void releaseRecordingFrameHandle(native_handle_t *handle);
+
// autoFocus - status returned from callback
status_t autoFocus();
@@ -161,6 +165,7 @@
virtual void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
camera_frame_metadata_t *metadata);
virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
+ virtual void recordingFrameHandleCallbackTimestamp(nsecs_t timestamp, native_handle_t* handle);
class RecordingProxy : public BnCameraRecordingProxy
{
@@ -171,6 +176,7 @@
virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener);
virtual void stopRecording();
virtual void releaseRecordingFrame(const sp<IMemory>& mem);
+ virtual void releaseRecordingFrameHandle(native_handle_t* handle);
private:
sp<Camera> mCamera;
diff --git a/include/camera/ICameraRecordingProxy.h b/include/camera/ICameraRecordingProxy.h
index 2aac284..cb6824a 100644
--- a/include/camera/ICameraRecordingProxy.h
+++ b/include/camera/ICameraRecordingProxy.h
@@ -18,6 +18,7 @@
#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H
#include <binder/IInterface.h>
+#include <cutils/native_handle.h>
#include <utils/RefBase.h>
namespace android {
@@ -83,6 +84,7 @@
virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener) = 0;
virtual void stopRecording() = 0;
virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
+ virtual void releaseRecordingFrameHandle(native_handle_t *handle) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/camera/ICameraRecordingProxyListener.h b/include/camera/ICameraRecordingProxyListener.h
index b6c0624..1fee5b9 100644
--- a/include/camera/ICameraRecordingProxyListener.h
+++ b/include/camera/ICameraRecordingProxyListener.h
@@ -18,6 +18,7 @@
#define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_LISTENER_H
#include <binder/IInterface.h>
+#include <cutils/native_handle.h>
#include <stdint.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>
@@ -34,6 +35,9 @@
virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,
const sp<IMemory>& data) = 0;
+
+ virtual void recordingFrameHandleCallbackTimestamp(nsecs_t timestamp,
+ native_handle_t* handle) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/camera/android/hardware/ICamera.h b/include/camera/android/hardware/ICamera.h
index 322b741..3b12afe 100644
--- a/include/camera/android/hardware/ICamera.h
+++ b/include/camera/android/hardware/ICamera.h
@@ -94,9 +94,13 @@
// get recording state
virtual bool recordingEnabled() = 0;
- // release a recording frame
+ // Release a recording frame that was received via ICameraClient::dataCallbackTimestamp.
virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
+ // Release a recording frame handle that was received via
+ // ICameraClient::recordingFrameHandleCallbackTimestamp.
+ virtual void releaseRecordingFrameHandle(native_handle_t *handle) = 0;
+
// auto focus
virtual status_t autoFocus() = 0;
diff --git a/include/camera/android/hardware/ICameraClient.h b/include/camera/android/hardware/ICameraClient.h
index d7f9a75..3f835a9 100644
--- a/include/camera/android/hardware/ICameraClient.h
+++ b/include/camera/android/hardware/ICameraClient.h
@@ -36,6 +36,11 @@
virtual void dataCallback(int32_t msgType, const sp<IMemory>& data,
camera_frame_metadata_t *metadata) = 0;
virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& data) = 0;
+
+ // Invoked to send a recording frame handle with a timestamp. Call
+ // ICamera::releaseRecordingFrameHandle to release the frame handle.
+ virtual void recordingFrameHandleCallbackTimestamp(nsecs_t timestamp,
+ native_handle_t* handle) = 0;
};
// ----------------------------------------------------------------------------