diff --git a/codec/bundle.json b/codec/bundle.json index 4af10caac0a3177ed677811572c0148e5590a6d0..f35e4c5129d6a811a927ac698854d33e10a9c241 100644 --- a/codec/bundle.json +++ b/codec/bundle.json @@ -13,7 +13,7 @@ "name": "drivers_interface_codec", "subsystem": "hdf", "syscap": [], - "adapted_system_type": ["standard"], + "adapted_system_type": ["small,standard"], "rom": "675KB", "ram": "7400KB", "deps": { @@ -28,6 +28,7 @@ "build": { "sub_component": [ "//drivers/interface/codec/v1_0:codec_idl_target", + "//drivers/interface/codec/v2_0:codec_idl_target", "//drivers/interface/codec/image/v1_0:image_idl_target" ], "test": [ @@ -57,6 +58,30 @@ "header_base": "//drivers/interface/codec" } }, + { + "name": "//drivers/interface/codec/v2_0:libcodec_proxy_2.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/codec" + } + }, + { + "name": "//drivers/interface/codec/v2_0:codec_idl_headers", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/codec" + } + }, + { + "name": "//drivers/interface/codec/v2_0:libcodec_stub_2.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/codec" + } + }, { "name": "//drivers/interface/codec/image/v1_0:libimage_proxy_1.0", "header": { diff --git a/codec/v2_0/BUILD.gn b/codec/v2_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d2112592a5dfdcc750dccbb58075a247c6a3e5e7 --- /dev/null +++ b/codec/v2_0/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# 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. + +import("../../../hdf_core/adapter/uhdf2/hdi.gni") +if (defined(ohos_lite)) { + group("libcodec_proxy_2.0") { + deps = [] + public_configs = [] + } +} else { + hdi("codec") { + module_name = "codec_service" + + sources = [ + "CodecExtTypes.idl", + "CodecTypes.idl", + "ICodecCallback.idl", + "ICodecComponent.idl", + "ICodecComponentManager.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_codec" + } +} diff --git a/codec/v2_0/CodecExtTypes.idl b/codec/v2_0/CodecExtTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..85cbdfa46820afb9344ff56b4b77de74ab432133 --- /dev/null +++ b/codec/v2_0/CodecExtTypes.idl @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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 ohos.hdi.codec.v2_0; + +import ohos.hdi.codec.v2_0.CodecTypes; + +/** + * @brief Enumerates the extended codec codingtyps. + */ +enum CodecVideoExType { + CODEC_VIDEO_CodingVP9 = 10, /** VP9 Index in Codec HDI */ + CODEC_VIDEO_CodingHEVC = 11, /** HEVC Index in Codec HDI */ +}; + +/** + * @brief Enumerates the extended HEVC profile. + */ +enum CodecHevcProfile { + CODEC_HEVC_PROFILE_INVALID = 0x0, + CODEC_HEVC_PROFILE_MAIN = 0x1, + CODEC_HEVC_PROFILE_MAIN10 = 0x2, + CODEC_HEVC_PROFILE_MAIN_STILL = 0x3, + // main_10 profile with HDR SEI support. + CODEC_HEVC_PROFILE_MAIN10_HDR10 = 0x1000, + CODEC_HEVC_PROFILE_MAIN10_HDR10_PLUS = 0x2000, + CODEC_HEVC_PROFILE_MAX = 0x7FFFFFFF +}; + +/** + * @brief Enumerates the extended HEVC level. + */ +enum CodecHevcLevel { + CODEC_HEVC_LEVEL_INVALID = 0x0, + CODEC_HEVC_MAIN_TIER_LEVEL1 = 0x1, + CODEC_HEVC_HIGH_TIER_LEVEL1 = 0x2, + CODEC_HEVC_MAIN_TIER_LEVEL2 = 0x4, + CODEC_HEVC_HIGH_TIER_LEVEL2 = 0x8, + CODEC_HEVC_MAIN_TIER_LEVEL21 = 0x10, + CODEC_HEVC_HIGH_TIER_LEVEL21 = 0x20, + CODEC_HEVC_MAIN_TIER_LEVEL3 = 0x40, + CODEC_HEVC_HIGH_TIER_LEVEL3 = 0x80, + CODEC_HEVC_MAIN_TIER_LEVEL31 = 0x100, + CODEC_HEVC_HIGH_TIER_LEVEL31 = 0x200, + CODEC_HEVC_MAIN_TIER_LEVEL4 = 0x400, + CODEC_HEVC_HIGH_TIER_LEVEL4 = 0x800, + CODEC_HEVC_MAIN_TIER_LEVEL41 = 0x1000, + CODEC_HEVC_HIGH_TIER_LEVEL41 = 0x2000, + CODEC_HEVC_MAIN_TIER_LEVEL5 = 0x4000, + CODEC_HEVC_HIGH_TIER_LEVEL5 = 0x8000, + CODEC_HEVC_MAIN_TIER_LEVEL51 = 0x10000, + CODEC_HEVC_HIGH_TIER_LEVEL51 = 0x20000, + CODEC_HEVC_MAIN_TIER_LEVEL52 = 0x40000, + CODEC_HEVC_HIGH_TIER_LEVEL52 = 0x80000, + CODEC_HEVC_MAIN_TIER_LEVEL6 = 0x100000, + CODEC_HEVC_HIGH_TIER_LEVEL6 = 0x200000, + CODEC_HEVC_MAIN_TIER_LEVEL61 = 0x400000, + CODEC_HEVC_HIGH_TIER_LEVEL61 = 0x800000, + CODEC_HEVC_MAIN_TIER_LEVEL62 = 0x1000000, + CODEC_HEVC_HIGH_TIER_LEVEL62 = 0x2000000, + CODEC_HEVC_HIGH_TIER_MAX = 0x7FFFFFFF +}; + +/** + * @brief Enumerates the buffer types. + */ +enum CodecBufferType { + /** Invalid buffer type. */ + CODEC_BUFFER_TYPE_INVALID = 0, + /** Virtual address type. */ + CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, + /** Shared memory. */ + CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, + /** Handle. */ + CODEC_BUFFER_TYPE_HANDLE = 0x4, + /** Dynamic handle. */ + CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8, + /** DMA memory. */ + CODEC_BUFFER_TYPE_DMA_MEM_FD, +}; + +/** + * @brief Defines the SupportBuffer. + */ +struct SupportBufferType { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned int bufferTypes; /** Supported buffer types */ +}; + +/** + * @brief Define the UseBuffer. + */ +struct UseBufferType { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned int bufferType; /** Buffer type */ +}; + +/** + * @brief Defines the BufferHandleUsage. + */ +struct GetBufferHandleUsageParams { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned long usage; /** Usage */ +}; + +/** + * @brief Defines the CodecVideoPortFormatParam. + */ +struct CodecVideoPortFormatParam { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned int codecColorIndex; /** Color format index */ + unsigned int codecColorFormat; /** Color format defined in Display */ + unsigned int codecCompressFormat; /** See */ + unsigned int framerate; /** Q16 format */ +}; + +/** + * @brief Defines the ControlRateConstantQuality. + */ +struct ControlRateConstantQuality { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned int qualityValue; /** Control rate constant quality */ +}; + +/** + * @brief Enumerates the extended codec indexes. + */ +enum CodecIndexExType { + /** Extended BufferType index, value = Codec_IndexExtBufferTypeStartUnused + 0x00a00000 */ + Codec_IndexExtBufferTypeStartUnused = 0x6F000000 + 0x00a00000, + /** SupportBuffer */ + Codec_IndexParamSupportBufferType, + /** UseBuffer */ + Codec_IndexParamUseBufferType, + /** GetBufferHandleUsage */ + Codec_IndexParamGetBufferHandleUsage, + /** CodecVideoPortFormatParam */ + Codec_IndexCodecVideoPortFormat, + /** ControlRateConstantQuality */ + Codec_IndexParamControlRateConstantQuality, + /** Codec_IndexParamVideoHevc */ + Codec_IndexParamVideoHevc, + /** range/primary/transfer/matrix */ + Codec_IndexColorAspects, +}; + +/** + * @brief Structure for controlling HEVC video encoding + */ +struct CodecVideoParamHevc { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + enum CodecHevcProfile profile; /** Hevc profile. For details, see {@link CodecHevcProfile}. */ + enum CodecHevcLevel level; /** Hevc level. For details, see {@link CodecHevcLevel}. */ + unsigned int keyFrameInterval; /** Distance between consecutive I-frames (including one of the I frams). + 0 means interval is unspecified and can be freely chosen by the codec. + 1 means a stream of only I frams. other means the real value. */ +}; + +enum RangeType { + RANGE_UNSPECIFIED, + RANGE_FULL, + RANGE_LIMITED, + RANGE_MAX = 0xff, +}; + +enum Primaries { + PRIMARIES_UNSPECIFIED, + PRIMARIES_BT709, //Rec. ITU-R BT.709-6 + PRIMARIES_BT470_6M, //Rec. ITU-R BT.470-6 System M + PRIMARIES_BT601_625, //Rec. ITU-R BT.601-7 625 or Rec. ITU-R BT.470-6 System B,G + PRIMARIES_BT601_525, //Rec. ITU-R BT.601-7 525 or SMPTE ST 170 or SMPTE ST 240 + PRIMARIES_GENERICFILM, //Generic Film + PRIMARIES_BT2020, //Rec. ITU-R BT.2020-2 or Rec. ITU-R BT.2100-2 + PRIMARIES_MAX = 0xff, +}; + +enum Transfer { + TRANSFER_UNSPECIFIED, + TRANSFER_LINEAR, //Linear transfer characteristics + TRANSFER_SRGB, //IEC 61966-2-1 sRGB + TRANSFER_SMPTE170, //SMPTE ST 170 or Rec. ITU-R BT.709-6 or BT.601-7 or BT.2020-2 + TRANSFER_GAMMA22, //Rec. ITU-R BT.470-6 System M + TRANSFER_GAMMA28, //Rec. ITU-R BT.470-6 System B,G + TRANSFER_PQ, //Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system + TRANSFER_HLG, //Rec. ITU-R BT.2100-2 hybrid log gamma (HLG) system + TRANSFER_SMPTE240 = 0x40, //SMPTE ST 240 + TRANSFER_XVYCC, //IEC 61966-2-4 + TRANSFER_BT1361, //Rec. ITU-R BT.1361-0 extended colour gamut system + TRANSFER_ST428, //SMPTE ST 428-1 + TRANSFER_MAX = 0xff, +}; + +enum MatrixCoeffs { + MATRIX_UNSPECIFED, + MATRIX_BT709, //Rec. ITU-R BT.709-6 + MATRIX_FCC, //United States Federal Communications Commission + MATRIX_BT601, //Rec. ITU-R BT.601-7 or Rec. ITU-R BT.470-6 System B,G + MATRIX_SMPTE240, //SMPTE ST 240 + MATRIX_BT2020, //Rec. ITU-R BT.2100-2 (non-constant luminance) + MATRIX_BT2020CONSTANT, //Rec. ITU-R BT.2100-2 (constant luminance) + MATRIX_MAX = 0xff, +}; + +struct ColorAspects { + enum RangeType range; + enum Primaries primaries; + enum Transfer transfer; + enum MatrixCoeffs matrixCoeffs; +}; + +/** + * @brief Structure for controlling color space + */ +struct CodecVideoColorspace { + unsigned int size; /** Size of the structure */ + union CodecVersionType version; /** Component version */ + unsigned int portIndex; /** Port index */ + unsigned int requestingDataSpace; + unsigned int dataSpaceChanged; + unsigned int pixeFormat; + unsigned int dataSpace; + struct ColorAspects aspects; +}; \ No newline at end of file diff --git a/codec/v2_0/CodecTypes.idl b/codec/v2_0/CodecTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..6b0ea607dc7897c936f12053c862331aa331648c --- /dev/null +++ b/codec/v2_0/CodecTypes.idl @@ -0,0 +1,393 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @addtogroup Codec + * @{ + * + * @brief Defines APIs of the Codec module. + * + * The Codec module provides APIs for initializing the custom data and audio and video codecs, + * setting codec parameters, and controlling and transferring data. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @file CodecTypes.idl + * + * @brief Defines custom data types used in the Codec module APIs, + * including the codec types, audio and video parameters, and buffers. + * + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the Codec module APIs. + * + * @since 4.1 + * @version 2.0 + */ +package ohos.hdi.codec.v2_0; + +/** + * @brief Enumerates the codec types. + */ +enum CodecType { + VIDEO_DECODER, /**< Video decoder. */ + VIDEO_ENCODER, /**< Video encoder. */ + AUDIO_DECODER, /**< Audio decoder. */ + AUDIO_ENCODER, /**< Audio encoder. */ + INVALID_TYPE, /**< Invalid type. */ +}; + +/** + * @brief Enumerates the types of audio and video that can be encoded or decoded. + */ +enum AvCodecRole { + MEDIA_ROLETYPE_IMAGE_JPEG = 0, /**< JPEG image. */ + MEDIA_ROLETYPE_VIDEO_AVC, /**< H.264 video. */ + MEDIA_ROLETYPE_VIDEO_HEVC, /**< H.265 video. */ + MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000, /**< Audio. */ + MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, /**< Advanced Audio Coding (AAC). */ + MEDIA_ROLETYPE_AUDIO_G711A, /**< G.711 a-law audio. */ + MEDIA_ROLETYPE_AUDIO_G711U, /**< G.711 μ-law audio. */ + MEDIA_ROLETYPE_AUDIO_G726, /**< G.726 audio. */ + MEDIA_ROLETYPE_AUDIO_PCM, /**< PCM audio. */ + MEDIA_ROLETYPE_AUDIO_MP3, /**< MP3. */ + MEDIA_ROLETYPE_INVALID, /**< Invalid type. */ +}; + +/** + * @brief Enumerates the codec profiles. + */ +enum Profile { + INVALID_PROFILE = 0, /**< Invalid profile. */ + AAC_LC_PROFILE = 0x1000, /**< AAC low complexity profile. */ + AAC_MAIN_PROFILE, /**< AAC main profile. */ + AAC_HE_V1_PROFILE, /**< Profile combining AAC high efficiency and spectral band replication (SBR), + also known as HE-AAC, AAC+, or aacPlus v1. */ + AAC_HE_V2_PROFILE, /**< HE-AAC combined with SBR and Parametric Stereo (PS), + also known as AAC++ or aacPlus v2. */ + AAC_LD_PROFILE, /**< AAC low delay profile. */ + AAC_ELD_PROFILE, /**< AAC enhanced low delay profile. */ + AVC_BASELINE_PROFILE = 0x2000, /**< H.264 baseline profile. */ + AVC_MAIN_PROFILE, /**< H.264 main profile. */ + AVC_HIGH_PROFILE, /**< H.264 high profile. */ + HEVC_MAIN_PROFILE = 0x3000, /**< H.265 main profile. */ + HEVC_MAIN_10_PROFILE, /**< H.265 10-bit main profile. */ +}; + +/** + * @brief Enumerates the playback capabilities. + */ +enum CodecCapsMask { + CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, /**< Adaptive playback. */ + CODEC_CAP_SECURE_PLAYBACK = 0x2, /**< Secure playback. */ + CODEC_CAP_TUNNEL_PLAYBACK = 0x4, /**< Tunnel playback. */ + CODEC_CAP_MULTI_PLANE = 0x10000, /**< Multi-plane (video image plane and audio channel plane) capability. */ +}; + +/** + * @brief Enumerates the audio sampling rates. + */ +enum AudioSampleRate { + AUD_SAMPLE_RATE_8000 = 8000, /**< 8000 */ + AUD_SAMPLE_RATE_12000 = 12000, /**< 12000 */ + AUD_SAMPLE_RATE_11025 = 11025, /**< 11025 */ + AUD_SAMPLE_RATE_16000 = 16000, /**< 16000 */ + AUD_SAMPLE_RATE_22050 = 22050, /**< 22050 */ + AUD_SAMPLE_RATE_24000 = 24000, /**< 24000 */ + AUD_SAMPLE_RATE_32000 = 32000, /**< 32000 */ + AUD_SAMPLE_RATE_44100 = 44100, /**< 44100 */ + AUD_SAMPLE_RATE_48000 = 48000, /**< 48000 */ + AUD_SAMPLE_RATE_64000 = 64000, /**< 64000 */ + AUD_SAMPLE_RATE_96000 = 96000, /**< 96000 */ + AUD_SAMPLE_RATE_INVALID, /**< Invalid sampling rate */ +}; + +/** + * @brief Enumerates the audio sampling formats. + * + * For the planar sampling format, the data of each channel is independently stored in data. + * For the packed sampling format, only the first data is used, and the data of each channel is interleaved. + */ +enum CodecAudioSampleFormat { + AUDIO_SAMPLE_FMT_U8 = 0, /**< Unsigned 8-bit integer, packed. */ + AUDIO_SAMPLE_FMT_S16, /**< Signed 16-bit integer, packed. */ + AUDIO_SAMPLE_FMT_S32, /**< Signed 32-bit integer, packed. */ + AUDIO_SAMPLE_FMT_FLOAT, /**< Float, packed. */ + AUDIO_SAMPLE_FMT_DOUBLE, /**< Double, packed. */ + AUDIO_SAMPLE_FMT_U8P, /**< Unsigned 8-bit integer, planar. */ + AUDIO_SAMPLE_FMT_S16P, /**< Signed 16-bit integer, planar. */ + AUDIO_SAMPLE_FMT_S32P, /**< Signed 32-bit integer, planar. */ + AUDIO_SAMPLE_FMT_FLOATP, /**< Float, planar. */ + AUDIO_SAMPLE_FMT_DOUBLEP, /**< Double, planar. */ + AUDIO_SAMPLE_FMT_INVALID, /**< Invalid sampling format. */ +}; + +/** + * @brief Enumerates the codec processing modes. + */ +enum CodecProcessMode { + PROCESS_BLOCKING_INPUT_BUFFER = 0x1, /**< Input buffer in sync mode. */ + PROCESS_BLOCKING_OUTPUT_BUFFER = 0x2, /**< Output buffer in sync mode. */ + PROCESS_BLOCKING_CONTROL_FLOW = 0x4, /**< Control flow in sync mode. */ + PROCESS_NONBLOCKING_INPUT_BUFFER = 0x100, /**< Input buffer in async mode. */ + PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0x200, /**< Output buffer in async mode. */ + PROCESS_NONBLOCKING_CONTROL_FLOW = 0x400, /**< Control flow in asynchronous mode. */ +}; + +/** + * @brief Enumerates the shared memory types. + */ +enum ShareMemTypes { + READ_WRITE_TYPE = 0x1, /**< Shared memory that is readable and writable. */ + READ_ONLY_TYPE = 0x2, /**< Shared memory that is read-only. */ +}; + +/** + * @brief Enumerates the bit rate modes. + */ +enum BitRateMode { + BIT_RATE_MODE_INVALID, /**< Invalid value. */ + BIT_RATE_MODE_VBR, /**< Variable bit rate. */ + BIT_RATE_MODE_CBR, /**< Constant bit rate. */ + BIT_RATE_MODE_CQ, /**< Constant quality. */ + BIT_RATE_MODE_VCBR, /**< Constrained variable bit rate. */ + BIT_RATE_MODE_ABR, /**< Average bit rate. */ +}; + +/** + * @brief Enumerates the component states. + */ +enum CodecEventType { + CODEC_EVENT_CMD_COMPLETE, /**< The component has completed a command. */ + CODEC_EVENT_ERROR, /**< The component has detected an error. */ + CODEC_EVENT_MARK, /**< The component has detected the buffer mark. */ + CODEC_EVENT_PORT_SETTINGS_CHANGED, /**< The component has reported port setting changes. */ + CODEC_EVENT_BUFFER_FLAG, /**< The component has detected an EOS. */ + CODEC_EVENT_RESOURCES_ACQUIRED, /**< The component has been granted resources and is automatically + starting the state change from CODEC_STATE_WAIT_FOR_RESOURCES + to CODEC_STATE_IDLE. */ + CODEC_EVENT_COMPONENT_RESUMED, /**< The component is resumed due to reacquisition of resources. */ + CODEC_EVENT_DYNAMIC_RESOURCES_AVAILABLE, /**< The component has acquired previously unavailable + dynamic resources. */ + CODEC_EVENT_PORT_FORMAT_DETECTED, /**< The component has detected a supported format. */ + CODEC_EVENT_KHRONOS_EXTENSIONS = 0x6F000000, /**< Reserved region for introducing Khronos standard extensions. */ + CODEC_EVENT_VENDOR_START_UNUSED = 0x7F000000, /**< Reserved region for introducing vendor extensions. */ + CODEC_EVENT_MAX = 0x7FFFFFFF, /**< Maximum value. */ +}; + +/** + * @brief Enumerates the cmd parameters of the SendCommand API in ICodecComponent. + */ +enum CodecCommandType +{ + CODEC_COMMAND_STATE_SET, /**< Change the component state. */ + CODEC_COMMAND_FLUSH, /**< Flush the data queue of a component. */ + CODEC_COMMAND_PORT_DISABLE, /**< Disable a port on a component. */ + CODEC_COMMAND_PORT_ENABLE, /**< Enable a port on a component. */ + CODEC_COMMAND_MARK_BUFFER, /**< Mark a component/buffer for observation. */ + CODEC_COMMAND_KHRONOS_EXTENSIONS = 0x6F000000, /**< Reserved region for introducing Khronos standard extensions. */ + CODEC_COMMAND_VENDOR_START_UNUSED = 0x7F000000, /**< Reserved region for introducing vendor extensions. */ + CODEC_COMMAND_MAX = 0x7FFFFFFF, /**< Maximum value. */ +}; + +/** + * @brief Enuerates the component states. + */ +enum CodecStateType +{ + CODEC_STATE_INVALID, /**< The component has detected that its internal data structures are + corrupted so that the state cannot be correctly determined. */ + CODEC_STATE_LOADED, /**< The component has been loaded but has not completed + initialization. Only ICodecComponent.SetParameter + and ICodecComponent.GetParameter can be called for a + component in this state. */ + CODEC_STATE_IDLE, /**< The component initialization is complete, and the component is + ready to start. */ + CODEC_STATE_EXECUTING, /**< The component has accepted the start command and is processing + data (if the data is available). */ + CODEC_STATE_PAUSE, /**< The component has received the pause command. */ + CODEC_STATE_WAIT_FOR_RESOURCES, /**< The component is waiting for resources, either after preemption + or before it acquires the requested resources. */ + CODEC_STATE_KHRONOS_EXTENSIONS = 0x6F000000, /**< Reserved region for introducing Khronos standard extensions. */ + CODEC_STATE_VENDOR_START_UNUSED = 0x7F000000, /**< Reserved region for introducing vendor extensions. */ + CODEC_STATE_MAX = 0x7FFFFFFF, /**< Maximum value. */ +}; +/** + * @brief Enuerates the port supplier preferences when establishing a tunnel between two ports. + */ +enum CodecBufferSupplierType +{ + CODEC_BUFFER_SUPPLY_UNSPECIFIED = 0, /**< The port that provides the buffers is not specified. */ + CODEC_BUFFER_SUPPLY_INPUT, /**< The input port provides the buffers. */ + CODEC_BUFFER_SUPPLY_OUTPUT, /**< The output port provides the buffers. */ + CODEC_BUFFER_SUPPLY_KHRONOS_EXTENSIONS = 0x6F000000, /**< Reserved region for introducing Khronos + standard extensions. */ + CODEC_BUFFER_SUPPLY_VENDOR_START_UNUSED = 0x7F000000, /**< Reserved region for introducing vendor extensions. */ + CODEC_BUFFER_SUPPLY_MAX = 0x7FFFFFFF, /**< Maximum value. */ +}; + +/** + * @brief Defines the alignment structure. + */ +struct Alignment { + int widthAlignment; /**< Alignment value of the width. */ + int heightAlignment; /**< Alignment value of the height. */ +}; + +/** + * @brief Defines a rectangle. + */ +struct Rect { + int width; /**< Width of the rectangle. */ + int height; /**< Height of the rectangle. */ +}; + +/** + * @brief Defines a value range. + */ +struct RangeValue { + int min; /**< Minimum value. */ + int max; /**< Maximum value. */ +}; + +/** + * @brief Defines the video encoding and decoding capabilities. + */ +struct CodecVideoPortCap { + struct Rect minSize; /**< Minimum resolution supported. */ + struct Rect maxSize; /**< Maximum resolution supported. */ + struct Alignment whAlignment; /**< Alignment values of the width and height. */ + struct RangeValue blockCount; /**< Value range for the number of blocks supported. */ + struct RangeValue blocksPerSecond; /**< Value range for the number of blocks processed per second. */ + struct Rect blockSize; /**< Block size supported. */ + int[] supportPixFmts; /**< Supported pixel formats. For details, see PixeFormat defined by + display_type.h in {@link Display}. */ + enum BitRateMode[] bitRatemode; /**< Transmission rate modes, which can be constant or variable. + For details, see {@link BitRateMode}. */ + struct RangeValue frameRate; /**< Frame rate range. */ + int[] measuredFrameRate; /**< Frame rate measured. */ +}; +/** + * @brief Defines the audio encoding and decoding capabilities. + */ +struct CodecAudioPortCap { + int[] sampleFormats; /**< Supported audio sampling formats. For details, see {@link AudioSampleFormat}. */ + int[] sampleRate; /**< Supported audio sampling rates. For details, see {@link AudioSampleRate}. */ + int[] channelLayouts; /**< Supported channel layouts, which include single channel, balanced channel, + and 3D stereo channel. */ + int[] channelCount; /**< Supported number of audio channels. */ +}; + +/** + * @brief Defines the audio and video encoding and decoding capabilities. + */ +struct PortCap { + struct CodecVideoPortCap video; /**< Video encoding and decoding capabilities. */ + struct CodecAudioPortCap audio; /**< Audio encoding and decoding capabilities. */ +}; + +/** + * @brief Defines the version type of a component. + */ +struct CodecVerType { + unsigned char majorVersion; /**< Major version accessor element. */ + unsigned char minorVersion; /**< Minor version accessor element. */ + unsigned char revision; /**< Revision version accessor element. */ + unsigned char step; /**< Step version accessor element. */ +}; + +/** + * @brief Defines the component version information. + */ +union CodecVersionType { + struct CodecVerType version; /**< Component version. */ + unsigned int nVersion; /**< 32-bit value to make accessing the version easily done in a single + word size copy or compare operation. */ +}; + +/** + * @brief Defines the codec capabilities. + */ +struct CodecCompCapability { + enum AvCodecRole role; /**< Media type. */ + enum CodecType type; /**< Codec type. */ + String compName; /**< Name of the codec component. */ + int[] supportProfiles; /**< Supported profiles. For details, see {@link Profile}. */ + int maxInst; /**< Maximum instance. */ + boolean isSoftwareCodec; /**< Whether it is a software codec. */ + int processModeMask; /**< Codec processing mode mask. For details, + see {@link CodecProcessMode}. */ + unsigned int capsMask; /**< Mask of the codec playback capabilities. For details, + see {@link CodecCapsMask}. */ + struct RangeValue bitRate; /**< Supported bit rate range. */ + struct PortCap port; /**< Supported audio and video encoding/decoding capabilities. */ + boolean canSwapWidthHeight; /**< Whether width and height verification is supported. */ +}; + +/** + * @brief Defines the codec buffer information. + */ +struct OmxCodecBuffer { + unsigned int bufferId; /**< Buffer ID. */ + unsigned int size; /**< Size of the structure. */ + union CodecVersionType version; /**< Component version. */ + unsigned int bufferType; /**< Buffer type. For details, see {@link CodecBufferType}. */ + NativeBuffer bufferhandle; /**< Buffer handle used for encoding or decoding. For details, + see {@link NativeBuffer}. */ + FileDescriptor fd; /**< Anonymous shared memory file descriptor. */ + unsigned int allocLen; /**< Size of the buffer allocated. */ + unsigned int filledLen; /**< Size of the buffer filled. */ + unsigned int offset; /**< Offset to the start position of the valid data in the buffer. */ + FileDescriptor fenceFd; /**< Fence file descriptor. */ + enum ShareMemTypes type; /**< Shared memory type. */ + long pts; /**< Timestamp of the first logical sample in the buffer. */ + unsigned int flag; /**< Buffer specific flag. */ + unsigned char[] alongParam; /**< Along frame parameter. */ +}; + +/** + * @brief Defines the structure that is used to pass data from an output port to an input port. + */ +struct CodecTunnelSetupType { + unsigned int tunnelFlags; /**< Bit flags for tunneling. */ + enum CodecBufferSupplierType supplier; /**< Supplier preference. */ +}; + +/** + * @brief Defines the component information. + */ +struct CompVerInfo { + String compName; /**< Component name. */ + unsigned char[] compUUID; /**< UUID of the component. */ + union CodecVersionType compVersion; /**< OMX component version. */ + union CodecVersionType specVersion; /**< Version of the specifications on which the component is built. */ +}; + +/** + * @brief Defines the event information to report. + */ +struct EventInfo { + long appData; /**< Upper-layer instance passed in when the callback is invoked. */ + unsigned int data1; /**< Error type, which can be portIndex or other data. */ + unsigned int data2; /**< Data 2 carried in the reported event. */ + byte[] eventData; /**< Data carried in the reported event. */ +}; diff --git a/codec/v2_0/ICodecCallback.idl b/codec/v2_0/ICodecCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..c3c0c0d9d41580cb23b1fea796b9c26e45d7f235 --- /dev/null +++ b/codec/v2_0/ICodecCallback.idl @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @addtogroup Codec + * @{ + * + * @brief Defines APIs of the Codec module. + * + * The Codec module provides APIs for initializing the custom data and audio and video codecs, + * setting codec parameters, and controlling and transferring data. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @file ICodecCallback.idl + * + * @brief Defines the callbacks used to report codec events and processing results of the input and output buffers. + * + * + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the Codec module APIs. + * + * @since 4.1 + * @version 2.0 + */ +package ohos.hdi.codec.v2_0; + +import ohos.hdi.codec.v2_0.CodecTypes; + +/** + * @brief Defines the callbacks of the Codec module. + * + * The following callbacks are provided: + * - Callback used to report component error events, command completion events, and port setting events. + * For details, see {@link EventHandler}. + * - Callback invoked when the input port has data processed in the buffer. For details, see {@link EmptyBufferDone}. + * - Callback invoked when the output port has data filled into the buffer. For details, see {@link FillBufferDone}. + * The callbacks are registered by using: + * - {@link CreateComponent} when a component is created. + * - {@link SetCallbacks} when the component is in the OMX_StateLoaded state. + */ + + +[callback] interface ICodecCallback { + + /** + * @brief Reports an event, such as an error, a command completion event, and port setting changes. + * + * - When event is CODEC_EVENT_CMD_COMPLETE and eventData is null, + * data2 indicates a state if data1 is CODEC_COMMAND_STATE_SET and indicates a port if + * data1 is any CodecCommandType other than CODEC_COMMAND_STATE_SET. + * - When event is CODEC_EVENT_ERROR, data1 indicates an error code and data2 + * and eventData are both 0. + * - When event is CODEC_EVENT_MARK, data1 and data2 are both 0 and + * eventData points to the mark. + * - When event is CODEC_EVENT_PORT_SETTINGS_CHANGED, data1 indicates a port and data2 + * and eventData are 0. + * - When event is CODEC_EVENT_BUFFER_FLAG, data1 indicates a port, data2 indicates a + * flag, and eventData is 0. + * - When event is CODEC_EVENT_RESOURCES_ACQUIRED or CODEC_EVENT_DYNAMIC_RESOURCES_AVAILABLE, + * data1, data2, and eventData are 0. + * + * @param event Indicates the type of the event to report. For details, see {@link CodecEventType}. + * @param info Indicates the pointer to the information to report. For details, see {@link EventInfo}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + EventHandler([in] enum CodecEventType event, [in] struct EventInfo info); + + /** + * @brief Reports an event indicating that the encoding or decoding in the input buffer is complete. + * + * + * @param appData Indicates the application data. Generally, it is an upper-layer instance + * passed in for the callback. + * @param buffer Indicates information about the input buffer that was emptied. For details, + * see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the + * error codes, see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + EmptyBufferDone([in] long appData, [in] struct OmxCodecBuffer buffer); + + /** + * @brief Reports an event indicating that the output buffer is filled. + * + * + * @param appData Indicates the application data. Generally, it is an upper-layer instance + * passed in for the callback. + * @param buffer Indicates information about the buffer that was filled. For details, see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + FillBufferDone([in] long appData, [in] struct OmxCodecBuffer buffer); +} diff --git a/codec/v2_0/ICodecComponent.idl b/codec/v2_0/ICodecComponent.idl new file mode 100644 index 0000000000000000000000000000000000000000..0abeac2e39ddccd3a8429d0aa4fe205147eca259 --- /dev/null +++ b/codec/v2_0/ICodecComponent.idl @@ -0,0 +1,447 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @addtogroup Codec + * @{ + * + * @brief Defines APIs of the Codec module. + * + * The Codec module provides APIs for initializing the custom data and audio and video codecs, + * setting codec parameters, and controlling and transferring data. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @file ICodecComponent.idl + * + * @brief Declares the APIs for codec components. + * + * You can use these APIs to obtain component information, send commands to components, + * set component parameters, and control and transfer buffer data. + * After creating a component, you can use these APIs to implement encoding and decoding. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the Codec module APIs. + * + * @since 4.1 + * @version 2.0 + */ +package ohos.hdi.codec.v2.0; + +import ohos.hdi.codec.v2_0.CodecTypes; +import ohos.hdi.codec.v2_0.ICodecCallback; + +/** + * @brief Defines the APIs for codec components. + * + * The APIs can be used to: + * - Obtain the component version. + * - Obtain and set component parameters. + * - Send a command to a component and obtain the component state. + * - Set callbacks. + * - Set or release the buffer used by a component. + * - Manage the input and output buffers for encoding and decoding. + * For details, see the description of the APIs. + */ + +interface ICodecComponent { + + /** + * @brief Obtains the version of this codec component. + * + * + * @param verInfo Indicates the pointer to the component version information. For details, see {@link CompVerInfo}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetComponentVersion([out] struct CompVerInfo verInfo); + + /** + * @brief Sends a command to this component. + * + * If the command is used to set the component state, a callback will be invoked to return the result. + * There is no callback invoked for other commands. + * + * @param cmd Indicates the command to send. For details, see {@link CodecCommandType}. + * @param param Indicates the parameter carried in the command. + * - If cmd is CODEC_COMMAND_STATE_SET, param can be set to any value of {@link CodecStateType}. + * - If cmd is CODEC_COMMAND_FLUSH, CODEC_COMMAND_PORT_DISABLE, CODEC_COMMAND_PORT_ENABLE, + * or CODEC_COMMAND_MARK_BUFFER, param is the target port. + * @param cmdData Indicates the pointer to the OMX_MARKTYPE structure when cmd + * is CODEC_COMMAND_MARK_BUFFER. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + SendCommand([in] enum CodecCommandType cmd, [in] unsigned int param, [in] byte[] cmdData); + + /** + * @brief Obtains the parameter settings of this component. + * + * For the component in a state other than OMX_StateInvalid, you can use this API to obtain the + * component's parameter settings. For details about the component states, see {@link OMX_STATETYPE}. + * + * @param index Indicates the index of the structure to fill. For details, + * see OMX_INDEXTYPE defined by OMX IL. + * @param inParamStruct Indicates the pointer to the application allocated structure to be filled by the component. + * @param outParamStruct Indicates the pointer to the application allocated structure filled by the component. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about + * the error codes, see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetParameter([in] unsigned int index, [in] byte[] inParamStruct, [out] byte[] outParamStruct); + + /** + * @brief Sets parameters for this component, that is, sends an initialization + * parameter structure to the component. + * + * You can use this API to set component parameters when: + * - The component is in the OMX_StateLoaded state (the component has been loaded). + * - The component is in the OMX_StateWaitForResources state (the component is waiting for required resources). + * - The component or port is disabled. + * For details about the component states, see {@link OMX_STATETYPE}. + * + * @param index Indicates the index of the structure to set. For details, see OMX_INDEXTYPE defined by OMX IL. + * @param paramStruct Indicates the pointer to the application allocated structure used to set + * parameters for this component. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + SetParameter([in] unsigned int index, [in] byte[] paramStruct); + + /** + * @brief Obtains the configuration of this component. + * + * You can use this API to obtain the component configuration after a component is loaded. + * + * @param index Indicates the index of the structure to fill. For details, see {@link OMX_INDEXTYPE}. + * @param inCfgStruct Indicates the pointer to the application allocated structure to be filled by the component. + * @param outCfgStruct Indicates the pointer to the application allocated structure filled by the component. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetConfig([in] unsigned int index, [in] byte[] inCfgStruct, [out] byte[] outCfgStruct); + + /** + * @brief Sets the component configuration. + * + * You can use this API to set the component configuration after a component is loaded. + * + * @param index Indicates the index of the structure to set. For details, see {@link OMX_INDEXTYPE}. + * @param cfgStruct Indicates the pointer to the application allocated structure used to set the component. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + SetConfig([in] unsigned int index, [in] byte[] cfgStruct); + + /** + * @brief Obtains the extended index of this component based on a given string. + * + * The extended string can be converted into an OpenMAX IL structure index, which is used (as an input parameter) + * in {@link GetParameter} or {@link SetParameter}. + * + * @param paramName Indicates the string that can be converted into the structure index. + * @param indexType Indicates the structure index obtained. For details, see {@link OMX_INDEXTYPE}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetExtensionIndex([in] String paramName, [out] unsigned int indexType); + + /** + * @brief Obtains the current state of this component. + * + * + * + * @param state Indicates the pointer to the state obtained. For details about the component + * states, see {@link CodecStateType}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetState([out] enum CodecStateType state); + + /** + * @brief Sets up tunneling for this component. + * + * For a component in the OMX_StateLoaded state (the component is loaded), you can use this API + * to determine whether + * tunneling is possible and if yes, to set up the tunneling. + * For details about the component states, see {@link OMX_STATETYPE}. + * + * @param port Indicates the port on the component used for the setting. + * @param tunneledComp Indicates the handle of the tunnel component. + * @param tunneledPort Indicates the port on the component to be used for tunneling. + * @param inTunnelSetup Indicates the pointer to the tunnel setup structure {@link OMX_TUNNELSETUPTYPE} to set. + * @param outTunnelSetup Indicates the pointer to the tunnel setup structure {@link OMX_TUNNELSETUPTYPE} set. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + ComponentTunnelRequest([in] unsigned int port, [in] int tunneledComp, [in] unsigned int tunneledPort, [in] + struct CodecTunnelSetupType inTunnelSetup, [out] struct CodecTunnelSetupType outTunnelSetup); + + /** + * @brief Requests the component to use a buffer that is already allocated by another component. + * + * This API is used when: + * - The component is in the OMX_StateLoaded state (the component is loaded) and has received a request for + * changing the state to OMX_StateIdle. + * - The component is in the OMX_StateWaitForResources state, the required resources are available, and the + * component is ready to enter the OMX_StateIdle state. + * - The component is in the OMX_StateExecuting, OMX_StatePause, or OMX_StateIdle state on a disabled port. + * For details about the component states, see {@link OMX_STATETYPE}. + * + * @param portIndex Indicates the component port. + * @param inBuffer Indicates the pointer to the structure of the buffer to be used. For details, see {@link OmxCodecBuffer}. + * @param outBuffer Indicates the pointer to the structure of the buffer to be used. For details, see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + UseBuffer([in] unsigned int portIndex, [in] struct OmxCodecBuffer inBuffer, [out] struct OmxCodecBuffer outBuffer); + + /** + * @brief Requests the component to allocate a new buffer. + * + * This API is used to request a new buffer from a component when: + * - The component is in the OMX_StateLoaded state and has received a request for changing the + * state to OMX_StateIdle. + * - The component is in the OMX_StateWaitForResources state, the required resources are available, + * and the component is ready to enter the OMX_StateIdle state. + * - The component is in the OMX_StateExecuting, OMX_StatePause, or OMX_StateIdle state on a disabled port. + * For details about the component states, see {@link OMX_STATETYPE}. + * + * @param portIndex Indicates the component port. + * @param inBuffer Indicates the pointer to the structure of the buffer to be allocated. For details about + * the structure, see {@link OmxCodecBuffer}. + * @param outBuffer Indicates the pointer to the structure of the buffer allocated. For details about the + * structure, see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + AllocateBuffer([in] unsigned int portIndex, [in] struct OmxCodecBuffer inBuffer, + [out] struct OmxCodecBuffer outBuffer); + + /** + * @brief Releases a buffer. + * + * This API is used when: + * - The component is in the OMX_StateIdle state and has received a request for changing the + * state to OMX_StateLoaded. + * - The component is in the OMX_StateExecuting, OMX_StatePause, or OMX_StateIdle state on a disabled port. + * For details about the component states, see {@link OMX_STATETYPE}. + * - This API can be called at any time. However, if it is not called in any of the previous conditions, + * the component may report an OMX_ErrorPortUnpopulated event. + * + * @param portIndex Indicates the component port. + * @param buffer Indicates the pointer to the structure of the buffer to release. For details about the + * structure, see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + FreeBuffer([in] unsigned int portIndex, [in] struct OmxCodecBuffer buffer); + + /** + * @brief Empties a buffer. + * + * This API can be called when the component is in the OMX_StateExecuting or OMX_StatePause state. For details + * about the component states, see {@link OMX_STATETYPE}. + * + * @param buffer Indicates the pointer to the structure of the buffer to empty. For details about the structure, + * see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + EmptyThisBuffer([in] struct OmxCodecBuffer buffer); + + /** + * @brief Fills a buffer with the encoding and decoding output by this component. + * + * This API can be called when the component is in the OMX_StateExecuting or OMX_StatePause state. For details + * about the component states, see {@link OMX_STATETYPE}. + * + * @param buffer Indicates the pointer to the structure of the buffer to be filled. For details about the + * structure, see {@link OmxCodecBuffer}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + FillThisBuffer([in] struct OmxCodecBuffer buffer); + + /** + * @brief Sets callbacks for this component. + * + * The callbacks will be invoked to report an event or report available input or output information when the + * component is in the OMX_StateLoaded state. For details about the component states, see {@link OMX_STATETYPE}. + * + * @param callbacks Indicates the pointer to the {@link ICodecCallback} object. + * @param appData Indicates the pointer to an application-defined value that will be returned by the callback. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + + */ + SetCallbacks([in] ICodecCallback callbacks, [in] long appData); + + /** + * @brief Deinitializes this component. + * + * This API will deinitialize and close a component in the OMX_StateLoaded state. For details about the + * component states, see {@link OMX_STATETYPE}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + ComponentDeInit(); + + /** + * @brief Uses the image provided by EGL as a buffer on the specified port. + * + * This API is used when: + * - The component is in the OMX_StateLoaded state and has received a request for changing the + * state to OMX_StateIdle. + * - The component is in the OMX_StateWaitForResources state, the required resources are available, + * and the component is ready to enter the OMX_StateIdle state. + * - The component is in the OMX_StateExecuting, OMX_StatePause, or OMX_StateIdle state on a disabled port. + * For details about the component states, see {@link OMX_STATETYPE}. + * + * @param portIndex Indicates the component port. + * @param inBuffer Indicates the pointer to the {@link OmxCodecBuffer} structure. + * @param outBuffer Indicates the pointer to the {@link OmxCodecBuffer} structure. + * @param eglImage Indicates the pointer to the image allocated by EGL. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + UseEglImage([in] unsigned int portIndex, [in] struct OmxCodecBuffer inBuffer, [out] struct OmxCodecBuffer + outBuffer, [in] byte[] eglImage); + + /** + * @brief Obtains the component role based on the index. + * + * + * + * @param role Indicates the role name obtained. + * @param index Indicates the index of the role. A component supports multiple roles. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error + * codes, see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + ComponentRoleEnum([out] unsigned char[] role, [in] unsigned int index); +} \ No newline at end of file diff --git a/codec/v2_0/ICodecComponentManager.idl b/codec/v2_0/ICodecComponentManager.idl new file mode 100644 index 0000000000000000000000000000000000000000..ca670d52cc33f30b265755359c754045de10ccab --- /dev/null +++ b/codec/v2_0/ICodecComponentManager.idl @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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. + */ + +/** + * @addtogroup Codec + * @{ + * + * @brief Defines APIs of the Codec module. + * + * The Codec module provides APIs for initializing the custom data and audio and video codecs, + * setting codec parameters, and controlling and transferring data. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @file ICodecComponentManager.idl + * + * @brief Declares the APIs for managing Codec components. + * + * You can use the APIs to obtain the component encoding and decoding capabilities, and create or destroy components. + * + * @since 4.1 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the Codec module APIs. + * + * @since 4.1 + * @version 2.0 + */ +package ohos.hdi.codec.v2_0; + +import ohos.hdi.codec.v2_0.CodecTypes; +import ohos.hdi.codec.v2_0.ICodecComponent; +import ohos.hdi.codec.v2_0.ICodecCallback; + +/** + * @brief Defines the APIs for managing the codec components. + * + * The APIs can be used to: + * - Obtain the number of codec components and codec capabilities. + * - Create or destroy a codec component. + */ + +interface ICodecComponentManager { + + /** + * @brief Obtains the number of codec components. + * + * Codec capabilities can be further obtained based on the number of codec components. + * + * @param count Indicates the number of codec components obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the + * error codes, see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetComponentNum([out] int count); + + /** + * @brief Obtains codec capabilities. + * + * You can use this API to obtain the encoding and decoding capabilities provided by the Codec module. + * For details, see {@link CodecCompCapability}. + * + * @param capList Indicates the codec capabilities {@link CodecCompCapability} obtained. + * @param count Indicates the number of codec components, which is obtained by {@link GetComponentNum}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + GetComponentCapabilityList([out] struct CodecCompCapability[] capList, [in] int count); + + /** + * @brief Creates a codec component instance. + * + * + * + * @param component Indicates the pointer to the Codec component created. + * @param componentId Indicates the ID of the component created. + * @param compName Indicates the component name. + * @param appData Indicates the pointer to an application-defined value that will be returned by the callback. + * @param callbacks Indicates the pointer to the OMX_CALLBACKTYPE structure. For details, + * see {@link ICodecCallback}. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + CreateComponent([out] ICodecComponent component, [out] unsigned int componentId, [in] String compName, + [in] long appData, [in] ICodecCallback callbacks); + + /** + * @brief Destroys a codec component instance. + * + * + * + * @param componentId Indicates the ID of the codec component to destroy. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the + * error codes, see OMX_ERRORTYPE defined by OpenMAX IL. + * + * @since 4.1 + */ + DestroyComponent([in] unsigned int componentId); +} \ No newline at end of file