media: Add a metadata type for native handle from camera
A payload of type kMetadataBufferTypeNativeHandleSource will
correspond to VideoNativeHandleMetadata which contains a
native_handle_t.
Bug: 26268807
Change-Id: I9805fc74c4b086b65ad57ac06385e12f255ada5b
diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h
index 1008c22..b1dd062 100644
--- a/include/media/hardware/HardwareAPI.h
+++ b/include/media/hardware/HardwareAPI.h
@@ -120,6 +120,17 @@
int nFenceFd; // -1 if unused
};
+// Meta data buffer layout for passing a native_handle to codec
+struct VideoNativeHandleMetadata {
+ MetadataBufferType eType; // must be kMetadataBufferTypeNativeHandleSource
+
+#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
+ OMX_PTR pHandle;
+#else
+ native_handle_t *pHandle;
+#endif
+};
+
// A pointer to this struct is passed to OMX_SetParameter() when the extension
// index "OMX.google.android.index.prepareForAdaptivePlayback" is given.
//
diff --git a/include/media/hardware/MetadataBufferType.h b/include/media/hardware/MetadataBufferType.h
index b765203..4f6d5e2 100644
--- a/include/media/hardware/MetadataBufferType.h
+++ b/include/media/hardware/MetadataBufferType.h
@@ -111,6 +111,28 @@
*/
kMetadataBufferTypeANWBuffer = 2,
+ /*
+ * kMetadataBufferTypeNativeHandleSource is used to indicate that
+ * the payload of the metadata buffers can be interpreted as
+ * a native_handle_t.
+ *
+ * In this case, the metadata that the encoder receives
+ * will have a byte stream that consists of two parts:
+ * 1. First, there is an integer indicating that the metadata contains a
+ * native handle (kMetadataBufferTypeNativeHandleSource).
+ * 2. This is followed by a pointer to native_handle_t. The encoder needs
+ * to interpret this native handle and encode the frame. The encoder must
+ * not free this native handle as it does not actually own this native
+ * handle. The handle will be freed after the encoder releases the buffer
+ * back to camera.
+ * ----------------------------------------------------------------
+ * | kMetadataBufferTypeNativeHandleSource | native_handle_t* nh |
+ * ----------------------------------------------------------------
+ *
+ * See the VideoNativeHandleMetadata structure.
+ */
+ kMetadataBufferTypeNativeHandleSource = 3,
+
/* This value is used by framework, but is never used inside a metadata buffer */
kMetadataBufferTypeInvalid = -1,