- Codec
- Overview
- Summary
- Files
- Data Structures
- Macros
- Typedefs
- Enumerations
- Functions
- Details
- Enumeration Type Documentation
- anonymous enum
- AllocateBufferMode
- AudioBitRate
- AudioSampleRate
- AudioSoundMode
- AvCodecMime
- BufferMode
- BufferType
- CapsMask
- CodecType
- DirectionType
- EventType
- Level
- ParamKey
- PicSize
- PixelFormat
- Profile
- StreamFlagType
- VenCodeGopMode
- VenCodeRcMode
- VideoField
- Function Documentation
- CodecCreate()
- CodecDeinit()
- CodecDequeInput()
- CodecDequeueOutput()
- CodecDestroy()
- CodecEnumerateCapbility()
- CodecFlush()
- CodecGetCapbility()
- CodecGetParameter()
- CodecInit()
- CodecQueueInput()
- CodecQueueOutput()
- CodecSetCallback()
- CodecSetParameter()
- CodecSetPortMode()
- CodecStart()
- CodecStop()
Codec
Overview
Defines codec-related APIs.
including custom data types and functions for initializing audio and video codecs, setting parameters, and controlling and transferring data.
Since:
1.0
Version:
1.0
Summary
Files
Data Structures
Describes the dynamic parameter structure, which is mainly used by CodecCreate and CodecSetParameter. |
|
Defines the buffer handle type. The virtual address of a handle maps to its physical address. |
|
Macros
Indicates the maximum number of reserved parameters in the array. |
Typedefs
Defines the pointer to the codec handle, which is the context information for function calls. |
|
Defines the pointer to the type of the dynamic parameter value. |
|
typedef struct BufferHandle Defines the buffer handle type. The virtual address of a handle maps to its physical address. |
|
typedef enum BufferType |
|
typedef struct OutputInfo |
|
typedef enum AllocateBufferMode |
|
typedef enum CapsMask |
|
typedef struct Capbility |
|
Redefines the unsigned pointer type, which is used for pointer conversion. |
Enumerations
Functions
CodecInit () |
Initializes the internal audio and video submodules of the codec. |
CodecDeinit () |
Deinitializes the internal audio and video submodules of the codec. |
CodecEnumerateCapbility (uint32_t index, CodecCapbility cap) |
Obtains the capabilities of a specified media type based on an index. |
CodecGetCapbility (AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility cap) |
|
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. |
CodecDestroy (CODEC_HANDLETYPE handle) |
|
CodecSetPortMode (CODEC_HANDLETYPE handle, DirectionType type, BufferMode mode) |
|
CodecSetParameter (CODEC_HANDLETYPE handle, const Param params, int paramCnt) |
|
CodecGetParameter (CODEC_HANDLETYPE handle, Param params, int paramCnt) |
|
CodecStart (CODEC_HANDLETYPE handle) |
|
CodecStop (CODEC_HANDLETYPE handle) |
|
CodecFlush (CODEC_HANDLETYPE handle, DirectionType directType) |
Clears the cache when the codec component is the running state. |
CodecQueueInput (CODEC_HANDLETYPE handle, const InputInfo inputData, uint32_t timeoutMs) |
|
CodecDequeInput (CODEC_HANDLETYPE handle, uint32_t timeoutMs, InputInfo inputData) |
|
CodecQueueOutput (CODEC_HANDLETYPE handle, OutputInfo outInfo, uint32_t timeoutMs, int releaseFenceFd) |
|
CodecDequeueOutput (CODEC_HANDLETYPE handle, uint32_t timeoutMs, int acquireFd, OutputInfo outInfo) |
|
CodecSetCallback (CODEC_HANDLETYPE handle, const CodecCallback *cb, UINTPTR instance) |
Details
Enumeration Type Documentation
anonymous enum
anonymous enum
Description:
Enumerates codec error types.
AllocateBufferMode
enum [AllocateBufferMode]($api-api-SmartVision-Devices-Codec.md#gaeae808d52153b2e33c6815162bbd11e0)
Description:
Enumerates allocation modes of input and output buffers.
AudioBitRate
enum [AudioBitRate]($api-api-SmartVision-Devices-Codec.md#gac8cc627a9912e6a338396a6f19bbba5d)
Description:
Enumerates audio bit rates.
AudioSampleRate
enum [AudioSampleRate]($api-api-SmartVision-Devices-Codec.md#gaa0280074adafe6d2581d31f71512b842)
Description:
Enumerates audio sampling rates.
AudioSoundMode
enum [AudioSoundMode]($api-api-SmartVision-Devices-Codec.md#gacecb40e35c431a27385f7b439fc7a76c)
Description:
Enumerates audio channel modes.
AvCodecMime
enum [AvCodecMime]($api-api-SmartVision-Devices-Codec.md#ga1bee586eafa91dfb60f94ba40fc95faa)
Description:
Enumerates MIME types.
BufferMode
enum [BufferMode]($api-api-SmartVision-Devices-Codec.md#gacc0fd55192fd9f663121b037b06f41e8)
Description:
Enumerates allocation types.
BufferType
enum [BufferType]($api-api-SmartVision-Devices-Codec.md#gadf8e136713c0691010d2bec6ba63e9cf)
Description:
Enumerates buffer types.
CapsMask
enum [CapsMask]($api-api-SmartVision-Devices-Codec.md#gae5751aa8514dcaf2217df12db5ef57a1)
Description:
Enumerates playback capabilities.
CodecType
enum [CodecType]($api-api-SmartVision-Devices-Codec.md#ga03b4b6ae5fb82af68d46aaea3d3e4d79)
Description:
Enumerates codec types.
DirectionType
enum [DirectionType]($api-api-SmartVision-Devices-Codec.md#ga8ef30fa9c08e08c8706653571f9f5b81)
Description:
Enumerates input and output types.
EventType
enum [EventType]($api-api-SmartVision-Devices-Codec.md#ga2628ea8d12e8b2563c32f05dc7fff6fa)
Description:
Enumerates event types.
Level
enum [Level]($api-api-SmartVision-Devices-Codec.md#ga221b779e6bb7b8d40677d7642bfefac5)
Description:
Enumerates codec levels.
ParamKey
enum [ParamKey]($api-api-SmartVision-Devices-Codec.md#ga575c56a2d6b42c48881cf47b0008d5a6)
Description:
Enumerates indexes of parameter types.
MIME type. For the value type, see AvCodecMime. |
|
Number of frames in the remaining data streams. The value type is uint32_t. |
|
Codec type. For the value type, see CodecType. |
|
Input/Output type. For the value type, see DirectionType. |
|
Video field. For the value type, see VideoField. |
|
Pixel format. For the value type, see PixelFormat. |
|
Rate control mode. For the value type, see VenCodeRcMode. |
|
GOP mode. For the value type, see VenCodeGopMode. |
|
Image resolution. For the value type, see PicSize. |
|
Bit width. For the value type, see AudioBitWidth. |
|
Audio channel mode. For the value type, see AudioSoundMode. |
|
Number of sampling points per frame. The value type is uint32_t. |
|
PicSize
enum [PicSize]($api-api-SmartVision-Devices-Codec.md#ga94981b885085085ed5f9dea406519b48)
Description:
Enumerates resolutions.
PixelFormat
enum [PixelFormat]($api-api-SmartVision-Devices-Codec.md#ga60883d4958a60b91661e97027a85072a)
Description:
Enumerates pixel formats.
Profile
enum [Profile]($api-api-SmartVision-Devices-Codec.md#ga85b10143618f300ff4f5bc6d45c72c01)
Description:
Enumerates codec profiles.
StreamFlagType
enum [StreamFlagType]($api-api-SmartVision-Devices-Codec.md#ga8a15793172118d64d8adeba0c8544e84)
Description:
Enumerates stream flags.
VenCodeGopMode
enum [VenCodeGopMode]($api-api-SmartVision-Devices-Codec.md#ga9532f651a003219a262c440f5621d129)
Description:
Enumerates types of group of pictures (GOP).
B-frames using only previous frames as references during encoding. |
|
VenCodeRcMode
enum [VenCodeRcMode]($api-api-SmartVision-Devices-Codec.md#ga94267d7ba495136561e1c65686b240f7)
Description:
Enumerates control modes of the channel encoding rate.
VideoField
enum [VideoField]($api-api-SmartVision-Devices-Codec.md#ga1420ddfb066b941fb55a153b869d9ccf)
Description:
Enumerates video frame fields.
Function Documentation
CodecCreate()
int32_t CodecCreate (const char * name, const [Param]($api-api-SmartVision-Devices-zh-cn_topic_0000001054718161.md) * attr, int len, [CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) * handle )
Description:
Creates a specific codec component and returns the component context through a handle.
You can adjust the parameters required for creating a component based on service requirements.
Parameters:
Indicates the pointer to the unique name of the component, for example, codec.avc.hardware.decoder. |
|
Indicates the pointer to the parameters in the array required for creating the component. |
|
Returns:
Returns 0 if the codec component is created and the handle is available; returns a non-zero value otherwise.
CodecDeinit()
int32_t CodecDeinit ()
Description:
Deinitializes the internal audio and video submodules of the codec.
This function needs to be called only once in a process.
Returns:
Returns 0 if the deinitialization is successful; returns a non-zero value otherwise.
See also:
CodecDequeInput()
int32_t CodecDequeInput ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, uint32_t timeoutMs, [InputInfo]($api-api-SmartVision-Devices-zh-cn_topic_0000001054879536.md) * inputData )
Description:
Dequeues input data that has been used.
This function works with CodecQueueInput to implement input data transmission.
Parameters:
Indicates the timeout duration. Generally, the value is less than or equal to 3 seconds. |
|
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecDequeueOutput()
int32_t CodecDequeueOutput ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, uint32_t timeoutMs, int * acquireFd, [OutputInfo]($api-api-SmartVision-Devices-zh-cn_topic_0000001054918167.md) * outInfo )
Description:
Dequeues output data.
This function works with CodecQueueOutput to implement output data transmission.
Parameters:
Indicates that this parameter is derived from the codec mode. The output data can be used only after waiting for acquireFd is successful. The value -1 indicates that acquireFd is invalid. |
|
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecDestroy()
int32_t CodecDestroy ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle)
Description:
Destroys a codec component.
Parameters:
Returns:
Returns 0 if the codec component is destroyed; returns a non-zero value otherwise.
See also:
CodecEnumerateCapbility()
int32_t CodecEnumerateCapbility (uint32_t index, [CodecCapbility]($api-api-SmartVision-Devices-Codec.md#ga1876710b1f2fe1d80e8b9de9ff28e0e3) * cap )
Description:
Obtains the capabilities of a specified media type based on an index.
You can call this function repeatedly to obtain the codec capabilities until CODEC_END is returned. The corresponding capabilities are described in the Capability structure, including the maximum and minimum resolutions, maximum and minimum bit rates, and supported profiles and levels. After obtaining the capabilities, determine whether they can meet your requirements, for example, whether specific media files can be played and whether audio and video frames can be compressed.
Parameters:
Returns:
Returns CODEC_SUCCESS if the capabilities corresponding to the index are available; returns CODEC_END otherwise.
CodecFlush()
int32_t CodecFlush ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, [DirectionType]($api-api-SmartVision-Devices-Codec.md#ga8ef30fa9c08e08c8706653571f9f5b81) directType )
Description:
Clears the cache when the codec component is the running state.
Generally, this function is called when the seek operation is performed during playback.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecGetCapbility()
int32_t CodecGetCapbility ([AvCodecMime]($api-api-SmartVision-Devices-Codec.md#ga1bee586eafa91dfb60f94ba40fc95faa) mime, [CodecType]($api-api-SmartVision-Devices-Codec.md#ga03b4b6ae5fb82af68d46aaea3d3e4d79) type, uint32_t flags, [CodecCapbility]($api-api-SmartVision-Devices-Codec.md#ga1876710b1f2fe1d80e8b9de9ff28e0e3) * cap )
Description:
Obtains the capabilities of a specified media type.
You can call this function to obtain the codec capabilities. The corresponding capabilities are described in the Capability structure, including the maximum and minimum resolutions, maximum and minimum bit rates, and supported profiles and levels. After obtaining the capabilities, determine whether they can meet your requirements, for example, whether specific media files can be played and whether audio and video frames can be compressed.
Parameters:
Indicates the media type. For details, see AvCodecMime. |
|
Indicates the audio and video codec types. For details, see CodecType. |
|
Indicates the audio and video codec flags. 0 indicates hardware codec, and 1 indicates software codec. |
|
Returns:
Returns 0 if the codec is supported and capabilities are available; returns a non-zero value if the codec is not supported or the capabilities are unavailable.
CodecGetParameter()
int32_t CodecGetParameter ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, [Param]($api-api-SmartVision-Devices-zh-cn_topic_0000001054718161.md) * params, int paramCnt )
Description:
Obtains parameters from a codec component.
This function must be called after CodecCreate.
Parameters:
Indicates the pointer to the parameters in the array used when the component is created. |
|
Returns:
Returns 0 if all parameters to obtain are supported; returns a non-zero value otherwise.
See also:
CodecInit()
int32_t CodecInit ()
Description:
Initializes the internal audio and video submodules of the codec.
This function needs to be called only once in a process.
Returns:
Returns 0 if the initialization is successful; returns a non-zero value otherwise.
See also:
CodecQueueInput()
int32_t CodecQueueInput ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, const [InputInfo]($api-api-SmartVision-Devices-zh-cn_topic_0000001054879536.md) * inputData, uint32_t timeoutMs )
Description:
Queues input data.
This function works with CodecDequeInput to implement input data transmission.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecQueueOutput()
int32_t CodecQueueOutput ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, [OutputInfo]($api-api-SmartVision-Devices-zh-cn_topic_0000001054918167.md) * outInfo, uint32_t timeoutMs, int releaseFenceFd )
Description:
Queues output data.
This function works with CodecDequeueOutput to implement output data transmission.
Parameters:
Indicates that the descriptor comes from a buffer consumer. The output data can be used only after waiting for releaseFenceFd is successful. The value -1 indicates that releaseFenceFd is invalid. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecSetCallback()
int32_t CodecSetCallback ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, const [CodecCallback]($api-api-SmartVision-Devices-zh-cn_topic_0000001055358102.md) * cb, [UINTPTR]($api-api-SmartVision-Devices-Codec.md#ga58d2f4a8d12daa1dcf4eb297f3ebaabc) instance )
Description:
Sets the callback function.
The codec uses the callback function to notify the upper layer of events and asynchronously report available input/output information.
Parameters:
Indicates the pointer to the callback function. For details, see CodecCallback. |
|
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecSetParameter()
int32_t CodecSetParameter ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, const [Param]($api-api-SmartVision-Devices-zh-cn_topic_0000001054718161.md) * params, int paramCnt )
Description:
Sets parameters required by a codec component.
You should call this function to set parameters after CodecCreate is called but before CodecStart is called.
Parameters:
Indicates the pointer to the parameters to set in the array. |
|
Returns:
Returns 0 if the setting is successful; returns a non-zero value otherwise.
See also:
CodecSetPortMode()
int32_t CodecSetPortMode ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle, [DirectionType]($api-api-SmartVision-Devices-Codec.md#ga8ef30fa9c08e08c8706653571f9f5b81) type, [BufferMode]($api-api-SmartVision-Devices-Codec.md#gacc0fd55192fd9f663121b037b06f41e8) mode )
Description:
Sets the input or output buffer mode.
You can learn about the support of the codec input/output buffer for internal and external buffer modes by calling CodecGetCapbility. In this way, you can determine whether to use an internal or external buffer mode. If the current codec can use only the specific buffer mode, you do not need to set it.
Parameters:
Specifies whether the buffer type is an input type or an output type. |
|
Specifies whether to use an internal or external buffer mode. |
Returns:
Returns 0 if the setting is successful; returns a non-zero value otherwise.
CodecStart()
int32_t CodecStart ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle)
Description:
Starts a codec component.
You can restart a component after it is stopped.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
CodecStop()
int32_t CodecStop ([CODEC_HANDLETYPE]($api-api-SmartVision-Devices-Codec.md#ga9381a619f36ac8d5d7f467d2f0404183) handle)
Description:
Stops a codec component.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.