Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c8b0b4c authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Codec 2.0 HIDL interfaces

Test: Builds

Bug: 31973802
Change-Id: I3704bbc54a059ef26f6ee12431ac8f357ffca36c
parent 643825e4
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_package_root {
    name: "vendor.google.media.c2",
    path: "frameworks/av/media/libstagefright/codec2/hidl/interfaces",
}

hidl_interface {
    name: "vendor.google.media.c2@1.0",
    root: "vendor.google.media.c2",
    vndk: {
        enabled: true,
    },
    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: [
        "Block",
        "BlockId",
        "Buffer",
        "FieldDescriptor",
        "FieldId",
        "FieldSupportedValues",
        "FieldSupportedValuesQuery",
        "FieldSupportedValuesQueryResult",
        "FieldType",
        "FrameData",
        "InfoBuffer",
        "ParamDescriptor",
        "ParamField",
        "ParamFieldValues",
        "SettingResult",
        "Status",
        "StructDescriptor",
        "Work",
        "WorkOrdinal",
        "Worklet",
    ],
    gen_java: false,
}
+311 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 vendor.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);

};
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 vendor.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.
     */
};
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 vendor.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);

};
+213 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 vendor.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);

};
Loading