diff --git a/distributed_audio/audioext/v2_1/BUILD.gn b/distributed_audio/audioext/v2_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..232c50dbbec54afb6148f4141d2e82b89a89cc3f --- /dev/null +++ b/distributed_audio/audioext/v2_1/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2024 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("//build/config/components/hdi/hdi.gni") +hdi("daudioext") { + module_name = "daudioext" + sources = [ + "IDAudioCallback.idl", + "IDAudioHdfCallback.idl", + "IDAudioManager.idl", + "Types.idl", + ] + language = "cpp" + root = "ohos.hdi://drivers/interface/" + subsystem_name = "hdf" + part_name = "drivers_interface_distributed_audio" +} diff --git a/distributed_audio/audioext/v2_1/IDAudioCallback.idl b/distributed_audio/audioext/v2_1/IDAudioCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..fd90fc03c3e6e06ed394b5fb26964591ef1e206f --- /dev/null +++ b/distributed_audio/audioext/v2_1/IDAudioCallback.idl @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2024-2025 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 Distributed Audio + * @{ + * + * @brief Provides APIs for communication to distributed audio SA service + * + * Call of the transmission interface between the distributed audio HDF service and + * the distributed audio SA service, and provide hardware driver interfaces for + * the upper layer. + * + * @since 5.0 + * @version 2.0 + */ + +package ohos.hdi.distributed_audio.audioext.v2_0; + +import ohos.hdi.distributed_audio.audioext.v2_0.Types; + +/** + * @brief Basic operations for Distributed Audio devices. + * + * Enabling and disabling distributed audio devices, setting audio parameters, + * event notifications, and other related operations + * + * @since 5.0 + * @version 2.0 + */ +[callback] interface IDAudioCallback { + /** + * @brief Create distributed audio stream. + * + * @param streamId Stream ID for distributed audio devices. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + CreateStream([in] int streamId); + + /** + * @brief Create distributed audio stream. + * + * @param streamId Stream ID for distributed audio devices. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + DestroyStream([in] int streamId); + + /** + * @brief Set distributed audio device parameters. + * + * @param streamId Stream ID for distributed audio devices. + * @param param Audio parameters (sampling rate, number of channels, etc.) + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + SetParameters([in] int streamId, [in] struct AudioParameter param); + + /** + * @brief Notify distributed audio SA of events. + * + * @param streamId Stream ID for distributed audio devices. + * @param event Notification event types (such as focus events, volume events) + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + NotifyEvent([in] int streamId, [in] struct DAudioEvent event); + + /** + * @brief Write stream to distributed audio devices. + * + * @param streamId Stream ID for distributed audio devices. + * @param data frame data of audio stream. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + WriteStreamData([in] int streamId, [in] struct AudioData data); + + /** + * @brief Reading recording streams from distributed audio devices. + * + * @param streamId Stream ID for distributed audio devices. + * @param data Frame data of audio stream. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + ReadStreamData([in] int streamId, [out] struct AudioData data); + + /** + * @brief Get the current frame rate and timestamp for reading and writing + * + * @param streamId Stream ID for distributed audio devices. + * @param frames current frame number + * @param time current timestamp + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + ReadMmapPosition([in] int streamId, [out] unsigned long frames, [out] struct CurrentTime time); + + /** + * @brief Refresh shared memory information + * + * @param streamId Stream ID for distributed audio devices. + * @param fd file descriptors corresponding to shared memory + * @param ashmemLength The total number of bytes of shared memory. + * @param lengthPerTrans The number of bytes to be transmitted. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + RefreshAshmemInfo([in] int streamId, [in] FileDescriptor fd, [in] int ashmemLength, [in] int lengthPerTrans); + + /** + * @brief Get the latency of the distributed audio device. + * + * @param streamId Stream ID for distributed audio devices. + * @param ms Latency in milliseconds. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 6.0 + * @version 1.0 + */ + GetLatency([in] int streamId, [out] unsigned int ms); + + /** + * @brief Get the current render position and timestamp of the distributed audio device. + * + * @param streamId Stream ID for distributed audio devices. + * @param frames Current frame number. + * @param time Current timestamp. + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 6.0 + * @version 1.0 + */ + GetRenderPosition([in] int streamId, [out] unsigned long frames, [out] struct CurrentTime time); +} \ No newline at end of file diff --git a/distributed_audio/audioext/v2_1/IDAudioHdfCallback.idl b/distributed_audio/audioext/v2_1/IDAudioHdfCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..116aba12eca34d0105c371b7eda1fe46d22d6ba4 --- /dev/null +++ b/distributed_audio/audioext/v2_1/IDAudioHdfCallback.idl @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 Distributed Audio + * @{ + * + * @brief Provides APIs for communication to distributed audio SA service + * + * Call of the transmission interface between the distributed audio HDF service and + * the distributed audio SA service, and provide hardware driver interfaces for + * the upper layer. + * + * @since 6.0 + * @version 1.0 + */ + +package ohos.hdi.distributed_audio.audioext.v2_0; + +import ohos.hdi.distributed_audio.audioext.v2_0.Types; + +/** + * @brief Basic operations for Distributed Audio devices. + * + * There are currently no events. + * + * @since 6.0 + * @version 1.0 + */ +[callback] interface IDAudioHdfCallback { + /** + * @brief Notify distributed audio HDF of events. + * + * @param devId Device ID for distributed audio devices. + * @param event Notification event types (such as focus events, volume events) + * + * @return a value of 0 if success, return a negative value if failed. + * + * @since 6.0 + * @version 1.0 + */ + NotifyEvent([in] int devId, [in] struct DAudioEvent event); +} \ No newline at end of file diff --git a/distributed_audio/audioext/v2_1/IDAudioManager.idl b/distributed_audio/audioext/v2_1/IDAudioManager.idl new file mode 100644 index 0000000000000000000000000000000000000000..780c708a2b898a1aa9aca1d7d2e8f9d21d0c01cd --- /dev/null +++ b/distributed_audio/audioext/v2_1/IDAudioManager.idl @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024-2025 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 Distributed Audio + * @{ + * + * @brief Provides APIs for registration, unregistration, and event notification. + * + * The interface for the distributed audio, providing hardware driver registration, + * unregistration, and event notification capabilities for distributed audio SA. + * + * @since 5.0 + * @version 2.0 + */ + +package ohos.hdi.distributed_audio.audioext.v2_0; + +import ohos.hdi.distributed_audio.audioext.v2_0.IDAudioCallback; +import ohos.hdi.distributed_audio.audioext.v2_0.IDAudioHdfCallback; +import ohos.hdi.distributed_audio.audioext.v2_0.Types; + +/** + * @brief Basic operations of Distributed Audio devices + * + * Register and unregister distributed audio devices, and provide event notification + * mechanisms for distributed audio SA to the HDF layer. + * + * @since 5.0 + * @version 2.0 + */ +interface IDAudioManager { + /** + * @brief Registering distributed audio device drivers + * + * @param adpName Distributed audio device NetworkID. + * @param devId Distributed audio device Port ID. + * @param capability Distributed audio device capability set (including sampling rate, channels, etc). + * @param callbackObj Distributed Audio SA Callback. + * + * @return a value of 0 if success and a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + RegisterAudioDevice([in] String adpName, [in] int devId, [in] String capability, [in] IDAudioCallback callbackObj); + + /** + * @brief Unregistering distributed audio device drivers + * + * @param adpName Distributed audio device NetworkID. + * @param devId Distributed audio device Port ID. + * + * @return a value of 0 if success and a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + UnRegisterAudioDevice([in] String adpName, [in] int devId); + + /** + * @brief Distribute audio device SA notification events. + * + * @param adpName Distributed audio device NetworkID. + * @param devId Distributed audio device Port ID. + * @param streamId Stream ID for distributed audio devices. + * @param event Notification event types (such as focus events, volume events). + * + * @return a value of 0 if success and a negative value if failed. + * + * @since 5.0 + * @version 2.0 + */ + NotifyEvent([in] String adpName, [in] int devId, [in] int streamId, [in] struct DAudioEvent event); + + /** + * @brief Registering distributed audio HDF drivers listener. + * + * @param serviceName Service name. + * @param callbackObj Distributed Audio HDF listener Callback. + * + * @return a value of 0 if success and a negative value if failed. + * + * @since 6.0 + * @version 1.0 + */ + RegisterAudioHdfListener([in] String serviceName, [in] IDAudioHdfCallback callbackObj); + + /** + * @brief Unregistering distributed audio HDF drivers listener. + * + * @param serviceName Service name. + * + * @return a value of 0 if success and a negative value if failed. + * + * @since 6.0 + * @version 1.0 + */ + UnRegisterAudioHdfListener([in] String serviceName); +} \ No newline at end of file diff --git a/distributed_audio/audioext/v2_1/Types.idl b/distributed_audio/audioext/v2_1/Types.idl new file mode 100644 index 0000000000000000000000000000000000000000..f573e8630d1d4e3b4002e991bda82dfafa516453 --- /dev/null +++ b/distributed_audio/audioext/v2_1/Types.idl @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 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 Distributed Audio + * @{ + * + * @brief Provides APIs for communication between drivers and SA of distributed audio. + * + * The Distributed Audio module includes operations on distributed audio devices, + * stream operations, and various callbacks. Communicate with Source SA through the IDAudioCallback + * and IDAudioManager interfaces to achieve distributed functionality. + * + * @since 5.0 + * @version 2.0 + */ + +package ohos.hdi.distributed_audio.audioext.v2_0; + +/** + * @brief Enumerates the mode of port operation. + * + * @since 5.0 + * @version 2.0 + */ +enum PortOperationMode { + NORMAL_MODE = 0, + MMAP_MODE = 1, +}; + +/** + * @brief Enumerates the audio parameters. + * + * @since 5.0 + * @version 2.0 + */ +struct AudioParameter { + unsigned int format; + unsigned int channelCount; + unsigned int sampleRate; + unsigned int period; + unsigned int frameSize; + unsigned int streamUsage; + enum PortOperationMode renderFlags; + enum PortOperationMode capturerFlags; + String ext; +}; + +/** + * @brief Defines audio frame data. + * + * @since 5.0 + * @version 2.0 + */ +struct AudioData { + struct AudioParameter param; + byte[] data; +}; + +/** + * @brief Defines the notification event of distributed audio. + * + * @since 5.0 + * @version 2.0 + */ +struct DAudioEvent { + int type; + String content; +}; + +/** + * @brief Defines the timestamp of distributed audio. + * + * @since 5.0 + * @version 2.0 + */ +struct CurrentTime { + long tvSec; + long tvNSec; +}; \ No newline at end of file