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