media c2.aidl: Add IPooledGraphicBufferAllocator support
Support media.bufferpool2 based output graphic buffer allocator.
Bug: 254050314
Change-Id: I7f21f08582d09b76e9222e002e02a8d8794f08b5
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
index 4439bc5..0a7e3c4 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponent.aidl
@@ -51,12 +51,18 @@
long blockPoolId;
android.hardware.media.c2.IConfigurable configurable;
}
- parcelable C2AidlGbAllocator {
- android.hardware.media.c2.IGraphicBufferAllocator igba;
+ parcelable GbAllocator {
ParcelFileDescriptor waitableFd;
+ android.hardware.media.c2.IGraphicBufferAllocator igba;
}
- union BlockPoolAllocator {
+ parcelable PooledGbAllocator {
+ ParcelFileDescriptor waitableFd;
+ long receiverId;
+ android.hardware.media.c2.IPooledGraphicBufferAllocator ipgba;
+ }
+ parcelable BlockPoolAllocator {
int allocatorId;
- android.hardware.media.c2.IComponent.C2AidlGbAllocator allocator;
+ @nullable android.hardware.media.c2.IComponent.GbAllocator gbAllocator;
+ @nullable android.hardware.media.c2.IComponent.PooledGbAllocator pooledGbAllocator;
}
}
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl
new file mode 100644
index 0000000..1a8c66d
--- /dev/null
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.media.c2;
+@VintfStability
+interface IPooledGraphicBufferAllocator {
+ android.hardware.media.c2.IPooledGraphicBufferAllocator.Allocation allocate(in android.hardware.media.c2.IPooledGraphicBufferAllocator.Description desc);
+ boolean deallocate(in int id);
+ parcelable Allocation {
+ int bufferId;
+ @nullable ParcelFileDescriptor fence;
+ }
+ parcelable Description {
+ int widthPixels;
+ int heightPixels;
+ int format;
+ long usage;
+ }
+}
diff --git a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
index 6bd30b4..6bcb5ff 100644
--- a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl
@@ -23,6 +23,7 @@
import android.hardware.media.c2.IInputSink;
import android.hardware.media.c2.IInputSurface;
import android.hardware.media.c2.IInputSurfaceConnection;
+import android.hardware.media.c2.IPooledGraphicBufferAllocator;
import android.hardware.media.c2.WorkBundle;
import android.os.ParcelFileDescriptor;
@@ -56,20 +57,36 @@
* graphic blocks. the waitable fd is used to create a specific type of
* C2Fence which can be used for waiting until to allocate is not blocked.
*/
- parcelable C2AidlGbAllocator {
- IGraphicBufferAllocator igba;
+ parcelable GbAllocator {
ParcelFileDescriptor waitableFd;
+ IGraphicBufferAllocator igba;
}
/**
+ * C2AIDL allocator interface based on media.bufferpool2 along with a waitable fd.
+ *
+ * The interface is used from a specific type of C2BlockPool to allocate
+ * graphic blocks. the waitable fd is used to create a specific type of
+ * C2Fence which can be used for waiting until to allocate is not blocked.
+ * receiverId is id of receiver IConnection of media.bufferpool2.
+ */
+ parcelable PooledGbAllocator {
+ ParcelFileDescriptor waitableFd;
+ long receiverId;
+ IPooledGraphicBufferAllocator ipgba;
+ }
+
+
+ /**
* Allocator for C2BlockPool.
*
* C2BlockPool will use a C2Allocator which is specified by an id.
- * or C2AIDL allocator interface directly.
+ * Based on allocator id, allocator is specified.
*/
- union BlockPoolAllocator {
+ parcelable BlockPoolAllocator {
int allocatorId;
- C2AidlGbAllocator allocator;
+ @nullable GbAllocator gbAllocator;
+ @nullable PooledGbAllocator pooledGbAllocator;
}
/**
diff --git a/media/c2/aidl/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl b/media/c2/aidl/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl
new file mode 100644
index 0000000..b599d52
--- /dev/null
+++ b/media/c2/aidl/android/hardware/media/c2/IPooledGraphicBufferAllocator.aidl
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.media.c2;
+
+import android.os.ParcelFileDescriptor;
+
+/**
+ * Interface for decoder output buffer allocator for HAL process
+ *
+ * A graphic buffer for decoder output is allocated by the interface.
+ */
+@VintfStability
+interface IPooledGraphicBufferAllocator {
+ /**
+ * A graphic buffer allocation.
+ *
+ * bufferId is id of buffer from a media.bufferpool2. The buffer is
+ * android.hardware.HardwareBuffer.
+ * fence is provided in order to signal readiness of the buffer I/O inside
+ * underlying Graphics subsystem. This is called a sync fence throughout Android framework.
+ */
+ parcelable Allocation {
+ int bufferId;
+ @nullable ParcelFileDescriptor fence;
+ }
+
+ /**
+ * Parameters for a graphic buffer allocation.
+ *
+ * Refer to AHardwareBuffer_Desc(libnativewindow) for details.
+ */
+ parcelable Description {
+ int widthPixels;
+ int heightPixels;
+ int format; // AHardwareBuffer_Format
+ long usage; // AHardwareBuffer_UsageFlags
+ }
+
+ /**
+ * Allocate a graphic buffer.
+ * deallocate() must be called after the allocated buffer is no longer needed.
+ *
+ * @param desc Allocation parameters.
+ * @return an id of a buffer, the id is created from media.bufferpool2 in order for
+ * caching and recycling,
+ * If underlying allocator is blocked, c2::Status::Blocked will be returned.
+ * Waitable fd must be obtained using the ndk object locally. The waitable fd must
+ * be passed to the receiver during BlockPool creation request via AIDL.
+ * @throws ServiceSpecificException with one of the following values:
+ * - `c2::Status::BAD_STATE` - The client is not in running states.
+ * - `c2::Status::BLOCKED` - Underlying graphics system is blocked.
+ * - `c2::Status::CORRUPTED` - Some unknown error occurred.
+ */
+ Allocation allocate(in Description desc);
+
+ /**
+ * De-allocate a graphic buffer by graphic buffer's unique id.
+ *
+ * @param id buffer id.
+ * @return {@code true} when de-allocate happened, {@code false} otherwise.
+ */
+ boolean deallocate(in int id);
+}