Codec

    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

    Data Structure Name

    Description

    Describes the dynamic parameter structure, which is mainly used by CodecCreate and .

    BufferHandle

    Defines the buffer handle type. The virtual address of a handle maps to its physical address.

    Describes buffer information.

    InputInfo

    Describes input information.

    Describes output information.

    ResizableArray

    Defines a variable-length queue.

    Defines the alignment.

    Rect

    Defines a rectangle.

    Defines the codec capability.

    CodecCallback

    Defines callbacks and their parameters.

    Macros

    Macro Name and Value

    Description

    ELEMENT_MAX_LEN 50

    Indicates the maximum number of reserved parameters in the array.

    Typedefs

    Typedef Name

    Description

    CODEC_HANDLETYPE

    typedef void

    Defines the pointer to the codec handle, which is the context information for function calls.

    ValueType

    typedef void

    Defines the pointer to the type of the dynamic parameter value.

    BufferHandle

    typedef struct

    Defines the buffer handle type. The virtual address of a handle maps to its physical address.

    BufferType

    typedef enum BufferType

    Enumerates buffer types.

    OutputInfo

    typedef struct

    Describes output information.

    AllocateBufferMode

    typedef enum AllocateBufferMode

    Enumerates allocation modes of input and output buffers.

    CapsMask

    typedef enum

    Enumerates playback capabilities.

    CodecCapbility

    typedef struct Capbility

    Defines the codec capability.

    UINTPTR

    typedef uintptr_t

    Redefines the unsigned pointer type, which is used for pointer conversion.

    Enumerations

    Enumeration Name

    Description

    { VIDEO_DECODER, , AUDIO_DECODER, , INVALID_TYPE }

    Enumerates codec types.

    { KEY_MIMETYPE = 0x01, , KEY_LEFT_STREAM_FRAMES, , KEY_DIRECTION_TYPE, = 0x500, KEY_WIDTH = 0x1000, , KEY_STRIDE, , KEY_PIXEL_FORMAT, , KEY_VIDEO_GOP_MODE, , KEY_VIDEO_PROFILE, , KEY_SAMPLE_RATE = 0x1500, , KEY_CHANNEL_COUNT, , KEY_SOUND_MODE, , KEY_DEVICE_ID }

    Enumerates indexes of parameter types.

    { VENCOD_RC_CBR = 0, , VENCOD_RC_AVBR, , VENCOD_RC_CVBR, , VENCOD_RC_FIXQP }

    Enumerates control modes of the channel encoding rate.

    { Resolution_CIF, , Resolution_D1_PAL, , Resolution_720P, , Resolution_INVALID }

    Enumerates resolutions.

    { VENCOD_GOPMODE_NORMALP = 0, = 1, VENCOD_GOPMODE_SMARTP = 2, = 3, VENCOD_GOPMODE_BIPREDB = 4, = 5, VENCOD_GOPMODE_INVALID }

    Enumerates types of group of pictures (GOP).

    { VID_FIELD_TOP = 0x1, = 0x2, VID_FIELD_INTERLACED = 0x3, = 0x4, VID_FIELD_INVALID }

    Enumerates video frame fields.

    { YVU_SEMIPLANAR_420 = 0, , PIX_FORMAT_INVALID }

    Enumerates pixel formats.

    { AUD_SOUND_MODE_MONO = 0, = 1, AUD_SOUND_MODE_INVALID }

    Enumerates audio channel modes.

    { AUD_SAMPLE_RATE_8000 = 8000, = 12000, AUD_SAMPLE_RATE_11025 = 11025, = 16000, AUD_SAMPLE_RATE_22050 = 22050, = 24000, AUD_SAMPLE_RATE_32000 = 32000, = 44100, AUD_SAMPLE_RATE_48000 = 48000, = 64000, AUD_SAMPLE_RATE_96000 = 96000, }

    Enumerates audio sampling rates.

    AudioBitRate { = 8000, AUD_AAC_BPS_16K = 16000, = 22000, AUD_AAC_BPS_24K = 24000, = 32000, AUD_AAC_BPS_48K = 48000, = 64000, AUD_AAC_BPS_96K = 96000, = 128000, AUD_AAC_BPS_256K = 256000, = 320000 }

    Enumerates audio bit rates.

    StreamFlagType { = 1, STREAM_FLAG_CODEC_SPECIFIC_INF = 2, = 4, STREAM_FLAG_PART_OF_FRAME = 8, = 16 }

    Enumerates stream flags.

    BufferType { = 0, BUFFER_TYPE_FD, }

    Enumerates buffer types.

    AvCodecMime { = 0, MEDIA_MIMETYPE_VIDEO_AVC, , MEDIA_MIMETYPE_AUDIO_AAC, }

    Enumerates MIME types.

    Profile { = 0, AAC_LC_PROFILE = 0x1000, , AAC_HE_V1_PROFILE, , AAC_LD_PROFILE, , AVC_BASELINE_PROFILE = 0x2000, , AVC_HIGH_PROFILE, = 0x3000, HEVC_MAIN_10_PROFILE }

    Enumerates codec profiles.

    { INVALID_LEVEL = 0, = 0x1000, HEVC_LEVEL_MAIN_1 = 0x2000, }

    Enumerates codec levels.

    AllocateBufferMode { = 0x1, ALLOCATE_INPUT_BUFFER_USER = 0x2, = 0x4, ALLOCATE_OUTPUT_BUFFER_USER = 0x8 }

    Enumerates allocation modes of input and output buffers.

    { ADAPTIVE_PLAYBACK = 0x1, = 0x2 }

    Enumerates playback capabilities.

    EventType { , EventFlushCompelte, , EventOutFormatChanged, = 0x1FFFFFFF }

    Enumerates event types.

    DirectionType { , OUTPUT_TYPE, }

    Enumerates input and output types.

    BufferMode { , EXTERNAL }

    Enumerates allocation types.

    { = 100, CODEC_ERR_FRAME_BUF_EMPTY, , CODEC_ERR_INVALID_OP }

    Enumerates codec error types.

    Functions

    Function Name

    Description

    ()

    int32_t

    Initializes the internal audio and video submodules of the codec.

    CodecDeinit ()

    int32_t

    Deinitializes the internal audio and video submodules of the codec.

    (uint32_t index, cap)

    int32_t

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

    CodecGetCapbility ( mime, CodecType type, uint32_t flags, cap)

    int32_t

    Obtains the capabilities of a specified media type.

    CodecCreate (const char name, const attr, int len, CODEC_HANDLETYPE handle)

    int32_t

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

    (CODEC_HANDLETYPE handle)

    int32_t

    Destroys a codec component.

    (CODEC_HANDLETYPE handle, type, BufferMode mode)

    int32_t

    Sets the input or output buffer mode.

    (CODEC_HANDLETYPE handle, const params, int paramCnt)

    int32_t

    Sets parameters required by a codec component.

    CodecGetParameter ( handle, Param params, int paramCnt)

    int32_t

    Obtains parameters from a codec component.

    (CODEC_HANDLETYPE handle)

    int32_t

    Starts a codec component.

    (CODEC_HANDLETYPE handle)

    int32_t

    Stops a codec component.

    (CODEC_HANDLETYPE handle, directType)

    int32_t

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

    CodecQueueInput ( handle, const InputInfo inputData, uint32_t timeoutMs)

    int32_t

    Queues input data.

    (CODEC_HANDLETYPE handle, uint32_t timeoutMs, inputData)

    int32_t

    Dequeues input data that has been used.

    CodecQueueOutput ( handle, OutputInfo outInfo, uint32_t timeoutMs, int releaseFenceFd)

    int32_t

    Queues output data.

    (CODEC_HANDLETYPE handle, uint32_t timeoutMs, int acquireFd, outInfo)

    int32_t

    Dequeues output data.

    CodecSetCallback ( handle, const CodecCallback *cb, instance)

    int32_t

    Sets the callback function.

    Details

    Enumeration Type Documentation

    anonymous enum

    Description:

    Enumerates codec error types.

    Enumerator

    Description

    CODEC_ERR_STREAM_BUF_FULL

    Elementary stream buffer queue is full.

    CODEC_ERR_FRAME_BUF_EMPTY

    Frame buffer queue is empty.

    CODEC_RECEIVE_EOS

    End of streams

    CODEC_ERR_INVALID_OP

    Invalid operation

    AllocateBufferMode

    Description:

    Enumerates allocation modes of input and output buffers.

    Enumerator

    Description

    ALLOCATE_INPUT_BUFFER_CODEC

    Input buffer allocated within the Codec module

    ALLOCATE_INPUT_BUFFER_USER

    Input buffer allocated by an external user

    ALLOCATE_OUTPUT_BUFFER_CODEC

    Output buffer allocated within the Codec module

    ALLOCATE_OUTPUT_BUFFER_USER

    Output buffer allocated by an external user

    AudioBitRate

    1. enum [AudioBitRate]($api-api-SmartVision-Devices-Codec.md#gac8cc627a9912e6a338396a6f19bbba5d)

    Description:

    Enumerates audio bit rates.

    Enumerator

    Description

    AUD_AAC_BPS_8K

    8 kbit/s

    AUD_AAC_BPS_16K

    16 kbit/s

    AUD_AAC_BPS_22K

    22 kbit/s

    AUD_AAC_BPS_24K

    24 kbit/s

    AUD_AAC_BPS_32K

    32 kbit/s

    AUD_AAC_BPS_48K

    48 kbit/s

    AUD_AAC_BPS_64K

    64 kbit/s

    AUD_AAC_BPS_96K

    96 kbit/s

    AUD_AAC_BPS_128K

    128 kbit/s

    AUD_AAC_BPS_256K

    256 kbit/s

    AUD_AAC_BPS_320K

    320 kbit/s

    AudioSampleRate

    1. enum [AudioSampleRate]($api-api-SmartVision-Devices-Codec.md#gaa0280074adafe6d2581d31f71512b842)

    Description:

    Enumerates audio sampling rates.

    Enumerator

    Description

    AUD_SAMPLE_RATE_8000

    8 KHz

    AUD_SAMPLE_RATE_12000

    12 KHz

    AUD_SAMPLE_RATE_11025

    11.025 KHz

    AUD_SAMPLE_RATE_16000

    16 KHz

    AUD_SAMPLE_RATE_22050

    22.050 KHz

    AUD_SAMPLE_RATE_24000

    24 KHz

    AUD_SAMPLE_RATE_32000

    32 KHz

    AUD_SAMPLE_RATE_44100

    44.1 KHz

    AUD_SAMPLE_RATE_48000

    48 KHz

    AUD_SAMPLE_RATE_64000

    64 KHz

    AUD_SAMPLE_RATE_96000

    96 KHz

    AUD_SAMPLE_RATE_INVALID

    Invalid sampling rate

    AudioSoundMode

    1. enum [AudioSoundMode]($api-api-SmartVision-Devices-Codec.md#gacecb40e35c431a27385f7b439fc7a76c)

    Description:

    Enumerates audio channel modes.

    Enumerator

    Description

    AUD_SOUND_MODE_MONO

    Mono channel

    AUD_SOUND_MODE_STEREO

    Stereo mode

    AUD_SOUND_MODE_INVALID

    Invalid mode

    AvCodecMime

    1. enum [AvCodecMime]($api-api-SmartVision-Devices-Codec.md#ga1bee586eafa91dfb60f94ba40fc95faa)

    Description:

    Enumerates MIME types.

    Enumerator

    MEDIA_MIMETYPE_IMAGE_JPEG

    JPEG image

    MEDIA_MIMETYPE_VIDEO_AVC

    H.264 video

    MEDIA_MIMETYPE_VIDEO_HEVC

    H.265 video

    MEDIA_MIMETYPE_AUDIO_AAC

    AAC audio

    MEDIA_MIMETYPE_INVALID

    Invalid MIME type

    1. enum [BufferMode]($api-api-SmartVision-Devices-Codec.md#gacc0fd55192fd9f663121b037b06f41e8)

    Description:

    Enumerates allocation types.

    Enumerator

    Description

    INTERNAL

    Internal

    EXTERNAL

    External

    BufferType

      Description:

      Enumerates buffer types.

      Enumerator

      Description

      BUFFER_TYPE_VIRTUAL

      Virtual memory

      BUFFER_TYPE_FD

      File descriptor, which can be used cross processes

      BUFFER_TYPE_HANDLE

      Handle, which can be used cross processes

      CapsMask

      1. enum [CapsMask]($api-api-SmartVision-Devices-Codec.md#gae5751aa8514dcaf2217df12db5ef57a1)

      Description:

      Enumerates playback capabilities.

      CodecType

      1. enum [CodecType]($api-api-SmartVision-Devices-Codec.md#ga03b4b6ae5fb82af68d46aaea3d3e4d79)

      Description:

      Enumerates codec types.

      Enumerator

      Description

      VIDEO_DECODER

      Video decoding

      VIDEO_ENCODER

      Video encoding

      AUDIO_DECODER

      Audio decoding

      AUDIO_ENCODER

      Audio encoding

      INVALID_TYPE

      Invalid type

      DirectionType

      1. enum [DirectionType]($api-api-SmartVision-Devices-Codec.md#ga8ef30fa9c08e08c8706653571f9f5b81)

      Description:

      Enumerates input and output types.

      Enumerator

      Description

      INPUT_TYPE

      Input

      OUTPUT_TYPE

      Output

      ALL_TYPE

      Input and output

      EventType

      1. enum [EventType]($api-api-SmartVision-Devices-Codec.md#ga2628ea8d12e8b2563c32f05dc7fff6fa)

      Description:

      Enumerates event types.

      Enumerator

      Description

      EventError

      Event error

      EventFlushCompelte

      Buffer flush completed

      EventStopCompelte

      Codec stopped

      EventOutFormatChanged

      Output format changed

      EventMax

      Maximum event value

      Level

      Description:

      Enumerates codec levels.

      Enumerator

      Description

      INVALID_LEVEL

      Invalid level

      AVC_LEVEL_1

      H.264 level 1

      HEVC_LEVEL_MAIN_1

      H.265 Main level 1

      HEVC_LEVEL_MAIN_2

      H.265 Main level 2

      ParamKey

      Description:

      Enumerates indexes of parameter types.

      Enumerator

      Description

      KEY_MIMETYPE

      MIME type. For the value type, see .

      KEY_BUFFERSIZE

      Buffer size. The value type is uint32_t.

      KEY_LEFT_STREAM_FRAMES

      Number of frames in the remaining data streams. The value type is uint32_t.

      KEY_CODEC_TYPE

      Codec type. For the value type, see CodecType.

      KEY_DIRECTION_TYPE

      Input/Output type. For the value type, see .

      KEY_BITRATE

      Bit rate. The value type is uint32_t.

      KEY_WIDTH

      Width. The value type is uint32_t.

      KEY_HEIGHT

      Hight. The value type is uint32_t.

      KEY_STRIDE

      Stride. The value type is uint32_t.

      KEY_VIDEO_FIELD

      Video field. For the value type, see VideoField.

      KEY_PIXEL_FORMAT

      Pixel format. For the value type, see .

      KEY_VIDEO_RC_MODE

      Rate control mode. For the value type, see VenCodeRcMode.

      KEY_VIDEO_GOP_MODE

      GOP mode. For the value type, see .

      KEY_VIDEO_PIC_SIZE

      Image resolution. For the value type, see PicSize.

      KEY_VIDEO_PROFILE

      Codec profile. The value type is uint32_t.

      KEY_VIDEO_FRAME_RATE

      Frame rate. The value type is uint32_t.

      KEY_SAMPLE_RATE

      Sampling rate. The value type is uint32_t.

      KEY_AUDIO_PROFILE

      Audio encoding profile. The value type is uint32_t.

      KEY_CHANNEL_COUNT

      Number of channels. The value type is uint32_t.

      KEY_BITWITH

      Bit width. For the value type, see .

      KEY_SOUND_MODE

      Audio channel mode. For the value type, see AudioSoundMode.

      KEY_POINT_NUM_PER_FRAME

      Number of sampling points per frame. The value type is uint32_t.

      KEY_DEVICE_ID

      Device ID. The value type is uint32_t.

      PicSize

      1. enum [PicSize]($api-api-SmartVision-Devices-Codec.md#ga94981b885085085ed5f9dea406519b48)

      Description:

      Enumerates resolutions.

      Enumerator

      Description

      Resolution_CIF

      352x288

      Resolution_360P

      640x360

      Resolution_D1_PAL

      720x576

      Resolution_D1_NTSC

      720x480

      Resolution_720P

      1280x720

      Resolution_1080P

      1920x1080

      Resolution_INVALID

      Invalid resolution

      PixelFormat

      1. enum [PixelFormat]($api-api-SmartVision-Devices-Codec.md#ga60883d4958a60b91661e97027a85072a)

      Description:

      Enumerates pixel formats.

      Enumerator

      Description

      YVU_SEMIPLANAR_420

      YUV 420 SP

      YVU_SEMIPLANAR_420_TILE

      YUV SP 420 TILE

      PIX_FORMAT_INVALID

      Invalid format

      Profile

      1. enum [Profile]($api-api-SmartVision-Devices-Codec.md#ga85b10143618f300ff4f5bc6d45c72c01)

      Description:

      Enumerates codec profiles.

      Enumerator

      Description

      INVALID_PROFILE

      Invalid profile

      AAC_LC_PROFILE

      AAC-Low Complex

      AAC_MAIN_PROFILE

      AAC-Main

      AAC_HE_V1_PROFILE

      HEAAC, AAC+, or AACPlusV1

      AAC_HE_V2_PROFILE

      AAC++ or AACPlusV2

      AAC_LD_PROFILE

      AAC-Low Delay

      AAC_ELD_PROFILE

      AAC-Enhanced Low Delay

      AVC_BASELINE_PROFILE

      H.264 Baseline

      AVC_MAIN_PROFILE

      H.264 Main

      AVC_HIGH_PROFILE

      H.264 High

      HEVC_MAIN_PROFILE

      H.265 Main

      HEVC_MAIN_10_PROFILE

      H.265 Main 10

      StreamFlagType

      1. enum [StreamFlagType]($api-api-SmartVision-Devices-Codec.md#ga8a15793172118d64d8adeba0c8544e84)

      Description:

      Enumerates stream flags.

      Enumerator

      Description

      STREAM_FLAG_KEYFRAME

      Keyframe

      STREAM_FLAG_CODEC_SPECIFIC_INF

      Codec specifications

      STREAM_FLAG_EOS

      End of streams

      STREAM_FLAG_PART_OF_FRAME

      Partial frame

      STREAM_FLAG_END_OF_FRAME

      End of frames, used in pair with STREAM_FLAG_PART_OF_FRAME

      VenCodeGopMode

      1. enum [VenCodeGopMode]($api-api-SmartVision-Devices-Codec.md#ga9532f651a003219a262c440f5621d129)

      Description:

      Enumerates types of group of pictures (GOP).

      Description

      VENCOD_GOPMODE_NORMALP

      P-frames using only one reference frame during encoding

      VENCOD_GOPMODE_DUALP

      P-frames using two reference frames during encoding

      VENCOD_GOPMODE_SMARTP

      Smart P-frames for encoding

      VENCOD_GOPMODE_ADVSMARTP

      Advanced smart P-frames for encoding

      VENCOD_GOPMODE_BIPREDB

      B-frames for encoding

      VENCOD_GOPMODE_LOWDELAYB

      B-frames using only previous frames as references during encoding.

      VENCOD_GOPMODE_INVALID

      Invalid type

      VenCodeRcMode

      1. enum [VenCodeRcMode]($api-api-SmartVision-Devices-Codec.md#ga94267d7ba495136561e1c65686b240f7)

      Description:

      Enumerates control modes of the channel encoding rate.

      Enumerator

      Description

      VENCOD_RC_CBR

      Fixed bit rate

      VENCOD_RC_VBR

      Variable bit rate

      VENCOD_RC_AVBR

      Adaptive variable bit rate

      VENCOD_RC_QVBR

      Quality-defined variable bit rate

      VENCOD_RC_CVBR

      Constrained variable bit rate

      VENCOD_RC_QPMAP

      Configuration-mapped quantization parameters

      VENCOD_RC_FIXQP

      Fixed quantization parameters

      VideoField

      1. enum [VideoField]($api-api-SmartVision-Devices-Codec.md#ga1420ddfb066b941fb55a153b869d9ccf)

      Description:

      Enumerates video frame fields.

      Enumerator

      Description

      VID_FIELD_TOP

      Top fields on even-number lines

      VID_FIELD_BOTTOM

      Bottom fields on odd-number lines

      VID_FIELD_INTERLACED

      Interlaced fields

      VID_FIELD_FRAME

      Non-interlaced frames

      VID_FIELD_INVALID

      Invalid fields

      Function Documentation

      1. 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:

      Name

      Description

      name

      Indicates the pointer to the unique name of the component, for example, codec.avc.hardware.decoder.

      attr

      Indicates the pointer to the parameters in the array required for creating the component.

      len

      Indicates the number of elements in the parameter array.

      handle

      Indicates the pointer to the codec handle returned.

      Returns:

      Returns 0 if the codec component is created and the handle is available; returns a non-zero value otherwise.

      CodecDeinit()

      1. 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:

      CodecInit

      CodecDequeInput()

      1. 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:

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      CodecDequeueOutput()

      Description:

      Dequeues output data.

      This function works with to implement output data transmission.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      timeoutMs

      Indicates the timeout duration.

      acquireFd

      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.

      outInfo

      Indicates the pointer to the output data.

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      CodecDestroy()

      Description:

      Destroys a codec component.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      Returns:

      Returns 0 if the codec component is destroyed; returns a non-zero value otherwise.

      See also:

      CodecEnumerateCapbility()

      1. 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:

      Name

      Description

      index

      Indicates the index of the capabilities.

      cap

      Indicates the pointer to the capabilities.

      Returns:

      Returns CODEC_SUCCESS if the capabilities corresponding to the index are available; returns CODEC_END otherwise.

      CodecFlush()

      1. 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:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      CodecGetCapbility()

      1. 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:

      Name

      Description

      mime

      Indicates the media type. For details, see AvCodecMime.

      type

      Indicates the audio and video codec types. For details, see .

      flags

      Indicates the audio and video codec flags. 0 indicates hardware codec, and 1 indicates software codec.

      cap

      Indicates the pointer to the capabilities.

      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()

      1. 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 .

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      params

      Indicates the pointer to the parameters in the array used when the component is created.

      paramCnt

      Indicates the number of elements in the parameter array.

      Returns:

      Returns 0 if all parameters to obtain are supported; returns a non-zero value otherwise.

      See also:

      CodecInit()

      1. 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()

      1. 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 to implement input data transmission.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      inputData

      Indicates the pointer to the input data.

      timeoutMs

      Indicates the timeout duration.

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      CodecQueueOutput()

      1. 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:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      outInfo

      Indicates the pointer to the output data.

      timeoutMs

      Indicates the timeout duration.

      releaseFenceFd

      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()

      1. 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:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      cb

      Indicates the pointer to the callback function. For details, see CodecCallback.

      instance

      Indicates the upper-layer instance to be notified.

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      CodecSetParameter()

      1. 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 is called.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      params

      Indicates the pointer to the parameters to set in the array.

      paramCnt

      Indicates the number of elements in the parameter array.

      Returns:

      Returns 0 if the setting is successful; returns a non-zero value otherwise.

      See also:

      CodecSetPortMode()

      1. 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 . 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:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      type

      Specifies whether the buffer type is an input type or an output type.

      mode

      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()

      Description:

      Starts a codec component.

      You can restart a component after it is stopped.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      Returns:

      Returns 0 if the operation is successful; returns a non-zero value otherwise.

      Description:

      Stops a codec component.

      Parameters:

      Name

      Description

      handle

      Indicates the handle of the codec component.

      Returns: