diff options
author | Pawin Vongmasa <pawin@google.com> | 2018-03-06 20:37:01 -0800 |
---|---|---|
committer | Pawin Vongmasa <pawin@google.com> | 2018-03-06 20:37:01 -0800 |
commit | 1e45a0989751585ce642ea5cd163f5d1e1d3c602 (patch) | |
tree | 57d697ba1b96f0f1c52ee0110de8fcbded6410f3 /media | |
parent | 137ea601e0777e6c9b63c4da5a39d6d85649a18f (diff) | |
download | interfaces-1e45a0989751585ce642ea5cd163f5d1e1d3c602.tar.gz |
Codec2.0 HIDL interfaces
Test: Builds with hardware/google/interfaces in PRODUCT_SOONG_NAMESPACES
Bug: 64121714
Bug: 31973802
Change-Id: I08bf23da658a2141dd236696054008931617d4ed
Diffstat (limited to 'media')
-rw-r--r-- | media/c2/1.0/Android.bp | 48 | ||||
-rw-r--r-- | media/c2/1.0/IComponent.hal | 311 | ||||
-rw-r--r-- | media/c2/1.0/IComponentInterface.hal | 39 | ||||
-rw-r--r-- | media/c2/1.0/IComponentListener.hal | 45 | ||||
-rw-r--r-- | media/c2/1.0/IComponentStore.hal | 213 | ||||
-rw-r--r-- | media/c2/1.0/IConfigurable.hal | 161 | ||||
-rw-r--r-- | media/c2/1.0/IInputSurface.hal | 60 | ||||
-rw-r--r-- | media/c2/1.0/IInputSurfaceConnection.hal | 35 | ||||
-rw-r--r-- | media/c2/1.0/types.hal | 581 |
9 files changed, 1493 insertions, 0 deletions
diff --git a/media/c2/1.0/Android.bp b/media/c2/1.0/Android.bp new file mode 100644 index 0000000..c940da2 --- /dev/null +++ b/media/c2/1.0/Android.bp @@ -0,0 +1,48 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "hardware.google.media.c2@1.0", + root: "hardware.google", + srcs: [ + "types.hal", + "IComponent.hal", + "IComponentInterface.hal", + "IComponentListener.hal", + "IComponentStore.hal", + "IConfigurable.hal", + "IInputSurface.hal", + "IInputSurfaceConnection.hal", + ], + interfaces: [ + "android.hardware.graphics.bufferqueue@1.0", + "android.hardware.graphics.common@1.0", + "android.hardware.media.bufferpool@1.0", + "android.hardware.media.omx@1.0", + "android.hardware.media@1.0", + "android.hidl.base@1.0", + ], + types: [ + "BaseBlock", + "Block", + "Buffer", + "FieldDescriptor", + "FieldId", + "FieldSupportedValues", + "FieldSupportedValuesQuery", + "FieldSupportedValuesQueryResult", + "FrameData", + "InfoBuffer", + "ParamDescriptor", + "ParamField", + "ParamFieldValues", + "SettingResult", + "Status", + "StructDescriptor", + "Work", + "WorkBundle", + "WorkOrdinal", + "Worklet", + ], + gen_java: false, +} + diff --git a/media/c2/1.0/IComponent.hal b/media/c2/1.0/IComponent.hal new file mode 100644 index 0000000..5844bb3 --- /dev/null +++ b/media/c2/1.0/IComponent.hal @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer; +import android.hardware.media.omx@1.0::IGraphicBufferSource; + +import IConfigurable; +import IComponentInterface; +import IComponentListener; +import IInputSurface; + +/** + * Interface for a Codec 2.0 component corresponding to API level 1.0 or + * below. Components have two states: stopped and running. The running + * state has three sub-states: executing, tripped and error. + */ +interface IComponent extends IComponentInterface { + + // METHODS AVAILABLE WHEN RUNNING + // ========================================================================= + + /** + * Queues up work for the component. + * + * This method must be supported in running (including tripped) states. + * + * This method must return within 1ms + * + * It is acceptable for this method to return OK and return an error value + * using the onWorkDone() callback. + * + * @param workBundle WorkBundle object containing Works to queue to the + * component. + * @return status Status of the call, which may be + * - OK - Works in \p workBundle were successfully queued. + * - BAD_INDEX - Some component(s) in some Work do(es) not exist. + * - CANNOT_DO - The components are not tunneled. + * - NO_MEMORY - Not enough memory to queue \p workBundle. + * - CORRUPTED - Some unknown error prevented queuing the Works. + * (unexpected). + */ + queue(WorkBundle workBundle) generates (Status status); + + /** + * Discards and abandons any pending work for the component. + * + * This method must be supported in running (including tripped) states. + * + * This method must return within 5ms. + * + * Work that could be immediately abandoned/discarded must be returned in + * \p flushedWorks; this can be done in an arbitrary order. + * + * Work that could not be abandoned or discarded immediately must be marked + * to be discarded at the earliest opportunity, and must be returned via + * the onWorkDone() callback. This must be completed within 500ms. + * + * @return status Status of the call, which may be + * - OK - The component has been successfully flushed. + * - TIMED_OUT - The flush could not be completed within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented flushing from + * completion. (unexpected) + * @return flushedWorkBundle WorkBundle object containing flushed Works. + */ + flush( + ) generates ( + Status status, + WorkBundle flushedWorkBundle + ); + + /** + * Drains the component, and optionally downstream components. This is a + * signalling method; as such it does not wait for any work completion. + * + * Marks last work item as "drain-till-here", so component is notified not + * to wait for further work before it processes work already queued. This + * method can also be used to set the end-of-stream flag after work has been + * queued. Client can continue to queue further work immediately after this + * method returns. + * + * This method must be supported in running (including tripped) states. + * + * This method must return within 1ms. + * + * Work that is completed must be returned via the onWorkDone() callback. + * + * @param withEos Whether to drain the component with marking end-of-stream. + * @return status Status of the call, which may be + * - OK - The drain request has been successfully recorded. + * - TIMED_OUT - The flush could not be completed within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented flushing from completion. + * (unexpected) + */ + drain(bool withEos) generates (Status status); + + /** + * Starts using a persistent input surface for a component. + * + * The component must be in running state. + * + * @param surface A persistent input surface to use for codec input. + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - CANNOT_DO - The component does not support an input surface. + * - BAD_STATE - Component is not in running state. + * - DUPLICATE - The component is already connected to an input surface. + * - REFUSED - The input surface is already in use. + * - NO_MEMORY - Not enough memory to start the component. + * - TIMED_OUT - The component could not be connected within the time + * limit. (unexpected) + * - CORRUPTED - Some unknown error prevented connecting the component. + * (unexpected) + */ + connectToInputSurface(IInputSurface surface) generates (Status status); + + /** + * Starts using a persistent OMX input surface for a component. + * + * The component must be in running state. + * + * @param producer Producer component of an OMX persistent input surface. + * @param source Source component of an OMX persistent input surface. + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - CANNOT_DO - The component does not support an input surface. + * - BAD_STATE - Component is not in running state. + * - DUPLICATE - The component is already connected to an input surface. + * - REFUSED - The input surface is already in use. + * - NO_MEMORY - Not enough memory to start the component. + * - TIMED_OUT - The component could not be connected within the time + * limit. (unexpected) + * - CORRUPTED - Some unknown error prevented connecting the component. + * (unexpected) + */ + connectToOmxInputSurface( + IGraphicBufferProducer producer, + IGraphicBufferSource source + ) generates (Status status); + + /** + * Stops using an input surface. + * + * This call is used for both Codec 2.0 and OMX input surfaces. + * + * The component must be in running state. + * + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - CANNOT_DO - The component does not support an input surface. + * - BAD_STATE - Component is not in running state. + * - NOT_FOUND - The component is not connected to an input surface. + * - TIMED_OUT - The component could not be connected within the time + * limit. (unexpected) + * - CORRUPTED - Some unknown error prevented connecting the component. + * (unexpected) + */ + disconnectFromInputSurface() generates (Status Status); + + /** + * Creates a local block pool backed by the given allocator and returns its + * identifier. + * + * This call must return within 100 msec. + * + * @param allocatorId The Codec 2.0 allocator ID + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - NO_MEMORY - Not enough memory to create the pool. + * - BAD_VALUE - Invalid allocator. + * - TIMED_OUT - The pool could not be created within the time + * limit. (unexpected) + * - CORRUPTED - Some unknown error prevented creating the pool. + * (unexpected) + * @return blockPoolId The Codec 2.0 blockpool ID for the created pool. + * @return configurable Configuration interface for the created pool. + */ + createBlockPool(uint32_t allocatorId) generates ( + Status status, + uint64_t blockPoolId, + IConfigurable configurable + ); + + // STATE CHANGE METHODS + // ========================================================================= + + /** + * Starts the component. + * + * This method must be supported in stopped state as well as tripped state. + * + * If the return value is OK, the component must be in the running state. + * If the return value is BAD_STATE or DUPLICATE, no state change is + * expected as a response to this call. + * Otherwise, the component must be in the stopped state. + * + * If a component is in the tripped state and start() is called while the + * component configuration still results in a trip, start must succeed and + * a new onTripped callback must be used to communicate the configuration + * conflict that results in the new trip. + * + * This method must return within 500ms. + * + * @return status Status of the call, which may be + * - OK - The component has started successfully. + * - BAD_STATE - Component is not in stopped or tripped state. + * - DUPLICATE - When called during another start call from another + * thread. + * - NO_MEMORY - Not enough memory to start the component. + * - TIMED_OUT - The component could not be started within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented starting the component. + * (unexpected) + */ + start() generates (Status status); + + /** + * Stops the component. + * + * This method must be supported in running (including tripped) state. + * + * This method must return withing 500ms. + * + * Upon this call, all pending work must be abandoned. + * If the return value is BAD_STATE or DUPLICATE, no state change is + * expected as a response to this call. + * For all other return values, the component must be in the stopped state. + * + * This does not alter any settings and tunings that may have resulted in a + * tripped state. + * + * @return status Status of the call, which may be + * - OK - The component has stopped successfully. + * - BAD_STATE - Component is not in running state. + * - DUPLICATE - When called during another stop call from another thread. + * - TIMED_OUT - The component could not be stopped within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented starting the component. + * (unexpected) + */ + stop() generates (Status status); + + /** + * Resets the component. + * + * This method must be supported in all (including tripped) states other + * than released. + * + * This method must be supported during any other blocking call. + * + * This method must return withing 500ms. + * + * After this call returns all work must have been abandoned, all references + * must have been released. + * + * If the return value is BAD_STATE or DUPLICATE, no state change is + * expected as a response to this call. + * For all other return values, the component shall be in the stopped state. + * + * This brings settings back to their default - "guaranteeing" no tripped + * state. + * + * @return status Status of the call, which may be + * - OK - The component has been reset. + * - BAD_STATE - Component is in released state. + * - DUPLICATE - When called during another reset call from another + * thread. + * - TIMED_OUT - The component could not be reset within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented resetting the component. + * (unexpected) + */ + reset() generates (Status status); + + /** + * Releases the component. + * + * This method must be supported in stopped state. + * + * This method must return withing 500ms. Upon return all references must + * be abandoned. + * + * @return status Status of the call, which may be + * - OK - The component has been released. + * - BAD_STATE - The component is running. + * - DUPLICATE - The component is already released. + * - TIMED_OUT - The component could not be released within the time + * limit. (unexpected) + * - CORRUPTED - Some unknown error prevented releasing the component. + * (unexpected) + */ + release() generates (Status status); + +}; + diff --git a/media/c2/1.0/IComponentInterface.hal b/media/c2/1.0/IComponentInterface.hal new file mode 100644 index 0000000..bd151a0 --- /dev/null +++ b/media/c2/1.0/IComponentInterface.hal @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +import IConfigurable; + +/** + * Component interface object. This object contains all of the configuration of + * a potential or actual component. It can be created and used independently of + * an actual Codec 2.0 component instance to query support and parameters for + * various component settings and configurations for a potential component. + * Actual components also expose this interface. + */ +interface IComponentInterface extends IConfigurable { + /* + * There are no additional methods to IConfigurable interface. + * + * Component interfaces have no states. + * + * The name of the component or component interface object is a unique name + * for that component or component interface 'class'; however, multiple + * instances of that component must have the same name. + */ +}; + diff --git a/media/c2/1.0/IComponentListener.hal b/media/c2/1.0/IComponentListener.hal new file mode 100644 index 0000000..6f41605 --- /dev/null +++ b/media/c2/1.0/IComponentListener.hal @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +/** + * This callback interface is used for handling notifications from IComponent. + */ +interface IComponentListener { + + /** + * Notify the listener that some works have been completed. + */ + oneway onWorkDone(WorkBundle workBundle); + + /** + * Notify the listener that the component is tripped. + */ + oneway onTripped(vec<SettingResult> settingResults); + + /** + * Notify the listener of an error. + * + * @param status The error type. \p status may be `OK`, which means that an + * error has occurred, but the error type is unknown. + * @param errorCode Additional error code. The framework may not recognize + * this. + */ + oneway onError(Status status, uint32_t errorCode); + +}; + diff --git a/media/c2/1.0/IComponentStore.hal b/media/c2/1.0/IComponentStore.hal new file mode 100644 index 0000000..54e016f --- /dev/null +++ b/media/c2/1.0/IComponentStore.hal @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +import android.hardware.media.bufferpool@1.0::IClientManager; +import IComponentInterface; +import IComponentListener; +import IComponent; +import IConfigurable; +import IInputSurface; + +interface IComponentStore extends IConfigurable { + + /** + * Creates a component by name. + * + * This method must return within 100ms. + * + * @param name Name of the component to create. This should match one of the + * names returned by listComponents(). + * @param listener The component listener to use for the component. + * @param pool The buffer pool client manager of the component listener. + * This must be null if the listener process does not own a buffer pool. + * @return status Status of the call, which may be + * - OK - The component was created successfully. + * - NOT_FOUND - There is no component with the given name. + * - NO_MEMORY - Not enough memory to create the component. + * - TIMED_OUT - The component could not be created within the time limit. + * (unexpected) + * - CORRUPTED - Some unknown error prevented the creation of the + * component. (unexpected) + * @return comp The created component if `Status = OK`. + */ + createComponent( + string name, + IComponentListener listener, + IClientManager pool + ) generates ( + Status status, + IComponent comp + ); + + /** + * Creates a component interface by name. + * + * This method must return within 100ms. + * + * @param name Name of the component interface to create. This should match + * one of the names returned by listComponents(). + * @return status Status of the call, which may be + * - OK - The component interface was created successfully. + * - NOT_FOUND - There is no component interface with the given name. + * - NO_MEMORY - Not enough memory to create the component interface. + * - TIMED_OUT - The component interface could not be created within the + * time limit. (unexpected) + * - CORRUPTED - Some unknown error prevented the creation of the + * component interface. (unexpected) + * @return compIntf The created component interface if `Status = OK`. + */ + createInterface( + string name + ) generates ( + Status status, + IComponentInterface compIntf + ); + + /** + * Component traits. + */ + struct ComponentTraits { + /** + * Name of the component. + */ + string name; + + enum Domain : uint32_t { + AUDIO, + VIDEO, + OTHER = 0xffffffff, + }; + /** + * Component domain. The framework may not recognize `OTHER`. + */ + Domain domain; + /** + * If #domain is `OTHER`, #domainOther can be used to provide additional + * information. Otherwise, #domainOther is ignored. The framework may + * not inspect this value. + */ + uint32_t domainOther; + + enum Kind : uint32_t { + DECODER, + ENCODER, + OTHER = 0xffffffff, + }; + /** + * Component kind. The framework may not recognize `OTHER`. + */ + Kind kind; + /** + * If #kind is `OTHER`, #kindOther can be used to provide additional + * information. Otherwise, #kindOther is ignored. The framework may not + * inspect this value. + */ + uint32_t kindOther; + + /** + * Rank used by MediaCodecList to determine component ordering. Lower + * value means higher priority. + */ + uint32_t rank; + + /** + * Media type. + */ + string mediaType; + + /** + * Aliases for component name for backward compatibility. + * + * \note Multiple components can have the same alias (but not the same + * component name) as long as their media types differ. + */ + vec<string> aliases; + }; + + /** + * Returns the list of components supported by this component store. + * + * This method must return within 500ms. + * + * @return traits List of component traits for all components supported by this store in no + * particular order. + */ + listComponents() generates (vec<ComponentTraits> traits); + + /** + * Creates a persistent input surface that can be used as an input surface + * for any IComponent instance + * + * This method must return within 100ms. + * + * @return surface A persistent input surface + */ + createInputSurface() generates (IInputSurface surface); + + /** + * Returns a list of StructDescriptor object for a set of requested + * structures that this store is aware of. + * + * This operation must be performed at best effort, e.g. the component + * store must simply ignore all struct indices that it is not aware of. + * + * @param indices struct indices to return des + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - NOT_FOUND - Some indices were not known. + * - NO_MEMORY - Not enough memory to complete this method. + * @return structs List of StructDescriptor objects. + */ + getStructDescriptors( + vec<ParamIndex> indices + ) generates ( + Status status, + vec<StructDescriptor> structs + ); + + /** + * Returns information required for using BufferPool API in buffer passing. + * If the returned pool is not null, the client can call registerSender() to + * register its IAccessor instance, hence allowing the client to send + * buffers to components hosted by this process. + * + * @return pool If the component store supports receiving buffers via + * BufferPool API, \p pool must be a valid `IClientManager` instance. + * Otherwise, \p pool must be null. + */ + getPoolClientManager( + ) generates ( + IClientManager pool + ); + + /** + * The store must copy the contents of \p src into \p dst without changing + * the format of \p dst. + * + * @param src Source buffer. + * @param dst Destination buffer. + * @return status Status of the call, which may be + * - OK - The copy is successful. + * - CANNOT_DO - \p src and \p dst are not compatible. + * - REFUSED - No permission to copy. + * - CORRUPTED - The copy cannot be done. (unexpected) + */ + copyBuffer(Buffer src, Buffer dst) generates (Status status); + +}; + diff --git a/media/c2/1.0/IConfigurable.hal b/media/c2/1.0/IConfigurable.hal new file mode 100644 index 0000000..406d311 --- /dev/null +++ b/media/c2/1.0/IConfigurable.hal @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +/** + * Generic configuration interface used by all configurable Codec 2.0 + * components. + * + * This interface must be supported in all states of the inheriting + * object, and must not change the state of the inheriting object. + */ +interface IConfigurable { + /** + * Returns the name of this object. This must match the name that was + * supplied during the creation of the object. + * + * @return name Name of this object. + */ + getName() generates (string name); + + /** + * Queries a set of parameters from the object. Querying is performed at + * best effort: the object must query all supported parameters and skip + * unsupported ones, or parameters that could not be allocated. Any errors + * are communicated in the return value. + * + * \note Parameter values do not depend on the order of query. + * + * This method must return within 1ms if \p mayBlock is DONT_BLOCK, and + * within 5ms otherwise. + * + * @param indices List of param indices for params to be queried. + * @param mayBlock Whether this call may block or not. + * @return status Status of the call, which may be + * - OK - All parameters could be queried. + * - BAD_INDEX - All supported parameters could be queried, but some + * parameters were not supported. + * - NO_MEMORY - Could not allocate memory for a supported parameter. + * - BLOCKING - Querying some parameters requires blocking. + * - CORRUPTED - Some unknown error prevented the querying of the + * parameters. (unexpected) + * @return params List of params queried corresponding to \p indices. + */ + query( + vec<ParamIndex> indices, + bool mayBlock + ) generates ( + Status status, + Params params + ); + + /** + * Sets a set of parameters for the object. Tuning is performed at best + * effort: the object must update all supported configuration at best + * effort and skip unsupported parameters. Any errors are communicated in + * the return value and in \p failures. + * + * \note Parameter tuning DOES depend on the order of the tuning parameters. + * E.g. some parameter update may allow some subsequent parameter update. + * + * This method must return within 1ms if \p mayBlock is false, and within + * 5ms otherwise. + * + * @param inParams Requested parameter updates. + * @param mayBlock Whether this call may block or not. + * @return status Status of the call, which may be + * - OK - All parameters could be updated successfully. + * - BAD_INDEX - All supported parameters could be updated successfully, + * but some parameters were not supported. + * - NO_MEMORY - Some supported parameters could not be updated + * successfully because they contained unsupported values. + * These are returned in \p failures. + * - BLOCKING - Setting some parameters requires blocking. + * - CORRUPTED - Some unknown error prevented the update of the + * parameters. (unexpected) + * @return failures List of parameter failures. + * @return outParams Resulting values for the configured parameters. + */ + config( + Params inParams, + bool mayBlock + ) generates ( + Status status, + vec<SettingResult> failures, + Params outParams + ); + + // REFLECTION MECHANISM + // ========================================================================= + + /** + * Returns a selected range of the set of supported parameters. + * + * The set of supported parameters are represented in a vector with a + * start index of 0, and the selected range are indices into this vector. + * Fewer than \p count parameters are returned if the selected range is + * not fully/not at all part of the available vector indices. + * + * This method must return within 1ms. + * + * @param start start index of selected range + * @param count size of the selected + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - NO_MEMORY - Not enough memory to complete this method. + * @return params Vector containing the selected range of supported + * parameters. + */ + querySupportedParams( + uint32_t start, + uint32_t count + ) generates ( + Status status, + vec<ParamDescriptor> params + ); + + /** + * Retrieves the supported values for the queried fields. + * + * Upon return the object must fill in the supported + * values for the fields listed as well as a status for each field. + * Object shall process all fields queried even if some queries fail. + * + * This method must return within 1ms if \p mayBlock is false, and within + * 5ms otherwise. + * + * @param inFields Vector of field queries. + * @param mayBlock Whether this call may block or not. + * @return status Status of the call, which may be + * - OK - The operation completed successfully. + * - BLOCKING - Querying some parameters requires blocking. + * - NO_MEMORY - Not enough memory to complete this method. + * - BAD_INDEX - At least one field was not recognized as a component + * field. + * @return outFields Vector containing supported values and query result + * for the selected fields. + */ + querySupportedValues( + vec<FieldSupportedValuesQuery> inFields, + bool mayBlock + ) generates ( + Status status, + vec<FieldSupportedValuesQueryResult> outFields + ); + +}; + diff --git a/media/c2/1.0/IInputSurface.hal b/media/c2/1.0/IInputSurface.hal new file mode 100644 index 0000000..8b1a2a5 --- /dev/null +++ b/media/c2/1.0/IInputSurface.hal @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +import android.hardware.graphics.bufferqueue@1.0::IGraphicBufferProducer; + +import IConfigurable; +import IInputSurfaceConnection; + +/** + * Input surface that can be configured for the IComponent. + */ +interface IInputSurface extends IGraphicBufferProducer { + + /** + * Connects this input surface to a component. + * + * This call must return within 100 ms. + * + * @param component The component to connect to. This must have type + * IComponent. + * @return status Status of the call, which may be + * - OK - The operation succeeded. + * - BAD_STATE - The component is in running state. + * - DUPLICATE - The surface is already connected to a component. + * - NO_MEMORY - Could not allocate memory to connect to the component. + * - CORRUPTED - Some unknown error prevented the connection. (unexpected) + * @return connection Connection object that is used to disconnect + * from the component. + */ + connectToComponent( + interface component + ) generates ( + Status status, + IInputSurfaceConnection connection + ); + + /** + * Returns the Codec 2.0 configuration object for this surface. + * + * @return configurable The configuration object for this surface. + */ + getConfigurable() generates (IConfigurable configurable); + +}; + diff --git a/media/c2/1.0/IInputSurfaceConnection.hal b/media/c2/1.0/IInputSurfaceConnection.hal new file mode 100644 index 0000000..293c601 --- /dev/null +++ b/media/c2/1.0/IInputSurfaceConnection.hal @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +interface IInputSurfaceConnection { + + /** + * Disconnects this input surface from the component. + * + * This call must return within 100 ms. + * + * @return status Status of the call, which may be + * - OK - The operation succeeded. + * - BAD_STATE - The component is not in running state. + * - NOT_FOUND - The surface is not connected to a component. + * - CORRUPTED - Some unknown error prevented the connection. (unexpected) + */ + disconnect() generates (Status status); + +}; + diff --git a/media/c2/1.0/types.hal b/media/c2/1.0/types.hal new file mode 100644 index 0000000..8454dfb --- /dev/null +++ b/media/c2/1.0/types.hal @@ -0,0 +1,581 @@ +/* + * Copyright (C) 2018 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 hardware.google.media.c2@1.0; + +import android.hardware.media.bufferpool@1.0::BufferStatusMessage; + +enum Status : int32_t { + /** operation completed successfully */ + OK = 0, + + // bad input + + /** argument has invalid value (user error) */ + BAD_VALUE = -22, + /** argument uses invalid index (user error) */ + BAD_INDEX = -75, + /** argument/index is valid but not possible */ + CANNOT_DO = -2147483646, + + // bad sequencing of events + + /** object already exists */ + DUPLICATE = -17, + /** object not found */ + NOT_FOUND = -2, + /** operation is not permitted in the current state */ + BAD_STATE = -38, + /** operation would block but blocking is not permitted */ + BLOCKING = -9930, + + // bad environment + + /** not enough memory to complete operation */ + NO_MEMORY = -12, + /** missing permission to complete operation */ + REFUSED = -1, + + /** operation did not complete within timeout */ + TIMED_OUT = -110, + + // missing functionality + + /** operation is not implemented/supported (optional only) */ + OMITTED = -74, + + // unknown fatal + + /** some unexpected error prevented the operation */ + CORRUPTED = -2147483648, + + // uninitialized + + /** status has not been initialized */ + NO_INIT = -19, +}; + +/** + * Codec 2.0 parameter index + */ +typedef uint32_t ParamIndex; + +/** + * Codec 2.0 parameter structure + * + * The description of a Params is provided by supplying a ParamIndex to + * IComponentStore::getStructDescriptors(). + */ +typedef vec<uint8_t> Params; + +/** + * Struct uniquely specifying a field in an arbitrary parameter structure. + */ +struct FieldId { + /** Offset of the field in bytes */ + uint32_t offset; + /** Size of the field in bytes */ + uint32_t size; +}; + +/** + * Struct representing a location of a field in a parameter with a given index. + */ +struct ParamField { + /** Index of the parameter */ + ParamIndex index; + /** Field identifier */ + FieldId fieldId; +}; + +/** + * Struct describing basic properties of a parameter with a given index. + */ +struct ParamDescriptor { + /** Parameter index */ + ParamIndex index; + + enum Attrib : uint32_t { + IS_REQUIRED = 1u << 0, + IS_PERSISTENT = 1u << 1, + }; + /** Parameter attributes */ + bitfield<Attrib> attrib; + + /** Parameter name */ + string name; + + /** index of other parameters that this parameter depends on */ + vec<ParamIndex> dependencies; +}; + +// Generic way to describe supported numeric values for Codec 2.0 interfaces. + +/** + * An untyped value that can fit on 64 bits - the type of which is communicated + * via a separate channel (FieldType). + */ +typedef uint64_t PrimitiveValue; + +/* + * Generic supported values for a field. + * + * This can be either a range or a set of values. The range can be linear or + * geometric with clear minimum and maximum values, and can have an optional + * step size or geometric ratio. Values can optionally represent flags. + */ +struct FieldSupportedValues { + struct Range { + PrimitiveValue min; + PrimitiveValue max; + PrimitiveValue step; + PrimitiveValue num; + PrimitiveValue denom; + }; + + enum Type : int32_t { + /** No supported values */ + EMPTY, + /** Numeric range that can be continuous or discrete */ + RANGE, + /** List of values */ + VALUES, + /** List of flags that can be OR-ed */ + FLAGS, + /** Other representations */ + OTHER = 0xffffffff, + }; + /** + * Type of the supported values. The framework may not recognize `OTHER`. + */ + Type type; + /** + * Codec2.0 type code of the supported values. + * * If #type is `OTHER`, #typeOther can be used to give more information. + * In this case, the interpretation of this structure is + * implementation-defined. + * * For all other values of #type, #typeOther is not used. + * The framework may not inspect this value. + */ + int32_t typeOther; + + /* + * If #type = EMPTY, #range and #value are unused. + */ + + /** + * If #type = RANGE, #range will specify the range of possible values. + * + * The intended type of members of #range will be clear in the context where + * FieldSupportedValues is used. + */ + Range range; + + /** + * If #type is `VALUES` or `FLAGS`, #value will list supported values. + * + * The intended type of components of #value will be clear in the context + * where FieldSupportedValues is used. + */ + vec<PrimitiveValue> values; +}; + +/** + * Supported values for a specific field. + * + * This is a pair of the field specifier together with an optional supported + * values object. This structure is used when reporting parameter configuration + * failures and conflicts. + */ +struct ParamFieldValues { + /** the field or parameter */ + ParamField paramOrField; + + /** + * optional supported values for the field if paramOrField specifies an + * actual field that is numeric (non struct, blob or string). Supported + * values for arrays (including string and blobs) describe the supported + * values for each element (character for string, and bytes for blobs). It + * is optional for read-only strings and blobs. + */ + vec<FieldSupportedValues> values; +}; + +/** + * Field descriptor. + */ +struct FieldDescriptor { + + /** Field id */ + FieldId fieldId; + + /** + * Possible types of a field. + */ + enum Type : uint32_t { + NO_INIT, + INT32, + UINT32, + CNTR32, + INT64, + UINT64, + CNTR64, + FLOAT, + /** + * Fixed-size string (POD) + */ + STRING = 0x100, + /** + * blobs have no sub-elements and can be thought of as byte arrays. + * However, bytes cannot be individually addressed by clients. + */ + BLOB, + /** + * Structs. Marked with this flag in addition to their coreIndex. + */ + STRUCT_FLAG = 0x20000, + }; + /** + * Type of the field. + */ + bitfield<Type> type; + + /** Extent of the field */ + uint32_t length; + /* + * Note: the last member of a param struct can be of arbitrary length (e.g. + * if it is T[] array, which extends to the last byte of the parameter.) + * This is marked with extent 0. + */ + + /** Name of the field */ + string name; + /** Named value type */ + struct NamedValue { + string name; + PrimitiveValue value; + }; + /** Named values for the field */ + vec<NamedValue> namedValues; +}; + +/** + * Struct descriptor. + */ +struct StructDescriptor { + /** Struct type */ + ParamIndex type; + /** Field descriptors for each field */ + vec<FieldDescriptor> fields; +}; + +/** + * Information describing the reason a parameter settings may fail, or + * may be overriden. + */ +struct SettingResult { + /** Failure code (of Codec 2.0 SettingResult failure type) */ + enum Failure : uint32_t { + /** Parameter is read-only and cannot be set. */ + READ_ONLY, + /** Parameter mismatches input data. */ + MISMATCH, + /** Parameter does not accept value. */ + BAD_VALUE, + /** Parameter is not supported. */ + BAD_TYPE, + /** Parameter is not supported on the specific port. */ + BAD_PORT, + /** Parameter is not supported on the specific stream. */ + BAD_INDEX, + /** Parameter is in conflict with an/other setting(s). */ + CONFLICT, + /** + * Parameter is out of range due to other settings. (This failure mode + * can only be used for strict parameters.) + */ + UNSUPPORTED, + /** + * Requested parameter value is in conflict with an/other setting(s) + * and has been corrected to the closest supported value. This failure + * mode is given to provide suggestion to the client as to how to enable + * the requested parameter value. */ + INFO_CONFLICT, + /** + * This failure mode is reported when all the above failure modes do not + * apply. + */ + OTHER = 0xffffffff, + }; + /** + * The failure type. The framework might not recognize `OTHER`. + */ + Failure failure; + /** + * The failure code. + * * If #failure is `OTHER`, #failureOther can be used to give more + * information. + * * For all other values of #failure, #failureOther is not used. + * The framework may not inspect this value. + */ + uint32_t failureOther; + + /** + * Failing (or corrected) field. Currently supported values for the field. + * This is set if different from the globally supported values (e.g. due to + * restrictions by another param or input data) + */ + ParamFieldValues field; + + /** + * Conflicting parameters or fields with + * (optional) suggested values for any conflicting fields to avoid the conflict. + */ + vec<ParamFieldValues> conflicts; +}; + +/** + * Data structure for ordering Work objects. Each member is used for comparing + * urgency in the same fashion: a smaller value indicates that the associated + * Work object is more urgent. + */ +struct WorkOrdinal { + /** + * Timestamp in microseconds - can wrap around. + */ + uint64_t timestampUs; + /** + * Frame index - can wrap around. + */ + uint64_t frameIndex; + /** + * Component specific frame ordinal - can wrap around. + */ + uint64_t customOrdinal; +}; + +/** + * A structure that holds information of a Block. There are two types of Blocks: + * NATIVE and POOLED. Each type has its own way of identifying blocks. + */ +struct BaseBlock { + enum Type : int32_t { + NATIVE, + POOLED, + }; + /** + * There are two types of blocks: NATIVE and POOLED. + */ + Type type; + + /** + * A "NATIVE" block is represented by a native handle. + */ + handle nativeBlock; + + /* + * A "POOLED" block is represented by `BufferStatusMessage`. + */ + BufferStatusMessage pooledBlock; +}; + +/** + * A Block in transfer consists of an index into an array of BaseBlock plus some + * extra information. One BaseBlock may occur in multiple blocks in one + * `WorkBundle`. + */ +struct Block { + /** + * Identity of the BaseBlock within a WorkBundle. This is an index into the + * `baseBlocks` array of a `WorkBundle` object. + */ + uint32_t index; + /** + * Metadata associated with the block. + */ + Params meta; + /** + * Fence for synchronizing block access. + */ + handle fence; +}; + +/** + * Type of buffers processed by a component. + */ +struct Buffer { + /** + * Metadata associated with the buffer. + */ + Params info; + /** + * Blocks contained in the buffer. + */ + vec<Block> blocks; +}; + +/** + * An extension of Buffer that also contains an index. + */ +struct InfoBuffer { + ParamIndex index; + Buffer buffer; +}; + +/** + * This structure represents a frame with its metadata. A frame consists of an + * ordered set of buffers, configuration changes, and info buffers along with + * some non-configuration metadata. + */ +struct FrameData { + enum Flags : uint32_t { + /** + * For input frames: no output frame will be generated when processing + * this frame, but metadata must still be processed. + * For output frames: this frame must be discarded but metadata is still + * valid. + */ + DROP_FRAME = (1 << 0), + /** + * This frame is the last frame of the current stream. Further frames + * are part of a new stream. + */ + END_OF_STREAM = (1 << 1), + /** + * This frame must be discarded with its metadata. + * This flag is only set by components - e.g. as a response to the flush + * command. + */ + DISCARD_FRAME = (1 << 2), + /** + * This frame contains only codec-specific configuration data, and no + * actual access unit. + * + * \deprecated Pass codec configuration with the codec-specific + * configuration info together with the access unit. + */ + CODEC_CONFIG = (1u << 31), + }; + + /** + * Frame flags. + */ + bitfield<Flags> flags; + + /** + * Ordinal of the frame. + */ + WorkOrdinal ordinal; + + /** + * Frame buffers. + */ + vec<Buffer> buffers; + + /** + * Params determining a configuration update. + */ + Params configUpdate; + + /** + * Info buffers. + */ + vec<InfoBuffer> infoBuffers; +}; + +/** + * Struct for + */ +struct Worklet { + /** + * List of Params describing tunings. + */ + vec<Params> tunings; + + /** + * List of failures. + */ + vec<SettingResult> failures; + + /** + * Output frame data. + */ + FrameData output; + + /* Note: Component id is not necessary as tunneling is not supported. */ +}; + +/** + * This structure holds information about a single work item. It must be passed + * by the client to the component. + */ +struct Work { + /** + * FrameData for the input. Indices of Blocks inside #input refer to + * BaseBlocks in the member `blocks` of the containing `WorkBundle`. + */ + FrameData input; + /** + * Worklet. Indices of Blocks inside `worklet.output` refer to + * BaseBlocks in the member `blocks` of the containing `WorkBundle`. + */ + Worklet worklet; + /** + * Whether the worklet was processed or not. + */ + bool workletProcessed; + Status result; +}; + +/** + * This structure holds a list of Work objects and a list of BaseBlocks. + */ +struct WorkBundle { + /** + * A list of Work items. + */ + vec<Work> works; + /** + * A list of blocks indexed by elements of #works. + */ + vec<BaseBlock> baseBlocks; +}; + +/** + * This structure describes a query for supported values of a field. This is + * used as input to IConfigurable::queryFieldSupportedValues(). + */ +struct FieldSupportedValuesQuery { + enum Type : uint32_t { + /** Query all possible values regardless of other settings */ + POSSIBLE, + /** Query currently possible values given dependent settings */ + CURRENT, + }; + + ParamField field; + Type type; +}; + +/** + * This structure is used to hold the result from + * IConfigurable::queryFieldSupportedValues(). + */ +struct FieldSupportedValuesQueryResult { + Status status; + FieldSupportedValues values; +}; + |