69 Star 68 Fork 971

OpenHarmony / drivers_peripheral

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 27.13 KB
一键复制 编辑 原始数据 按行查看 历史
王勃懿 提交于 2023-04-24 09:15 . fix:modify dead url

Codec

Introduction

This repository mainly defines and implements the Hardware Driver Interfaces (HDIs) of the codec module, allowing upper-layer services to perform the following operations:

  • Creating and destroying a codec
  • Starting and stopping the codec
  • Encoding original code streams into compressed code streams
  • Decoding compressed code streams into original code streams
  • Flushing the cache

Directory Structure

The source code directory structure is as follows:

/drivers/peripheral/codec
├── interfaces         # Driver capability APIs provided for upper-layer services
│   └── include       # APIs exposed externally

Available APIs

The codec module provides APIs that can be directly called by the framework layer to create or destroy a codec, start or stop a codec, perform encoding or decoding operations, flush the cache, and set a callback.

The table below describes major HDI 1.0 APIs provided by the codec module.

Table 1 Major HDI 1.0 APIs of the codec module

Header File

API

Description

codec_interface.h

int32_t CodecInit();

Initializes the internal audio and video submodules of the codec.

int32_t CodecDeinit();

Deinitializes the internal audio and video submodules of the codec.

int32_t CodecEnumerateCapbility(uint32_t index, CodecCapbility *cap);

Obtains the capabilities of a specified media type based on an index.

int32_t CodecGetCapbility(AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility *cap);

Obtains the capabilities of a specified media type.

int32_t CodecCreate(const char* name, const Param *attr, int len, CODEC_HANDLETYPE *handle);

Creates a specific codec component and returns the component context through a handle.

int32_t CodecDestroy(CODEC_HANDLETYPE handle);

Destroys a codec component.

int32_t CodecSetPortMode(CODEC_HANDLETYPE handle, DirectionType type, BufferMode mode);

Sets the input or output buffer mode.

int32_t CodecSetParameter(CODEC_HANDLETYPE handle, const Param *params, int paramCnt);

Sets parameters required by a codec component.

int32_t CodecGetParameter(CODEC_HANDLETYPE handle, Param *params, int paramCnt);

Obtains parameters from a codec component.

int32_t CodecStart(CODEC_HANDLETYPE handle);

Starts a codec component.

int32_t CodecStop(CODEC_HANDLETYPE handle);

Stops a codec component.

int32_t CodecFlush(CODEC_HANDLETYPE handle, DirectionType directType);

Clears the cache when the codec component is the running state.

int32_t CodecQueueInput(CODEC_HANDLETYPE handle, const InputInfo *inputData, uint32_t timeoutMs);

Queues input data.

int32_t CodecDequeInput(CODEC_HANDLETYPE handle, uint32_t timeoutMs, InputInfo *inputData);

Dequeues input data that has been used.

int32_t CodecQueueOutput(CODEC_HANDLETYPE handle, OutputInfo *outInfo, uint32_t timeoutMs, int releaseFenceFd);

Queues output data.

int32_t CodecDequeueOutput(CODEC_HANDLETYPE handle, uint32_t timeoutMs, int *acquireFd, OutputInfo *outInfo);

Dequeues output data.

int32_t CodecSetCallback(CODEC_HANDLETYPE handle, const CodecCallback *cb, UINTPTR instance);

Sets the callback function.

The codec module also provides codec HDI 2.0 APIs based on the OMX interfaces. The table below describes the HDI 2.0 APIs.

Table 2 HDI 2.0 APIs of the codec module

Header File

API

Description

codec_component _manager.h

int32_t (*GetComponentNum)();

Obtains the number of codec components

int32_t (*GetComponentCapabilityList)(CodecCompCapability *capList, int32_t count);

Obtains the codec capability list

int32_t (*CreateComponent)(struct CodecComponentType **component, uint32_t *componentId, char *compName, int64_t appData, struct CodecCallbackType *callbacks);

Creates a codec instance

int32_t (*DestroyComponent)(uint32_t componentId);

Destroys a codec component instance

codec_component _if.h

int32_t (*GetComponentVersion)(struct CodecComponentType *self, struct CompVerInfo *verInfo);

Obtains the version of a codec component

int32_t (*SendCommand)(struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen);

Sends a command to a component

int32_t (*GetParameter)(struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen);

Obtains parameter settings of a component

int32_t (*SetParameter)(struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen);

Sets parameters for a component

int32_t (*GetConfig)(struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen);

Obtains the configuration of a component

int32_t (*SetConfig)(struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen);

Sets the component parameters

int32_t (*GetExtensionIndex)(struct CodecComponentType *self, const char *paramName, uint32_t *indexType);

Obtains the extended index of a component based on a given string

int32_t (*GetState)(struct CodecComponentType *self, enum OMX_STATETYPE *state);

Obtains component status

int32_t (*ComponentTunnelRequest)(struct CodecComponentType *self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup);

Sets tunnel communication for a component

int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer);

Specify the buffer of the component port

int32_t (*AllocateBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer);

Requests a port buffer from the component

int32_t (*FreeBuffer)(struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer);

Releases a buffer

int32_t (*EmptyThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer);

Specify the buffer to be emptied by a component

int32_t (*FillThisBuffer)(struct CodecComponentType *self, const struct OmxCodecBuffer *buffer);

Specify the buffer to be filled with the encoding and decoding output by a component

int32_t (*SetCallbacks)(struct CodecComponentType *self, struct CodecCallbackType *callback, int64_t appData);

Set a callback for the codec component

int32_t (*ComponentDeInit)(struct CodecComponentType *self);

Deinitializes a component

int32_t (*UseEglImage)(struct CodecComponentType *self, struct OmxCodecBuffer *buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen);

Uses the space allocated by EGL

int32_t (*ComponentRoleEnum)(struct CodecComponentType *self, uint8_t *role, uint32_t roleLen, uint32_t index);

Obtains the component roles

codec_callback_if.h

int32_t (*EventHandler)(struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info);

Reports an event

int32_t (*EmptyBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);

Reports an event indicating that the encoding or decoding in the input buffer is complete

int32_t (*FillBufferDone)(struct CodecCallbackType *self, int64_t appData, const struct OmxCodecBuffer *buffer);

Reports an event indicating that the output buffer is filled

Usage Guidelines

The core functionalities of this repository are as follows:

  • Provides codec HDIs that can be directly called by the framework layer to perform encoding and decoding-related operations.
  • Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem.

For details about the invocation and implementation, see the API reference.

Repositories Involved

Driver subsystem

drivers_framework

drivers_adapter

drivers_adapter_khdf_linux

drivers_peripheral

1
https://gitee.com/openharmony/drivers_peripheral.git
git@gitee.com:openharmony/drivers_peripheral.git
openharmony
drivers_peripheral
drivers_peripheral
master

搜索帮助