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