From 0699cc1403a8a072014a00221f31cf8e59534cf2 Mon Sep 17 00:00:00 2001 From: zenglifeng Date: Thu, 24 Feb 2022 18:34:34 +0800 Subject: [PATCH] =?UTF-8?q?audio:=E6=B7=BB=E5=8A=A0IDL=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zenglifeng --- audio/v1_0/AudioTypes.idl | 425 +++++++++++++++++++++++++++++++++ audio/v1_0/BUILD.gn | 43 ++++ audio/v1_0/IAudioAdapter.idl | 173 ++++++++++++++ audio/v1_0/IAudioAttribute.idl | 136 +++++++++++ audio/v1_0/IAudioCallback.idl | 45 ++++ audio/v1_0/IAudioCapture.idl | 96 ++++++++ audio/v1_0/IAudioControl.idl | 114 +++++++++ audio/v1_0/IAudioManager.idl | 91 +++++++ audio/v1_0/IAudioRender.idl | 167 +++++++++++++ audio/v1_0/IAudioScene.idl | 82 +++++++ audio/v1_0/IAudioVolume.idl | 133 +++++++++++ 11 files changed, 1505 insertions(+) create mode 100755 audio/v1_0/AudioTypes.idl create mode 100755 audio/v1_0/BUILD.gn create mode 100755 audio/v1_0/IAudioAdapter.idl create mode 100755 audio/v1_0/IAudioAttribute.idl create mode 100755 audio/v1_0/IAudioCallback.idl create mode 100755 audio/v1_0/IAudioCapture.idl create mode 100755 audio/v1_0/IAudioControl.idl create mode 100755 audio/v1_0/IAudioManager.idl create mode 100755 audio/v1_0/IAudioRender.idl create mode 100755 audio/v1_0/IAudioScene.idl create mode 100755 audio/v1_0/IAudioVolume.idl diff --git a/audio/v1_0/AudioTypes.idl b/audio/v1_0/AudioTypes.idl new file mode 100755 index 00000000..cf214c32 --- /dev/null +++ b/audio/v1_0/AudioTypes.idl @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_types.h + * + * @brief Defines custom data types used in API declarations for the audio module, including audio ports, + * adapter descriptors, device descriptors, scene descriptors, sampling attributes, and timestamp. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +/** + * @brief Defines the audio handle. + */ +//typedef byte *AudioHandle; + +/** + * @brief Enumerates the audio port type. + */ +enum AudioPortDirection { + PORT_OUT = 1, /**< Output port */ + PORT_IN = 2, /**< Input port */ + PORT_OUT_IN = 3, /**< Input/output port, supporting both audio input and output */ +}; + +/** + * @brief Defines the audio port. + */ +struct AudioPort { + enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */ + unsigned int portId; /**< Audio port ID */ + unsigned char[] portName; /**< Audio port name */ +}; + +/** + * @brief Defines the audio adapter descriptor. + * + * An audio adapter is a set of port drivers for a sound card, including the output and input ports. + * One port corresponds to multiple pins, and each pin belongs to a physical component (such as a + * speaker or a wired headset). + */ +struct AudioAdapterDescriptor { + unsigned char[] adapterName; /**< Name of the audio adapter */ + unsigned int portNum; /**< Number of ports supported by an audio adapter */ + struct AudioPort ports; /**< List of ports supported by an audio adapter */ +}; + +/** + * @brief Enumerates the pin of an audio adapter. + */ +enum AudioPortPin { + PIN_NONE = 0, /**< Invalid pin */ + PIN_OUT_SPEAKER = 1, /**< Speaker output pin */ + PIN_OUT_HEADSET = 2, /**< Wired headset pin for output */ + PIN_OUT_LINEOUT = 4, /**< Line-out pin */ + PIN_OUT_HDMI = 8, /**< HDMI output pin */ + PIN_IN_MIC = 134217729, /**< Microphone input pin */ + PIN_IN_HS_MIC = 134217730, /**< Wired headset microphone pin for input */ + PIN_IN_LINEIN = 134217732, /**< Line-in pin */ +}; + +/** + * @brief Defines the audio device descriptor. + */ +struct AudioDeviceDescriptor { + unsigned int portId; /**< Audio port ID */ + enum AudioPortPin pins; /**< Pins of audio ports (input and output). For details, see {@link AudioPortPin}. */ + unsigned char[] desc; /**< Audio device name */ +}; + +/** + * @brief Enumerates the audio category. + */ +enum AudioCategory { + AUDIO_IN_MEDIA = 0, /**< Media */ + AUDIO_IN_COMMUNICATION, /**< Communications */ + AUDIO_IN_RINGTONE, /**< Ringtone */ + AUDIO_IN_CALL, /**< Call */ +}; + +union SceneDesc { + unsigned int id; /**< Audio scene ID */ + unsigned char[] desc; /**< Name of the audio scene */ +}; /**< The scene object */ + +/** + * @brief Defines the audio scene descriptor. + */ +struct AudioSceneDescriptor { + /** + * @brief Describes the audio scene. + */ + union SceneDesc scene; + struct AudioDeviceDescriptor desc; /**< Audio device descriptor */ +}; + +/** + * @brief Enumerates the audio format. + */ +enum AudioFormat { + AUDIO_FORMAT_PCM_8_BIT = 1, /**< 8-bit PCM */ + AUDIO_FORMAT_PCM_16_BIT = 2, /**< 16-bit PCM */ + AUDIO_FORMAT_PCM_24_BIT = 3, /**< 24-bit PCM */ + AUDIO_FORMAT_PCM_32_BIT = 4, /**< 32-bit PCM */ + AUDIO_FORMAT_AAC_MAIN = 16777217, /**< AAC main */ + AUDIO_FORMAT_AAC_LC = 16777218, /**< AAC LC */ + AUDIO_FORMAT_AAC_LD = 16777219, /**< AAC LD */ + AUDIO_FORMAT_AAC_ELD = 16777220, /**< AAC ELD */ + AUDIO_FORMAT_AAC_HE_V1 = 16777221, /**< AAC HE_V1 */ + AUDIO_FORMAT_AAC_HE_V2 = 16777222, /**< AAC HE_V2 */ + AUDIO_FORMAT_G711A = 33554433, /**< G711A */ + AUDIO_FORMAT_G711U = 33554434, /**< G711u */ + AUDIO_FORMAT_G726 = 33554435, /**< G726 */ +}; + +/** + * @brief Enumerates the audio channel mask. + * + * A mask describes an audio channel position. + */ +enum AudioChannelMask { + AUDIO_CHANNEL_FRONT_LEFT = 1, /**< Front left channel */ + AUDIO_CHANNEL_FRONT_RIGHT = 2, /**< Front right channel */ + AUDIO_CHANNEL_MONO = 1, /**< Mono channel */ + AUDIO_CHANNEL_STEREO = 3, /**< Stereo channel, consisting of front left and front right channels */ +}; + +/** + * @brief Enumerates masks of audio sampling rates. + */ +enum AudioSampleRatesMask { + AUDIO_SAMPLE_RATE_MASK_8000 = 1, /**< 8 kHz */ + AUDIO_SAMPLE_RATE_MASK_12000 = 2, /**< 12 kHz */ + AUDIO_SAMPLE_RATE_MASK_11025 = 4, /**< 11.025 kHz */ + AUDIO_SAMPLE_RATE_MASK_16000 = 8, /**< 16 kHz */ + AUDIO_SAMPLE_RATE_MASK_22050 = 16, /**< 22.050 kHz */ + AUDIO_SAMPLE_RATE_MASK_24000 = 32, /**< 24 kHz */ + AUDIO_SAMPLE_RATE_MASK_32000 = 64, /**< 32 kHz */ + AUDIO_SAMPLE_RATE_MASK_44100 = 128, /**< 44.1 kHz */ + AUDIO_SAMPLE_RATE_MASK_48000 = 256, /**< 48 kHz */ + AUDIO_SAMPLE_RATE_MASK_64000 = 512, /**< 64 kHz */ + AUDIO_SAMPLE_RATE_MASK_96000 = 1024, /**< 96 kHz */ + AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295, /**< Invalid sampling rate */ +}; + +/** + * @brief Defines audio sampling attributes. + */ +struct AudioSampleAttributes { + enum AudioCategory type; /**< Audio type. For details, see {@link AudioCategory} */ + boolean interleaved; /**< Interleaving flag of audio data */ + enum AudioFormat format; /**< Audio data format. For details, see {@link AudioFormat}. */ + unsigned int sampleRate; /**< Audio sampling rate */ + unsigned int channelCount; /**< Number of audio channels. For example, for the mono channel, the value is 1, + * and for the stereo channel, the value is 2. + */ + unsigned int period; /**< Audio sampling period */ + unsigned int frameSize; /**< Frame size of the audio data */ + boolean isBigEndian; /**< Big endian flag of audio data */ + boolean isSignedData; /**< Signed or unsigned flag of audio data */ + unsigned int startThreshold; /**< Audio render start threshold. */ + unsigned int stopThreshold; /**< Audio render stop threshold. */ + unsigned int silenceThreshold; /**< Audio capture buffer threshold. */ + int streamId; /**< Audio Identifier of render or capture */ +}; + +/** + * @brief Defines the audio timestamp, which is a substitute for POSIX timespec. + */ +struct AudioTimeStamp { + long tvSec; /**< Seconds */ + long tvNSec; /**< Nanoseconds */ +}; + +/** + * @brief Enumerates the passthrough data transmission mode of an audio port. + */ +enum AudioPortPassthroughMode { + PORT_PASSTHROUGH_LPCM = 1, /**< Stereo PCM */ + PORT_PASSTHROUGH_RAW = 2, /**< HDMI passthrough */ + PORT_PASSTHROUGH_HBR2LBR = 4, /**< Blu-ray next-generation audio output with reduced specifications */ + PORT_PASSTHROUGH_AUTO = 8, /**< Mode automatically matched based on the HDMI EDID */ +}; + +/** + * @brief Defines the sub-port capability. + */ +struct AudioSubPortCapability { + unsigned int portId; /**< Sub-port ID */ + unsigned char[] desc; /**< Sub-port name */ + enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details, + * see {@link AudioPortPassthroughMode}. + */ +}; + +/** + * @brief Defines formats of raw audio samples. + */ +enum AudioSampleFormat { + /* 8 bits */ + AUDIO_SAMPLE_FORMAT_S8, /**< signed 8 bit sample */ + AUDIO_SAMPLE_FORMAT_S8P, /**< signed 8 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U8, /**< unsigned 8 bit sample */ + AUDIO_SAMPLE_FORMAT_U8P, /**< unsigned 8 bit planar sample */ + /* 16 bits */ + AUDIO_SAMPLE_FORMAT_S16, /**< signed 16 bit sample */ + AUDIO_SAMPLE_FORMAT_S16P, /**< signed 16 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U16, /**< unsigned 16 bit sample */ + AUDIO_SAMPLE_FORMAT_U16P, /**< unsigned 16 bit planar sample */ + /* 24 bits */ + AUDIO_SAMPLE_FORMAT_S24, /**< signed 24 bit sample */ + AUDIO_SAMPLE_FORMAT_S24P, /**< signed 24 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U24, /**< unsigned 24 bit sample */ + AUDIO_SAMPLE_FORMAT_U24P, /**< unsigned 24 bit planar sample */ + /* 32 bits */ + AUDIO_SAMPLE_FORMAT_S32, /**< signed 32 bit sample */ + AUDIO_SAMPLE_FORMAT_S32P, /**< signed 32 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U32, /**< unsigned 32 bit sample */ + AUDIO_SAMPLE_FORMAT_U32P, /**< unsigned 32 bit planar sample */ + /* 64 bits */ + AUDIO_SAMPLE_FORMAT_S64, /**< signed 64 bit sample */ + AUDIO_SAMPLE_FORMAT_S64P, /**< signed 64 bit planar sample */ + AUDIO_SAMPLE_FORMAT_U64, /**< unsigned 64 bit sample */ + AUDIO_SAMPLE_FORMAT_U64P, /**< unsigned 64 bit planar sample */ + /* float double */ + AUDIO_SAMPLE_FORMAT_F32, /**< float 32 bit sample */ + AUDIO_SAMPLE_FORMAT_F32P, /**< float 32 bit planar sample */ + AUDIO_SAMPLE_FORMAT_F64, /**< double 64 bit sample */ + AUDIO_SAMPLE_FORMAT_F64P, /**< double 64 bit planar sample */ +}; + +/** + * @brief Defines the audio port capability. + */ +struct AudioPortCapability { + unsigned int deviceType; /**< Device type (output or input) */ + unsigned int deviceId; /**< Device ID used for device binding */ + boolean hardwareMode; /**< Whether to support device binding */ + unsigned int formatNum; /**< Number of the supported audio formats */ + enum AudioFormat formats; /**< Supported audio formats. For details, see {@link AudioFormat}. */ + unsigned int sampleRateMasks; /**< Supported audio sampling rates (8 kHz, 16 kHz, 32 kHz, and 48 kHz) */ + enum AudioChannelMask channelMasks; /**< Audio channel layout mask of the device. For details, + * see {@link AudioChannelMask}. + */ + unsigned int channelCount; /**< Supported maximum number of audio channels */ + unsigned int subPortsNum; /**< Number of supported sub-ports (for output devices only) */ + struct AudioSubPortCapability subPorts; /**< List of supported sub-ports */ + unsigned int supportSampleFormatNum; /**< Number of the supported audio sample format enum. */ + enum AudioSampleFormat supportSampleFormats; /**< Supported audio sample formats. For details, + * see {@link AudioSampleFormat}. + */ +}; + +/** + * @brief Enumerates channel modes for audio rendering. + * + * @attention The following modes are set for rendering dual-channel audios. Others are not supported. + */ +enum AudioChannelMode { + AUDIO_CHANNEL_NORMAL = 0, /**< Normal mode. No processing is required. */ + AUDIO_CHANNEL_BOTH_LEFT, /**< Two left channels */ + AUDIO_CHANNEL_BOTH_RIGHT, /**< Two right channels */ + AUDIO_CHANNEL_EXCHANGE, /**< Data exchange between the left and right channels. The left channel takes the audio + * stream of the right channel, and the right channel takes that of the left channel. + */ + AUDIO_CHANNEL_MIX, /**< Mix of streams of the left and right channels */ + AUDIO_CHANNEL_LEFT_MUTE, /**< Left channel muted. The stream of the right channel is output. */ + AUDIO_CHANNEL_RIGHT_MUTE, /**< Right channel muted. The stream of the left channel is output. */ + AUDIO_CHANNEL_BOTH_MUTE, /**< Both left and right channels muted */ +}; + +/** + * @brief Enumerates the execution types of the DrainBuffer function. + */ +enum AudioDrainNotifyType { + AUDIO_DRAIN_NORMAL_MODE, /**< The DrainBuffer function returns after all data finishes playback. */ + AUDIO_DRAIN_EARLY_MODE, /**< The DrainBuffer function returns before all the data of the current track + * finishes playback to reserve time for a smooth track switch by the audio service. + */ +}; + +/** + * @brief Enumerates callback notification events. + */ +enum AudioCallbackType { + AUDIO_NONBLOCK_WRITE_COMPELETED, /**< The non-block write is complete. */ + AUDIO_DRAIN_COMPELETED, /**< The draining is complete. */ + AUDIO_FLUSH_COMPLETED, /**< The flush is complete. */ + AUDIO_RENDER_FULL, /**< The render buffer is full.*/ + AUDIO_ERROR_OCCUR, /**< An error occurs.*/ +}; + +/** + * @brief Describes a mmap buffer. + */ +struct AudioMmapBufferDescripter { + byte memoryAddress; /**< Pointer to the mmap buffer */ + int memoryFd; /**< File descriptor of the mmap buffer */ + int totalBufferFrames; /**< Total size of the mmap buffer (unit: frame )*/ + int transferFrameSize; /**< Transfer size (unit: frame) */ + int isShareable; /**< Whether the mmap buffer can be shared among processes */ + unsigned int offset; +}; + +/** + * @brief Describes AudioPortRole. + */ +enum AudioPortRole { + AUDIO_PORT_UNASSIGNED_ROLE = 0, /**< Unassigned port role */ + AUDIO_PORT_SOURCE_ROLE = 1, /**< Assigned source role */ + AUDIO_PORT_SINK_ROLE = 2, /**< Assigned sink role */ +}; + +/** + * @brief Describes AudioPortType. + */ +enum AudioPortType { + AUDIO_PORT_UNASSIGNED_TYPE = 0, /**< Unassigned port type */ + AUDIO_PORT_DEVICE_TYPE = 1, /**< Assigned device type */ + AUDIO_PORT_MIX_TYPE = 2, /**< Assigned mix type */ + AUDIO_PORT_SESSION_TYPE = 3, /**< Assigned session type */ +}; + +/** + * @brief Describes AudioDevExtInfo. + */ +struct AudioDevExtInfo { + int moduleId; /**< Identifier of the module stream is attached to */ + enum AudioPortPin type; /**< Device type For details, see {@link AudioPortPin}. */ + unsigned char[] desc; /**< Address */ +}; + +/** + * @brief Describes AudioMixInfo. + */ +struct AudioMixExtInfo { + int moduleId; /**< Identifier of the module stream is attached to */ + int streamId; /**< Identifier of the capture or render passed by caller */ +}; + +/** + * @brief Describes AudioSessionType. + */ +enum AudioSessionType { + AUDIO_OUTPUT_STAGE_SESSION = 0, + AUDIO_OUTPUT_MIX_SESSION, + AUDIO_ALLOCATE_SESSION, + AUDIO_INVALID_SESSION, +}; + +/** + * @brief Describes AudioSessionExtInfo. + */ +struct AudioSessionExtInfo { + enum AudioSessionType sessionType; +}; + +union AudioSpecificExt { + struct AudioDevExtInfo device; /* Specific Device Ext info */ + struct AudioMixExtInfo mix; /* Specific mix info */ + struct AudioSessionExtInfo session; /* session specific info */ +}; + +/** + * @brief Describes AudioRouteNode. + */ +struct AudioRouteNode { + int portId; /**< Audio port ID */ + enum AudioPortRole role; /**< Audio port as a sink or a source */ + enum AudioPortType type; /**< device, mix ... */ + union AudioSpecificExt ext; +}; + +/** + * @brief Describes AudioRoute. + */ +struct AudioRoute { + unsigned int sourcesNum; + struct AudioRouteNode sources; + unsigned int sinksNum; + struct AudioRouteNode sinks; +}; + +struct AudioCapture { + int xx; +}; + +struct AudioRender { + int xx; +}; + +struct AudioAdapter { + int xx; +}; + +struct AudioManager { + int xx; +}; \ No newline at end of file diff --git a/audio/v1_0/BUILD.gn b/audio/v1_0/BUILD.gn new file mode 100755 index 00000000..7c96626d --- /dev/null +++ b/audio/v1_0/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/uhdf2/hdi.gni") +if (defined(ohos_lite)) { + group("libaudio_proxy_1.0") { + deps = [] + public_configs = [] + } +} else { + hdi("audio") { + package = "audio.v1_0" + + module_name = "audio_service" + + sources = [ + "AudioTypes.idl", + "IAudioAdapter.idl", + "IAudioAttribute.idl", + "IAudioCallback.idl", + "IAudioCapture.idl", + "IAudioControl.idl", + "IAudioManager.idl", + "IAudioRender.idl", + "IAudioScene.idl", + "IAudioVolume.idl" + ] + + language = "c" + subsystem_name = "hdf" + part_name = "audio_device_driver" + } +} diff --git a/audio/v1_0/IAudioAdapter.idl b/audio/v1_0/IAudioAdapter.idl new file mode 100755 index 00000000..0a09c61a --- /dev/null +++ b/audio/v1_0/IAudioAdapter.idl @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_adapter.h + * + * @brief Declares APIs for operations related to the audio adapter. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; +import audio.v1_0.IAudioRender; +import audio.v1_0.IAudioCapture; + +/** + * @brief Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks, + * and obtaining the port capability set. + * + * @see AudioRender + * @see AudioCapture + * @since 1.0 + * @version 1.0 + */ +interface IAudioAdapter { + /** + * @brief Initializes all ports of an audio adapter. + * + * Call this function before calling other driver functions to check whether the initialization is complete. + * If the initialization is not complete, wait for a while (for example, 100 ms) and perform the check again + * until the port initialization is complete. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @return Returns 0 if the initialization is successful; returns a negative value otherwise. + */ + InitAllPorts([out] struct AudioAdapter adapter); + + /** + * @brief Creates an AudioRender object. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter to start. + * @param attrs Indicates the pointer to the audio sampling attributes to open. + * @param render Indicates the double pointer to the AudioRender object. + * @return Returns 0 if the AudioRender object is created successfully; + * returns a negative value otherwise. + * @see GetPortCapability + * @see DestroyRender + */ + CreateRender([out] struct AudioAdapter adapter, [in] struct AudioDeviceDescriptor desc, + [in] struct AudioSampleAttributes attrs, [out] struct AudioRender[] render); + + /** + * @brief Destroys an AudioRender object. + * + * @attention Do not destroy the object during audio rendering. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param render Indicates the pointer to the AudioRender object to operate. + * @return Returns 0 if the AudioRender object is destroyed; returns a negative value otherwise. + * @see CreateRender + */ + DestroyRender([out] struct AudioAdapter adapter, [out] struct AudioRender render); + + /** + * @brief Creates an AudioCapture object. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter to start. + * @param attrs Indicates the pointer to the audio sampling attributes to open. + * @param capture Indicates the double pointer to the AudioCapture object. + * @return Returns 0 if the AudioCapture object is created successfully; + * returns a negative value otherwise. + * @see GetPortCapability + * @see DestroyCapture + */ + CreateCapture([out] struct AudioAdapter adapter, [in] struct AudioDeviceDescriptor desc, + [in] struct AudioSampleAttributes attrs, [out] struct AudioCapture[] capture); + + /** + * @brief Destroys an AudioCapture object. + * + * @attention Do not destroy the object during audio capturing. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param capture Indicates the pointer to the AudioCapture object to operate. + * @return Returns 0 if the AudioCapture object is destroyed; returns a negative value otherwise. + * @see CreateCapture + */ + DestroyCapture([out] struct AudioAdapter adapter, [out] struct AudioCapture capture); + + /** + * @brief Obtains the capability set of the port driver for the audio adapter. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param capability Indicates the pointer to the capability set to obtain. + * @return Returns 0 if the capability set is successfully obtained; returns a negative value otherwise. + */ + GetPortCapability([out] struct AudioAdapter adapter, [in] struct AudioPort port, + [out] struct AudioPortCapability capability); + + /** + * @brief Sets the passthrough data transmission mode of the audio port driver. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param mode Indicates the passthrough transmission mode to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetPassthroughMode + */ + SetPassthroughMode([out] struct AudioAdapter adapter, [in] struct AudioPort port, + [out] enum AudioPortPassthroughMode mode); + + /** + * @brief Obtains the passthrough data transmission mode of the audio port driver. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param port Indicates the pointer to the port. + * @param mode Indicates the pointer to the passthrough transmission mode to obtain. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + */ + GetPassthroughMode([out] struct AudioAdapter adapter, [in] struct AudioPort port, + [out] enum AudioPortPassthroughMode mode); + + /** + * @brief Update audio route on several source and sink ports. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param route Indicates route information. + * @param routeHandle Indicates route handle. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + */ + UpdateAudioRoute([out] struct AudioAdapter adapter, [in] struct AudioRoute route, [out] unsigned int routeHandle); + + /** + * @brief Release an audio route. + * + * @param adapter Indicates the pointer to the audio adapter to operate. + * @param routeHandle Indicates route handle. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetPassthroughMode + */ + ReleaseAudioRoute([out]struct AudioAdapter adapter, [out] unsigned int routeHandle); +} diff --git a/audio/v1_0/IAudioAttribute.idl b/audio/v1_0/IAudioAttribute.idl new file mode 100755 index 00000000..ce259289 --- /dev/null +++ b/audio/v1_0/IAudioAttribute.idl @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_attribute.h + * + * @brief Declares APIs for audio attributes. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; + +/** + * @brief Provides attribute-related APIs for audio rendering or capturing, including functions to + * obtain frame information and set audio sampling attributes. + * + * @since 1.0 + * @version 1.0 + */ +interface IAudioAttribute { + /** + * @brief Obtains the audio frame size, that is, the length (in bytes) of a frame. + * + * @param handle Indicates the audio handle. + * @param size Indicates the pointer to the audio frame size (in bytes). + * @return Returns 0 if the audio frame size is obtained; returns a negative value otherwise. + */ + GetFrameSize([in] byte handle, [out] unsigned long size); + + /** + * @brief Obtains the number of audio frames in the audio buffer. + * + * @param handle Indicates the audio handle. + * @param count Indicates the pointer to the number of audio frames in the audio buffer. + * @return Returns 0 if the number of audio frames is obtained; returns a negative value otherwise. + */ + GetFrameCount([in] byte handle, [out] unsigned long count); + + /** + * @brief Sets audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes to set, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetSampleAttributes + */ + SetSampleAttributes([in] byte handle, [in] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains audio sampling attributes. + * + * @param handle Indicates the audio handle. + * @param attrs Indicates the pointer to the audio sampling attributes, such as the sampling rate, + * sampling precision, and channel. + * @return Returns 0 if audio sampling attributes are obtained; returns a negative value otherwise. + * @see SetSampleAttributes + */ + GetSampleAttributes([in] byte handle, [out] struct AudioSampleAttributes attrs); + + /** + * @brief Obtains the data channel ID of the audio. + * + * @param handle Indicates the audio handle. + * @param channelId Indicates the pointer to the data channel ID. + * @return Returns 0 if the data channel ID is obtained; returns a negative value otherwise. + */ + GetCurrentChannelId([in] byte handle, [out] unsigned int channelId); + + /** + * @brief Sets extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + SetExtraParams([in] byte handle, [in] unsigned char[] keyValueList); + + /** + * @brief Obtains extra audio parameters. + * + * @param handle Indicates the audio handle. + * @param keyValueList Indicates the pointer to the key-value list of the extra audio parameters. + * The format is key=value. Separate multiple key-value pairs by semicolons (;). + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + GetExtraParams([in] byte handle, [out] unsigned char keyValueList, [out] unsigned int listLenth); + + /** + * @brief Requests a mmap buffer. + * + * @param handle Indicates the audio handle. + * @param reqSize Indicates the size of the request mmap buffer. + * @param desc Indicates the pointer to the mmap buffer descriptor. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + ReqMmapBuffer([in] byte handle, [out] unsigned int reqSize, [out] struct AudioMmapBufferDescripter desc); + + /** + * @brief Obtains the read/write position of the current mmap buffer. + * + * @param handle Indicates the audio handle. + * @param frames Indicates the pointer to the frame where the read/write starts. + * @param time Indicates the pointer to the timestamp associated with the frame where the read/write starts. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + GetMmapPosition([in] byte handle,[out] unsigned long frames, [out] struct AudioTimeStamp time); +} diff --git a/audio/v1_0/IAudioCallback.idl b/audio/v1_0/IAudioCallback.idl new file mode 100755 index 00000000..d94bd0a8 --- /dev/null +++ b/audio/v1_0/IAudioCallback.idl @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdiSensor + * @{ + * + * @brief Provides unified APIs for sensor services to access sensor drivers. + * + * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to + * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, + * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, + * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. + * + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; + +/** + * @brief Called when an event defined in {@link AudioCallbackType} occurs. + * + * @param AudioCallbackType Indicates the occurred event that triggers this callback. + * @param reserved Indicates the pointer to a reserved field. + * @param cookie Indicates the pointer to the cookie for data transmission. + * @return Returns 0 if the callback is successfully executed; returns a negative value otherwise. + * @see RegCallback + */ +[callback] interface IAudioCallback { + RenderCallback([out] enum AudioCallbackType type, [out] byte reserved, [out] byte cookie); +} diff --git a/audio/v1_0/IAudioCapture.idl b/audio/v1_0/IAudioCapture.idl new file mode 100755 index 00000000..608ae35c --- /dev/null +++ b/audio/v1_0/IAudioCapture.idl @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_capture.h + * + * @brief Declares APIs for audio capturing. + * + * @since 1.0 + * @version 1.0 + */ +package audio.v1_0; + +import audio.v1_0.AudioTypes; +import audio.v1_0.IAudioScene; +import audio.v1_0.IAudioVolume; +import audio.v1_0.IAudioControl; +import audio.v1_0.IAudioAttribute; + + +/** + * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, + * scenes, and volume, and capturing audio frames. + * + * @see AudioControl + * @see AudioAttribute + * @see AudioScene + * @see AudioVolume + * @since 1.0 + * @version 1.0 + */ +interface IAudioCapture { + /** + * @brief Defines the audio control. For details, see {@link AudioControl}. + */ + //struct AudioControl control; + /** + * @brief Defines the audio attribute. For details, see {@link AudioAttribute}. + */ + //struct AudioAttribute attr; + /** + * @brief Defines the audio scene. For details, see {@link AudioScene}. + */ + //struct AudioScene scene; + /** + * @brief Defines audio volume. For details, see {@link AudioVolume}. + */ + //struct AudioVolume volume; + + /** + * @brief Reads a frame of input data (uplink data) from the audio driver for capturing. + * + * @param capture Indicates the pointer to the AudioCapture object to operate. + * @param frame Indicates the pointer to the input data to read. + * @param requestBytes Indicates the size of the input data, in bytes. + * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to read. + * @return Returns 0 if the input data is read successfully; returns a negative value otherwise. + */ + CaptureFrame([out] struct AudioCapture capture,[out] byte frame, [out] unsigned long requestBytes, + [out] unsigned long replyBytes); + + /** + * @brief Obtains the last number of input audio frames. + * + * @param capture Indicates the pointer to the AudioCapture object to operate. + * @param frames Indicates the pointer to the last number of input audio frames. + * @param time Indicates the pointer to the timestamp associated with the frame. + * @return Returns 0 if the last number is obtained; returns a negative value otherwise. + * @see CaptureFrame + */ + GetCapturePosition([out]struct AudioCapture capture, [out] unsigned long frames, + [out] struct AudioTimeStamp time); +} diff --git a/audio/v1_0/IAudioControl.idl b/audio/v1_0/IAudioControl.idl new file mode 100755 index 00000000..6c9e42ee --- /dev/null +++ b/audio/v1_0/IAudioControl.idl @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_control.h + * + * @brief Declares APIs for audio control. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; + +/** + * @brief Provides control-related APIs for audio rendering or capturing, including functions to + * start, stop, pause, and resume audio rendering or capturing, and flush data in the audio buffer. + * + * @since 1.0 + * @version 1.0 + */ +interface IAudioControl { + /** + * @brief Starts audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully started; + * returns a negative value otherwise. + * @see Stop + */ + Start([out] byte handle); + + /** + * @brief Stops audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully stopped; + * returns a negative value otherwise. + * @see Start + */ + Stop([out] byte handle); + + /** + * @brief Pauses audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully paused; + * returns a negative value otherwise. + * @see Resume + */ + Pause([out] byte handle); + + /** + * @brief Resumes audio rendering or capturing. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the rendering or capturing is successfully resumed; + * returns a negative value otherwise. + * @see Pause + */ + Resume([out] byte handle); + + /** + * @brief Flushes data in the audio buffer. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the flush is successful; returns a negative value otherwise. + */ + Flush([out] byte handle); + + /** + * @brief Sets or cancels the standby mode of the audio device. + * + * @param handle Indicates the audio handle. + * @return Returns 0 if the device is set to standby mode; returns a positive value if the standby mode is + * canceled; returns a negative value if the setting fails. + */ + TurnStandbyMode([out] byte handle); + + /** + * @brief Dumps information about the audio device. + * + * @param handle Indicates the audio handle. + * @param range Indicates the range of the device information to dump, which can be brief or full information. + * @param fd Indicates the file to which the device information will be dumped. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + AudioDevDump([out] byte handle, [out] unsigned int range, [out] unsigned int fd); +} diff --git a/audio/v1_0/IAudioManager.idl b/audio/v1_0/IAudioManager.idl new file mode 100755 index 00000000..cd724dec --- /dev/null +++ b/audio/v1_0/IAudioManager.idl @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_manager.h + * + * @brief Declares APIs for audio adapter management and loading. + * + * @since 1.0 + * @version 1.0 + */ +package audio.v1_0; + +import audio.v1_0.AudioTypes; +import audio.v1_0.IAudioAdapter; + +/** + * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio + * adapter descriptor. + * + * @see AudioAdapter + * @since 1.0 + * @version 1.0 + */ +interface IAudioManager { + /** + * @brief Obtains the list of all adapters supported by an audio driver. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param descs Indicates the double pointer to the audio adapter list. + * @param size Indicates the pointer to the length of the list. + * @return Returns 0 if the list is obtained successfully; returns a negative value otherwise. + * @see LoadAdapter + */ + GetAllAdapters([out] struct AudioManager manager,[out] struct AudioAdapterDescriptor[] descs, [out] int size); + + /** + * @brief Loads the driver for an audio adapter. + * + * For example, to load a USB driver, you may need to load a dynamic-link library (*.so) in specific implementation. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param desc Indicates the pointer to the descriptor of the audio adapter. + * @param adapter Indicates the double pointer to the audio adapter. + * @return Returns 0 if the driver is loaded successfully; returns a negative value otherwise. + * @see GetAllAdapters + * @see UnloadAdapter + */ + LoadAdapter([out] struct AudioManager manager,[in] struct AudioAdapterDescriptor desc, + [out]struct AudioAdapter[] adapter); + + /** + * @brief Unloads the driver of an audio adapter. + * + * @param manager Indicates the pointer to the audio adapter manager to operate. + * @param adapter Indicates the pointer to the audio adapter whose driver will be unloaded. + * @see LoadAdapter + */ + UnloadAdapter([out] struct AudioManager manager,[out] struct AudioAdapter adapter); + + /** + * @brief Release the AudioManager Object. + * + * @param object Indicates the pointer to the audio adapter manager to operate. + * @return Returns true if the Object is released; returns false otherwise. + */ + ReleaseAudioManagerObject([out] struct AudioManager object); +} diff --git a/audio/v1_0/IAudioRender.idl b/audio/v1_0/IAudioRender.idl new file mode 100755 index 00000000..ba70096d --- /dev/null +++ b/audio/v1_0/IAudioRender.idl @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_render.h + * + * @brief Declares APIs for audio rendering. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; +import audio.v1_0.IAudioScene; +import audio.v1_0.IAudioVolume; +import audio.v1_0.IAudioControl; +import audio.v1_0.IAudioCallback; +import audio.v1_0.IAudioAttribute; + +/** + * @brief Provides capabilities for audio rendering, including controlling the rendering, setting audio attributes, + * scenes, and volume, obtaining hardware latency, and rendering audio frames. + * + * @see AudioControl + * @see AudioAttribute + * @see AudioScene + * @see AudioVolume + * @since 1.0 + * @version 1.0 + */ +interface IAudioRender { + /** + * @brief Defines the audio control. For details, see {@link AudioControl}. + */ + //struct AudioControl control; + /** + * @brief Defines the audio attribute. For details, see {@link AudioAttribute}. + */ + //struct AudioAttribute attr; + /** + * @brief Defines the audio scene. For details, see {@link AudioScene}. + */ + //struct AudioScene scene; + /** + * @brief Defines audio volume. For details, see {@link AudioVolume}. + */ + //struct AudioVolume volume; + + /** + * @brief Obtains the estimated latency of the audio device driver. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param ms Indicates the pointer to the latency (in milliseconds) to be obtained. + * @return Returns 0 if the latency is obtained; returns a negative value otherwise. + */ + GetLatency([out] struct AudioRender render,[out] unsigned int ms); + + /** + * @brief Writes a frame of output data (downlink data) into the audio driver for rendering. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param frame Indicates the pointer to the frame to write. + * @param requestBytes Indicates the size of the frame, in bytes. + * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to write. + * @return Returns 0 if the data is written successfully; returns a negative value otherwise. + */ + RenderFrame([out] struct AudioRender render, [in] byte frame, [out] unsigned long requestBytes, [out] unsigned long replyBytes); + + /** + * @brief Obtains the last number of output audio frames. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param frames Indicates the pointer to the last number of output audio frames. + * @param time Indicates the pointer to the timestamp associated with the frame. + * @return Returns 0 if the last number is obtained; returns a negative value otherwise. + * @see RenderFrame + */ + GetRenderPosition([out] struct AudioRender render, [out] unsigned long frames, [out] struct AudioTimeStamp time); + + /** + * @brief Sets the audio rendering speed. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param speed Indicates the rendering speed to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetRenderSpeed + */ + SetRenderSpeed([out] struct AudioRender render, [out] float speed); + + /** + * @brief Obtains the current audio rendering speed. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param speed Indicates the pointer to the current rendering speed to obtain. + * @return Returns 0 if the speed is successfully obtained; returns a negative value otherwise. + * @see SetRenderSpeed + */ + GetRenderSpeed([out] struct AudioRender render, [out] float speed); + + /** + * @brief Sets the channel mode for audio rendering. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param mode Indicates the channel mode to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetChannelMode + */ + SetChannelMode([out] struct AudioRender render, [out] enum AudioChannelMode mode); + + /** + * @brief Obtains the current channel mode for audio rendering. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param mode Indicates the pointer to the channel mode to obtain. + * @return Returns 0 if the mode is successfully obtained; returns a negative value otherwise. + * @see SetChannelMode + */ + GetChannelMode([out] struct AudioRender render, [out] enum AudioChannelMode mode); + + /** + * @brief Registers an audio callback that will be invoked during playback when buffer data writing or + * buffer drain is complete. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param callback Indicates the callback to register. + * @param cookie Indicates the pointer to the callback parameters. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see RegCallback + */ + RegCallback([out] struct AudioRender render, [out] IAudioCallback audioCallback, [out] byte cookie); + + /** + * @brief Drains the buffer. + * + * @param render Indicates the pointer to the AudioRender object to operate. + * @param type Indicates the pointer to the execution type of this function. For details, + * see {@link AudioDrainNotifyType}. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + * @see RegCallback + */ + DrainBuffer([out] struct AudioRender render,[out] enum AudioDrainNotifyType type); +} diff --git a/audio/v1_0/IAudioScene.idl b/audio/v1_0/IAudioScene.idl new file mode 100755 index 00000000..0768c534 --- /dev/null +++ b/audio/v1_0/IAudioScene.idl @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_scene.h + * + * @brief Declares APIs for audio scenes. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; + +/** + * @brief Provides scene-related APIs for audio rendering or capturing, including functions to + * select an audio scene and check whether the configuration of an audio scene is supported. + * + * @since 1.0 + * @version 1.0 + */ +interface IAudioScene { + /** + * @brief Checks whether the configuration of an audio scene is supported. + * + * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene. + * @param supported Indicates the pointer to the variable specifying whether the configuration is supported. + * Value true means that the configuration is supported, and false means the opposite. + * @return Returns 0 if the result is obtained; returns a negative value otherwise. + * @see SelectScene + */ + CheckSceneCapability([in] byte handle, [in] struct AudioSceneDescriptor scene, [out] int supported); + + /** + * @brief Selects an audio scene. + * + * + * @param handle Indicates the audio handle. + * @param scene Indicates the pointer to the descriptor of the audio scene to select. + * @return Returns 0 if the scene is selected successfully; returns a negative value otherwise. + * @see CheckSceneCapability + */ + SelectScene([in] byte handle, [in] struct AudioSceneDescriptor scene); +} diff --git a/audio/v1_0/IAudioVolume.idl b/audio/v1_0/IAudioVolume.idl new file mode 100755 index 00000000..79571100 --- /dev/null +++ b/audio/v1_0/IAudioVolume.idl @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Audio + * @{ + * + * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, + * accessing a driver adapter, and rendering and capturing audios. + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file audio_volume.h + * + * @brief Declares APIs for audio volume. + * + * @since 1.0 + * @version 1.0 + */ + +package audio.v1_0; + +import audio.v1_0.AudioTypes; + +/** + * @brief Provides volume-related APIs for audio rendering or capturing, including functions to + * set the mute operation, volume, and gain. + * + * @since 1.0 + * @version 1.0 + */ +interface IAudioVolume { + /** + * @brief Sets the mute operation for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Specifies whether to mute the audio. Value true means to mute the audio, + * and false means the opposite. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetMute + */ + SetMute([in] byte handle, [out] boolean mute); + + /** + * @brief Obtains the mute operation set for the audio. + * + * @param handle Indicates the audio handle. + * @param mute Indicates the pointer to the mute operation set for the audio. Value true means that + * the audio is muted, and false means the opposite. + * @return Returns 0 if the mute operation is obtained; returns a negative value otherwise. + * @see SetMute + */ + GetMute([in] byte handle, [out] boolean mute); + + /** + * @brief Sets the audio volume. + * + * The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, + * 0.0 indicates that the audio is muted, and 1.0 indicates the maximum volume level (15). + * + * @param handle Indicates the audio handle. + * @param volume Indicates the volume to set. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetVolume + */ + SetVolume([in] byte handle, [out] float volume); + + /** + * @brief Obtains the audio volume. + * + * @param handle Indicates the audio handle. + * @param volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0. + * @return Returns 0 if the volume is obtained; returns a negative value otherwise. + * @see SetVolume + */ + GetVolume([in] byte handle, [out] float volume); + + /** + * @brief Obtains the range of the audio gain. + * + * The audio gain can be expressed in one of the following two ways (depending on the chip platform), + * corresponding to two types of value ranges: + * + * @param handle Indicates the audio handle. + * @param min Indicates the pointer to the minimum value of the range. + * @param max Indicates the pointer to the maximum value of the range. + * @return Returns 0 if the range is obtained; returns a negative value otherwise. + * @see GetGain + * @see SetGain + */ + GetGainThreshold([in] byte handle, [out] float min, [out] float max); + + /** + * @brief Obtains the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the pointer to the audio gain. + * @return Returns 0 if the audio gain is obtained; returns a negative value otherwise. + * @see GetGainThreshold + * @see SetGain + */ + GetGain([in] byte handle, [out] float gain); + + /** + * @brief Sets the audio gain. + * + * @param handle Indicates the audio handle. + * @param gain Indicates the audio gain to set. + * @return Returns 0 if the setting is successful; returns a negative value otherwise. + * @see GetGainThreshold + * @see GetGain + */ + SetGain([in] byte handle, [out] float gain); +} -- Gitee