diff --git a/media/c2/aidl/Android.bp b/media/c2/aidl/Android.bp index 84cb38298a..b511e45701 100644 --- a/media/c2/aidl/Android.bp +++ b/media/c2/aidl/Android.bp @@ -22,6 +22,9 @@ aidl_interface { "android.hardware.common-V2", "android.hardware.media.bufferpool2-V1", ], + include_dirs: [ + "frameworks/native/aidl/gui", + ], stability: "vintf", backend: { cpp: { 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 7d58340923..4439bc5e43 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 @@ -45,6 +45,8 @@ interface IComponent { void reset(); void start(); void stop(); + android.hardware.media.c2.IInputSurfaceConnection connectToInputSurface(in android.hardware.media.c2.IInputSurface inputSurface); + android.hardware.media.c2.IInputSink asInputSink(); parcelable BlockPool { long blockPoolId; android.hardware.media.c2.IConfigurable configurable; diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl index d1b59157d4..d7a4706d19 100644 --- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl +++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IComponentStore.aidl @@ -41,6 +41,7 @@ interface IComponentStore { android.hardware.media.bufferpool2.IClientManager getPoolClientManager(); android.hardware.media.c2.StructDescriptor[] getStructDescriptors(in int[] indices); android.hardware.media.c2.IComponentStore.ComponentTraits[] listComponents(); + android.hardware.media.c2.IInputSurface createInputSurface(); @VintfStability parcelable ComponentTraits { String name; diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl new file mode 100644 index 0000000000..e6ea4d54e8 --- /dev/null +++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSink.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 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 -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 IInputSink { + void queue(in android.hardware.media.c2.WorkBundle workBundle); +} diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl new file mode 100644 index 0000000000..14455cb71f --- /dev/null +++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurface.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 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 -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 IInputSurface { + android.view.Surface getSurface(); + android.hardware.media.c2.IConfigurable getConfigurable(); + android.hardware.media.c2.IInputSurfaceConnection connect(in android.hardware.media.c2.IInputSink sink); +} diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl new file mode 100644 index 0000000000..28fff65e14 --- /dev/null +++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IInputSurfaceConnection.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2023 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 -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 IInputSurfaceConnection { + void disconnect(); + void signalEndOfStream(); +} diff --git a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl index fc923ab87a..ed2eaf4519 100644 --- a/media/c2/aidl/android/hardware/media/c2/IComponent.aidl +++ b/media/c2/aidl/android/hardware/media/c2/IComponent.aidl @@ -21,6 +21,9 @@ import android.hardware.common.NativeHandle; import android.hardware.media.c2.IComponentInterface; import android.hardware.media.c2.IConfigurable; import android.hardware.media.c2.IGraphicBufferAllocator; +import android.hardware.media.c2.IInputSink; +import android.hardware.media.c2.IInputSurface; +import android.hardware.media.c2.IInputSurfaceConnection; import android.hardware.media.c2.WorkBundle; import android.os.ParcelFileDescriptor; @@ -308,4 +311,32 @@ interface IComponent { * - `Status::CORRUPTED` - Some unknown error occurred. */ void stop(); + + /** + * Starts using an input surface. + * + * The component must be in running state. + * + * @param inputSurface Input surface to connect to. + * @return connection `IInputSurfaceConnection` object, which can be used to + * query and configure properties of the connection. This cannot be + * null. + * @throws ServiceSpecificException with one of the following values: + * - `Status::CANNOT_DO` - The component does not support an input surface. + * - `Status::BAD_STATE` - The component is not in running state. + * - `Status::DUPLICATE` - The component is already connected to an input surface. + * - `Status::REFUSED` - The input surface is already in use. + * - `Status::NO_MEMORY` - Not enough memory to start the component. + * - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner. + * - `Status::CORRUPTED` - Some unknown error occurred. + */ + IInputSurfaceConnection connectToInputSurface(in IInputSurface inputSurface); + + /** + * Returns an @ref IInputSink instance that has the component as the + * underlying implementation. + * + * @return sink `IInputSink` instance. + */ + IInputSink asInputSink(); } diff --git a/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl b/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl index 1435a7e4bc..019405df4b 100644 --- a/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl +++ b/media/c2/aidl/android/hardware/media/c2/IComponentStore.aidl @@ -21,6 +21,7 @@ import android.hardware.media.c2.IComponent; import android.hardware.media.c2.IComponentInterface; import android.hardware.media.c2.IComponentListener; import android.hardware.media.c2.IConfigurable; +import android.hardware.media.c2.IInputSurface; import android.hardware.media.c2.StructDescriptor; /** @@ -182,4 +183,16 @@ interface IComponentStore { * - `Status::CORRUPTED` - Some unknown error occurred. */ ComponentTraits[] listComponents(); + + /** + * Creates a persistent input surface that can be used as an input surface + * for any IComponent instance + * + * @return IInputSurface A persistent input surface. + * @throws ServiceSpecificException with one of following values: + * - `Status::NO_MEMORY` - Not enough memory to complete this method. + * - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner. + * - `Status::CORRUPTED` - Some unknown error occurred. + */ + IInputSurface createInputSurface(); } diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl new file mode 100644 index 0000000000..eb8ad3d4cf --- /dev/null +++ b/media/c2/aidl/android/hardware/media/c2/IInputSink.aidl @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 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.hardware.media.c2.WorkBundle; + +/** + * An `IInputSink` is a receiver of work items. + * + * An @ref IComponent instance can present itself as an `IInputSink` via a thin + * wrapper. + * + * @sa IInputSurface, IComponent. + */ +@VintfStability +interface IInputSink { + /** + * Feeds work to the sink. + * + * @param workBundle `WorkBundle` object containing a list of `Work` objects + * to queue to the component. + * @throws ServiceSpecificException with one of the following values: + * - `Status::BAD_INDEX` - Some component id in some `Worklet` is not valid. + * - `Status::CANNOT_DO` - Tunneling has not been set up for this sink, but some + * `Work` object contains tunneling information. + * - `Status::NO_MEMORY` - Not enough memory to queue @p workBundle. + * - `Status::TIMED_OUT` - The operation cannot be finished in a timely manner. + * - `Status::CORRUPTED` - Some unknown error occurred. + */ + void queue(in WorkBundle workBundle); +} diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl new file mode 100644 index 0000000000..77cb1fd4a5 --- /dev/null +++ b/media/c2/aidl/android/hardware/media/c2/IInputSurface.aidl @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2023 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.hardware.media.c2.IConfigurable; +import android.hardware.media.c2.IInputSink; +import android.hardware.media.c2.IInputSurfaceConnection; +import android.view.Surface; + +/** + * Input surface for a Codec2 component. + * + * An input surface is an instance of `IInputSurface`, which may be + * created by calling IComponentStore::createInputSurface(). Once created, the + * client may + * 1. write data to it via the `NativeWindow` interface; and + * 2. use it as input to a Codec2 encoder. + * + * @sa IInputSurfaceConnection, IComponentStore::createInputSurface(), + * IComponent::connectToInputSurface(). + */ +@VintfStability +interface IInputSurface { + /** + * Returns the producer interface into the internal buffer queue. + * + * @return producer `Surface` instance(actually ANativeWindow). This must not + * be null. + */ + Surface getSurface(); + + /** + * Returns the @ref IConfigurable instance associated to this input surface. + * + * @return configurable `IConfigurable` instance. This must not be null. + */ + IConfigurable getConfigurable(); + + /** + * Connects the input surface to an input sink. + * + * This function is generally called from inside the implementation of + * IComponent::connectToInputSurface(), where @p sink is a thin wrapper of + * the component that consumes buffers from this surface. + * + * @param sink Input sink. See `IInputSink` for more information. + * @return connection `IInputSurfaceConnection` object. This must not be + * null if @p status is `OK`. + * @throws ServiceSpecificException with one of following values: + * - `Status::BAD_VALUE` - @p sink is invalid. + * - `Status::CORRUPTED` - Some unknown error occurred. + */ + IInputSurfaceConnection connect(in IInputSink sink); +} diff --git a/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl b/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl new file mode 100644 index 0000000000..36524ebfe4 --- /dev/null +++ b/media/c2/aidl/android/hardware/media/c2/IInputSurfaceConnection.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 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; + +/** + * Connection between an IInputSink and an IInpuSurface. + */ +@VintfStability +interface IInputSurfaceConnection { + /** + * Destroys the connection between an input surface and a component. + * + * @throws ServiceSpecificException with one of following values: + * - `Status::BAD_STATE` - The component is not in running state. + * - `Status::NOT_FOUND` - The surface is not connected to a component. + * - `Status::CORRUPTED` - Some unknown error occurred. + */ + void disconnect(); + + /** + * Signal the end of stream. + + * @throws ServiceSpecificException with one of following values: + * - `Status::BAD_STATE` - The component is not in running state. + */ + void signalEndOfStream(); +}