Codec
简介
该仓下主要包含Codec模块HDI(Hardware Driver Interface)接口定义及其实现,对上层提供媒体编解码的驱动能力接口,HDI接口主要提供如下功能:
- 创建、销毁编解码器对象;
- 启停编解码器
- 原始码流编码为压缩码流;
- 压缩码流恢复为原始码流
- 清除编解码缓存。
目录
该仓下源代码目录结构如下所示
/drivers/peripheral/codec
├── interfaces # codec模块对上层服务提供的驱动能力接口
│ └── include # codec模块对外提供的接口定义
接口说明
Codec驱动提供给framework层可直接调用的能力接口,主要功能有:创建、销毁编解码器对象,启停编解码器操作,编解码处理、清除缓存、事件上报等
提供的部分接口说明如表1 Codec HDI接口列表所示:
表 1 Codec HDI接口列表
头文件
|
接口名称
|
功能描述
|
codec_interface.h
|
int32_t CodecInit();
|
codec模块初始化处理
|
int32_t CodecDeinit();
|
codec模块去初始化处理
|
int32_t CodecEnumerateCapbility(uint32_t index, CodecCapbility *cap);
|
获取某一个编解码能力
|
int32_t CodecGetCapbility(AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility *cap);
|
获取指定编解码能力
|
int32_t CodecCreate(const char* name, const Param *attr, int len, CODEC_HANDLETYPE *handle);
|
创建编解码对象
|
int32_t CodecDestroy(CODEC_HANDLETYPE handle);
|
销毁编解码对象
|
int32_t CodecSetPortMode(CODEC_HANDLETYPE handle, DirectionType type, BufferMode mode);
|
设置端口buffer模式:内部buffer或外部buffer
|
int32_t CodecSetParameter(CODEC_HANDLETYPE handle, const Param *params, int paramCnt);
|
扩展接口。设置编解码属性
|
int32_t CodecGetParameter(CODEC_HANDLETYPE handle, Param *params, int paramCnt);
|
扩展接口。获取编解码属性
|
int32_t CodecStart(CODEC_HANDLETYPE handle);
|
启动工作。
|
int32_t CodecStop(CODEC_HANDLETYPE handle);
|
停止工作
|
int32_t CodecFlush(CODEC_HANDLETYPE handle, DirectionType directType);
|
清除缓存处理
|
int32_t CodecQueueInput(CODEC_HANDLETYPE handle, const InputInfo *inputData, uint32_t timeoutMs);
|
送入输入buffer
|
int32_t CodecDequeInput(CODEC_HANDLETYPE handle, uint32_t timeoutMs, InputInfo *inputData);
|
取出输入buffer
|
int32_t CodecQueueOutput(CODEC_HANDLETYPE handle, OutputInfo *outInfo, uint32_t timeoutMs, int releaseFenceFd);
|
送入输出buffer
|
int32_t CodecDequeueOutput(CODEC_HANDLETYPE handle, uint32_t timeoutMs, int *acquireFd, OutputInfo *outInfo);
|
取出输出buffer
|
int32_t CodecSetCallback(CODEC_HANDLETYPE handle, const CodecCallback *cb, UINTPTR instance);
|
设置回调函数
|
使用说明
该仓核心功能包括两个方面:
- 提供Codec HDI接口供framework层调用,实现编码和解码基本功能。
- 作为标准南向接口,保证南向OEM产商实现HDI-adapter的规范性,保证生态良性演进。
具体接口调用及实现,以接口注释为准。
相关仓
驱动子系统
drivers_framework
drivers_adapter
drivers_adapter_khdf_linux
drivers_peripheral