• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 HdiAudio
18 *
19 * @brief Provides unified APIs for audio services to access audio drivers.
20 *
21 * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to
22 * access different types of audio devices based on the audio IDs, thereby obtaining audio information,
23 * subscribing to or unsubscribing from audio data, enabling or disabling an audio,
24 * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range.
25 *
26 * @since 4.1
27 * @version 4.0
28 */
29
30package ohos.hdi.audio.v4_0;
31
32/**
33 * @brief Enumerates the audio port type.
34 *
35 * @since 4.1
36 * @version 2.0
37 */
38enum AudioPortDirection {
39    PORT_OUT    = 1, /**< Output port */
40    PORT_IN     = 2, /**< Input port */
41    PORT_OUT_IN = 3, /**< Input/output port, supporting both audio input and output */
42};
43
44/**
45 * @brief Enumerates the pin of an audio adapter.
46 *
47 * @since 4.1
48 * @version 3.1
49 */
50enum AudioPortPin {
51    PIN_NONE                     = 0,                 /**< Invalid pin */
52    PIN_OUT_SPEAKER              = 1 << 0,            /**< Speaker output pin */
53    PIN_OUT_HEADSET              = 1 << 1,            /**< Wired headset pin for output */
54    PIN_OUT_LINEOUT              = 1 << 2,            /**< Line-out pin */
55    PIN_OUT_HDMI                 = 1 << 3,            /**< HDMI output pin */
56    PIN_OUT_USB                  = 1 << 4,            /**< USB output pin */
57    PIN_OUT_USB_EXT              = 1 << 5,            /**< Extended USB output pin*/
58    PIN_OUT_EARPIECE             = 1 << 5 | 1 << 4,   /**< Earpiece output pin */
59    PIN_OUT_BLUETOOTH_SCO        = 1 << 6,            /**< Bluetooth SCO output pin */
60    PIN_OUT_DAUDIO_DEFAULT       = 1 << 7,            /**< Daudio default output pin */
61    PIN_OUT_HEADPHONE            = 1 << 8,            /**< Wired headphone output pin*/
62    PIN_OUT_USB_HEADSET          = 1 << 9,            /**< ARM USB out pin */
63    PIN_OUT_BLUETOOTH_A2DP       = 1 << 10,           /**< Bluetooth A2DP output pin */
64    PIN_OUT_DP                   = 1 << 11,           /**< Dp output pin */
65    PIN_OUT_NEARLINK_SCO         = 1 << 12,           /**< Nearlink SCO output pin */
66    PIN_OUT_NEARLINK             = 1 << 13,           /**< Nearlink output pin */
67    PIN_IN_MIC                   = 1 << 27 | 1 << 0,  /**< Microphone input pin */
68    PIN_IN_HS_MIC                = 1 << 27 | 1 << 1,  /**< Wired headset microphone pin for input */
69    PIN_IN_LINEIN                = 1 << 27 | 1 << 2,  /**< Line-in pin */
70    PIN_IN_USB_EXT               = 1 << 27 | 1 << 3,  /**< Extended USB input pin*/
71    PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4,  /**< Bluetooth SCO headset input pin */
72    PIN_IN_DAUDIO_DEFAULT        = 1 << 27 | 1 << 5,  /**< Daudio default input pin */
73    PIN_IN_USB_HEADSET           = 1 << 27 | 1 << 6,  /**< ARM USB input pin */
74    PIN_IN_PENCIL                = 1 << 27 | 1 << 7,  /**< Pencil input pin */
75    PIN_IN_UWB                   = 1 << 27 | 1 << 8,  /**< UWB input pin */
76    PIN_IN_NEARLINK              = 1 << 27 | 1 << 9,  /**< Nearlink input pin */
77};
78
79/**
80 * @brief Enumerates the audio category.
81 *
82 * @since 4.1
83 * @version 3.0
84 */
85enum AudioCategory {
86    AUDIO_IN_MEDIA         = 0, /**< Media */
87    AUDIO_IN_COMMUNICATION = 1, /**< Communications */
88    AUDIO_IN_RINGTONE      = 2, /**< Ringtone */
89    AUDIO_IN_CALL          = 3, /**< Call */
90    AUDIO_MMAP_NOIRQ       = 4, /**< Mmap mode */
91    AUDIO_OFFLOAD          = 5, /**< Offload */
92    AUDIO_MULTI_CHANNEL    = 6, /**< Multi channel */
93    AUDIO_DP               = 7, /**< Audio dp */
94    AUDIO_MMAP_VOIP        = 8, /**< Audio voip */
95    AUDIO_IN_NAVIGATION    = 9, /**< Audio navigation */
96    AUDIO_DIRECT           = 10,/**< Audio direct */
97};
98
99/**
100 * @brief Enumerates the audio format.
101 *
102 * @since 4.1
103 * @version 2.0
104 */
105enum AudioFormat {
106    AUDIO_FORMAT_TYPE_PCM_8_BIT  = 1 << 0,                      /**< 8-bit PCM */
107    AUDIO_FORMAT_TYPE_PCM_16_BIT = 1 << 1,                      /**< 16-bit PCM */
108    AUDIO_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0,             /**< 24-bit PCM */
109    AUDIO_FORMAT_TYPE_PCM_32_BIT = 1 << 2,                      /**< 32-bit PCM */
110    AUDIO_FORMAT_TYPE_PCM_FLOAT  = 1 << 2 | 1 << 0,             /**< FLOAT PCM */
111    AUDIO_FORMAT_TYPE_MP3        = 1 << 24,                     /**< MP3 */
112    AUDIO_FORMAT_TYPE_AAC_MAIN   = 1 << 24 | 1 << 0,            /**< AAC main */
113    AUDIO_FORMAT_TYPE_AAC_LC     = 1 << 24 | 1 << 1,            /**< AAC LC */
114    AUDIO_FORMAT_TYPE_AAC_LD     = 1 << 24 | 1 << 1 | 1 << 0,   /**< AAC LD */
115    AUDIO_FORMAT_TYPE_AAC_ELD    = 1 << 24 | 1 << 2,            /**< AAC ELD */
116    AUDIO_FORMAT_TYPE_AAC_HE_V1  = 1 << 24 | 1 << 2 | 1 << 0,   /**< AAC HE_V1 */
117    AUDIO_FORMAT_TYPE_AAC_HE_V2  = 1 << 24 | 1 << 2 | 1 << 1,   /**< AAC HE_V2 */
118    AUDIO_FORMAT_TYPE_G711A      = 1 << 25 | 1 << 0,            /**< G711A */
119    AUDIO_FORMAT_TYPE_G711U      = 1 << 25 | 1 << 1,            /**< G711u */
120    AUDIO_FORMAT_TYPE_G726       = 1 << 25 | 1 << 1 | 1 << 0,   /**< G726 */
121};
122
123/**
124 * @brief Enumerates the audio channel mask.
125 *
126 * A mask describes an audio channel position.
127 *
128 * @since 4.1
129 * @version 2.0
130 */
131enum AudioChannelMask {
132    AUDIO_CHANNEL_FRONT_LEFT  = 1,  /**< Front left channel */
133    AUDIO_CHANNEL_FRONT_RIGHT = 2,  /**< Front right channel */
134    AUDIO_CHANNEL_MONO        = 1,  /**< Mono channel */
135    AUDIO_CHANNEL_STEREO      = 3,  /**< Stereo channel, consisting of front left and front right channels */
136};
137
138/**
139 * @brief Enumerates masks of audio sampling rates.
140 *
141 * @since 4.1
142 * @version 2.0
143 */
144enum AudioSampleRatesMask {
145    AUDIO_SAMPLE_RATE_MASK_8000    = 1 << 0,        /**< 8 kHz */
146    AUDIO_SAMPLE_RATE_MASK_12000   = 1 << 1,        /**< 12 kHz */
147    AUDIO_SAMPLE_RATE_MASK_11025   = 1 << 2,        /**< 11.025 kHz */
148    AUDIO_SAMPLE_RATE_MASK_16000   = 1 << 3,        /**< 16 kHz */
149    AUDIO_SAMPLE_RATE_MASK_22050   = 1 << 4,        /**< 22.050 kHz */
150    AUDIO_SAMPLE_RATE_MASK_24000   = 1 << 5,        /**< 24 kHz */
151    AUDIO_SAMPLE_RATE_MASK_32000   = 1 << 6,        /**< 32 kHz */
152    AUDIO_SAMPLE_RATE_MASK_44100   = 1 << 7,        /**< 44.1 kHz */
153    AUDIO_SAMPLE_RATE_MASK_48000   = 1 << 8,        /**< 48 kHz */
154    AUDIO_SAMPLE_RATE_MASK_64000   = 1 << 9,        /**< 64 kHz */
155    AUDIO_SAMPLE_RATE_MASK_96000   = 1 << 10,       /**< 96 kHz */
156    AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295,    /**< Invalid sampling rate */
157};
158
159/**
160 * @brief Enumerates the passthrough data transmission mode of an audio port.
161 *
162 * @since 4.1
163 * @version 2.0
164 */
165enum AudioPortPassthroughMode {
166    PORT_PASSTHROUGH_LPCM    = 1 << 0, /**< Stereo PCM */
167    PORT_PASSTHROUGH_RAW     = 1 << 1, /**< HDMI passthrough */
168    PORT_PASSTHROUGH_HBR2LBR = 1 << 2, /**< Blu-ray next-generation audio output with reduced specifications */
169    PORT_PASSTHROUGH_AUTO    = 1 << 3, /**< Mode automatically matched based on the HDMI EDID */
170};
171
172/**
173 * @brief Defines formats of raw audio samples.
174 *
175 * @since 4.1
176 * @version 2.0
177 */
178enum AudioSampleFormat {
179    /* 8 bits */
180    AUDIO_SAMPLE_FORMAT_S8   = 0,  /**< signed 8 bit sample */
181    AUDIO_SAMPLE_FORMAT_S8P  = 1,  /**< signed 8 bit planar sample */
182    AUDIO_SAMPLE_FORMAT_U8   = 2,  /**< unsigned 8 bit sample */
183    AUDIO_SAMPLE_FORMAT_U8P  = 3,  /**< unsigned 8 bit planar sample */
184    /* 16 bits */
185    AUDIO_SAMPLE_FORMAT_S16  = 4,  /**< signed 16 bit sample */
186    AUDIO_SAMPLE_FORMAT_S16P = 5,  /**< signed 16 bit planar sample */
187    AUDIO_SAMPLE_FORMAT_U16  = 6,  /**< unsigned 16 bit sample */
188    AUDIO_SAMPLE_FORMAT_U16P = 7,  /**< unsigned 16 bit planar sample */
189    /* 24 bits */
190    AUDIO_SAMPLE_FORMAT_S24  = 8,  /**< signed 24 bit sample */
191    AUDIO_SAMPLE_FORMAT_S24P = 9,  /**< signed 24 bit planar sample */
192    AUDIO_SAMPLE_FORMAT_U24  = 10, /**< unsigned 24 bit sample */
193    AUDIO_SAMPLE_FORMAT_U24P = 11, /**< unsigned 24 bit planar sample */
194    /* 32 bits */
195    AUDIO_SAMPLE_FORMAT_S32  = 12, /**< signed 32 bit sample */
196    AUDIO_SAMPLE_FORMAT_S32P = 13, /**< signed 32 bit planar sample */
197    AUDIO_SAMPLE_FORMAT_U32  = 14, /**< unsigned 32 bit sample */
198    AUDIO_SAMPLE_FORMAT_U32P = 15, /**< unsigned 32 bit planar sample */
199    /* 64 bits */
200    AUDIO_SAMPLE_FORMAT_S64  = 16, /**< signed 64 bit sample */
201    AUDIO_SAMPLE_FORMAT_S64P = 17, /**< signed 64 bit planar sample */
202    AUDIO_SAMPLE_FORMAT_U64  = 18, /**< unsigned 64 bit sample */
203    AUDIO_SAMPLE_FORMAT_U64P = 19, /**< unsigned 64 bit planar sample */
204    /* float double */
205    AUDIO_SAMPLE_FORMAT_F32  = 20, /**< float 32 bit sample */
206    AUDIO_SAMPLE_FORMAT_F32P = 21, /**< float 32 bit planar sample */
207    AUDIO_SAMPLE_FORMAT_F64  = 22, /**< double 64 bit sample */
208    AUDIO_SAMPLE_FORMAT_F64P = 23, /**< double 64 bit planar sample */
209};
210
211/**
212 * @brief Enumerates channel modes for audio rendering.
213 *
214 * @attention The following modes are set for rendering dual-channel audios. Others are not supported.
215 *
216 * @since 4.1
217 * @version 2.0
218 */
219enum AudioChannelMode {
220    AUDIO_CHANNEL_NORMAL     = 0, /**< Normal mode. No processing is required. */
221    AUDIO_CHANNEL_BOTH_LEFT  = 1, /**< Two left channels */
222    AUDIO_CHANNEL_BOTH_RIGHT = 2, /**< Two right channels */
223    AUDIO_CHANNEL_EXCHANGE   = 3, /**< Data exchange between the left and right channels. The left channel takes the audio
224                                   * stream of the right channel, and the right channel takes that of the left channel.
225                                   */
226    AUDIO_CHANNEL_MIX        = 4, /**< Mix of streams of the left and right channels */
227    AUDIO_CHANNEL_LEFT_MUTE  = 5, /**< Left channel muted. The stream of the right channel is output. */
228    AUDIO_CHANNEL_RIGHT_MUTE = 6, /**< Right channel muted. The stream of the left channel is output. */
229    AUDIO_CHANNEL_BOTH_MUTE  = 7, /**< Both left and right channels are muted */
230};
231
232/**
233 * @brief Enumerates the execution types of the <b>DrainBuffer</b> function.
234 *
235 * @since 4.1
236 * @version 2.0
237 */
238enum AudioDrainNotifyType {
239    AUDIO_DRAIN_NORMAL_MODE = 0, /**< The <b>DrainBuffer</b> function returns after all data finishes playback. */
240    AUDIO_DRAIN_EARLY_MODE  = 1, /**< The <b>DrainBuffer</b> function returns before all the data of the current track
241                                  * finishes playback to reserve time for a smooth track switch by the audio service.
242                                  */
243
244};
245
246/**
247 * @brief Enumerates callback notification events.
248 *
249 * @since 4.1
250 * @version 2.0
251 */
252enum AudioCallbackType {
253    AUDIO_NONBLOCK_WRITE_COMPLETED = 0, /**< The non-block write is complete. */
254    AUDIO_DRAIN_COMPLETED          = 1, /**< The draining is complete. */
255    AUDIO_FLUSH_COMPLETED          = 2, /**< The flush is complete. */
256    AUDIO_RENDER_FULL              = 3, /**< The render buffer is full.*/
257    AUDIO_ERROR_OCCUR              = 4, /**< An error occurs.*/
258};
259
260/**
261 * @brief Describes AudioPortRole.
262 *
263 * @since 4.1
264 * @version 2.0
265 */
266enum AudioPortRole {
267    AUDIO_PORT_UNASSIGNED_ROLE = 0, /**< Unassigned port role */
268    AUDIO_PORT_SOURCE_ROLE     = 1, /**< Assigned source role */
269    AUDIO_PORT_SINK_ROLE       = 2, /**< Assigned sink role */
270};
271
272/**
273 * @brief Describes AudioPortType.
274 *
275 * @since 4.1
276 * @version 2.0
277 */
278enum AudioPortType {
279    AUDIO_PORT_UNASSIGNED_TYPE = 0, /**< Unassigned port type */
280    AUDIO_PORT_DEVICE_TYPE     = 1, /**< Assigned device type */
281    AUDIO_PORT_MIX_TYPE        = 2, /**< Assigned mix type */
282    AUDIO_PORT_SESSION_TYPE    = 3, /**< Assigned session type */
283};
284
285/**
286 * @brief Describes AudioSessionType.
287 *
288 * @since 4.1
289 * @version 2.0
290 */
291enum AudioSessionType {
292    AUDIO_OUTPUT_STAGE_SESSION = 0, /**< Assigned output stage session */
293    AUDIO_OUTPUT_MIX_SESSION   = 1, /**< Assigned output mix session */
294    AUDIO_ALLOCATE_SESSION     = 2, /**< Assigned allocate session */
295    AUDIO_INVALID_SESSION      = 3, /**< Assigned invalid session */
296};
297
298/**
299 * @brief Describes AudioDeviceType.
300 *
301 * @since 4.1
302 * @version 3.0
303 */
304enum AudioDeviceType {
305    AUDIO_LINEOUT        = 1 << 0, /**< Assigned lineout device type */
306    AUDIO_HEADPHONE      = 1 << 1, /**< Assigned headphone device type */
307    AUDIO_HEADSET        = 1 << 2, /**< Assigned headset device type */
308    AUDIO_USB_HEADSET    = 1 << 3, /**< Assigned usb headset device type */
309    AUDIO_USB_HEADPHONE  = 1 << 4, /**< Assigned usb headphone device type */
310    AUDIO_USBA_HEADSET   = 1 << 5, /**< Assigned usba headset device type */
311    AUDIO_USBA_HEADPHONE = 1 << 6, /**< Assigned usba headphone device type */
312    AUDIO_PRIMARY_DEVICE = 1 << 7, /**< Assigned primary device type */
313    AUDIO_USB_DEVICE     = 1 << 8, /**< Assigned usb device type */
314    AUDIO_A2DP_DEVICE    = 1 << 9, /**< Assigned a2dp device type */
315    AUDIO_HDMI_DEVICE    = 1 << 10, /**< Assigned hdmi device type */
316    AUDIO_ADAPTER_DEVICE = 1 << 11, /**< Assigned adapter device type */
317    AUDIO_DP_DEVICE      = 1 << 12, /**< Assigned dp device type */
318    AUDIO_DEVICE_UNKNOWN,           /**< Assigned unknown device type */
319};
320
321/**
322 * @brief Describes AudioEventType.
323 *
324 * @since 4.1
325 * @version 2.0
326 */
327enum AudioEventType {
328    AUDIO_DEVICE_ADD        = 1,  /**< Assigned add device event type */
329    AUDIO_DEVICE_REMOVE     = 2,  /**< Assigned remove device event type */
330    AUDIO_LOAD_SUCCESS      = 3,  /**< Assigned load sucess event type */
331    AUDIO_LOAD_FAILURE      = 4,  /**< Assigned load failure event type */
332    AUDIO_UNLOAD            = 5,  /**< Assigned unload event type */
333    AUDIO_SERVICE_VALID     = 7,  /**< Assigned valid service event type */
334    AUDIO_SERVICE_INVALID   = 8,  /**< Assigned invalid service event type */
335    AUDIO_CAPTURE_THRESHOLD = 9,  /**< Assigned threshold capture event type */
336    AUDIO_EVENT_UNKNOWN     = 10, /**< Assigned unknown event type */
337};
338
339/**
340 * @brief Enumerates the restricted key type of the parameters
341 *
342 * @since 4.1
343 * @version 2.0
344 */
345enum AudioExtParamKey {
346    AUDIO_EXT_PARAM_KEY_NONE     = 0,    /**< Distributed audio extra param key none */
347    AUDIO_EXT_PARAM_KEY_VOLUME   = 1,    /**< Distributed audio extra param key volume event */
348    AUDIO_EXT_PARAM_KEY_FOCUS    = 2,    /**< Distributed audio extra param key focus event */
349    AUDIO_EXT_PARAM_KEY_BUTTON   = 3,    /**< Distributed audio extra param key media button event */
350    AUDIO_EXT_PARAM_KEY_EFFECT   = 4,    /**< Distributed audio extra param key audio effect event */
351    AUDIO_EXT_PARAM_KEY_STATUS   = 5,    /**< Distributed audio extra param key device status event */
352    AUDIO_EXT_PARAM_KEY_USB_DEVICE = 101, /**< Check USB device type ARM or HIFI */
353    AUDIO_EXT_PARAM_KEY_PERF_INFO = 201, /**< Distributed audio extra param key dsp load event */
354    AUDIO_EXT_PARAM_KEY_MMI      = 301,  /**< Distributed audio extra param key Man-Machine interface Test */
355    AUDIO_EXT_PARAM_KEY_LOWPOWER = 1000, /**< Low power event type */
356};
357
358/**
359 * @brief Describes status of audio deivce.@link enum AudioDeviceType
360 *
361 * @since 4.1
362 * @version 2.0
363 */
364struct AudioDeviceStatus {
365    unsigned int pnpStatus; /**< Audio pnp status */
366};
367
368/**
369 * @brief Describes the audio scene.
370 *
371 * @since 4.1
372 * @version 2.0
373 */
374union SceneDesc {
375    unsigned int id; /**< Audio scene ID */
376};
377
378/**
379 * @brief Defines the audio port.
380 *
381 * @since 4.1
382 * @version 2.0
383 */
384struct AudioPort {
385    enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */
386    unsigned int portId;         /**< Audio port ID */
387    String portName;             /**< Audio port name */
388};
389
390/**
391 * @brief Defines the audio adapter descriptor.
392 *
393 * An audio adapter is a set of port drivers for a sound card, including the output and input ports.
394 * One port corresponds to multiple pins, and each pin belongs to a physical component (such as a
395 * speaker or a wired headset).
396 *
397 * @since 4.1
398 * @version 2.0
399 */
400struct AudioAdapterDescriptor {
401    String adapterName;       /**< Name of the audio adapter */
402    struct AudioPort[] ports; /**< List of ports supported by an audio adapter */
403};
404
405/**
406 * @brief Defines the audio device descriptor.
407 *
408 * @since 4.1
409 * @version 2.0
410 */
411struct AudioDeviceDescriptor {
412    unsigned int portId;    /**< Audio port ID */
413    enum AudioPortPin pins; /**< Pins of audio ports (input and output). For details, see {@link AudioPortPin}. */
414    String desc;            /**< Audio device name */
415};
416
417/**
418 * @brief Defines the audio scene descriptor.
419 *
420 * @since 4.1
421 * @version 2.0
422 */
423struct AudioSceneDescriptor {
424    union SceneDesc scene;             /**< Describes the audio scene */
425    struct AudioDeviceDescriptor desc; /**< Audio device descriptor */
426};
427
428/**
429 * @brief Defines audio input type.
430 *
431 * @since 4.1
432 * @version 3.1
433 */
434enum AudioInputType {
435    AUDIO_INPUT_DEFAULT_TYPE             = 0,      /**< Assigned default input type */
436    AUDIO_INPUT_MIC_TYPE                 = 1 << 0, /**< Assigned mic input type */
437    AUDIO_INPUT_SPEECH_WAKEUP_TYPE       = 1 << 1, /**< Assigned speech wakeup input type */
438    AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, /**< Assigned voice communication input type */
439    AUDIO_INPUT_VOICE_RECOGNITION_TYPE   = 1 << 3, /**< Assigned voice recognition input type */
440    AUDIO_INPUT_VOICE_UPLINK_TYPE        = 1 << 4, /**< Assigned voice uplink input type */
441    AUDIO_INPUT_VOICE_DOWNLINK_TYPE      = 1 << 5, /**< Assigned voice downlink input type */
442    AUDIO_INPUT_VOICE_CALL_TYPE          = 1 << 6, /**< Assigned voice call input type */
443    AUDIO_INPUT_CAMCORDER_TYPE           = 1 << 7, /**< Assigned camcorder input type */
444    AUDIO_INPUT_EC_TYPE                  = 1 << 8, /**< Assigned EC input type */
445    AUDIO_INPUT_NOISE_REDUCTION_TYPE     = 1 << 9, /**< Assigned noise reduction input type */
446    AUDIO_INPUT_RAW_TYPE                 = 1 << 10, /**< Assigned raw input type */
447    AUDIO_INPUT_LIVE_TYPE                = 1 << 11, /**< Assigned live input type */
448};
449
450/**
451 * @brief Defines audio offload attributes.
452 *
453 * @since 4.1
454 * @version 2.0
455 */
456struct AudioOffloadInfo
457{
458    unsigned int sampleRate;    /**< Audio sampling rate */
459    unsigned int channelCount;  /**< Number of audio channels */
460    unsigned long channelLayout;   /**< Audio channel layout */
461    unsigned int bitRate;       /**< bitRate of compressed audio data */
462    unsigned int bitWidth;      /**< bitwidth of audio data */
463    enum AudioFormat format;       /**< Audio data format. */
464    unsigned int offloadBufferSize;    /**< buffersize for offload audio data */
465    unsigned long duration;           /** audio duration, unit is nanosecond*/
466};
467
468/**
469 * @brief Defines audio Ecsampling attributes.
470 *
471 * @since 5.0
472 * @version 1.0
473 */
474struct EcSampleAttributes {
475    boolean ecInterleaved;            /**< Interleaving flag of audio data */
476    enum AudioFormat ecFormat;        /**< Audio data format. For details, see {@link AudioFormat}. */
477    unsigned int ecSampleRate;        /**< Audio sampling rate */
478    unsigned int ecChannelCount;      /**< Number of audio channels */
479    unsigned long ecChannelLayout;    /**< Audio channel layout */
480    unsigned int ecPeriod;            /**< Audio sampling period */
481    unsigned int ecFrameSize;         /**< Frame size of the audio data */
482    boolean ecIsBigEndian;            /**< Big endian flag of audio data */
483    boolean ecIsSignedData;           /**< Signed or unsigned flag of audio data */
484    unsigned int ecStartThreshold;    /**< Audio start threshold. */
485    unsigned int ecStopThreshold;     /**< Audio stop threshold. */
486    unsigned int ecSilenceThreshold;  /**< Audio buffer threshold. */
487};
488
489/**
490 * @brief Defines audio captureEc attributes.
491 *
492 * @since 5.0
493 * @version 1.0
494 */
495struct AudioCaptureFrameInfo {
496    byte[] frame;                /**< Audio capture frame */
497    unsigned long replyBytes;    /**< The actual length of the audio capture frame */
498    byte[] frameEc;              /**< Audio capture ec frame */
499    unsigned long replyBytesEc;  /**< The actual length of the audio capture ec frame */
500};
501
502/**
503 * @brief Defines audio len of captureEc frame.
504 *
505 * @since 5.0
506 * @version 1.0
507 */
508struct AudioFrameLen {
509    unsigned int frameLen;     /**< The length of the audio capture frame */
510    unsigned int frameEcLen;   /**< The length of the audio capture ec frame */
511};
512
513/**
514 * @brief Defines audio sampling attributes.
515 *
516 * @since 4.1
517 * @version 3.0
518 */
519struct AudioSampleAttributes {
520    enum AudioCategory type;       /**< Audio type. For details, see {@link AudioCategory} */
521    boolean interleaved;           /**< Interleaving flag of audio data */
522    enum AudioFormat format;       /**< Audio data format. For details, see {@link AudioFormat}. */
523    unsigned int sampleRate;       /**< Audio sampling rate */
524    unsigned int channelCount;     /**< Number of audio channels. For example, for the mono channel, the value is 1,
525                                    * and for the stereo channel, the value is 2.
526                                    */
527    unsigned long channelLayout;   /**< Audio channel layout */
528    unsigned int period;           /**< Audio sampling period */
529    unsigned int frameSize;        /**< Frame size of the audio data */
530    boolean isBigEndian;           /**< Big endian flag of audio data */
531    boolean isSignedData;          /**< Signed or unsigned flag of audio data */
532    unsigned int startThreshold;   /**< Audio render start threshold. */
533    unsigned int stopThreshold;    /**< Audio render stop threshold. */
534    unsigned int silenceThreshold; /**< Audio capture buffer threshold. */
535    int streamId;                  /**< Audio Identifier of render or capture */
536    int sourceType;                /**< Audio sourceType of render or capture */
537    struct AudioOffloadInfo offloadInfo;  /**< offload info for offload stream */
538    struct EcSampleAttributes ecSampleAttributes; /**< ec config */
539};
540
541/**
542 * @brief Defines the audio timestamp, which is a substitute for POSIX <b>timespec</b>.
543 *
544 * @since 4.1
545 * @version 2.0
546 */
547struct AudioTimeStamp {
548    long tvSec;  /**< Seconds */
549    long tvNSec; /**< Nanoseconds */
550};
551
552/**
553 * @brief Defines the sub-port capability.
554 *
555 * @since 4.1
556 * @version 2.0
557 */
558struct AudioSubPortCapability {
559    unsigned int portId;                /**< Sub-port ID */
560    String desc;                        /**< Sub-port name */
561    enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details,
562                                         * see {@link AudioPortPassthroughMode}.
563                                         */
564};
565
566/**
567 * @brief Defines the audio port capability.
568 *
569 * @since 4.1
570 * @version 2.0
571 */
572struct AudioPortCapability {
573    unsigned int deviceType;                       /**< Device type (output or input) */
574    unsigned int deviceId;                         /**< Device ID used for device binding */
575    boolean hardwareMode;                          /**< Whether to support device binding */
576    unsigned int formatNum;                        /**< Number of the supported audio formats */
577    enum AudioFormat[] formats;                    /**< Supported audio formats. For details, see {@link AudioFormat}. */
578    unsigned int sampleRateMasks;                  /**< Supported audio sampling rates (8 kHz, 16 kHz, 32 kHz, and 48 kHz) */
579    enum AudioChannelMask channelMasks;            /**< Audio channel layout mask of the device. For details,
580                                                    * see {@link AudioChannelMask}.
581                                                    */
582    unsigned int channelCount;                     /**< Supported maximum number of audio channels */
583    struct AudioSubPortCapability[] subPorts;      /**< List of supported sub-ports */
584    enum AudioSampleFormat[] supportSampleFormats; /**< Supported audio sample formats. For details,
585                                                    * see {@link AudioSampleFormat}.
586                                                    */
587};
588
589/**
590 * @brief Describes a mmap buffer.
591 *
592 * @since 4.1
593 * @version 2.0
594 */
595struct AudioMmapBufferDescriptor {
596    byte[] memoryAddress;    /**< Pointer to the mmap buffer */
597    FileDescriptor memoryFd; /**< File descriptor of the mmap buffer */
598    int totalBufferFrames;   /**< Total size of the mmap buffer (unit: frame )*/
599    int transferFrameSize;   /**< Transfer size (unit: frame) */
600    int isShareable;         /**< Whether the mmap buffer can be shared among processes */
601    unsigned int offset;     /**< off set */
602    String filePath;         /**< file path */
603};
604
605/**
606 * @brief Describes AudioDevExtInfo.
607 *
608 * @since 4.1
609 * @version 2.0
610 */
611struct AudioDevExtInfo {
612    int moduleId;           /**< Identifier of the module stream is attached to */
613    enum AudioPortPin type; /**< Device type For details, see {@link AudioPortPin}. */
614    String desc;            /**< Address */
615};
616
617/**
618 * @brief Describes AudioMixInfo.
619 *
620 * @since 4.1
621 * @version 3.0
622 */
623struct AudioMixExtInfo {
624    int moduleId; /**< Identifier of the module stream is attached to */
625    int streamId; /**< Identifier of the capture or render passed by caller */
626    int source;   /**< Identifier of the source by capture or render */
627};
628
629/**
630 * @brief Describes AudioSessionExtInfo.
631 *
632 * @since 4.1
633 * @version 2.0
634 */
635struct AudioSessionExtInfo {
636    enum AudioSessionType sessionType; /**< Audio session type */
637};
638
639/**
640 * @brief Describes AudioInfo.
641 *
642 * @since 4.1
643 * @version 2.0
644 */
645struct AudioInfo {
646    struct AudioDevExtInfo device;      /* Specific Device Ext info */
647    struct AudioMixExtInfo mix;         /* Specific mix info */
648    struct AudioSessionExtInfo session; /* session specific info */
649};
650
651/**
652 * @brief Describes AudioRouteNode.
653 *
654 * @since 4.1
655 * @version 2.0
656 */
657struct AudioRouteNode {
658    int portId;              /**< Audio port ID */
659    enum AudioPortRole role; /**< Audio port as a sink or a source */
660    enum AudioPortType type; /**< device, mix ... */
661    struct AudioInfo ext;    /**< The <b>ext</b> object */
662};
663
664/**
665 * @brief Describes AudioRoute.
666 *
667 * @since 4.1
668 * @version 2.0
669 */
670struct AudioRoute {
671    struct AudioRouteNode[] sources; /**< List of sources */
672    struct AudioRouteNode[] sinks;   /**< List of sinks */
673};
674
675/**
676 * @brief Describes AudioEvent.
677 *
678 * @since 4.1
679 * @version 2.0
680 */
681struct AudioEvent {
682    unsigned int eventType;  /**< @link enum AudioEventType */
683    unsigned int deviceType; /**< @link enum AudioDeviceType */
684};
685