• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @addtogroup Codec
18 * @{
19 *
20 * @brief Defines APIs of the Codec module.
21 *
22 * The Codec module provides APIs for initializing the custom data and audio and video codecs,
23 * setting codec parameters, and controlling and transferring data.
24 *
25 * @since 3.2
26 * @version 1.0
27 */
28
29/**
30 * @file CodecTypes.idl
31 *
32 * @brief Defines custom data types used in the Codec module APIs,
33 * including the codec types, audio and video parameters, and buffers.
34 *
35 *
36 * @since 3.2
37 * @version 1.0
38 */
39
40/**
41 * @brief Defines the path for the package of the Codec module APIs.
42 *
43 * @since 3.2
44 * @version 1.0
45 */
46package ohos.hdi.codec.v1_0;
47sequenceable OHOS.HDI.DISPLAY.BufferHandleParcelable;
48
49/**
50 * @brief Enumerates the codec types.
51 */
52enum CodecType {
53    VIDEO_DECODER,   /**< Video decoder. */
54    VIDEO_ENCODER,   /**< Video encoder. */
55    AUDIO_DECODER,   /**< Audio decoder. */
56    AUDIO_ENCODER,   /**< Audio encoder. */
57    INVALID_TYPE,    /**< Invalid type. */
58};
59
60/**
61 * @brief Enumerates the types of audio and video that can be encoded or decoded.
62 */
63enum AvCodecRole {
64    MEDIA_ROLETYPE_IMAGE_JPEG = 0,          /**< JPEG image. */
65    MEDIA_ROLETYPE_VIDEO_AVC,               /**< H.264 video. */
66    MEDIA_ROLETYPE_VIDEO_HEVC,              /**< H.265 video. */
67    MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000,   /**< Audio. */
68    MEDIA_ROLETYPE_AUDIO_AAC = 0x10000,     /**< Advanced Audio Coding (AAC). */
69    MEDIA_ROLETYPE_AUDIO_G711A,             /**< G.711 a-law audio. */
70    MEDIA_ROLETYPE_AUDIO_G711U,             /**< G.711 μ-law audio. */
71    MEDIA_ROLETYPE_AUDIO_G726,              /**< G.726 audio. */
72    MEDIA_ROLETYPE_AUDIO_PCM,               /**< PCM audio. */
73    MEDIA_ROLETYPE_AUDIO_MP3,               /**< MP3. */
74    MEDIA_ROLETYPE_INVALID,                 /**< Invalid type. */
75};
76
77/**
78 * @brief Enumerates the codec profiles.
79 */
80enum Profile {
81    INVALID_PROFILE = 0,             /**< Invalid profile. */
82    AAC_LC_PROFILE = 0x1000,         /**< AAC low complexity profile. */
83    AAC_MAIN_PROFILE,                /**< AAC main profile. */
84    AAC_HE_V1_PROFILE,               /**< Profile combining AAC high efficiency and spectral band replication (SBR),
85                                          also known as HE-AAC, AAC+, or aacPlus v1. */
86    AAC_HE_V2_PROFILE,               /**< HE-AAC combined with SBR and Parametric Stereo (PS),
87                                          also known as AAC++ or aacPlus v2. */
88    AAC_LD_PROFILE,                  /**< AAC low delay profile. */
89    AAC_ELD_PROFILE,                 /**< AAC enhanced low delay profile. */
90    AVC_BASELINE_PROFILE = 0x2000,   /**< H.264 baseline profile. */
91    AVC_MAIN_PROFILE,                /**< H.264 main profile. */
92    AVC_HIGH_PROFILE,                /**< H.264 high profile. */
93    HEVC_MAIN_PROFILE = 0x3000,      /**< H.265 main profile. */
94    HEVC_MAIN_10_PROFILE,            /**< H.265 10-bit main profile. */
95};
96
97/**
98 * @brief Enumerates the playback capabilities.
99 */
100enum CodecCapsMask {
101    CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1,    /**< Adaptive playback. */
102    CODEC_CAP_SECURE_PLAYBACK = 0x2,      /**< Secure playback. */
103    CODEC_CAP_TUNNEL_PLAYBACK = 0x4,      /**< Tunnel playback. */
104    CODEC_CAP_MULTI_PLANE = 0x10000,      /**< Multi-plane (video image plane and audio channel plane) capability. */
105};
106
107/**
108 * @brief Enumerates the audio sampling rates.
109 */
110enum AudioSampleRate {
111    AUD_SAMPLE_RATE_8000 = 8000,      /**< 8000 */
112    AUD_SAMPLE_RATE_12000 = 12000,    /**< 12000 */
113    AUD_SAMPLE_RATE_11025 = 11025,    /**< 11025 */
114    AUD_SAMPLE_RATE_16000 = 16000,    /**< 16000 */
115    AUD_SAMPLE_RATE_22050 = 22050,    /**< 22050 */
116    AUD_SAMPLE_RATE_24000 = 24000,    /**< 24000 */
117    AUD_SAMPLE_RATE_32000 = 32000,    /**< 32000 */
118    AUD_SAMPLE_RATE_44100 = 44100,    /**< 44100 */
119    AUD_SAMPLE_RATE_48000 = 48000,    /**< 48000 */
120    AUD_SAMPLE_RATE_64000 = 64000,    /**< 64000 */
121    AUD_SAMPLE_RATE_96000 = 96000,    /**< 96000 */
122    AUD_SAMPLE_RATE_INVALID,          /**< Invalid sampling rate */
123};
124
125/**
126 * @brief Enumerates the audio sampling formats.
127 *
128 * For the planar sampling format, the data of each channel is independently stored in <b>data</b>.
129 * For the packed sampling format, only the first data is used, and the data of each channel is interleaved.
130 */
131enum CodecAudioSampleFormat {
132    AUDIO_SAMPLE_FMT_U8 = 0,     /**< Unsigned 8-bit integer, packed. */
133    AUDIO_SAMPLE_FMT_S16,        /**< Signed 16-bit integer, packed. */
134    AUDIO_SAMPLE_FMT_S32,        /**< Signed 32-bit integer, packed. */
135    AUDIO_SAMPLE_FMT_FLOAT,      /**< Float, packed. */
136    AUDIO_SAMPLE_FMT_DOUBLE,     /**< Double, packed. */
137    AUDIO_SAMPLE_FMT_U8P,        /**< Unsigned 8-bit integer, planar. */
138    AUDIO_SAMPLE_FMT_S16P,       /**< Signed 16-bit integer, planar. */
139    AUDIO_SAMPLE_FMT_S32P,       /**< Signed 32-bit integer, planar. */
140    AUDIO_SAMPLE_FMT_FLOATP,     /**< Float, planar. */
141    AUDIO_SAMPLE_FMT_DOUBLEP,    /**< Double, planar. */
142    AUDIO_SAMPLE_FMT_INVALID,    /**< Invalid sampling format. */
143};
144
145/**
146 * @brief Enumerates the codec processing modes.
147 */
148enum CodecProcessMode {
149    PROCESS_BLOCKING_INPUT_BUFFER = 0x1,        /**< Input buffer in sync mode. */
150    PROCESS_BLOCKING_OUTPUT_BUFFER = 0x2,       /**< Output buffer in sync mode. */
151    PROCESS_BLOCKING_CONTROL_FLOW = 0x4,        /**< Control flow in sync mode. */
152    PROCESS_NONBLOCKING_INPUT_BUFFER = 0x100,   /**< Input buffer in async mode. */
153    PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0x200,  /**< Output buffer in async mode. */
154    PROCESS_NONBLOCKING_CONTROL_FLOW = 0x400,   /**< Control flow in asynchronous mode. */
155};
156
157/**
158 * @brief Enumerates the shared memory types.
159 */
160enum ShareMemTypes {
161    READ_WRITE_TYPE = 0x1,     /**< Shared memory that is readable and writable. */
162    READ_ONLY_TYPE = 0x2,      /**< Shared memory that is read-only. */
163};
164
165/**
166 * @brief Enumerates the bit rate modes.
167 */
168enum BitRateMode {
169    BIT_RATE_MODE_INVALID,    /**< Invalid value. */
170    BIT_RATE_MODE_VBR,        /**< Variable bit rate. */
171    BIT_RATE_MODE_CBR,        /**< Constant bit rate. */
172    BIT_RATE_MODE_CQ,         /**< Constant quality. */
173    BIT_RATE_MODE_VCBR,       /**< Constrained variable bit rate. */
174    BIT_RATE_MODE_ABR,        /**< Average bit rate. */
175};
176
177/**
178 * @brief Enumerates the component states.
179 */
180enum OMX_EVENTTYPE {
181    OMX_EventCmdComplete,                    /**< The component has completed a command. */
182    OMX_EventError,                          /**< The component has detected an error. */
183    OMX_EventMark,                           /**< The component has detected the buffer mark. */
184    OMX_EventPortSettingsChanged,            /**< The component has reported port setting changes. */
185    OMX_EventBufferFlag,                     /**< The component has detected an EOS. */
186    OMX_EventResourcesAcquired,              /**< The component has been granted resources and is automatically
187                                                  starting the state change from OMX_StateWaitForResources
188                                                  to OMX_StateIdle. */
189    OMX_EventComponentResumed,               /**< The component is resumed due to reacquisition of resources. */
190    OMX_EventDynamicResourcesAvailable,      /**< The component has acquired previously unavailable
191                                                  dynamic resources. */
192    OMX_EventPortFormatDetected,             /**< The component has detected a supported format. */
193    OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos standard extensions. */
194    OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing vendor extensions. */
195    OMX_EventMax = 0x7FFFFFFF,               /**< Maximum value. */
196};
197
198/**
199 * @brief Enumerates the cmd parameters of the <b>SendCommand</b> API in <b>ICodecComponent</b>.
200 */
201enum OMX_COMMANDTYPE
202{
203    OMX_CommandStateSet,                        /**< Change the component state. */
204    OMX_CommandFlush,                           /**< Flush the data queue of a component. */
205    OMX_CommandPortDisable,                     /**< Disable a port on a component. */
206    OMX_CommandPortEnable,                      /**< Enable a port on a component. */
207    OMX_CommandMarkBuffer,                      /**< Mark a component/buffer for observation. */
208    OMX_CommandKhronosExtensions = 0x6F000000,  /**< Reserved region for introducing Khronos standard extensions. */
209    OMX_CommandVendorStartUnused = 0x7F000000,  /**< Reserved region for introducing vendor extensions. */
210    OMX_CommandMax = 0x7FFFFFFF,                /**< Maximum value. */
211};
212
213/**
214 * @brief Enuerates the component states.
215 */
216enum OMX_STATETYPE
217{
218    OMX_StateInvalid,                           /**< The component has detected that its internal data structures are
219                                                     corrupted so that the state cannot be correctly determined. */
220    OMX_StateLoaded,                            /**< The component has been loaded but has not completed
221                                                     initialization. Only <b>ICodecComponent.SetParameter</b>
222                                                     and <b>ICodecComponent.GetParameter</b> can be called for a
223                                                     component in this state. */
224    OMX_StateIdle,                              /**< The component initialization is complete, and the component is
225                                                     ready to start. */
226    OMX_StateExecuting,                         /**< The component has accepted the start command and is processing
227                                                     data (if the data is available). */
228    OMX_StatePause,                             /**< The component has received the pause command. */
229    OMX_StateWaitForResources,                  /**< The component is waiting for resources, either after preemption
230                                                     or before it acquires the requested resources. */
231    OMX_StateKhronosExtensions = 0x6F000000,    /**< Reserved region for introducing Khronos standard extensions. */
232    OMX_StateVendorStartUnused = 0x7F000000,    /**< Reserved region for introducing vendor extensions. */
233    OMX_StateMax = 0x7FFFFFFF,                  /**< Maximum value. */
234};
235
236 * @brief Enuerates the port supplier preferences when establishing a tunnel between two ports.
237 */
238enum OMX_BUFFERSUPPLIERTYPE
239{
240    OMX_BufferSupplyUnspecified = 0,                 /**< The port that provides the buffers is not specified. */
241    OMX_BufferSupplyInput,                           /**< The input port provides the buffers. */
242    OMX_BufferSupplyOutput,                          /**< The output port provides the buffers. */
243    OMX_BufferSupplyKhronosExtensions = 0x6F000000,  /**< Reserved region for introducing Khronos standard extensions. */
244    OMX_BufferSupplyVendorStartUnused = 0x7F000000,  /**< Reserved region for introducing vendor extensions. */
245    OMX_BufferSupplyMax = 0x7FFFFFFF,                /**< Maximum value. */
246};
247
248/**
249* @brief Defines the alignment structure.
250 */
251struct Alignment {
252    int widthAlignment;   /**< Alignment value of the width. */
253    int heightAlignment;  /**< Alignment value of the height. */
254};
255
256/**
257 * @brief Defines a rectangle.
258 */
259struct Rect {
260    int width;  /**< Width of the rectangle. */
261    int height; /**< Height of the rectangle. */
262};
263
264/**
265 * @brief Defines a value range.
266 */
267struct RangeValue {
268    int min;  /**< Minimum value. */
269    int max;  /**< Maximum value. */
270};
271
272/**
273 * @brief Defines the video encoding and decoding capabilities.
274 */
275struct CodecVideoPortCap {
276    struct Rect minSize;                   /**< Minimum resolution supported. */
277    struct Rect maxSize;                   /**< Maximum resolution supported. */
278    struct Alignment whAlignment;          /**< Alignment values of the width and height. */
279    struct RangeValue blockCount;          /**< Value range for the number of blocks supported. */
280    struct RangeValue blocksPerSecond;     /**< Value range for the number of blocks processed per second. */
281    struct Rect blockSize;                 /**< Block size supported. */
282    int[] supportPixFmts;                  /**< Supported pixel formats. For details, see <b>PixeFormat</b> defined by
283                                                <b>display_type.h</b> in {@link Display}. */
284    enum BitRateMode[] bitRatemode;        /**< Transmission rate modes, which can be constant or variable.
285                                                For details, see {@link BitRateMode}. */
286    struct RangeValue frameRate;           /**< Frame rate range. */
287    int[] measuredFrameRate;               /**< Frame rate measured. */
288};
289
290 * @brief Defines the audio encoding and decoding capabilities.
291 */
292struct CodecAudioPortCap {
293    int[] sampleFormats;  /**< Supported audio sampling formats. For details, see {@link AudioSampleFormat}. */
294    int[] sampleRate;     /**< Supported audio sampling rates. For details, see {@link AudioSampleRate}. */
295    int[] channelLayouts; /**< Supported channel layouts, which include single channel, balanced channel,
296                               and 3D stereo channel. */
297    int[] channelCount;   /**< Supported number of audio channels. */
298};
299
300/**
301 * @brief Defines the audio and video encoding and decoding capabilities.
302 */
303struct PortCap {
304    struct CodecVideoPortCap video;           /**< Video encoding and decoding capabilities. */
305    struct CodecAudioPortCap audio;           /**< Audio encoding and decoding capabilities. */
306};
307
308/**
309 * @brief Defines the version type of a component.
310 */
311struct OmxVerType {
312    unsigned char nVersionMajor;        /**<  Major version accessor element. */
313    unsigned char nVersionMinor;        /**<  Minor version accessor element. */
314    unsigned char nRevision;            /**< Revision version accessor element. */
315    unsigned char nStep;                /**< Step version accessor element. */
316};
317
318/**
319 * @brief Defines the component version information.
320 */
321union OMX_VERSIONTYPE {
322    struct OmxVerType s;          /**< Component version. */
323    unsigned int nVersion;        /**< 32-bit value to make accessing the version easily done in a single
324                                       word size copy or compare operation. */
325};
326
327/**
328 * @brief Defines the codec capabilities.
329 */
330struct CodecCompCapability {
331    enum AvCodecRole role;                     /**< Media type. */
332    enum CodecType type;                       /**< Codec type. */
333    String compName;                           /**< Name of the codec component. */
334    int[] supportProfiles;                     /**< Supported profiles. For details, see {@link Profile}. */
335    int maxInst;                               /**< Maximum instance. */
336    boolean isSoftwareCodec;                   /**< Whether it is a software codec. */
337    int processModeMask;                       /**< Codec processing mode mask. For details,
338                                                    see {@link CodecProcessMode}. */
339    unsigned int capsMask;                     /**< Mask of the codec playback capabilities. For details,
340                                                    see {@link CodecCapsMask}. */
341    struct RangeValue bitRate;                 /**< Supported bit rate range. */
342    struct PortCap port;                       /**< Supported audio and video encoding/decoding capabilities. */
343};
344
345/**
346 * @brief Defines the codec buffer information.
347 */
348struct OmxCodecBuffer {
349    unsigned int bufferId;               /**< Buffer ID. */
350    unsigned int size;                   /**< Size of the structure. */
351    union OMX_VERSIONTYPE version;       /**< Component version. */
352    unsigned int bufferType;             /**< Buffer type. For details, see {@link CodecBufferType}. */
353    BufferHandleParcelable bufferhandle; /**< Buffer handle used for encoding or decoding. For details,
354                                              see {@link BufferHandleParcelable}. */
355    FileDescriptor fd;                   /**< Anonymous shared memory file descriptor. */
356    unsigned int allocLen;               /**< Size of the buffer allocated. */
357    unsigned int filledLen;              /**< Size of the buffer filled. */
358    unsigned int offset;                 /**< Offset to the start position of the valid data in the buffer. */
359    FileDescriptor fenceFd;              /**< Fence file descriptor. */
360    enum ShareMemTypes type;             /**< Shared memory type. */
361    long pts;                            /**< Timestamp of the first logical sample in the buffer. */
362    unsigned int flag;                   /**< Buffer specific flag. */
363};
364
365/**
366 * @brief Defines the structure that is used to pass data from an output port to an input port.
367 */
368struct OMX_TUNNELSETUPTYPE {
369    unsigned int nTunnelFlags;                /**< Bit flags for tunneling. */
370    enum OMX_BUFFERSUPPLIERTYPE eSupplier;    /**< Supplier preference. */
371};
372
373/**
374 * @brief Defines the component information.
375 */
376struct CompVerInfo {
377    String compName;                    /**< Component name. */
378    unsigned char[] compUUID;           /**< UUID of the component. */
379    union OMX_VERSIONTYPE compVersion;  /**< OMX component version. */
380    union OMX_VERSIONTYPE specVersion;  /**< Version of the specifications on which the component is built. */
381};
382
383/**
384 * @brief Defines the event information to report.
385 */
386struct EventInfo {
387    long appData;                /**< Upper-layer instance passed in when the callback is invoked. */
388    unsigned int data1;          /**< Error type, which can be <b>portIndex</b> or other data. */
389    unsigned int data2;          /**< Data 2 carried in the reported event. */
390    byte[] eventData;            /**< Data carried in the reported event. */
391};