diff --git a/bundle.json b/bundle.json index 59de4502abacc870d300e8e8defc8b8494f336fc..4222a801e966a4ccc7a0e9303cb9839dceea5ea0 100755 --- a/bundle.json +++ b/bundle.json @@ -34,6 +34,7 @@ "c_utils", "distributed_hardware_fwk", "drivers_interface_audio", + "drivers_interface_distributed_audio", "dsoftbus", "eventhandler", "hdf_core", diff --git a/distributedaudio.gni b/distributedaudio.gni index 0b98805811c851b5d58cee508f53e5c048a070ec..2227a8bab4555b89dc8e3d52df9966a61ac215eb 100644 --- a/distributedaudio.gni +++ b/distributedaudio.gni @@ -32,9 +32,8 @@ audio_processor_path = "${services_path}/audioprocessor" audio_transport_path = "${services_path}/audiotransport" softbusadapter_path = "${services_path}/softbusadapter" interfaces_path = "${distributedaudio_path}/interfaces" -hdf_interfaces_path = - "${distributedaudio_path}/hdf_interfaces/distributed_audio" -hdf_service_path = "${distributedaudio_path}/hdf_service/distributed_audio" +hdf_interfaces_path = "//drivers/interface/distributed_audio" +hdf_service_path = "//drivers/peripheral/distributed_audio" hdf_ser_aud_path = "${hdf_service_path}/hdi_service/audio/v1_0" hdf_ser_aud_ext_path = "${hdf_service_path}/hdi_service/audio_ext/v1_0" diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl b/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl deleted file mode 100644 index 830a0c5dda0ba844990382811b01d7b5e49cc1f9..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright (c) 2022-2023 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 HdiAudio - * @{ - * - * @brief Provides unified APIs for audio services to access audio drivers. - * - * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to - * access different types of audio devices based on the audio IDs, thereby obtaining audio information, - * subscribing to or unsubscribing from audio data, enabling or disabling an audio, - * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. - * - * @since 4.0 - * @version 1.0 - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -/** - * @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 Enumerates the pin of an audio adapter. - */ -enum AudioPortPin { - PIN_NONE = 0, /**< Invalid pin */ - PIN_OUT_SPEAKER = 1 << 0, /**< Speaker output pin */ - PIN_OUT_HEADSET = 1 << 1, /**< Wired headset pin for output */ - PIN_OUT_LINEOUT = 1 << 2, /**< Line-out pin */ - PIN_OUT_HDMI = 1 << 3, /**< HDMI output pin */ - PIN_OUT_USB = 1 << 4, /**< USB output pin */ - PIN_OUT_USB_EXT = 1 << 5, /**< Extended USB output pin*/ - PIN_OUT_EARPIECE = 1 << 5 | 1 << 4, /**< Earpiece output pin */ - PIN_OUT_BLUETOOTH_SCO = 1 << 6, /**< Bluetooth SCO output pin */ - PIN_OUT_DAUDIO_DEFAULT = 1 << 7, /**< Daudio default output pin */ - PIN_OUT_HEADPHONE = 1 << 8, /**< Wired headphone output pin*/ - PIN_OUT_USB_HEADSET = 1 << 9, /**< ARM USB out pin */ - PIN_IN_MIC = 1 << 27 | 1 << 0, /**< Microphone input pin */ - PIN_IN_HS_MIC = 1 << 27 | 1 << 1, /**< Wired headset microphone pin for input */ - PIN_IN_LINEIN = 1 << 27 | 1 << 2, /**< Line-in pin */ - PIN_IN_USB_EXT = 1 << 27 | 1 << 3, /**< Extended USB input pin*/ - PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, /**< Bluetooth SCO headset input pin */ - PIN_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, /**< Daudio default input pin */ - PIN_IN_USB_HEADSET = 1 << 27 | 1 << 6, /**< ARM USB input pin */ -}; - -/** - * @brief Enumerates the audio category. - */ -enum AudioCategory { - AUDIO_IN_MEDIA = 0, /**< Media */ - AUDIO_IN_COMMUNICATION = 1, /**< Communications */ - AUDIO_IN_RINGTONE = 2, /**< Ringtone */ - AUDIO_IN_CALL = 3, /**< Call */ - AUDIO_MMAP_NOIRQ = 4, /**< Mmap mode */ -}; - -/** - * @brief Enumerates the audio format. - */ -enum AudioFormat { - AUDIO_FORMAT_TYPE_PCM_8_BIT = 1 << 0, /**< 8-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_16_BIT = 1 << 1, /**< 16-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0, /**< 24-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_32_BIT = 1 << 2, /**< 32-bit PCM */ - AUDIO_FORMAT_TYPE_AAC_MAIN = 1 << 24 | 1 << 0, /**< AAC main */ - AUDIO_FORMAT_TYPE_AAC_LC = 1 << 24 | 1 << 1, /**< AAC LC */ - AUDIO_FORMAT_TYPE_AAC_LD = 1 << 24 | 1 << 1 | 1 << 0, /**< AAC LD */ - AUDIO_FORMAT_TYPE_AAC_ELD = 1 << 24 | 1 << 2, /**< AAC ELD */ - AUDIO_FORMAT_TYPE_AAC_HE_V1 = 1 << 24 | 1 << 2 | 1 << 0, /**< AAC HE_V1 */ - AUDIO_FORMAT_TYPE_AAC_HE_V2 = 1 << 24 | 1 << 2 | 1 << 1, /**< AAC HE_V2 */ - AUDIO_FORMAT_TYPE_G711A = 1 << 25 | 1 << 0, /**< G711A */ - AUDIO_FORMAT_TYPE_G711U = 1 << 25 | 1 << 1, /**< G711u */ - AUDIO_FORMAT_TYPE_G726 = 1 << 25 | 1 << 1 | 1 << 0, /**< 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 << 0, /**< 8 kHz */ - AUDIO_SAMPLE_RATE_MASK_12000 = 1 << 1, /**< 12 kHz */ - AUDIO_SAMPLE_RATE_MASK_11025 = 1 << 2, /**< 11.025 kHz */ - AUDIO_SAMPLE_RATE_MASK_16000 = 1 << 3, /**< 16 kHz */ - AUDIO_SAMPLE_RATE_MASK_22050 = 1 << 4, /**< 22.050 kHz */ - AUDIO_SAMPLE_RATE_MASK_24000 = 1 << 5, /**< 24 kHz */ - AUDIO_SAMPLE_RATE_MASK_32000 = 1 << 6, /**< 32 kHz */ - AUDIO_SAMPLE_RATE_MASK_44100 = 1 << 7, /**< 44.1 kHz */ - AUDIO_SAMPLE_RATE_MASK_48000 = 1 << 8, /**< 48 kHz */ - AUDIO_SAMPLE_RATE_MASK_64000 = 1 << 9, /**< 64 kHz */ - AUDIO_SAMPLE_RATE_MASK_96000 = 1 << 10, /**< 96 kHz */ - AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295, /**< Invalid sampling rate */ -}; - -/** - * @brief Enumerates the passthrough data transmission mode of an audio port. - */ -enum AudioPortPassthroughMode { - PORT_PASSTHROUGH_LPCM = 1 << 0, /**< Stereo PCM */ - PORT_PASSTHROUGH_RAW = 1 << 1, /**< HDMI passthrough */ - PORT_PASSTHROUGH_HBR2LBR = 1 << 2, /**< Blu-ray next-generation audio output with reduced specifications */ - PORT_PASSTHROUGH_AUTO = 1 << 3, /**< Mode automatically matched based on the HDMI EDID */ -}; - -/** - * @brief Defines formats of raw audio samples. - */ -enum AudioSampleFormat { - /* 8 bits */ - AUDIO_SAMPLE_FORMAT_S8 = 0, /**< signed 8 bit sample */ - AUDIO_SAMPLE_FORMAT_S8P = 1, /**< signed 8 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U8 = 2, /**< unsigned 8 bit sample */ - AUDIO_SAMPLE_FORMAT_U8P = 3, /**< unsigned 8 bit planar sample */ - /* 16 bits */ - AUDIO_SAMPLE_FORMAT_S16 = 4, /**< signed 16 bit sample */ - AUDIO_SAMPLE_FORMAT_S16P = 5, /**< signed 16 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U16 = 6, /**< unsigned 16 bit sample */ - AUDIO_SAMPLE_FORMAT_U16P = 7, /**< unsigned 16 bit planar sample */ - /* 24 bits */ - AUDIO_SAMPLE_FORMAT_S24 = 8, /**< signed 24 bit sample */ - AUDIO_SAMPLE_FORMAT_S24P = 9, /**< signed 24 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U24 = 10, /**< unsigned 24 bit sample */ - AUDIO_SAMPLE_FORMAT_U24P = 11, /**< unsigned 24 bit planar sample */ - /* 32 bits */ - AUDIO_SAMPLE_FORMAT_S32 = 12, /**< signed 32 bit sample */ - AUDIO_SAMPLE_FORMAT_S32P = 13, /**< signed 32 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U32 = 14, /**< unsigned 32 bit sample */ - AUDIO_SAMPLE_FORMAT_U32P = 15, /**< unsigned 32 bit planar sample */ - /* 64 bits */ - AUDIO_SAMPLE_FORMAT_S64 = 16, /**< signed 64 bit sample */ - AUDIO_SAMPLE_FORMAT_S64P = 17, /**< signed 64 bit planar sample */ - AUDIO_SAMPLE_FORMAT_U64 = 18, /**< unsigned 64 bit sample */ - AUDIO_SAMPLE_FORMAT_U64P = 19, /**< unsigned 64 bit planar sample */ - /* float double */ - AUDIO_SAMPLE_FORMAT_F32 = 20, /**< float 32 bit sample */ - AUDIO_SAMPLE_FORMAT_F32P = 21, /**< float 32 bit planar sample */ - AUDIO_SAMPLE_FORMAT_F64 = 22, /**< double 64 bit sample */ - AUDIO_SAMPLE_FORMAT_F64P = 23, /**< double 64 bit planar sample */ -}; - -/** - * @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 = 1, /**< Two left channels */ - AUDIO_CHANNEL_BOTH_RIGHT = 2, /**< Two right channels */ - AUDIO_CHANNEL_EXCHANGE = 3, /**< 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 = 4, /**< Mix of streams of the left and right channels */ - AUDIO_CHANNEL_LEFT_MUTE = 5, /**< Left channel muted. The stream of the right channel is output. */ - AUDIO_CHANNEL_RIGHT_MUTE = 6, /**< Right channel muted. The stream of the left channel is output. */ - AUDIO_CHANNEL_BOTH_MUTE = 7, /**< Both left and right channels are muted */ -}; - -/** - * @brief Enumerates the execution types of the DrainBuffer function. - */ -enum AudioDrainNotifyType { - AUDIO_DRAIN_NORMAL_MODE = 0, /**< The DrainBuffer function returns after all data finishes playback. */ - AUDIO_DRAIN_EARLY_MODE = 1, /**< 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_COMPLETED = 0, /**< The non-block write is complete. */ - AUDIO_DRAIN_COMPLETED = 1, /**< The draining is complete. */ - AUDIO_FLUSH_COMPLETED = 2, /**< The flush is complete. */ - AUDIO_RENDER_FULL = 3, /**< The render buffer is full.*/ - AUDIO_ERROR_OCCUR = 4, /**< An error occurs.*/ -}; - -/** - * @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 AudioSessionType. - */ -enum AudioSessionType { - AUDIO_OUTPUT_STAGE_SESSION = 0, /**< Assigned output stage session */ - AUDIO_OUTPUT_MIX_SESSION = 1, /**< Assigned output mix session */ - AUDIO_ALLOCATE_SESSION = 2, /**< Assigned allocate session */ - AUDIO_INVALID_SESSION = 3, /**< Assigned invalid session */ -}; - -/** - * @brief Describes AudioDeviceType. - */ -enum AudioDeviceType { - AUDIO_LINEOUT = 1 << 0, /**< Assigned lineout device type */ - AUDIO_HEADPHONE = 1 << 1, /**< Assigned headphone device type */ - AUDIO_HEADSET = 1 << 2, /**< Assigned headset device type */ - AUDIO_USB_HEADSET = 1 << 3, /**< Assigned usb headset device type */ - AUDIO_USB_HEADPHONE = 1 << 4, /**< Assigned usb headphone device type */ - AUDIO_USBA_HEADSET = 1 << 5, /**< Assigned usba headset device type */ - AUDIO_USBA_HEADPHONE = 1 << 6, /**< Assigned usba headphone device type */ - AUDIO_PRIMARY_DEVICE = 1 << 7, /**< Assigned primary device type */ - AUDIO_USB_DEVICE = 1 << 8, /**< Assigned usb device type */ - AUDIO_A2DP_DEVICE = 1 << 9, /**< Assigned a2dp device type */ - AUDIO_HDMI_DEVICE = 1 << 10, /**< Assigned hdmi device type */ - AUDIO_ADAPTER_DEVICE = 1 << 11, /**< Assigned adapter device type */ - AUDIO_DEVICE_UNKNOWN, /**< Assigned unknown device type */ -}; - -/** - * @brief Describes AudioEventType. - */ -enum AudioEventType { - AUDIO_DEVICE_ADD = 1, /**< Assigned add device event type */ - AUDIO_DEVICE_REMOVE = 2, /**< Assigned remove device event type */ - AUDIO_LOAD_SUCCESS = 3, /**< Assigned load sucess event type */ - AUDIO_LOAD_FAILURE = 4, /**< Assigned load failure event type */ - AUDIO_UNLOAD = 5, /**< Assigned unload event type */ - AUDIO_SERVICE_VALID = 7, /**< Assigned valid service event type */ - AUDIO_SERVICE_INVALID = 8, /**< Assigned invalid service event type */ - AUDIO_CAPTURE_THRESHOLD = 9, /**< Assigned threshold capture event type */ - AUDIO_EVENT_UNKNOWN = 10, /**< Assigned unknown event type */ -}; - -/** - * @brief Enumerates the restricted key type of the parameters - */ -enum AudioExtParamKey { - AUDIO_EXT_PARAM_KEY_NONE = 0, /**< Distributed audio extra param key none */ - AUDIO_EXT_PARAM_KEY_VOLUME = 1, /**< Distributed audio extra param key volume event */ - AUDIO_EXT_PARAM_KEY_FOCUS = 2, /**< Distributed audio extra param key focus event */ - AUDIO_EXT_PARAM_KEY_BUTTON = 3, /**< Distributed audio extra param key media button event */ - AUDIO_EXT_PARAM_KEY_EFFECT = 4, /**< Distributed audio extra param key audio effect event */ - AUDIO_EXT_PARAM_KEY_STATUS = 5, /**< Distributed audio extra param key device status event */ - AUDIO_EXT_PARAM_KEY_USB_DEVICE = 101, /**< Check USB device type ARM or HIFI */ - AUDIO_EXT_PARAM_KEY_LOWPOWER = 1000, /**< Low power event type */ -}; - -/** - * @brief Describes status of audio deivce.@link enum AudioDeviceType - */ -struct AudioDeviceStatus { - unsigned int pnpStatus; /**< Audio pnp status */ -}; - -/** - * @brief Describes the audio scene. - */ -union SceneDesc { - unsigned int id; /**< Audio scene ID */ -}; - -/** - * @brief Defines the audio port. - */ -struct AudioPort { - enum AudioPortDirection dir; /**< Audio port type. For details, see {@link AudioPortDirection} */ - unsigned int portId; /**< Audio port ID */ - String 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 { - String adapterName; /**< Name of the audio adapter */ - struct AudioPort[] ports; /**< List of ports supported by an audio adapter */ -}; - -/** - * @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}. */ - String desc; /**< Audio device name */ -}; - -/** - * @brief Defines the audio scene descriptor. - */ -struct AudioSceneDescriptor { - union SceneDesc scene; /**< Describes the audio scene */ - struct AudioDeviceDescriptor desc; /**< Audio device descriptor */ -}; - -/** - * @brief Defines audio input type. - */ -enum AudioInputType { - AUDIO_INPUT_DEFAULT_TYPE = 0, /**< Assigned default input type */ - AUDIO_INPUT_MIC_TYPE = 1 << 0, /**< Assigned mic input type */ - AUDIO_INPUT_SPEECH_WAKEUP_TYPE = 1 << 1, /**< Assigned speech wakeup input type */ - AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, /**< Assigned voice communication input type */ - AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, /**< Assigned voice recognition input type */ -}; - -/** - * @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 */ - int sourceType; /**< Audio sourceType 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 Defines the sub-port capability. - */ -struct AudioSubPortCapability { - unsigned int portId; /**< Sub-port ID */ - String desc; /**< Sub-port name */ - enum AudioPortPassthroughMode mask; /**< Passthrough mode of data transmission. For details, - * see {@link AudioPortPassthroughMode}. - */ -}; - -/** - * @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 */ - struct AudioSubPortCapability[] subPorts; /**< List of supported sub-ports */ - enum AudioSampleFormat[] supportSampleFormats; /**< Supported audio sample formats. For details, - * see {@link AudioSampleFormat}. - */ -}; - -/** - * @brief Describes a mmap buffer. - */ -struct AudioMmapBufferDescriptor { - byte[] memoryAddress; /**< Pointer to the mmap buffer */ - FileDescriptor 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; /**< off set */ - String filePath; /**< file path */ -}; - -/** - * @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}. */ - String 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 AudioSessionExtInfo. - */ -struct AudioSessionExtInfo { - enum AudioSessionType sessionType; /**< Audio session type */ -}; - -/** - * @brief Describes AudioInfo. - */ -struct AudioInfo { - 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 ... */ - struct AudioInfo ext; /**< The ext object */ -}; - -/** - * @brief Describes AudioRoute. - */ -struct AudioRoute { - struct AudioRouteNode[] sources; /**< List of sources */ - struct AudioRouteNode[] sinks; /**< List of sinks */ -}; - -/** - * @brief Describes AudioEvent. - */ -struct AudioEvent { - unsigned int eventType; /**< @link enum AudioEventType */ - unsigned int deviceType; /**< @link enum AudioDeviceType */ -}; diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn b/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn deleted file mode 100644 index 05f1c7e2f3b5a8eaa00919fd932e900d43823213..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2022 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/hdf_core/adapter/uhdf2/hdi.gni") -hdi("daudio") { - module_name = "daudio" - sources = [ - "AudioTypes.idl", - "IAudioAdapter.idl", - "IAudioCallback.idl", - "IAudioCapture.idl", - "IAudioManager.idl", - "IAudioRender.idl", - ] - language = "cpp" - root = "ohos.hdi://foundation/distributedhardware/distributed_audio/hdf_interfaces/" - subsystem_name = "distributedhardware" - part_name = "drivers_interface_distributed_audio" -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl deleted file mode 100644 index 739a4fa32e269ef94d76efd73799ad1346ef26cb..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCapture; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioRender; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCallback; - -/** - * @brief Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks, - * and obtaining the port capability set. - * - * @see IAudioRender - * @see IAudioCapture - * @since 4.0 - * @version 1.0 - */ -interface IAudioAdapter { - InitAllPorts(); - CreateRender([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, - [out] IAudioRender render, [out] unsigned int renderId); - DestroyRender([in] unsigned int renderId); - CreateCapture([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, - [out] IAudioCapture capture, [out] unsigned int captureId); - DestroyCapture([in] unsigned int captureId); - GetPortCapability([in] struct AudioPort port, [out] struct AudioPortCapability capability); - SetPassthroughMode([in] struct AudioPort port, [in] enum AudioPortPassthroughMode mode); - GetPassthroughMode([in] struct AudioPort port, [out] enum AudioPortPassthroughMode mode); - GetDeviceStatus([out] struct AudioDeviceStatus status); - UpdateAudioRoute([in] struct AudioRoute route, [out] int routeHandle); - ReleaseAudioRoute([in] int routeHandle); - SetMicMute([in] boolean mute); - GetMicMute([out] boolean mute); - SetVoiceVolume([in] float volume); - SetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [in] String value); - GetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [out] String value); - RegExtraParamObserver([in] IAudioCallback audioCallback, [in] byte cookie); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl deleted file mode 100644 index 7e29d458d442e0d2204900cee956d573dc3a8b64..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022-2023 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 HdiAudio - * @{ - * - * @brief Provides unified APIs for audio services to access audio drivers. - * - * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to - * access different types of audio devices based on the audio IDs, thereby obtaining audio information, - * subscribing to or unsubscribing from audio data, enabling or disabling an audio, - * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. - * - * @version 1.0 - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.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([in] enum AudioCallbackType type, [out] byte reserved, [out] byte cookie); - ParamCallback([in] enum AudioExtParamKey key, [in] String condition, [in] String value, [out] byte reserved, [in] byte cookie); -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl deleted file mode 100644 index 51b6f0d30f36a72b5b39ae872c0c6b2a6200fd3b..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; - -/** - * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, - * scenes, and volume, and capturing audio frames. - * @since 4.0 - * @version 1.0 - */ -interface IAudioCapture { - CaptureFrame([out] byte[] frame, [out] unsigned long replyBytes); - GetCapturePosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); - SelectScene([in] struct AudioSceneDescriptor scene); - SetMute([in] boolean mute); - GetMute([out] boolean mute); - SetVolume([in] float volume); - GetVolume([out] float volume); - GetGainThreshold([out] float min, [out] float max); - GetGain([out] float gain); - SetGain([in] float gain); - GetFrameSize([out] unsigned long size); - GetFrameCount([out] unsigned long count); - SetSampleAttributes([in] struct AudioSampleAttributes attrs); - GetSampleAttributes([out] struct AudioSampleAttributes attrs); - GetCurrentChannelId([out] unsigned int channelId); - SetExtraParams([in] String keyValueList); - GetExtraParams([out] String keyValueList); - ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); - GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - AddAudioEffect([in] unsigned long effectid); - RemoveAudioEffect([in] unsigned long effectid); - GetFrameBufferSize([out] unsigned long bufferSize); - Start(); - Stop(); - Pause(); - Resume(); - Flush(); - TurnStandbyMode(); - AudioDevDump([in] int range, [in] int fd); - IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl deleted file mode 100644 index 16061bf17d0f103cd3d5f659b94ba166dc778f86..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioAdapter; - -/** - * @brief Manages audio adapters through a specific adapter driver program loaded based on the given audio - * adapter descriptor. - * - * @see IAudioAdapter - * @since 4.0 - * @version 1.0 - */ -interface IAudioManager { - GetAllAdapters([out] struct AudioAdapterDescriptor[] descs); - LoadAdapter([in] struct AudioAdapterDescriptor desc, [out] IAudioAdapter adapter); - UnloadAdapter([in] String adapterName); - ReleaseAudioManagerObject(); -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl deleted file mode 100644 index c4a898bf1314a4a5b3ac34fef7158e600e20f61c..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCallback; - -/** - * @brief Provides capabilities for audio rendering, including controlling the rendering, setting audio attributes, - * scenes, and volume, obtaining hardware latency, and rendering audio frames. - * - * @since 4.0 - * @version 1.0 - */ -interface IAudioRender { - GetLatency([out] unsigned int ms); - RenderFrame([in] byte[] frame, [out] unsigned long replyBytes); - GetRenderPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - SetRenderSpeed([in] float speed); - GetRenderSpeed([out] float speed); - SetChannelMode([in] enum AudioChannelMode mode); - GetChannelMode([out] enum AudioChannelMode mode); - RegCallback([in] IAudioCallback audioCallback, [in] byte cookie); - DrainBuffer([out] enum AudioDrainNotifyType type); - IsSupportsDrain([out] boolean support); - CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); - SelectScene([in] struct AudioSceneDescriptor scene); - SetMute([in] boolean mute); - GetMute([out] boolean mute); - SetVolume([in] float volume); - GetVolume([out] float volume); - GetGainThreshold([out] float min, [out] float max); - GetGain([out] float gain); - SetGain([in] float gain); - GetFrameSize([out] unsigned long size); - GetFrameCount([out] unsigned long count); - SetSampleAttributes([in] struct AudioSampleAttributes attrs); - GetSampleAttributes([out] struct AudioSampleAttributes attrs); - GetCurrentChannelId([out] unsigned int channelId); - SetExtraParams([in] String keyValueList); - GetExtraParams([out] String keyValueList); - ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); - GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - AddAudioEffect([in] unsigned long effectid); - RemoveAudioEffect([in] unsigned long effectid); - GetFrameBufferSize([out] unsigned long bufferSize); - Start(); - Stop(); - Pause(); - Resume(); - Flush(); - TurnStandbyMode(); - AudioDevDump([in] int range, [in] int fd); - IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn b/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn deleted file mode 100644 index 7c8160df54e5aa0139ef663746e39d69fa7d25e0..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2022 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/hdf_core/adapter/uhdf2/hdi.gni") -hdi("daudioext") { - module_name = "daudioext" - sources = [ - "IDAudioCallback.idl", - "IDAudioManager.idl", - "Types.idl", - ] - language = "cpp" - root = "ohos.hdi://foundation/distributedhardware/distributed_audio/hdf_interfaces/" - subsystem_name = "distributedhardware" - part_name = "drivers_interface_distributed_audio" -} diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl deleted file mode 100644 index b4f787c74dc56948a30b3986be291b3317fcfe76..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package ohos.hdi.distributed_audio.audioext.v1_0; - -import ohos.hdi.distributed_audio.audioext.v1_0.Types; - -[callback] interface IDAudioCallback { - OpenDevice([in] String adpName, [in] int devId); - CloseDevice([in] String adpName, [in] int devId); - SetParameters([in] String adpName, [in] int devId, [in] struct AudioParameter param); - NotifyEvent([in] String adpName, [in] int devId, [in] struct DAudioEvent event); - WriteStreamData([in] String adpName, [in] int devId, [in] struct AudioData data); - ReadStreamData([in] String adpName, [in] int devId, [out] struct AudioData data); - ReadMmapPosition([in] String adpName, [in] int devId, [out] unsigned long frames, [out] struct CurrentTime time); - RefreshAshmemInfo([in] String adpName, [in] int devId, [in] FileDescriptor fd, [in] int ashmemLength, [in] int lengthPerTrans); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl deleted file mode 100644 index 9ea0f8bacd6c1b37b7bb6c80eabcbf43eebfdd42..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package ohos.hdi.distributed_audio.audioext.v1_0; - -import ohos.hdi.distributed_audio.audioext.v1_0.IDAudioCallback; -import ohos.hdi.distributed_audio.audioext.v1_0.Types; - -interface IDAudioManager { - RegisterAudioDevice([in] String adpName, [in] int devId, [in] String capability, [in] IDAudioCallback callbackObj); - UnRegisterAudioDevice([in] String adpName, [in] int devId); - NotifyEvent([in] String adpName, [in] int devId, [in] struct DAudioEvent event); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl deleted file mode 100644 index 35b5c1fb6b8f382d42205c50922046c8b7f77681..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -package ohos.hdi.distributed_audio.audioext.v1_0; -enum PortOperationMode { - NORMAL_MODE = 0, - MMAP_MODE = 1, -}; -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; -}; -struct AudioData { - struct AudioParameter param; - byte[] data; -}; -struct DAudioEvent { - int type; - String content; -}; -struct CurrentTime { - long tvSec; - long tvNSec; -}; \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/bundle.json b/hdf_interfaces/distributed_audio/bundle.json deleted file mode 100644 index 524bddbe4174bfe3eb05157d8d754b0921f4968c..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/bundle.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@ohos/drivers_interface_distributed_audio", - "description": "distributed audio device driver interface", - "version": "4.0", - "license": "Apache License 2.0", - "segment": { - "destPath": "foundation/distributedhardware/distributed_audio/hdf_interfaces/" - }, - "component": { - "name": "drivers_interface_distributed_audio", - "subsystem": "distributedhardware", - "adapted_system_type": [ - "standard" - ], - "rom": "675KB", - "ram": "1024KB", - "deps": { - "components": [ - "ipc", - "hdf_core", - "hilog", - "c_utils" - ], - "third_party": [] - }, - "build": { - "sub_component": [ - "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:daudio_idl_target", - "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:daudioext_idl_target" - ], - "test": [ - - ], - "inner_kits": [{ - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:libdaudio_proxy_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio" - } - }, - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:libdaudio_stub_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio" - } - }, - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:libdaudioext_proxy_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext" - } - }, - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:libdaudioext_stub_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext" - } - } - ] - } - } -} \ No newline at end of file diff --git a/hdf_service/distributed_audio/BUILD.gn b/hdf_service/distributed_audio/BUILD.gn deleted file mode 100644 index 3e332e5e6576eec60d69ee50bc3d3a63192b624e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2022 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. - -if (defined(ohos_lite)) { - group("distributed_audio_entry") { - deps = [] - } -} else { - group("distributed_audio_entry") { - deps = [ - "./../../hdf_interfaces/distributed_audio/audio/v1_0:daudio_idl_target", - "./../../hdf_interfaces/distributed_audio/audioext/v1_0:daudioext_idl_target", - "./hdi_service/audio/v1_0:hdf_daudio_primary_service", - "./hdi_service/audio_ext/v1_0:hdf_daudio_ext_service", - ] - } -} diff --git a/hdf_service/distributed_audio/bundle.json b/hdf_service/distributed_audio/bundle.json deleted file mode 100644 index b6c6e78f85d88ac14708db84d063d61d990aef64..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/bundle.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@ohos/drivers_peripheral_distributed_audio", - "description": "distributed audo device driver", - "version": "4.0", - "license": "Apache License 2.0", - "segment": { - "destPath": "foundation/distributedhardware/distributed_audio/hdf_service/" - }, - "component": { - "name": "drivers_peripheral_distributed_audio", - "subsystem": "distributedhardware", - "adapted_system_type": [ - "standard" - ], - "rom": "1000KB", - "ram": "8000KB", - "deps": { - "components": [ - "c_utils", - "drivers_interface_distributed_audio", - "hdf_core", - "hilog", - "ipc" - ], - "third_party": [ - "cJSON" - ] - }, - "build": { - "sub_component": [ - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio:distributed_audio_entry", - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/common:libdaudio_hdf_utils" - ], - "test": [ - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest:hdi_service_audio_test", - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest:hdi_service_audio_ext_test" - ], - "inner_kits": [{ - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:libdaudio_proxy_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio" - } - }, - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:libdaudioext_proxy_1.0", - "header": { - "header_files": [], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext" - } - } - ] - } - } -} \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn deleted file mode 100644 index ec6968e92070820d91176a1aaedd334f02c6a3de..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright (c) 2023 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/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../distributedaudio.gni") - -ohos_shared_library("libaudio_manager_daudio_primary_service_1.0") { - include_dirs = [ - "//third_party/cJSON", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - if (distributed_audio_extension) { - include_dirs += - [ "${distributedaudio_ext_path}/hdf_service_extension/include/" ] - } - - sources = [ - "./src/audio_adapter_interface_impl.cpp", - "./src/audio_capture_interface_impl.cpp", - "./src/audio_manager_interface_impl.cpp", - "./src/audio_render_interface_impl.cpp", - ] - - if (distributed_audio_extension) { - sources += [ - "${distributedaudio_ext_path}/hdf_service_extension/src/audio_capture_ext_impl.cpp", - "${distributedaudio_ext_path}/hdf_service_extension/src/audio_render_ext_impl.cpp", - ] - } - - deps = [ "//third_party/cJSON:cjson" ] - public_deps = [ "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "ipc:ipc_single", - ] - - if (distributed_audio_extension) { - cflags = [ "-DDAUDIO_SUPPORT_EXTENSION" ] - } - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - if (build_variant == "root") { - defines += [ - "DUMP_CAPTURE_FILE", - "DUMP_RENDER_FILE", - ] - } - - install_images = [ chipset_base_dir ] - subsystem_name = "distributedhardware" - part_name = "drivers_peripheral_distributed_audio" -} - -ohos_shared_library("libdaudio_primary_driver") { - include_dirs = [ "${hdf_ser_aud_path}/include" ] - - sources = [ "./src/audio_driver.cpp" ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "hdf_core:libhdf_ipc_adapter", - "hdf_core:libhdf_utils", - "hdf_core:libhdi", - "hilog:libhilog", - "ipc:ipc_single", - ] - - shlib_type = "hdi" - install_images = [ chipset_base_dir ] - subsystem_name = "distributedhardware" - part_name = "drivers_peripheral_distributed_audio" -} - -group("hdf_daudio_primary_service") { - deps = [ - ":libaudio_manager_daudio_primary_service_1.0", - ":libdaudio_primary_driver", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h deleted file mode 100644 index 5509e44c4951b010b20e74421315e1197032205f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H -#define OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H - -#include -#include -#include - -#include -#include -#include - -#include "audio_capture_interface_impl.h" -#include "audio_capture_interface_impl_base.h" -#include "audio_render_interface_impl.h" -#include "audio_render_interface_impl_base.h" -#ifdef DAUDIO_SUPPORT_EXTENSION -#include "audio_capture_ext_impl.h" -#include "audio_render_ext_impl.h" -#endif - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::PortOperationMode; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -typedef enum { - STATUS_ONLINE = 0, - STATUS_OFFLINE, - STATUS_LOAD, - STATUS_UNLOAD, - STATUS_CREATE_RENDER, -} AudioAdapterStatus; - -typedef enum { - EVENT_DEV_CLOSED = 0, - EVENT_OPEN_SPK, - EVENT_CLOSE_SPK, - EVENT_OPEN_MIC, - EVENT_CLOSE_MIC, -} AudioDeviceEvent; - -typedef enum { - EVENT_GET_VOLUME = 1, - EVENT_GET_MIN_VOLUME = 2, - EVENT_GET_MAX_VOLUME = 3, - EVENT_IS_STREAM_MUTE = 4, -} VolumeEventType; - -class AudioAdapterInterfaceImpl : public IAudioAdapter { -public: - explicit AudioAdapterInterfaceImpl(const AudioAdapterDescriptor &desc); - ~AudioAdapterInterfaceImpl() override; - - int32_t InitAllPorts() override; - int32_t CreateRender(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - sptr &render, uint32_t &renderId) override; - int32_t DestroyRender(uint32_t renderId) override; - int32_t CreateCapture(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - sptr &capture, uint32_t &captureId) override; - int32_t DestroyCapture(uint32_t captureId) override; - int32_t GetPortCapability(const AudioPort &port, AudioPortCapability &capability) override; - int32_t SetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode mode) override; - int32_t GetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode &mode) override; - int32_t GetDeviceStatus(AudioDeviceStatus& status) override; - int32_t UpdateAudioRoute(const AudioRoute &route, int32_t &routeHandle) override; - int32_t ReleaseAudioRoute(int32_t routeHandle) override; - int32_t SetMicMute(bool mute) override; - int32_t GetMicMute(bool& mute) override; - int32_t SetVoiceVolume(float volume) override; - int32_t SetExtraParams(AudioExtParamKey key, const std::string &condition, const std::string &value) override; - int32_t GetExtraParams(AudioExtParamKey key, const std::string &condition, std::string &value) override; - int32_t RegExtraParamObserver(const sptr &audioCallback, int8_t cookie) override; - -public: - void SetSpeakerCallback(const int32_t dhId, const sptr &speakerCallback); - void SetMicCallback(const int32_t dhId, const sptr &micCallback); - AudioAdapterDescriptor GetAdapterDesc(); - std::string GetDeviceCapabilitys(const uint32_t devId); - int32_t AdapterLoad(); - int32_t AdapterUnload(); - int32_t Notify(const uint32_t devId, const DAudioEvent &event); - int32_t AddAudioDevice(const uint32_t devId, const std::string &caps); - int32_t RemoveAudioDevice(const uint32_t devId); - uint32_t GetVolumeGroup(const uint32_t devId); - uint32_t GetInterruptGroup(const uint32_t devId); - bool IsPortsNoReg(); - -private: - int32_t OpenRenderDevice(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - const sptr extSpkCallback, const int32_t dhId); - int32_t CloseRenderDevice(const AudioDeviceDescriptor &desc, const sptr extSpkCallback, - const int32_t dhId); - int32_t OpenCaptureDevice(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - const sptr extMicCallback, const int32_t dhId); - int32_t CloseCaptureDevice(const AudioDeviceDescriptor &desc, const sptr extMicCallback, - const int32_t dhId); - int32_t SetAudioVolume(const std::string& condition, const std::string ¶m); - int32_t GetAudioVolume(const std::string& condition, std::string ¶m); - int32_t HandleFocusChangeEvent(const DAudioEvent &event); - int32_t HandleRenderStateChangeEvent(const DAudioEvent &event); - int32_t HandleVolumeChangeEvent(const DAudioEvent &event); - int32_t HandleSANotifyEvent(const DAudioEvent &event); - int32_t WaitForSANotify(const AudioDeviceEvent &event); - int32_t HandleDeviceClosed(const DAudioEvent &event); - int32_t getEventTypeFromCondition(const std::string& condition); - int32_t InsertRenderImpl(const sptr &audioRender, const int32_t dhId, - uint32_t &renderId); - int32_t InsertCapImpl(const sptr &audioCapture, const int32_t dhId, - uint32_t &captureId); - inline bool IsIdValid(const uint32_t id); - bool CheckRendersValid(); - bool CheckCapsValid(); - bool CheckDevCapability(const AudioDeviceDescriptor &desc); - void SetDumpFlag(bool isRender); - sptr MatchStreamCallback(const AudioSampleAttributes &attrs, - const AudioDeviceDescriptor &desc, int32_t &dhId); - int32_t GetVolFromEvent(const std::string &content, const std::string &key, int32_t &vol); - int32_t ConvertMsg2Code(const std::string &msg); - -private: - static constexpr uint8_t WAIT_SECONDS = 20; - static constexpr int32_t TYPE_CONDITION = 11; - AudioAdapterDescriptor adpDescriptor_; - AudioAdapterStatus status_ = STATUS_OFFLINE; - - std::mutex extCallbackMtx_; - std::map> extCallbackMap_; - sptr paramCallback_ = nullptr; - std::mutex renderDevMtx_; - std::vector>> renderDevs_; - AudioParameter renderParam_; - std::mutex capDevMtx_; - std::vector>> captureDevs_; - AudioParameter captureParam_; - - std::mutex devMapMtx_; - std::mutex captureOptMtx_; - std::mutex renderOptMtx_; - std::map mapAudioDevice_; - std::mutex spkWaitMutex_; - std::condition_variable spkWaitCond_; - std::mutex micWaitMutex_; - std::condition_variable micWaitCond_; - - bool isSpkOpened_ = false; - int32_t errCode_ = -1; - bool isMicOpened_ = false; - bool spkNotifyFlag_ = false; - bool micNotifyFlag_ = false; - - uint32_t spkPinInUse_ = 0; - uint32_t micPinInUse_ = 0; - uint32_t streamMuteStatus_ = 0; - uint32_t timeInterval_ = 5; - - // mmap param - PortOperationMode renderFlags_ = Audioext::V1_0::NORMAL_MODE; - PortOperationMode capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - - const std::string NOT_MUTE_STATUS = "0"; - const std::string IS_MUTE_STATUS = "1"; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h deleted file mode 100644 index 64acc241cc5b1ff2043006f37a3d8127f508be1f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H - -#include -#include - -#include "audio_capture_interface_impl_base.h" - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioCaptureInterfaceImpl : public AudioCaptureInterfaceImplBase { -public: - AudioCaptureInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback); - ~AudioCaptureInterfaceImpl() override; - - int32_t CaptureFrame(std::vector &frame, uint64_t &replyBytes) override; - int32_t GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override; - int32_t SelectScene(const AudioSceneDescriptor &scene) override; - int32_t SetMute(bool mute) override; - int32_t GetMute(bool &mute) override; - int32_t SetVolume(float volume) override; - int32_t GetVolume(float &volume) override; - int32_t GetGainThreshold(float &min, float &max) override; - int32_t GetGain(float &gain) override; - int32_t SetGain(float gain) override; - int32_t GetFrameSize(uint64_t &size) override; - int32_t GetFrameCount(uint64_t &count) override; - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override; - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override; - int32_t GetCurrentChannelId(uint32_t &channelId) override; - int32_t SetExtraParams(const std::string &keyValueList) override; - int32_t GetExtraParams(std::string &keyValueList) override; - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override; - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t AddAudioEffect(uint64_t effectid) override; - int32_t RemoveAudioEffect(uint64_t effectid) override; - int32_t GetFrameBufferSize(uint64_t &bufferSize) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Pause() override; - int32_t Resume() override; - int32_t Flush() override; - int32_t TurnStandbyMode() override; - int32_t AudioDevDump(int32_t range, int32_t fd) override; - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override; - const AudioDeviceDescriptor &GetCaptureDesc() override; - void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) override; - void SetDumpFlagInner() override; - -private: - static constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; - const std::string HDF_CAPTURE_FILENAME = "/data/data/daudio/hdf_capture_from_sa.pcm"; - std::string adapterName_; - AudioDeviceDescriptor devDesc_; - AudioSampleAttributes devAttrs_; - bool dumpFlag_ = false; - uint32_t timeInterval_ = 5; - int64_t frameIndex_ = 0; - int64_t framePeriodNs_ = 0; - int64_t startTime_ = 0; - int64_t lastCaptureStartTime_ = 0; - std::atomic muteState_ = false; - - std::mutex captureMtx_; - AudioCaptureStatus captureStatus_ = CAPTURE_STATUS_CLOSE; - sptr audioExtCallback_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h deleted file mode 100644 index dbd4192712027ed0fe7884d771a7a5fbfb61a716..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H - -#include - -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -typedef enum { - CAPTURE_STATUS_OPEN = 0, - CAPTURE_STATUS_CLOSE, - CAPTURE_STATUS_START, - CAPTURE_STATUS_STOP, - CAPTURE_STATUS_PAUSE, -} AudioCaptureStatus; - -class AudioCaptureInterfaceImplBase : public IAudioCapture { -public: - AudioCaptureInterfaceImplBase() = default; - virtual ~AudioCaptureInterfaceImplBase() = default; - - virtual const AudioDeviceDescriptor &GetCaptureDesc() = 0; - virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) = 0; - virtual void SetDumpFlagInner() = 0; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h deleted file mode 100644 index ca3dfc669ba2db968021124ae94e3a8ab47b5f4f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H -#define OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H - -#include -#include -#include - -#include "hdf_device_desc.h" -#include "iremote_object.h" -#include -#include - -#include "audio_adapter_interface_impl.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -typedef struct { - std::string adapterName; - uint32_t dhId; - uint32_t eventType; - uint32_t deviceType; - uint32_t volGroupId; - uint32_t iptGroupId; -} DAudioDevEvent; - -class AudioManagerInterfaceImpl : public IAudioManager { -public: - static AudioManagerInterfaceImpl *GetAudioManager() - { - if (audioManager_ == nullptr) { - std::unique_lock mgr_mutex(audioManagerMtx_); - if (audioManager_ == nullptr) { - audioManager_ = new AudioManagerInterfaceImpl(); - } - } - return audioManager_; - } - - ~AudioManagerInterfaceImpl() override; - int32_t GetAllAdapters(std::vector &descs) override; - int32_t LoadAdapter(const AudioAdapterDescriptor &desc, sptr &adapter) override; - int32_t UnloadAdapter(const std::string &adapterName) override; - int32_t ReleaseAudioManagerObject() override; - - int32_t AddAudioDevice(const std::string &adpName, const uint32_t dhId, const std::string &caps, - const sptr &callback); - int32_t RemoveAudioDevice(const std::string &adpName, const uint32_t dhId); - int32_t Notify(const std::string &adpName, const uint32_t devId, const DAudioEvent &event); - void SetDeviceObject(struct HdfDeviceObject *deviceObject); - -private: - AudioManagerInterfaceImpl(); - int32_t NotifyFwk(const DAudioDevEvent &event); - int32_t CreateAdapter(const std::string &adpName, const uint32_t devId, const sptr &callback); - -private: - class Deletor { - public: - ~Deletor() - { - if (AudioManagerInterfaceImpl::audioManager_ != nullptr) { - delete AudioManagerInterfaceImpl::audioManager_; - } - }; - }; - - class AudioManagerRecipient : public IRemoteObject::DeathRecipient { - public: - void OnRemoteDied(const wptr &remote) override; - }; - static Deletor deletor; - sptr audioManagerRecipient_; - -private: - static AudioManagerInterfaceImpl *audioManager_; - static std::mutex audioManagerMtx_; - struct HdfDeviceObject *deviceObject_ = nullptr; - std::mutex adapterMapMtx_; - std::map> mapAudioAdapter_; - sptr remote_; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h deleted file mode 100644 index 1537f059efcbdd62c7caace41c360379f0f1869d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_AUDIO_RENDER_INTERFACE_IMPL_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_H - -#include -#include -#include - -#include "audio_render_interface_impl_base.h" - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -constexpr uint32_t DURATION_FRAMES = 100; -constexpr uint32_t CUR_FRAME_INIT_VALUE = 0; - -class AudioRenderInterfaceImpl : public AudioRenderInterfaceImplBase { -public: - AudioRenderInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback); - ~AudioRenderInterfaceImpl() override; - - int32_t GetLatency(uint32_t &ms) override; - int32_t RenderFrame(const std::vector &frame, uint64_t &replyBytes) override; - int32_t GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t SetRenderSpeed(float speed) override; - int32_t GetRenderSpeed(float &speed) override; - int32_t SetChannelMode(AudioChannelMode mode) override; - int32_t GetChannelMode(AudioChannelMode &mode) override; - int32_t RegCallback(const sptr &audioCallback, int8_t cookie) override; - int32_t DrainBuffer(AudioDrainNotifyType &type) override; - int32_t IsSupportsDrain(bool &support) override; - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override; - int32_t SelectScene(const AudioSceneDescriptor &scene) override; - int32_t SetMute(bool mute) override; - int32_t GetMute(bool &mute) override; - int32_t SetVolume(float volume) override; - int32_t GetVolume(float &volume) override; - int32_t GetGainThreshold(float &min, float &max) override; - int32_t SetGain(float gain) override; - int32_t GetGain(float &gain) override; - int32_t GetFrameSize(uint64_t &size) override; - int32_t GetFrameCount(uint64_t &count) override; - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override; - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override; - int32_t GetCurrentChannelId(uint32_t &channelId) override; - int32_t SetExtraParams(const std::string &keyValueList) override; - int32_t GetExtraParams(std::string &keyValueList) override; - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override; - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t AddAudioEffect(uint64_t effectid) override; - int32_t RemoveAudioEffect(uint64_t effectid) override; - int32_t GetFrameBufferSize(uint64_t &bufferSize) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Pause() override; - int32_t Resume() override; - int32_t Flush() override; - int32_t TurnStandbyMode() override; - int32_t AudioDevDump(int32_t range, int32_t fd) override; - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override; - - const AudioDeviceDescriptor &GetRenderDesc() override; - void SetVolumeInner(const uint32_t vol) override; - void SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) override; - uint32_t GetVolumeInner() override; - uint32_t GetMaxVolumeInner() override; - uint32_t GetMinVolumeInner() override; - void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) override; - void SetDumpFlagInner() override; - -private: - float GetFadeRate(uint32_t currentIndex, const uint32_t durationIndex); - int32_t FadeInProcess(const uint32_t durationFrame, int8_t* frameData, const size_t frameLength); - -private: - static constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; - const std::string HDF_RENDER_FILENAME = "/data/data/daudio/hdf_render_to_sa.pcm"; - - std::string adapterName_; - AudioDeviceDescriptor devDesc_; - AudioSampleAttributes devAttrs_; - - std::mutex renderMtx_; - std::mutex volMtx_; - bool firstOpenFlag_ = true; - bool dumpFlag_ = false; - uint32_t timeInterval_ = 5; - uint32_t currentFrame_ = 0; - uint32_t vol_ = 0; - uint32_t volMax_ = 0; - uint32_t volMin_ = 0; - int64_t frameIndex_ = 0; - float renderSpeed_ = 0; - int64_t lastRenderStartTime_ = 0; - AudioChannelMode channelMode_ = AUDIO_CHANNEL_NORMAL; - AudioRenderStatus renderStatus_ = RENDER_STATUS_CLOSE; - sptr audioExtCallback_ = nullptr; - sptr renderCallback_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h deleted file mode 100644 index 9915b950f508707afdf82f5c1a8e3449b714f4bb..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H - -#include -#include -#include - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -typedef enum { - RENDER_STATUS_OPEN = 0, - RENDER_STATUS_CLOSE, - RENDER_STATUS_START, - RENDER_STATUS_STOP, - RENDER_STATUS_PAUSE, -} AudioRenderStatus; - -class AudioRenderInterfaceImplBase : public IAudioRender { -public: - AudioRenderInterfaceImplBase() = default; - virtual ~AudioRenderInterfaceImplBase() = default; - - virtual const AudioDeviceDescriptor &GetRenderDesc() = 0; - virtual void SetVolumeInner(const uint32_t vol) = 0; - virtual void SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) = 0; - virtual uint32_t GetVolumeInner() = 0; - virtual uint32_t GetMaxVolumeInner() = 0; - virtual uint32_t GetMinVolumeInner() = 0; - virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) = 0; - virtual void SetDumpFlagInner() = 0; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp deleted file mode 100644 index 4e71c742b8cbaffb4ab23fbf776095fdbb7aa6a3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp +++ /dev/null @@ -1,1136 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "audio_adapter_interface_impl.h" - -#include -#include -#include - -#include "cJSON.h" - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioAdapterInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -static constexpr uint32_t MAX_AUDIO_STREAM_NUM = 10; - -AudioAdapterInterfaceImpl::AudioAdapterInterfaceImpl(const AudioAdapterDescriptor &desc) - : adpDescriptor_(desc) -{ - renderDevs_ = std::vector>>( - MAX_AUDIO_STREAM_NUM, std::make_pair(0, sptr(nullptr))); - captureDevs_ = std::vector>>( - MAX_AUDIO_STREAM_NUM, std::make_pair(0, sptr(nullptr))); - renderParam_ = { 0, 0, 0, 0, 0, 0 }; - captureParam_ = { 0, 0, 0, 0, 0, 0 }; - - DHLOGD("Distributed audio adapter constructed, name(%s).", GetAnonyString(desc.adapterName).c_str()); -} - -AudioAdapterInterfaceImpl::~AudioAdapterInterfaceImpl() -{ - DHLOGD("Distributed audio adapter destructed, name(%s).", GetAnonyString(adpDescriptor_.adapterName).c_str()); -} - -void AudioAdapterInterfaceImpl::SetSpeakerCallback(const int32_t dhId, const sptr &spkCallback) -{ - if (spkCallback == nullptr) { - DHLOGE("Callback is nullptr."); - return; - } - std::lock_guard callbackLck(extCallbackMtx_); - if (extCallbackMap_.find(dhId) != extCallbackMap_.end()) { - DHLOGI("The callback of daudio is already set."); - return; - } - extCallbackMap_[dhId] = spkCallback; -} - -void AudioAdapterInterfaceImpl::SetMicCallback(const int32_t dhId, const sptr &micCallback) -{ - if (micCallback == nullptr) { - DHLOGE("Callback is nullptr."); - return; - } - std::lock_guard callbackLck(extCallbackMtx_); - if (extCallbackMap_.find(dhId) != extCallbackMap_.end()) { - DHLOGI("The callback of daudio is already set."); - return; - } - extCallbackMap_[dhId] = micCallback; -} - -int32_t AudioAdapterInterfaceImpl::InitAllPorts() -{ - DHLOGI("Init (%zu) distributed audio ports.", mapAudioDevice_.size()); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CreateRender(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, sptr &render, uint32_t &renderId) -{ - DHLOGI("Create distributed audio render, {pin: %zu, sampleRate: %zu, channel: %zu, formats: %zu, type: %d}.", - desc.pins, attrs.sampleRate, attrs.channelCount, attrs.format, static_cast(attrs.type)); - render = nullptr; - sptr audioRender = nullptr; - if (!CheckDevCapability(desc)) { - DHLOGE("Can not find device, create render failed."); - return HDF_FAILURE; - } - int renderPinId = 0; - auto extSpkCallback = MatchStreamCallback(attrs, desc, renderPinId); - if (extSpkCallback == nullptr) { - DHLOGE("Matched callback is null."); - return HDF_FAILURE; - } -#ifdef DAUDIO_SUPPORT_EXTENSION - if (attrs.type == AUDIO_MMAP_NOIRQ) { - DHLOGI("Try to mmap mode."); - renderFlags_ = Audioext::V1_0::MMAP_MODE; - audioRender = new AudioRenderExtImpl(); - audioRender->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extSpkCallback, renderPinId); - } else { - DHLOGI("Try to normal mode."); - renderFlags_ = Audioext::V1_0::NORMAL_MODE; - audioRender = new AudioRenderInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extSpkCallback); - } -#else - renderFlags_ = Audioext::V1_0::NORMAL_MODE; - audioRender = new AudioRenderInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extSpkCallback); -#endif - int32_t ret = OpenRenderDevice(desc, attrs, extSpkCallback, renderPinId); - if (ret != DH_SUCCESS) { - DHLOGE("Open render device failed."); - audioRender = nullptr; - return ret == ERR_DH_AUDIO_HDF_WAIT_TIMEOUT ? HDF_ERR_TIMEOUT : HDF_FAILURE; - } - render = audioRender; - if (InsertRenderImpl(audioRender, renderPinId, renderId) != HDF_SUCCESS) { - DHLOGE("Generrate render ID and insert render failed."); - return HDF_FAILURE; - } - DHLOGI("Create render success, render ID is %u.", renderId); - return HDF_SUCCESS; -} - -sptr AudioAdapterInterfaceImpl::MatchStreamCallback(const AudioSampleAttributes &attrs, - const AudioDeviceDescriptor &desc, int32_t &dhId) -{ - dhId = static_cast(desc.pins); - if (desc.pins == DEFAULT_RENDER_ID && attrs.type == AUDIO_MMAP_NOIRQ) { - dhId = LOW_LATENCY_RENDER_ID; - } - - std::lock_guard callbackLck(extCallbackMtx_); - auto iter = extCallbackMap_.find(dhId); - if (iter == extCallbackMap_.end()) { - DHLOGE("Can't find matched callback"); - return nullptr; - } - return iter->second; -} - -int32_t AudioAdapterInterfaceImpl::InsertRenderImpl(const sptr &audioRender, - const int32_t dhId, uint32_t &renderId) -{ - std::lock_guard devLck(renderDevMtx_); - if (renderDevs_.size() != MAX_AUDIO_STREAM_NUM) { - DHLOGE("Render device contain check error."); - return HDF_FAILURE; - } - renderId = MAX_AUDIO_STREAM_NUM; - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (renderDevs_[i].second == nullptr) { - renderId = i; - renderDevs_[renderId] = std::make_pair(dhId, audioRender); - return HDF_SUCCESS; - } - } - DHLOGE("The device is busy, can't create render anymore."); - return HDF_FAILURE; -} - -int32_t AudioAdapterInterfaceImpl::DestroyRender(uint32_t renderId) -{ - DHLOGI("Destroy distributed audio render, ID: %u.", renderId); - if (!IsIdValid(renderId)) { - DHLOGE("The input render ID is invalid."); - return HDF_FAILURE; - } - sptr audioRender(nullptr); - int32_t dhId = 0; - { - std::lock_guard devLck(renderDevMtx_); - audioRender = renderDevs_[renderId].second; - dhId = renderDevs_[renderId].first; - } - std::lock_guard callbackLck(extCallbackMtx_); - sptr extSpkCallback(extCallbackMap_[dhId]); - if (audioRender == nullptr) { - DHLOGD("Render has not been created, do not need destroy."); - return HDF_SUCCESS; - } - - int32_t ret = CloseRenderDevice(audioRender->GetRenderDesc(), extSpkCallback, dhId); - if (ret != DH_SUCCESS) { - DHLOGE("Close render device failed."); - return HDF_FAILURE; - } - { - std::lock_guard devLck(renderDevMtx_); - renderDevs_[renderId] = std::make_pair(0, sptr(nullptr)); - } - return HDF_SUCCESS; -} - -bool AudioAdapterInterfaceImpl::CheckDevCapability(const AudioDeviceDescriptor &desc) -{ - std::lock_guard devLck(devMapMtx_); - if (mapAudioDevice_.find(desc.pins) == mapAudioDevice_.end()) { - DHLOGE("Can not find device, create render failed."); - return false; - } - return true; -} - -int32_t AudioAdapterInterfaceImpl::CreateCapture(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, sptr &capture, uint32_t &captureId) -{ - DHLOGI("Create distributed audio capture, {pin: %zu, sampleRate: %zu, channel: %zu, formats: %zu}.", - desc.pins, attrs.sampleRate, attrs.channelCount, attrs.format); - capture = nullptr; - sptr audioCapture(nullptr); - if (!CheckDevCapability(desc)) { - DHLOGE("Can not find device, create capture failed."); - return HDF_FAILURE; - } - int32_t capPinId = 0; - auto extMicCallback = MatchStreamCallback(attrs, desc, capPinId); - if (extMicCallback == nullptr) { - DHLOGE("Matched callback is null."); - return HDF_FAILURE; - } -#ifdef DAUDIO_SUPPORT_EXTENSION - if (attrs.type == AUDIO_MMAP_NOIRQ) { - DHLOGI("Try to mmap mode."); - capturerFlags_ = Audioext::V1_0::MMAP_MODE; - audioCapture = new AudioCaptureExtImpl(); - audioCapture->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extMicCallback, desc.pins); - } else { - DHLOGI("Try to normal mode."); - capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - audioCapture = new AudioCaptureInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extMicCallback); - } -#else - capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - audioCapture = new AudioCaptureInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extMicCallback); -#endif - int32_t ret = OpenCaptureDevice(desc, attrs, extMicCallback, capPinId); - if (ret != DH_SUCCESS) { - DHLOGE("Open capture device failed."); - audioCapture = nullptr; - return ret == ERR_DH_AUDIO_HDF_WAIT_TIMEOUT ? HDF_ERR_TIMEOUT : HDF_FAILURE; - } - capture = audioCapture; - if (InsertCapImpl(audioCapture, capPinId, captureId) != HDF_SUCCESS) { - DHLOGE("Generrate capture ID and insert capture failed."); - return HDF_FAILURE; - } - DHLOGI("Create capture success, capture ID is %u.", captureId); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::InsertCapImpl(const sptr &audioCapture, - const int32_t dhId, uint32_t &captureId) -{ - std::lock_guard devLck(capDevMtx_); - if (captureDevs_.size() != MAX_AUDIO_STREAM_NUM) { - DHLOGE("Capture device's size check error."); - return HDF_FAILURE; - } - captureId = MAX_AUDIO_STREAM_NUM; - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (captureDevs_[i].second == nullptr) { - captureId = i; - captureDevs_[captureId] = std::make_pair(dhId, audioCapture); - return HDF_SUCCESS; - } - } - DHLOGE("The device is busy, can't create capture anymore."); - return HDF_FAILURE; -} - -int32_t AudioAdapterInterfaceImpl::DestroyCapture(uint32_t captureId) -{ - DHLOGI("Destroy distributed audio capture, ID: %u.", captureId); - if (!IsIdValid(captureId)) { - DHLOGE("The input capture ID is invalid."); - return HDF_FAILURE; - } - sptr audioCapture(nullptr); - int32_t dhId = 0; - { - std::lock_guard devLck(capDevMtx_); - audioCapture = captureDevs_[captureId].second; - dhId = captureDevs_[captureId].first; - } - std::lock_guard callbackLck(extCallbackMtx_); - sptr extMicCallback(extCallbackMap_[dhId]); - if (audioCapture == nullptr) { - DHLOGD("Capture has not been created, do not need destroy."); - return HDF_SUCCESS; - } - - int32_t ret = CloseCaptureDevice(audioCapture->GetCaptureDesc(), extMicCallback, dhId); - if (ret != DH_SUCCESS) { - DHLOGE("Close capture device failed."); - return HDF_FAILURE; - } - { - std::lock_guard devLck(capDevMtx_); - captureDevs_[captureId].first = 0; - captureDevs_[captureId].second = nullptr; - } - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetPortCapability(const AudioPort &port, AudioPortCapability &capability) -{ - DHLOGD("Get audio port capability."); - (void)port; - capability.sampleRateMasks = AUDIO_SAMPLE_RATE_DEFAULT; - capability.channelCount = AUDIO_CHANNEL_COUNT_DEFAULT; - - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode mode) -{ - (void)port; - (void)mode; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode &mode) -{ - (void)port; - (void)mode; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetDeviceStatus(AudioDeviceStatus& status) -{ - (void) status; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::UpdateAudioRoute(const AudioRoute &route, int32_t &routeHandle) -{ - (void) route; - (void) routeHandle; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::ReleaseAudioRoute(int32_t routeHandle) -{ - (void) routeHandle; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetMicMute(bool mute) -{ - (void) mute; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetMicMute(bool& mute) -{ - (void) mute; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetVoiceVolume(float volume) -{ - (void) volume; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetExtraParams(AudioExtParamKey key, const std::string &condition, - const std::string &value) -{ - DHLOGD("Set audio parameters, key = %d, condition: %s value: %s.", key, condition.c_str(), value.c_str()); - int32_t ret = ERR_DH_AUDIO_HDF_FAIL; - switch (key) { - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME: - ret = SetAudioVolume(condition, value); - if (ret != DH_SUCCESS) { - DHLOGE("Set audio parameters failed."); - return HDF_FAILURE; - } - break; - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE: - DHLOGE("Parameter is unknown."); - break; - default: - DHLOGE("Parameter is invalid."); - return HDF_ERR_INVALID_PARAM; - } - DHLOGI("Set audio parameters success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetExtraParams(AudioExtParamKey key, const std::string &condition, - std::string &value) -{ - DHLOGD("Get audio parameters, key: %d, condition: %s.", key, condition.c_str()); - int32_t ret = ERR_DH_AUDIO_HDF_FAIL; - switch (key) { - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME: - ret = GetAudioVolume(condition, value); - if (ret != DH_SUCCESS) { - DHLOGE("Get audio parameters failed."); - return HDF_FAILURE; - } - break; - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE: - DHLOGE("Parameter is unknown."); - break; - default: - DHLOGE("Parameter is invalid."); - return HDF_ERR_INVALID_PARAM; - } - DHLOGI("Get audio parameters success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::RegExtraParamObserver(const sptr &audioCallback, int8_t cookie) -{ - DHLOGD("Register audio param observer."); - paramCallback_ = audioCallback; - (void) cookie; - return HDF_SUCCESS; -} - -AudioAdapterDescriptor AudioAdapterInterfaceImpl::GetAdapterDesc() -{ - adpDescriptor_.ports.clear(); - std::lock_guard devLck(devMapMtx_); - for (auto pin = mapAudioDevice_.begin(); pin != mapAudioDevice_.end(); pin++) { - AudioPort port = {PORT_OUT_IN, pin->first, ""}; - adpDescriptor_.ports.emplace_back(port); - } - return adpDescriptor_; -} - -std::string AudioAdapterInterfaceImpl::GetDeviceCapabilitys(const uint32_t devId) -{ - std::lock_guard devLck(devMapMtx_); - auto dev = mapAudioDevice_.find(devId); - if (dev == mapAudioDevice_.end()) { - DHLOGE("Device not found."); - return ""; - } - return dev->second; -} - -int32_t AudioAdapterInterfaceImpl::AdapterLoad() -{ - status_ = AudioAdapterStatus::STATUS_LOAD; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::AdapterUnload() -{ - if (CheckRendersValid() || CheckCapsValid()) { - DHLOGE("Adapter is busy, audio render or capture is not null."); - return HDF_ERR_DEVICE_BUSY; - } - status_ = AudioAdapterStatus::STATUS_UNLOAD; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::Notify(const uint32_t devId, const DAudioEvent &event) -{ - switch (static_cast(event.type)) { - case HDF_AUDIO_EVENT_VOLUME_CHANGE: - DHLOGI("Notify event: VOLUME_CHANGE, event content: %s.", event.content.c_str()); - return HandleVolumeChangeEvent(event); - case HDF_AUDIO_EVENT_FOCUS_CHANGE: - DHLOGI("Notify event: FOCUS_CHANGE, event content: %s.", event.content.c_str()); - return HandleFocusChangeEvent(event); - case HDF_AUDIO_EVENT_RENDER_STATE_CHANGE: - DHLOGI("Notify event: RENDER_STATE_CHANGE, event content: %s.", event.content.c_str()); - return HandleRenderStateChangeEvent(event); - case HDF_AUDIO_EVENT_OPEN_SPK_RESULT: - case HDF_AUDIO_EVENT_CLOSE_SPK_RESULT: - case HDF_AUDIO_EVENT_OPEN_MIC_RESULT: - case HDF_AUDIO_EVENT_CLOSE_MIC_RESULT: - case HDF_AUDIO_EVENT_SPK_DUMP: - case HDF_AUDIO_EVENT_MIC_DUMP: - return HandleSANotifyEvent(event); - case HDF_AUDIO_EVENT_SPK_CLOSED: - case HDF_AUDIO_EVENT_MIC_CLOSED: - return HandleDeviceClosed(event); - default: - DHLOGE("Audio event: %d is undefined.", event.type); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } -} - -int32_t AudioAdapterInterfaceImpl::AddAudioDevice(const uint32_t devId, const std::string &caps) -{ - DHLOGI("Add distributed audio device %d.", devId); - std::lock_guard devLck(devMapMtx_); - auto dev = mapAudioDevice_.find(devId); - if (dev != mapAudioDevice_.end()) { - DHLOGI("Device has been add, do not repeat add."); - return DH_SUCCESS; - } - mapAudioDevice_.insert(std::make_pair(devId, caps)); - - DHLOGI("Add audio device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::RemoveAudioDevice(const uint32_t devId) -{ - DHLOGI("Remove distributed audio device %d.", devId); - { - std::lock_guard devLck(devMapMtx_); - if (mapAudioDevice_.find(devId) == mapAudioDevice_.end()) { - DHLOGE("Device has not been add, remove device failed."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - mapAudioDevice_.erase(devId); - } - if (devId == spkPinInUse_) { - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - DestroyRender(i); - } - } - if (devId == micPinInUse_) { - for (uint32_t capId = 0; capId < MAX_AUDIO_STREAM_NUM; capId++) { - DestroyCapture(capId); - } - } - - DHLOGI("Remove audio device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::OpenRenderDevice(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr extSpkCallback, int32_t dhId) -{ - DHLOGI("Open render device, pin: %d.", dhId); - if (isSpkOpened_) { - DHLOGI("Render already opened."); - return DH_SUCCESS; - } - std::lock_guard devLck(renderOptMtx_); - spkPinInUse_ = static_cast(dhId); - renderParam_.format = attrs.format; - renderParam_.channelCount = attrs.channelCount; - renderParam_.sampleRate = attrs.sampleRate; - renderParam_.streamUsage = attrs.type; - renderParam_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, - timeInterval_, renderFlags_ == Audioext::V1_0::MMAP_MODE); - renderParam_.renderFlags = renderFlags_; - - int32_t ret = extSpkCallback->SetParameters(adpDescriptor_.adapterName, dhId, renderParam_); - if (ret != HDF_SUCCESS) { - DHLOGE("Set render parameters failed."); - return ERR_DH_AUDIO_HDF_SET_PARAM_FAIL; - } - ret = extSpkCallback->OpenDevice(adpDescriptor_.adapterName, dhId); - if (ret != HDF_SUCCESS) { - DHLOGE("Open render device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_OPEN_SPK); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed. ret: %d", ret); - return ret; - } - DHLOGI("Open render device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CloseRenderDevice(const AudioDeviceDescriptor &desc, - sptr extSpkCallback, const int32_t dhId) -{ - DHLOGI("Close render device, pin: %d.", dhId); - if (extSpkCallback == nullptr) { - DHLOGE("Callback is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - std::lock_guard devLck(renderOptMtx_); - if (spkPinInUse_ == 0) { - DHLOGI("No need close render device."); - return DH_SUCCESS; - } - renderParam_ = {}; - int32_t ret = extSpkCallback->CloseDevice(adpDescriptor_.adapterName, dhId); - if (ret != HDF_SUCCESS) { - DHLOGE("Close audio device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_CLOSE_SPK); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed. ret: %d.", ret); - return ret; - } - spkPinInUse_ = 0; - DHLOGI("Close render device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::OpenCaptureDevice(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr extMicCallback, const int32_t dhId) -{ - DHLOGI("Open capture device, pin: %d.", dhId); - if (isMicOpened_) { - DHLOGI("Capture already opened."); - return DH_SUCCESS; - } - std::lock_guard devLck(captureOptMtx_); - micPinInUse_ = dhId; - captureParam_.format = attrs.format; - captureParam_.channelCount = attrs.channelCount; - captureParam_.sampleRate = attrs.sampleRate; - captureParam_.streamUsage = attrs.type; - captureParam_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, - attrs.format, timeInterval_, capturerFlags_ == Audioext::V1_0::MMAP_MODE); - captureParam_.capturerFlags = capturerFlags_; - - int32_t ret = extMicCallback->SetParameters(adpDescriptor_.adapterName, dhId, captureParam_); - if (ret != HDF_SUCCESS) { - DHLOGE("Set audio parameters failed."); - return ERR_DH_AUDIO_HDF_SET_PARAM_FAIL; - } - ret = extMicCallback->OpenDevice(adpDescriptor_.adapterName, dhId); - if (ret != HDF_SUCCESS) { - DHLOGE("Open audio device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_OPEN_MIC); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed. ret: %d.", ret); - return ret; - } - DHLOGI("Open capture device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CloseCaptureDevice(const AudioDeviceDescriptor &desc, - const sptr extMicCallback, const int32_t dhId) -{ - DHLOGI("Close capture device, pin: %d.", dhId); - std::lock_guard devLck(captureOptMtx_); - if (micPinInUse_ == 0) { - DHLOGI("No need close capture device."); - return DH_SUCCESS; - } - captureParam_ = {}; - int32_t ret = extMicCallback->CloseDevice(adpDescriptor_.adapterName, dhId); - if (ret != HDF_SUCCESS) { - DHLOGE("Close audio device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_CLOSE_MIC); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed. ret:%d.", ret); - return ret; - } - micPinInUse_ = 0; - DHLOGI("Close capture device success."); - return DH_SUCCESS; -} - -uint32_t AudioAdapterInterfaceImpl::GetVolumeGroup(const uint32_t devId) -{ - uint32_t volGroup = VOLUME_GROUP_ID_DEFAULT; - std::lock_guard devLck(devMapMtx_); - auto caps = mapAudioDevice_.find(devId); - if (caps == mapAudioDevice_.end()) { - DHLOGE("Can not find caps of dev:%u.", devId); - return volGroup; - } - - int32_t ret = GetAudioParamUInt(caps->second, VOLUME_GROUP_ID, volGroup); - if (ret != DH_SUCCESS) { - DHLOGE("Get volume group param failed, use default value, ret = %d.", ret); - } - return volGroup; -} - -uint32_t AudioAdapterInterfaceImpl::GetInterruptGroup(const uint32_t devId) -{ - uint32_t iptGroup = INTERRUPT_GROUP_ID_DEFAULT; - std::lock_guard devLck(devMapMtx_); - auto caps = mapAudioDevice_.find(devId); - if (caps == mapAudioDevice_.end()) { - DHLOGE("Can not find caps of dev:%u.", devId); - return iptGroup; - } - - int32_t ret = GetAudioParamUInt(caps->second, INTERRUPT_GROUP_ID, iptGroup); - if (ret != DH_SUCCESS) { - DHLOGE("Get interrupt group param failed, use default value, ret = %d.", ret); - } - return iptGroup; -} - -int32_t AudioAdapterInterfaceImpl::SetAudioVolume(const std::string& condition, const std::string ¶m) -{ - std::string content = condition; - int32_t type = getEventTypeFromCondition(content); - EXT_PARAM_EVENT eventType; - - if (type == VolumeEventType::EVENT_IS_STREAM_MUTE) { - if (param == IS_MUTE_STATUS) { - streamMuteStatus_ = 1; - } else if (param == NOT_MUTE_STATUS) { - streamMuteStatus_ = 0; - } else { - DHLOGE("Mute param is error."); - return ERR_DH_AUDIO_HDF_FAIL; - } - eventType = HDF_AUDIO_EVNET_MUTE_SET; - SetAudioParamStr(content, STREAM_MUTE_STATUS, param); - } else { - eventType = HDF_AUDIO_EVENT_VOLUME_SET; - streamMuteStatus_ = 0; - SetAudioParamStr(content, VOLUME_LEVEL, param); - } - DAudioEvent event = { eventType, content }; - - { - std::lock_guard devLck(renderDevMtx_); - for (const auto &item : renderDevs_) { - std::lock_guard callbackLck(extCallbackMtx_); - sptr extSpkCallback(extCallbackMap_[item.first]); - SetAudioParamStr(event.content, "dhId", std::to_string(item.first)); - auto render = item.second; - if (render == nullptr || extSpkCallback == nullptr) { - continue; - } - if (extSpkCallback->NotifyEvent(adpDescriptor_.adapterName, - item.first, event) != HDF_SUCCESS) { - DHLOGE("NotifyEvent failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - } - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetAudioVolume(const std::string& condition, std::string ¶m) -{ - int renderId = 0; // fromaudio framwork - sptr audioRender(nullptr); - { - std::lock_guard devLck(renderDevMtx_); - audioRender = renderDevs_[renderId].second; - } - if (audioRender == nullptr) { - DHLOGE("Render has not been created."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int32_t type = getEventTypeFromCondition(condition); - uint32_t vol; - switch (type) { - case VolumeEventType::EVENT_GET_VOLUME: - vol = audioRender->GetVolumeInner(); - break; - case VolumeEventType::EVENT_GET_MAX_VOLUME: - vol = audioRender->GetMaxVolumeInner(); - break; - case VolumeEventType::EVENT_GET_MIN_VOLUME: - vol = audioRender->GetMinVolumeInner(); - break; - case VolumeEventType::EVENT_IS_STREAM_MUTE: - vol = streamMuteStatus_; - break; - default: - vol = 0; - DHLOGE("Get volume failed."); - } - param = std::to_string(vol); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::getEventTypeFromCondition(const std::string &condition) -{ - std::string::size_type position = condition.find_first_of(";"); - if (position < TYPE_CONDITION || position == std::string::npos) { - DHLOGE("Position is illegal or not find split word"); - return ERR_DH_AUDIO_HDF_FAIL; - } - std::string val = condition.substr(TYPE_CONDITION, position - TYPE_CONDITION); - if (!CheckIsNum(val)) { - DHLOGE("String is not number. str:%s.", val.c_str()); - return ERR_DH_AUDIO_HDF_FAIL; - } - int32_t type = std::stoi(val); - return static_cast(type); -} - -int32_t AudioAdapterInterfaceImpl::HandleVolumeChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Vol change (%s).", event.content.c_str()); - int renderId = 0; // daudio SA - sptr audioRender(nullptr); - { - std::lock_guard devLck(renderDevMtx_); - audioRender = renderDevs_[renderId].second; - } - if (audioRender == nullptr) { - DHLOGE("Render has not been created."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int32_t vol = AUDIO_DEFAULT_MIN_VOLUME_LEVEL; - int32_t ret = GetVolFromEvent(event.content, VOLUME_LEVEL, vol); - if (ret != DH_SUCCESS) { - DHLOGE("Get volume value failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - - if (event.content.rfind("FIRST_VOLUME_CHANAGE", 0) == 0) { - int32_t maxVol = AUDIO_DEFAULT_MAX_VOLUME_LEVEL; - ret = GetVolFromEvent(event.content, MAX_VOLUME_LEVEL, maxVol); - if (ret != DH_SUCCESS) { - DHLOGE("Get max volume value failed, use defult max volume."); - } - int32_t minVol = AUDIO_DEFAULT_MIN_VOLUME_LEVEL; - ret = GetVolFromEvent(event.content, MIN_VOLUME_LEVEL, minVol); - if (ret != DH_SUCCESS) { - DHLOGE("Get min volume value failed, use defult min volume."); - } - audioRender->SetVolumeInner(vol); - audioRender->SetVolumeRangeInner(maxVol, minVol); - return DH_SUCCESS; - } - - audioRender->SetVolumeInner(vol); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved = 0; - int8_t cookie = 0; - ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_VOLUME, event.content, std::to_string(vol), - reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify vol failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetVolFromEvent(const std::string &content, const std::string &key, int32_t &vol) -{ - cJSON *jParam = cJSON_Parse(content.c_str()); - if (jParam == nullptr) { - DHLOGE("Failed to parse JSON: %s", cJSON_GetErrorPtr()); - cJSON_Delete(jParam); - return ERR_DH_AUDIO_HDF_FAIL; - } - cJSON *dhIdItem = cJSON_GetObjectItem(jParam, key.c_str()); - if (dhIdItem == NULL || !cJSON_IsString(dhIdItem)) { - DHLOGE("Not found the keys of dhId."); - cJSON_Delete(jParam); - return ERR_DH_AUDIO_HDF_FAIL; - } - std::string val(dhIdItem->valuestring); - if (!CheckIsNum(val)) { - DHLOGE("String is not number. str:%s.", val.c_str()); - return ERR_DH_AUDIO_HDF_FAIL; - } - vol = std::stoi(val); - cJSON_Delete(jParam); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleFocusChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Focus change (%s).", event.content.c_str()); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved = 0; - int8_t cookie = 0; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_FOCUS, event.content, "", reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify Focus failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleRenderStateChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Render state change (%s).", event.content.c_str()); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved = 0; - int8_t cookie = 0; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_STATUS, event.content, "", reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify render state failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::ConvertMsg2Code(const std::string &msg) -{ - if (msg == HDF_EVENT_RESULT_SUCCESS) { - return DH_SUCCESS; - } else if (msg == HDF_EVENT_INIT_ENGINE_FAILED) { - return ERR_DH_AUDIO_HDF_INIT_ENGINE_FAILED; - } else if (msg == HDF_EVENT_NOTIFY_SINK_FAILED) { - return ERR_DH_AUDIO_HDF_NOTIFY_SINK_FAILED; - } else if (msg == HDF_EVENT_TRANS_SETUP_FAILED) { - return ERR_DH_AUDIO_HDF_TRANS_SETUP_FAILED; - } else if (msg == HDF_EVENT_TRANS_START_FAILED) { - return ERR_DH_AUDIO_HDF_TRANS_START_FAILED; - } else { - return ERR_DH_AUDIO_HDF_FAIL; - } -} - -int32_t AudioAdapterInterfaceImpl::HandleSANotifyEvent(const DAudioEvent &event) -{ - DHLOGD("Notify event type %d, event content: %s.", event.type, event.content.c_str()); - switch (event.type) { - case HDF_AUDIO_EVENT_OPEN_SPK_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isSpkOpened_ = true; - } - errCode_ = ConvertMsg2Code(event.content); - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); - break; - case HDF_AUDIO_EVENT_CLOSE_SPK_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isSpkOpened_ = false; - } - errCode_ = ConvertMsg2Code(event.content); - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); - break; - case HDF_AUDIO_EVENT_OPEN_MIC_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = true; - } - errCode_ = ConvertMsg2Code(event.content); - micNotifyFlag_ = true; - micWaitCond_.notify_all(); - break; - case HDF_AUDIO_EVENT_CLOSE_MIC_RESULT: - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = false; - } - errCode_ = ConvertMsg2Code(event.content); - micNotifyFlag_ = true; - micWaitCond_.notify_all(); - break; - case HDF_AUDIO_EVENT_SPK_DUMP: - SetDumpFlag(true); - break; - case HDF_AUDIO_EVENT_MIC_DUMP: - SetDumpFlag(false); - break; - default: - DHLOGE("Notify not support event type %d, event content: %s.", event.type, event.content.c_str()); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::WaitForSANotify(const AudioDeviceEvent &event) -{ - if (event == EVENT_OPEN_SPK || event == EVENT_CLOSE_SPK) { - spkNotifyFlag_ = false; - std::unique_lock lck(spkWaitMutex_); - auto status = spkWaitCond_.wait_for(lck, std::chrono::seconds(WAIT_SECONDS), [this, event]() { - return spkNotifyFlag_ || - (event == EVENT_OPEN_SPK && isSpkOpened_) || (event == EVENT_CLOSE_SPK && !isSpkOpened_); - }); - if (!status) { - DHLOGE("Wait spk event: %d timeout(%d)s.", event, WAIT_SECONDS); - return ERR_DH_AUDIO_HDF_WAIT_TIMEOUT; - } - if (event == EVENT_OPEN_SPK && !isSpkOpened_) { - DHLOGE("Wait open render device failed."); - return errCode_; - } else if (event == EVENT_CLOSE_SPK && isSpkOpened_) { - DHLOGE("Wait close render device failed."); - return errCode_; - } - return DH_SUCCESS; - } - - if (event == EVENT_OPEN_MIC || event == EVENT_CLOSE_MIC) { - micNotifyFlag_ = false; - std::unique_lock lck(micWaitMutex_); - auto status = micWaitCond_.wait_for(lck, std::chrono::seconds(WAIT_SECONDS), [this, event]() { - return micNotifyFlag_ || - (event == EVENT_OPEN_MIC && isMicOpened_) || (event == EVENT_CLOSE_MIC && !isMicOpened_); - }); - if (!status) { - DHLOGE("Wait mic event: %d timeout(%d)s.", event, WAIT_SECONDS); - return ERR_DH_AUDIO_HDF_WAIT_TIMEOUT; - } - if (event == EVENT_OPEN_MIC && !isMicOpened_) { - DHLOGE("Wait open capture device failed."); - return errCode_; - } else if (event == EVENT_CLOSE_MIC && isMicOpened_) { - DHLOGE("Wait close capture device failed."); - return errCode_; - } - return DH_SUCCESS; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleDeviceClosed(const DAudioEvent &event) -{ - DHLOGI("Handle device closed, event type: %d.", event.type); - if (paramCallback_ != nullptr) { - std::stringstream ss; - ss << "ERR_EVENT;DEVICE_TYPE=" << - (event.type == HDF_AUDIO_EVENT_SPK_CLOSED ? AUDIO_DEVICE_TYPE_SPEAKER : AUDIO_DEVICE_TYPE_MIC) << ";"; - int8_t reserved = 0; - int8_t cookie = 0; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_STATUS, ss.str(), - std::to_string(EVENT_DEV_CLOSED), reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify fwk failed."); - } - } - - if (isSpkOpened_ && event.type == HDF_AUDIO_EVENT_SPK_CLOSED) { - DHLOGE("Render device status error, close render."); - bool destroyStatus = true; - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (DestroyRender(i) != DH_SUCCESS) { - destroyStatus = false; - } - } - return destroyStatus ? DH_SUCCESS : ERR_DH_AUDIO_HDF_FAIL; - } else if (isMicOpened_ && event.type == HDF_AUDIO_EVENT_MIC_CLOSED) { - DHLOGE("Capture device status error, close capture."); - bool capCloseStatus = true; - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (DestroyCapture(i) != DH_SUCCESS) { - capCloseStatus = false; - } - } - return capCloseStatus ? DH_SUCCESS : ERR_DH_AUDIO_HDF_FAIL; - } - DHLOGI("Handle device closed success."); - return DH_SUCCESS; -} - -bool AudioAdapterInterfaceImpl::IsPortsNoReg() -{ - std::lock_guard devLck(devMapMtx_); - return mapAudioDevice_.empty(); -} - -inline bool AudioAdapterInterfaceImpl::IsIdValid(const uint32_t id) -{ - if (id >= MAX_AUDIO_STREAM_NUM) { - DHLOGE("Current id:%u is not supported.", id); - return false; - } - return true; -} - -bool AudioAdapterInterfaceImpl::CheckRendersValid() -{ - { - std::lock_guard devLck(renderDevMtx_); - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (renderDevs_[i].second != nullptr) { - DHLOGI("Containing active render."); - return true; - } - } - } - return false; -} - -bool AudioAdapterInterfaceImpl::CheckCapsValid() -{ - { - std::lock_guard devLck(capDevMtx_); - for (uint32_t i = 0; i < MAX_AUDIO_STREAM_NUM; i++) { - if (captureDevs_[i].second != nullptr) { - DHLOGI("Containing active capture."); - return true; - } - } - } - return false; -} - -void AudioAdapterInterfaceImpl::SetDumpFlag(bool isRender) -{ - if (isRender) { - std::lock_guard renderLck(renderDevMtx_); - for (auto item : renderDevs_) { - auto render = item.second; - if (render == nullptr) { - continue; - } - render->SetDumpFlagInner(); - } - } else { - std::lock_guard capLck(capDevMtx_); - for (auto item : captureDevs_) { - auto capture = item.second; - if (capture == nullptr) { - continue; - } - capture->SetDumpFlagInner(); - } - } -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp deleted file mode 100644 index 56070cc53dc47d3aff281de87f97540f05bfd8a6..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "audio_capture_interface_impl.h" - -#include -#include -#include "sys/time.h" -#include - -#include "cJSON.h" - -#include "daudio_constants.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioCaptureInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioCaptureInterfaceImpl::AudioCaptureInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) - : adapterName_(adpName), devDesc_(desc), devAttrs_(attrs), audioExtCallback_(callback) -{ - devAttrs_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, timeInterval_, false); - const int32_t sizePerSec = static_cast(attrs.sampleRate * attrs.channelCount) *attrs.format; - framePeriodNs_ = (static_cast(devAttrs_.frameSize) * AUDIO_NS_PER_SECOND) / sizePerSec; - DHLOGD("Distributed audio capture constructed, period(%d),frameSize(%d), framePeriodNs_(%d).", - attrs.period, devAttrs_.frameSize, framePeriodNs_); - DHLOGD("Distributed audio capture constructed, id(%d).", desc.pins); -} - -AudioCaptureInterfaceImpl::~AudioCaptureInterfaceImpl() -{ - DHLOGD("Distributed audio capture destructed, id(%d).", devDesc_.pins); -} - -int32_t AudioCaptureInterfaceImpl::GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get capture position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::CaptureFrame(std::vector &frame, uint64_t &replyBytes) -{ - DHLOGD("Capture frame[sampleRate: %d, channelCount: %d, format: %d, frameSize: %d].", devAttrs_.sampleRate, - devAttrs_.channelCount, devAttrs_.format, devAttrs_.frameSize); - int64_t timeOffset = UpdateTimeOffset(frameIndex_, framePeriodNs_, startTime_); - DHLOGD("Capture framIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); - - int64_t startTime = GetNowTimeUs(); - std::lock_guard captureLck(captureMtx_); - if (captureStatus_ != CAPTURE_STATUS_START) { - DHLOGE("Capture status wrong, return false."); - return HDF_FAILURE; - } - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - - AudioData audioData; - int32_t ret = audioExtCallback_->ReadStreamData(adapterName_, devDesc_.pins, audioData); - if (ret != HDF_SUCCESS) { - DHLOGE("Read stream data failed."); - return HDF_FAILURE; - } -#ifdef DUMP_CAPTURE_FILE - if (dumpFlag_) { - SaveFile(HDF_CAPTURE_FILENAME, reinterpret_cast(audioData.data.data()), audioData.data.size()); - } -#endif - frame.clear(); - frame.resize(devAttrs_.frameSize, 0); - if (!muteState_.load() && memcpy_s(frame.data(), frame.size(), audioData.data.data(), audioData.data.size()) != - EOK) { - DHLOGE("Copy capture frame failed"); - return HDF_FAILURE; - } - ++frameIndex_; - AbsoluteSleep(startTime_ + frameIndex_ * framePeriodNs_ - timeOffset); - DHLOGD("Capture audio frame success."); - int64_t endTime = GetNowTimeUs(); - if (IsOutDurationRange(startTime, endTime, lastCaptureStartTime_)) { - DHLOGD("This time capture frame spend: %lld, The interval of this capture frame time and the last time: %lld", - endTime - startTime, startTime - lastCaptureStartTime_); - } - lastCaptureStartTime_ = startTime; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Start() -{ - DHLOGI("Start capture."); - cJSON *jParam = cJSON_CreateObject(); - if (jParam == nullptr) { - DHLOGE("Failed to create cJSON object."); - return HDF_FAILURE; - } - cJSON_AddStringToObject(jParam, KEY_DH_ID, std::to_string(devDesc_.pins).c_str()); - char *jsonData = cJSON_PrintUnformatted(jParam); - if (jsonData == nullptr) { - DHLOGE("Failed to create JSON data."); - cJSON_Delete(jParam); - return HDF_FAILURE; - } - std::string content(jsonData); - cJSON_Delete(jParam); - cJSON_free(jsonData); - DAudioEvent event = { HDF_AUDIO_EVENT_START, content }; - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - if (audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event) != HDF_SUCCESS) { - DHLOGE("Notify start event failed."); - return HDF_FAILURE; - } - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_START; - frameIndex_ = 0; - startTime_ = 0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Stop() -{ - DHLOGI("Stop capture."); - cJSON *jParam = cJSON_CreateObject(); - if (jParam == nullptr) { - DHLOGE("Failed to create cJSON object."); - return HDF_FAILURE; - } - cJSON_AddStringToObject(jParam, KEY_DH_ID, std::to_string(devDesc_.pins).c_str()); - char *jsonData = cJSON_PrintUnformatted(jParam); - if (jsonData == nullptr) { - DHLOGE("Failed to create JSON data."); - cJSON_Delete(jParam); - return HDF_FAILURE; - } - cJSON_Delete(jParam); - cJSON_free(jsonData); - std::string content(jsonData); - DAudioEvent event = { HDF_AUDIO_EVENT_STOP, content }; - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - if (audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event) != HDF_SUCCESS) { - DHLOGE("Notify stop event failed."); - return HDF_FAILURE; - } - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_STOP; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Pause() -{ - DHLOGI("Pause capture."); - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_PAUSE; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Resume() -{ - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Flush() -{ - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::TurnStandbyMode() -{ - DHLOGI("Turn stand by mode, not support yet."); - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::AudioDevDump(int32_t range, int32_t fd) -{ - DHLOGI("Dump audio info, not support yet."); - (void)range; - (void)fd; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) -{ - DHLOGI("Check whether pause and resume is supported, not support yet."); - (void)supportPause; - (void)supportResume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) -{ - DHLOGI("Check scene capability."); - (void)scene; - supported = false; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SelectScene(const AudioSceneDescriptor &scene) -{ - DHLOGI("Select audio scene, not support yet."); - (void)scene; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetMute(bool mute) -{ - DHLOGI("Set audio mute state."); - muteState_.store(mute); - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetMute(bool &mute) -{ - DHLOGI("Get audio mute state."); - mute = muteState_.load(); - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetVolume(float volume) -{ - DHLOGI("Can not set vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetVolume(float &volume) -{ - DHLOGI("Can not get vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetGainThreshold(float &min, float &max) -{ - DHLOGI("Get gain threshold, not support yet."); - min = 0; - max = 0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetGain(float gain) -{ - DHLOGI("Set gain, not support yet."); - (void)gain; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetGain(float &gain) -{ - DHLOGI("Get gain, not support yet."); - gain = 1.0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameSize(uint64_t &size) -{ - (void)size; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameCount(uint64_t &count) -{ - (void)count; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetSampleAttributes(const AudioSampleAttributes &attrs) -{ - DHLOGI("Set sample attributes."); - devAttrs_ = attrs; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetSampleAttributes(AudioSampleAttributes &attrs) -{ - DHLOGI("Get sample attributes."); - attrs = devAttrs_; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetCurrentChannelId(uint32_t &channelId) -{ - DHLOGI("Get current channel id, not support yet."); - (void)channelId; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetExtraParams(const std::string &keyValueList) -{ - DHLOGI("Set extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetExtraParams(std::string &keyValueList) -{ - DHLOGI("Get extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) -{ - DHLOGI("Request mmap buffer, not support yet."); - (void)reqSize; - (void)desc; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get mmap position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::AddAudioEffect(uint64_t effectid) -{ - DHLOGI("Add audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::RemoveAudioEffect(uint64_t effectid) -{ - DHLOGI("Remove audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) -{ - DHLOGI("Get frame buffer size, not support yet."); - (void)bufferSize; - return HDF_SUCCESS; -} - -void AudioCaptureInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) -{ - DHLOGI("Set attrs, not support yet."); -} - -void AudioCaptureInterfaceImpl::SetDumpFlagInner() -{ - dumpFlag_ = true; -} - -const AudioDeviceDescriptor &AudioCaptureInterfaceImpl::GetCaptureDesc() -{ - return devDesc_; -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp deleted file mode 100644 index 5aed2588b59b88ff7d82ed4c52ed31c1b56f462e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include -#include -#include -#include -#include - -#include "audio_manager_interface_impl.h" - -using namespace OHOS::HDI::DistributedAudio::Audio::V1_0; - -struct HdfAudioManagerHost { - struct IDeviceIoService ioService; - OHOS::sptr stub; -}; - -static int32_t AudioManagerDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, - struct HdfSBuf *reply) -{ - auto *hdfAudioManagerHost = CONTAINER_OF(client->device->service, struct HdfAudioManagerHost, ioService); - - OHOS::MessageParcel *dataParcel = nullptr; - OHOS::MessageParcel *replyParcel = nullptr; - OHOS::MessageOption option; - - if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - return hdfAudioManagerHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); -} - -int HdfAudioManagerDriverInit(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver init."); - AudioManagerInterfaceImpl::GetAudioManager()->SetDeviceObject(deviceObject); - HdfDeviceSetClass(deviceObject, DEVICE_CLASS_AUDIO); - return HDF_SUCCESS; -} - -int HdfAudioManagerDriverBind(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver bind."); - - auto *hdfAudioManagerHost = new (std::nothrow) HdfAudioManagerHost; - if (hdfAudioManagerHost == nullptr) { - HDF_LOGE("%{public}s: failed to create create HdfAudioManagerHost object", __func__); - return HDF_FAILURE; - } - - hdfAudioManagerHost->ioService.Dispatch = AudioManagerDriverDispatch; - hdfAudioManagerHost->ioService.Open = NULL; - hdfAudioManagerHost->ioService.Release = NULL; - - auto serviceImpl = IAudioManager::Get("daudio_primary_service", true); - if (serviceImpl == nullptr) { - HDF_LOGE("%{public}s: failed to get of implement service", __func__); - delete hdfAudioManagerHost; - return HDF_FAILURE; - } - - hdfAudioManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, - IAudioManager::GetDescriptor()); - if (hdfAudioManagerHost->stub == nullptr) { - HDF_LOGE("%{public}s: failed to get stub object", __func__); - delete hdfAudioManagerHost; - return HDF_FAILURE; - } - - deviceObject->service = &hdfAudioManagerHost->ioService; - return HDF_SUCCESS; -} - -void HdfAudioManagerDriverRelease(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver release."); - auto *hdfAudioManagerHost = CONTAINER_OF(deviceObject->service, struct HdfAudioManagerHost, ioService); - delete hdfAudioManagerHost; -} - -struct HdfDriverEntry g_audiomanagerDriverEntry = { - .moduleVersion = 1, - .moduleName = "daudio", - .Bind = HdfAudioManagerDriverBind, - .Init = HdfAudioManagerDriverInit, - .Release = HdfAudioManagerDriverRelease, -}; - -#ifndef __cplusplus -extern "C" { -#endif -HDF_INIT(g_audiomanagerDriverEntry); -#ifndef __cplusplus -} -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp deleted file mode 100644 index bd160cfd13f777c90cf0c7197f5637cadc9580d8..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "audio_manager_interface_impl.h" - -#include -#include -#include "hdf_device_object.h" -#include "iservice_registry.h" -#include "iproxy_broker.h" -#include "iservmgr_hdi.h" -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioManagerInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioManagerInterfaceImpl *AudioManagerInterfaceImpl::audioManager_ = nullptr; -std::mutex AudioManagerInterfaceImpl::audioManagerMtx_; -extern "C" IAudioManager *AudioManagerImplGetInstance(void) -{ - return AudioManagerInterfaceImpl::GetAudioManager(); -} - -AudioManagerInterfaceImpl::AudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio manager constructed."); - audioManagerRecipient_ = new AudioManagerRecipient(); -} - -AudioManagerInterfaceImpl::~AudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio manager destructed."); -} - -int32_t AudioManagerInterfaceImpl::GetAllAdapters(std::vector &descs) -{ - DHLOGI("Get all distributed audio adapters."); - std::lock_guard adpLck(adapterMapMtx_); - - std::transform(mapAudioAdapter_.begin(), mapAudioAdapter_.end(), std::back_inserter(descs), - [](auto& adp) { return adp.second->GetAdapterDesc(); }); - - DHLOGI("Get adapters success, total is (%zu). ", mapAudioAdapter_.size()); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::LoadAdapter(const AudioAdapterDescriptor &desc, sptr &adapter) -{ - DHLOGI("Load distributed audio adapter: %s.", GetAnonyString(desc.adapterName).c_str()); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(desc.adapterName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Load audio adapter failed, can not find adapter."); - adapter = nullptr; - return HDF_FAILURE; - } - - int32_t ret = adp->second->AdapterLoad(); - if (ret != DH_SUCCESS) { - DHLOGE("Load audio adapter failed, adapter return: %d.", ret); - adapter = nullptr; - return HDF_FAILURE; - } - - adapter = adp->second; - DHLOGI("Load adapter success."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::UnloadAdapter(const std::string &adapterName) -{ - DHLOGI("Unload distributed audio adapter: %s.", GetAnonyString(adapterName).c_str()); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adapterName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Unload audio adapter failed, can not find adapter."); - return HDF_SUCCESS; - } - - int32_t ret = adp->second->AdapterUnload(); - if (ret != DH_SUCCESS) { - DHLOGE("Unload audio adapter failed, adapter return: %d.", ret); - return ret; - } - DHLOGI("Unload adapter success."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::ReleaseAudioManagerObject() -{ - DHLOGD("Release distributed audio manager object."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::AddAudioDevice(const std::string &adpName, const uint32_t dhId, - const std::string &caps, const sptr &callback) -{ - DHLOGI("Add audio device name: %s, device: %d.", GetAnonyString(adpName).c_str(), dhId); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end()) { - int32_t ret = CreateAdapter(adpName, dhId, callback); - if (ret != DH_SUCCESS) { - DHLOGE("Create audio adapter failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - } - remote_ = OHOS::HDI::hdi_objcast(callback); - if (remote_ == nullptr) { - DHLOGE("remote callback is nullptr."); - return ERR_DH_AUDIO_HDF_FAIL; - } - remote_->AddDeathRecipient(audioManagerRecipient_); - adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end() || adp->second == nullptr) { - DHLOGE("Audio device has not been created or is null ptr."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - switch (GetDevTypeByDHId(dhId)) { - case AUDIO_DEVICE_TYPE_SPEAKER: - adp->second->SetSpeakerCallback(dhId, callback); - break; - case AUDIO_DEVICE_TYPE_MIC: - adp->second->SetMicCallback(dhId, callback); - break; - default: - DHLOGE("DhId is illegal, devType is unknow."); - return ERR_DH_AUDIO_HDF_FAIL; - } - int32_t ret = adp->second->AddAudioDevice(dhId, caps); - if (ret != DH_SUCCESS) { - DHLOGE("Add audio device failed, adapter return: %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - - DAudioDevEvent event = { adpName, dhId, HDF_AUDIO_DEVICE_ADD, - 0, adp->second->GetVolumeGroup(dhId), - adp->second->GetInterruptGroup(dhId) }; - ret = NotifyFwk(event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio fwk failed, ret = %d.", ret); - return ret; - } - DHLOGI("Add audio device success."); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::RemoveAudioDevice(const std::string &adpName, const uint32_t dhId) -{ - DHLOGI("Remove audio device name: %s, device: %d.", GetAnonyString(adpName).c_str(), dhId); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end() || adp->second == nullptr) { - DHLOGE("Audio device has not been created or is null ptr."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - - int32_t ret = adp->second->RemoveAudioDevice(dhId); - if (ret != DH_SUCCESS) { - DHLOGE("Remove audio device failed, adapter return: %d.", ret); - return ret; - } - remote_->RemoveDeathRecipient(audioManagerRecipient_); - DAudioDevEvent event = { adpName, dhId, HDF_AUDIO_DEVICE_REMOVE, 0, 0, 0 }; - ret = NotifyFwk(event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio fwk failed, ret = %d.", ret); - } - if (adp->second->IsPortsNoReg()) { - mapAudioAdapter_.erase(adpName); - } - DHLOGI("Remove audio device success, mapAudioAdapter size() is : %d .", mapAudioAdapter_.size()); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::Notify(const std::string &adpName, const uint32_t devId, const DAudioEvent &event) -{ - DHLOGI("Notify event, adapter name: %s. event type: %d", GetAnonyString(adpName).c_str(), - event.type); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Notify failed, can not find adapter."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - - int32_t ret = adp->second->Notify(devId, event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify failed, adapter return: %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::NotifyFwk(const DAudioDevEvent &event) -{ - DHLOGD("Notify audio fwk event(type:%d, adapter:%s, pin:%d).", event.eventType, - GetAnonyString(event.adapterName).c_str(), event.dhId); - std::stringstream ss; - ss << "EVENT_TYPE=" << event.eventType << ";NID=" << event.adapterName << ";PIN=" << event.dhId << ";VID=" << - event.volGroupId << ";IID=" << event.iptGroupId; - std::string eventInfo = ss.str(); - int ret = HdfDeviceObjectSetServInfo(deviceObject_, eventInfo.c_str()); - if (ret != HDF_SUCCESS) { - DHLOGE("Set service info failed, ret = %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - ret = HdfDeviceObjectUpdate(deviceObject_); - if (ret != HDF_SUCCESS) { - DHLOGE("Update service info failed, ret = %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - - DHLOGI("Notify audio fwk success."); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::CreateAdapter(const std::string &adpName, const uint32_t devId, - const sptr &callback) -{ - DHLOGI("Create adapter, pin id: %d.", devId); - if (callback == nullptr) { - DHLOGE("Adapter callback is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - if (devId != DEFAULT_RENDER_ID && devId != DEFAULT_CAPTURE_ID && devId != LOW_LATENCY_RENDER_ID) { - DHLOGE("Pin is not default, can not create audio adapter."); - return ERR_DH_AUDIO_HDF_FAIL; - } - - AudioAdapterDescriptor desc = { adpName }; - sptr adapter(new AudioAdapterInterfaceImpl(desc)); - if (adapter == nullptr) { - DHLOGE("Create new audio adapter failed."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - mapAudioAdapter_.insert(std::make_pair(adpName, adapter)); - return DH_SUCCESS; -} - -void AudioManagerInterfaceImpl::SetDeviceObject(struct HdfDeviceObject *deviceObject) -{ - deviceObject_ = deviceObject; -} - -void AudioManagerInterfaceImpl::AudioManagerRecipient::OnRemoteDied(const wptr &remote) -{ - DHLOGE("Exit the current process."); - _Exit(0); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOSf diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp deleted file mode 100644 index 58404368b94f4a02af4431daaaf924845fa7022e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "audio_render_interface_impl.h" - -#include -#include -#include "sys/time.h" - -#include "cJSON.h" -#include "daudio_constants.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioRenderInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioRenderInterfaceImpl::AudioRenderInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) - : adapterName_(adpName), devDesc_(desc), - devAttrs_(attrs), audioExtCallback_(callback) -{ - devAttrs_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, timeInterval_, false); - DHLOGD("Distributed audio render constructed, period(%d), frameSize(%d).", - attrs.period, devAttrs_.frameSize); -} - -AudioRenderInterfaceImpl::~AudioRenderInterfaceImpl() -{ - DHLOGD("Distributed audio render destructed, id(%d).", devDesc_.pins); -} - -int32_t AudioRenderInterfaceImpl::GetLatency(uint32_t &ms) -{ - DHLOGI("Get render device latency, not support yet."); - ms = 0; - return HDF_SUCCESS; -} - -float AudioRenderInterfaceImpl::GetFadeRate(uint32_t currentIndex, const uint32_t durationIndex) -{ - if (currentIndex > durationIndex) { - return 1.0f; - } - - float fadeRate = static_cast(currentIndex) / durationIndex * DAUDIO_FADE_NORMALIZATION_FACTOR; - if (fadeRate < 1) { - return pow(fadeRate, DAUDIO_FADE_POWER_NUM) / DAUDIO_FADE_NORMALIZATION_FACTOR; - } - return -pow(fadeRate - DAUDIO_FADE_MAXIMUM_VALUE, DAUDIO_FADE_POWER_NUM) / - DAUDIO_FADE_NORMALIZATION_FACTOR + 1; -} - -int32_t AudioRenderInterfaceImpl::FadeInProcess(const uint32_t durationFrame, - int8_t* frameData, const size_t frameLength) -{ - int16_t* frame = reinterpret_cast(frameData); - const size_t newFrameLength = frameLength / 2; - - for (size_t k = 0; k < newFrameLength; ++k) { - float rate = GetFadeRate(currentFrame_ * newFrameLength + k, durationFrame * newFrameLength); - frame[k] = currentFrame_ == durationFrame - 1 ? frame[k] : static_cast(rate * frame[k]); - } - DHLOGI("Fade-in frame[currentFrame: %d].", currentFrame_); - ++currentFrame_; - currentFrame_ = currentFrame_ >= durationFrame ? durationFrame - 1 : currentFrame_; - - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RenderFrame(const std::vector &frame, uint64_t &replyBytes) -{ - DHLOGD("Render frame[sampleRate: %u, channelCount: %u, format: %d, frameSize: %u].", devAttrs_.sampleRate, - devAttrs_.channelCount, devAttrs_.format, devAttrs_.frameSize); - DHLOGD("Render frameIndex: %lld.", frameIndex_); - - int64_t startTime = GetNowTimeUs(); - std::lock_guard renderLck(renderMtx_); - if (renderStatus_ != RENDER_STATUS_START) { - DHLOGE("Render status wrong, return false."); - return HDF_FAILURE; - } - - AudioParameter param = { devAttrs_.format, devAttrs_.channelCount, devAttrs_.sampleRate, 0, devAttrs_.frameSize}; - AudioData data = { param, frame }; -#ifdef DUMP_RENDER_FILE - if (dumpFlag_) { - SaveFile(HDF_RENDER_FILENAME, reinterpret_cast(data.data.data()), frame.size()); - } -#endif - FadeInProcess(DURATION_FRAMES, data.data.data(), frame.size()); - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - int32_t ret = audioExtCallback_->WriteStreamData(adapterName_, devDesc_.pins, data); - if (ret != HDF_SUCCESS) { - DHLOGE("Write stream data failed."); - return HDF_FAILURE; - } - - ++frameIndex_; - DHLOGD("Render audio frame success."); - int64_t endTime = GetNowTimeUs(); - if (IsOutDurationRange(startTime, endTime, lastRenderStartTime_)) { - DHLOGE("This time render frame spend: %lld, The interval of render frame this time and the last time: %lld", - endTime - startTime, startTime - lastRenderStartTime_); - } - lastRenderStartTime_ = startTime; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get render position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetRenderSpeed(float speed) -{ - DHLOGI("Set render speed, control render speed is not support yet."); - renderSpeed_ = speed; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetRenderSpeed(float &speed) -{ - DHLOGI("Get render speed, control render speed is not support yet."); - speed = renderSpeed_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetChannelMode(AudioChannelMode mode) -{ - DHLOGI("Set channel mode, control channel mode is not support yet."); - channelMode_ = mode; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetChannelMode(AudioChannelMode &mode) -{ - DHLOGI("Get channel mode, control channel mode is not support yet."); - mode = channelMode_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RegCallback(const sptr &audioCallback, int8_t cookie) -{ - DHLOGI("Register render callback."); - (void)cookie; - renderCallback_ = audioCallback; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::DrainBuffer(AudioDrainNotifyType &type) -{ - DHLOGI("Drain audio buffer, not support yet."); - (void)type; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::IsSupportsDrain(bool &support) -{ - DHLOGI("Check whether drain is supported, not support yet."); - (void)support; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Start() -{ - DHLOGI("Start render."); - if (firstOpenFlag_) { - firstOpenFlag_ = false; - } else { - cJSON *jParam = cJSON_CreateObject(); - if (jParam == nullptr) { - DHLOGE("Failed to create cJSON object."); - return HDF_FAILURE; - } - cJSON_AddStringToObject(jParam, KEY_DH_ID, std::to_string(devDesc_.pins).c_str()); - cJSON_AddStringToObject(jParam, "ChangeType", HDF_EVENT_RESTART.c_str()); - char *jsonData = cJSON_PrintUnformatted(jParam); - if (jsonData == nullptr) { - DHLOGE("Failed to create JSON data."); - cJSON_Delete(jParam); - return HDF_FAILURE; - } - std::string content(jsonData); - cJSON_Delete(jParam); - cJSON_free(jsonData); - DAudioEvent event = { HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS, content}; - int32_t ret = audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event); - if (ret != HDF_SUCCESS) { - DHLOGE("Restart failed."); - } - } - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_START; - currentFrame_ = CUR_FRAME_INIT_VALUE; - frameIndex_ = 0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Stop() -{ - DHLOGI("Stop render."); - cJSON *jParam = cJSON_CreateObject(); - if (jParam == nullptr) { - DHLOGE("Failed to create cJSON object."); - return HDF_FAILURE; - } - cJSON_AddStringToObject(jParam, KEY_DH_ID, std::to_string(devDesc_.pins).c_str()); - cJSON_AddStringToObject(jParam, "ChangeType", HDF_EVENT_RESTART.c_str()); - char *jsonData = cJSON_PrintUnformatted(jParam); - if (jsonData == nullptr) { - DHLOGE("Failed to create JSON data."); - cJSON_Delete(jParam); - return HDF_FAILURE; - } - std::string content(jsonData); - cJSON_Delete(jParam); - cJSON_free(jsonData); - DAudioEvent event = { HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS, content}; - int32_t ret = audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event); - if (ret != HDF_SUCCESS) { - DHLOGE("Pause and clear cache streams failed."); - } - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_STOP; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Pause() -{ - DHLOGI("Pause render."); - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_PAUSE; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Resume() -{ - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Flush() -{ - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::TurnStandbyMode() -{ - DHLOGI("Turn stand by mode, not support yet."); - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::AudioDevDump(int32_t range, int32_t fd) -{ - DHLOGI("Dump audio info, not support yet."); - (void)range; - (void)fd; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) -{ - DHLOGI("Check whether pause and resume is supported, not support yet."); - (void)supportPause; - (void)supportResume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) -{ - DHLOGI("Check scene capability."); - (void)scene; - (void)supported; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SelectScene(const AudioSceneDescriptor &scene) -{ - DHLOGI("Select audio scene, not support yet."); - (void)scene; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetMute(bool mute) -{ - DHLOGI("Set mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetMute(bool &mute) -{ - DHLOGI("Get mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetVolume(float volume) -{ - DHLOGI("Can not set vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetVolume(float &volume) -{ - DHLOGI("Can not get vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetGainThreshold(float &min, float &max) -{ - DHLOGI("Get gain threshold, not support yet."); - min = 0; - max = 0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetGain(float gain) -{ - DHLOGI("Set gain, not support yet."); - (void)gain; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetGain(float &gain) -{ - DHLOGI("Get gain, not support yet."); - gain = 1.0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameSize(uint64_t &size) -{ - (void)size; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameCount(uint64_t &count) -{ - (void)count; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetSampleAttributes(const AudioSampleAttributes &attrs) -{ - DHLOGI("Set sample attributes."); - devAttrs_ = attrs; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetSampleAttributes(AudioSampleAttributes &attrs) -{ - DHLOGI("Get sample attributes."); - attrs = devAttrs_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetCurrentChannelId(uint32_t &channelId) -{ - DHLOGI("Get current channel id, not support yet."); - (void)channelId; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetExtraParams(const std::string &keyValueList) -{ - DHLOGI("Set extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetExtraParams(std::string &keyValueList) -{ - DHLOGI("Get extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) -{ - DHLOGI("Request mmap buffer, not support yet."); - (void)reqSize; - (void)desc; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get mmap position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::AddAudioEffect(uint64_t effectid) -{ - DHLOGI("Add audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RemoveAudioEffect(uint64_t effectid) -{ - DHLOGI("Remove audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) -{ - DHLOGI("Get frame buffer size, not support yet."); - (void)bufferSize; - return HDF_SUCCESS; -} - -const AudioDeviceDescriptor &AudioRenderInterfaceImpl::GetRenderDesc() -{ - return devDesc_; -} - -void AudioRenderInterfaceImpl::SetVolumeInner(const uint32_t vol) -{ - std::lock_guard volLck(volMtx_); - vol_ = vol; -} - -void AudioRenderInterfaceImpl::SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) -{ - std::lock_guard volLck(volMtx_); - volMin_ = volMin; - volMax_ = volMax; -} - -uint32_t AudioRenderInterfaceImpl::GetVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return vol_; -} - -uint32_t AudioRenderInterfaceImpl::GetMaxVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return volMax_; -} - -uint32_t AudioRenderInterfaceImpl::GetMinVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return volMin_; -} - -void AudioRenderInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback, const int32_t dhId) -{ - DHLOGI("Set attrs, not support yet."); -} - -void AudioRenderInterfaceImpl::SetDumpFlagInner() -{ - dumpFlag_ = true; -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn deleted file mode 100644 index 718f13d92a3e054f454b39c812385f20084b6a09..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CaptureFrameFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/captureframe_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/captureframe_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "captureframe_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CaptureFrameFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CaptureFrameFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp deleted file mode 100644 index e15c3fe225b2c63b54b2cd7701e87c24fa515f64..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "captureframe_fuzzer.h" - -#include -#include - -#include "audio_capture_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CaptureFrameFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(uint64_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = nullptr; - auto audioCapture = std::make_shared(adpName, desc, attrs, callback); - std::vector frame; - uint64_t requestBytes = *(reinterpret_cast(data)); - - audioCapture->CaptureFrame(frame, requestBytes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CaptureFrameFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h deleted file mode 100644 index ba15a80b77ee397ff5d05d5cba9eaeaa60104d04..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef CAPTUREFRAME_FUZZER_H -#define CAPTUREFRAME_FUZZER_H - -#define FUZZ_PROJECT_NAME "captureframe_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn deleted file mode 100644 index 8a447c484c6c87559f5e9f3cc86a47b491ee8679..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CreateCaptureFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/createcapture_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/createcapture_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "createcapture_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CreateCaptureFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CreateCaptureFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp deleted file mode 100644 index d49cd09ab53c4b0ae4283734884a1f594aeb1fab..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "createcapture_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CreateCaptureFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - AudioSampleAttributes sampleAttr = { - .type = *(reinterpret_cast(data)), - .interleaved = *(reinterpret_cast(data)), - .format = *(reinterpret_cast(data)), - .sampleRate = *(reinterpret_cast(data)), - .channelCount = *(reinterpret_cast(data)), - .period = *(reinterpret_cast(data)), - .frameSize = *(reinterpret_cast(data)), - .isBigEndian = *(reinterpret_cast(data)), - .isSignedData = *(reinterpret_cast(data)), - .startThreshold = *(reinterpret_cast(data)), - .stopThreshold = *(reinterpret_cast(data)), - .silenceThreshold = *(reinterpret_cast(data)), - .streamId = *(reinterpret_cast(data)), - }; - - sptr capture; - uint32_t capId; - audioAdapter->CreateCapture(deviceDes, sampleAttr, capture, capId); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CreateCaptureFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h deleted file mode 100644 index 46d8462958a59798058c78ac6c9318dfb3a2edab..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef CREATECAPTURE_FUZZER_H -#define CREATECAPTURE_FUZZER_H - -#define FUZZ_PROJECT_NAME "createrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn deleted file mode 100644 index a80b2dd36aed374efb081bcdbe8acdf0ae32ceb3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CreateRenderFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/createrender_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/createrender_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "createrender_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CreateRenderFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CreateRenderFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp deleted file mode 100644 index 9b0289cdb440c2cea1143c53586ccefc43245dbb..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "createrender_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CreateRenderFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - AudioSampleAttributes sampleAttr = { - .type = *(reinterpret_cast(data)), - .interleaved = *(reinterpret_cast(data)), - .format = *(reinterpret_cast(data)), - .sampleRate = *(reinterpret_cast(data)), - .channelCount = *(reinterpret_cast(data)), - .period = *(reinterpret_cast(data)), - .frameSize = *(reinterpret_cast(data)), - .isBigEndian = *(reinterpret_cast(data)), - .isSignedData = *(reinterpret_cast(data)), - .startThreshold = *(reinterpret_cast(data)), - .stopThreshold = *(reinterpret_cast(data)), - .silenceThreshold = *(reinterpret_cast(data)), - .streamId = *(reinterpret_cast(data)), - }; - - sptr render; - uint32_t renderId; - audioAdapter->CreateRender(deviceDes, sampleAttr, render, renderId); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CreateRenderFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h deleted file mode 100644 index 56001ad0c5582a575077682e7c0849da9c491e22..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef CREATERENDER_FUZZER_H -#define CREATERENDER_FUZZER_H - -#define FUZZ_PROJECT_NAME "createrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn deleted file mode 100644 index a36e3ca6eb58e12682c38b97a3154814a3781388..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DestroyCaptureFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/destroycapture_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/destroycapture_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "destroycapture_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DestroyCaptureFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":DestroyCaptureFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp deleted file mode 100644 index 3cd068680e8301e18703f101b6e7e89800218fef..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "destroycapture_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void DestroyCaptureFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - uint32_t capId = *(reinterpret_cast(data)); - audioAdapter->DestroyCapture(capId); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::DestroyCaptureFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h deleted file mode 100644 index eaac4aaa471a046a9bdfaeb22720f9c1c5f3ac27..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef DESTROYCAPTURE_FUZZER_H -#define DESTROYCAPTURE_FUZZER_H - -#define FUZZ_PROJECT_NAME "destroycapture_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn deleted file mode 100644 index d89604b0124a1ab0857690de827361438d9e20f0..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DestroyRenderFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/destroyrender_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/destroyrender_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "destroyrender_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DestroyRenderFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":DestroyRenderFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp deleted file mode 100644 index 1ca043aae2a8d1620d295e2846d3a3421f5ac0d9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "destroyrender_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void DestroyRenderFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - uint32_t renderId = *(reinterpret_cast(data)); - audioAdapter->DestroyRender(renderId); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::DestroyRenderFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h deleted file mode 100644 index 7e1f6e106ac7d494eb3468c51617bb649884ccec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef DESTROYRENDER_FUZZER_H -#define DESTROYRENDER_FUZZER_H - -#define FUZZ_PROJECT_NAME "destroyrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn deleted file mode 100644 index 7452483e413e7439ea700f48619d6576f21f17d8..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("GetAllAdaptersFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/getalladapters_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/getalladapters_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getalladapters_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"GetAllAdaptersFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":GetAllAdaptersFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp deleted file mode 100644 index d3b5db040c206f3539d51dcb3a7ebcc0156b6a3a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "getalladapters_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void GetAllAdaptersFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::vector descriptors; - AudioManagerInterfaceImpl::GetAudioManager()->GetAllAdapters(descriptors); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::GetAllAdaptersFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h deleted file mode 100644 index e6e66c0a9dcfccc5afde8dff0b4491de301a567b..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef GETALLADAPTERS_FUZZER_H -#define GETALLADAPTERS_FUZZER_H - -#define FUZZ_PROJECT_NAME "getalladapters_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn deleted file mode 100644 index 36ce96dfae7e35eb66e7d8c708ea27a574b4bc92..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("GetExtraParamsFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/getextraparams_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/getextraparams_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getextraparams_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"GetExtraParamsFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":GetExtraParamsFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp deleted file mode 100644 index e422c0404b806075a780efe7567443fc1a40230f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "getextraparams_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void GetExtraParamsFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - AudioExtParamKey key = *(reinterpret_cast(data)); - std::string condition(reinterpret_cast(data), size); - std::string value(reinterpret_cast(data), size); - - audioAdapter->GetExtraParams(key, condition, value); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::GetExtraParamsFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h deleted file mode 100644 index 4b6bfd094497ac3fba5271cca6b12fdc03c75690..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef GETEXTRAPARAMS_FUZZER_H -#define GETEXTRAPARAMS_FUZZER_H - -#define FUZZ_PROJECT_NAME "getextraparams_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn deleted file mode 100644 index 1ae5fd52abb45d2d783fc1abe427b87f1c242dd3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("LoadAdapterFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/loadadapter_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/loadadapter_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "loadadapter_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"LoadAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":LoadAdapterFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp deleted file mode 100644 index 0501f9b83f796d01746a6dc59dc473e66532d8b7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "loadadapter_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void LoadAdapterFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor descriptor; - sptr adapter = nullptr; - AudioManagerInterfaceImpl::GetAudioManager()->LoadAdapter(descriptor, adapter); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::LoadAdapterFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h deleted file mode 100644 index 47123aea3309a2e5ce62f8addd53d2f8c18c36e7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef LOADADAPTER_FUZZER_H -#define LOADADAPTER_FUZZER_H - -#define FUZZ_PROJECT_NAME "getalladapters_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn deleted file mode 100644 index 6931d7689b353d3bf219f6886c3b79ea8a9cb545..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("RenderFrameFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/renderframe_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/renderframe_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "renderframe_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"RenderFrameFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":RenderFrameFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp deleted file mode 100644 index 4174b196071b9168cd0de5ba843170398f4843d9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "renderframe_fuzzer.h" - -#include -#include - -#include "audio_render_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void RenderFrameFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(uint64_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = nullptr; - auto audioRender = std::make_shared(adpName, desc, attrs, callback); - - std::vector frame; - uint64_t replyBytes = *(reinterpret_cast(data)); - audioRender->RenderFrame(frame, replyBytes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::RenderFrameFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h deleted file mode 100644 index c50605544451d8726ce481450daa85be7ea3ad65..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef RENDERFRAME_FUZZER_H -#define RENDERFRAME_FUZZER_H - -#define FUZZ_PROJECT_NAME "renderframe_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn deleted file mode 100644 index e9f951d5968b9105edc7b98215252cb4a5ba57fd..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("SetExtraParamsFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/setextraparams_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/setextraparams_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "setextraparams_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SetExtraParamsFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":SetExtraParamsFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp deleted file mode 100644 index c6da6a795465b5a3c3b8f85fb31ea99a7a375594..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "setextraparams_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void SetExtraParamsFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - AudioExtParamKey key = *(reinterpret_cast(data)); - std::string condition(reinterpret_cast(data), size); - std::string value(reinterpret_cast(data), size); - - audioAdapter->SetExtraParams(key, condition, value); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::SetExtraParamsFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h deleted file mode 100644 index c6420264bb5ab69dc9ca54f78e00c732f50a5b03..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef SETEXTRAPARAMS_FUZZER_H -#define SETEXTRAPARAMS_FUZZER_H - -#define FUZZ_PROJECT_NAME "setextraparams_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn deleted file mode 100644 index cb86345a33f904df9e6208a4a37aa32af46a5550..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("UnloadAdapterFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/unloadadapter_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/unloadadapter_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "unloadadapter_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"UnloadAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":UnloadAdapterFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp deleted file mode 100644 index 2de0fe95761f04d7d5dd547b96d445770afca827..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "unloadadapter_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void UnloadAdapterFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioManagerInterfaceImpl::GetAudioManager()->UnloadAdapter(adpName); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::UnloadAdapterFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h deleted file mode 100644 index 00d51d772333b9840f871efbaf4070760e800a32..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef UNLOADADAPTER_FUZZER_H -#define UNLOADADAPTER_FUZZER_H - -#define FUZZ_PROJECT_NAME "unloadadapter_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn deleted file mode 100644 index 72d69d8c9794e8857d2e0e6911b4e473cc116279..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023 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/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../distributedaudio.gni") - -group("hdi_service_audio_test") { - testonly = true - deps = [ - "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface:hdi_service_audio_adapter_test", - "${hdf_ser_aud_path}/test/unittest/audio_capture_interface:hdi_service_audio_capture_test", - "${hdf_ser_aud_path}/test/unittest/audio_manager_interface:hdi_service_audio_manager_test", - "${hdf_ser_aud_path}/test/unittest/audio_render_interface:hdi_service_audio_render_test", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn deleted file mode 100644 index 196096b356a0760f0eed0ef596fc283ae99d6313..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface/include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_ser_aud_ext_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_adapter_test -ohos_unittest("HDIServiceAudioAdapterTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_adapter_test") { - testonly = true - deps = [ ":HDIServiceAudioAdapterTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h deleted file mode 100644 index 312e23c2ea766b553e2f16944e71391b005187c4..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H - -#include -#include - -#include - -#include "audio_render_interface_impl.h" -#include "audio_test_utils.h" - -#define private public -#include "audio_adapter_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioAdapterInterfaceImpTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - sptr callback_ = nullptr; - std::shared_ptr AdapterTest_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp deleted file mode 100644 index c1af1c60d301052c8a7e08b87016c815cbe5a8ea..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp +++ /dev/null @@ -1,1258 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include -#include - -#include "audio_adapter_interface_impl_test.h" -#include "daudio_constants.h" - -using namespace testing::ext; -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -static constexpr int32_t DEFAULT_CAPTURE_ID = 1 << 27 | 1 << 0; - -void AudioAdapterInterfaceImpTest::SetUpTestCase(void) {} - -void AudioAdapterInterfaceImpTest::TearDownTestCase(void) {} - -void AudioAdapterInterfaceImpTest::SetUp(void) -{ - AudioAdapterDescriptor adaDesc; - AdapterTest_ = std::make_shared(adaDesc); -} - -void AudioAdapterInterfaceImpTest::TearDown(void) -{ - AdapterTest_ = nullptr; -} - -/** - * @tc.name: InitAllPorts_001 - * @tc.desc: Verify the InitAllPorts function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, InitAllPorts_001, TestSize.Level1) -{ - sptr speakerCallback = nullptr; - int32_t dhId = 1; - AdapterTest_->SetSpeakerCallback(dhId, speakerCallback); - AdapterTest_->extCallbackMap_.erase(dhId); - speakerCallback = new MockIDAudioCallback(); - AdapterTest_->SetSpeakerCallback(dhId, speakerCallback); - - dhId = DEFAULT_CAPTURE_ID; - sptr micCallback = nullptr; - AdapterTest_->SetMicCallback(dhId, micCallback); - AdapterTest_->extCallbackMap_.erase(dhId); - micCallback = new MockIDAudioCallback(); - AdapterTest_->SetMicCallback(dhId, micCallback); - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->InitAllPorts()); -} - -/** - * @tc.name: CreateRender_001 - * @tc.desc: Verify the CreateRender function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CreateRender_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - sptr render = nullptr; - uint32_t renderId = 0; - int32_t dhId = 1; - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateRender(devDesc, attrs, render, renderId)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(renderId)); - - AdapterTest_->mapAudioDevice_.insert(std::make_pair(PIN_OUT_DAUDIO_DEFAULT, "hello")); - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateRender(devDesc, attrs, render, renderId)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(renderId)); -} - -/** - * @tc.name: DestroyRender_001 - * @tc.desc: Verify the DestroyRender function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, DestroyRender_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - std::string adpterName = "adbcef"; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - AdapterTest_->extCallbackMap_[dhId] = new MockRevertIDAudioCallback(); - - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - uint32_t renderId = 0; - AdapterTest_->renderDevs_[renderId] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, devDesc, attrs, callback)); - AdapterTest_->spkPinInUse_ = 0; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(renderId)); - renderId = 10; - EXPECT_EQ(HDF_FAILURE, AdapterTest_->DestroyRender(renderId)); - renderId = 1; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(renderId)); -} - -/** - * @tc.name: CreateCapture_001 - * @tc.desc: Verify the CreateCapture function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CreateCapture_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - sptr capture = nullptr; - uint32_t capId = 0; - int32_t dhId = DEFAULT_CAPTURE_ID; - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateCapture(devDesc, attrs, capture, capId)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(capId)); - - AdapterTest_->mapAudioDevice_.insert(std::make_pair(PIN_OUT_DAUDIO_DEFAULT, "hello")); - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateCapture(devDesc, attrs, capture, capId)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(capId)); -} - -/** - * @tc.name: CreateRender_001 - * @tc.desc: Verify the DestroyCapture function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, DestroyCapture_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - std::string adpterName = "adbcef"; - sptr callback = new MockIDAudioCallback(); - int32_t dhId = DEFAULT_CAPTURE_ID; - AdapterTest_->extCallbackMap_[dhId] = new MockRevertIDAudioCallback(); - - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - uint32_t capId = 0; - AdapterTest_->captureDevs_[capId] = std::make_pair(dhId, - new AudioCaptureInterfaceImpl(adpterName, devDesc, attrs, callback)); - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(capId)); - capId = 10; - EXPECT_EQ(HDF_FAILURE, AdapterTest_->DestroyCapture(capId)); - capId = 1; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(capId)); -} - -/** - * @tc.name: GetPortCapability_001 - * @tc.desc: Verify the GetPortCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetPortCapability_001, TestSize.Level1) -{ - AudioPort port; - AudioPortCapability capability; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetPortCapability(port, capability)); -} - -/** - * @tc.name: SetPassthroughMode_001 - * @tc.desc: Verify the SetPassthroughMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetPassthroughMode_001, TestSize.Level1) -{ - AudioPort port; - AudioPortPassthroughMode mode = AudioPortPassthroughMode::PORT_PASSTHROUGH_LPCM; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetPassthroughMode(port, mode)); -} - -/** - * @tc.name: GetPassthroughMode_001 - * @tc.desc: Verify the GetPassthroughMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetPassthroughMode_001, TestSize.Level1) -{ - AudioPort port; - AudioPortPassthroughMode mode = AudioPortPassthroughMode::PORT_PASSTHROUGH_LPCM; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetPassthroughMode(port, mode)); -} - -/** - * @tc.name: GetDeviceStatus_001 - * @tc.desc: Verify the GetDeviceStatus function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceStatus_001, TestSize.Level1) -{ - AudioDeviceStatus sta; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetDeviceStatus(sta)); -} - -/** - * @tc.name: SetMicMute_001 - * @tc.desc: Verify the SetMicMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetMicMute_001, TestSize.Level1) -{ - bool muteTmp = true; - bool muteGetted; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetMicMute(muteTmp)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetMicMute(muteGetted)); -} - -/** - * @tc.name: SetVoiceVolume_001 - * @tc.desc: Verify the SetVoiceVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetVoiceVolume_001, TestSize.Level1) -{ - float vol = 1.0f; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetVoiceVolume(vol)); -} - -/** - * @tc.name: UpdateAudioRoute_001 - * @tc.desc: Verify the UpdateAudioRoute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, UpdateAudioRoute_001, TestSize.Level1) -{ - AudioRoute route; - int32_t handle = 0; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->UpdateAudioRoute(route, handle)); -} - -/** - * @tc.name: ReleaseAudioRoute_001 - * @tc.desc: Verify the ReleaseAudioRoute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, ReleaseAudioRoute_001, TestSize.Level1) -{ - int32_t handle = 0; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->ReleaseAudioRoute(handle)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetExtraParams_001, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE; - std::string condition = "{\"dhId\":\"1\"}"; - std::string value = "world"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); - key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); - key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_LOWPOWER; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_001, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE; - std::string condition = "hello"; - std::string value = "world"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_002 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_002, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - std::string condition = "hello"; - std::string value = "1"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_003 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_003, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string value = "1"; - EXPECT_EQ(HDF_FAILURE, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_004 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_004, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_STATUS; - std::string condition = "hello"; - std::string value = "world"; - EXPECT_EQ(HDF_ERR_INVALID_PARAM, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: RegExtraParamObserver_001 - * @tc.desc: Verify the RegExtraParamObserver function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RegExtraParamObserver_001, TestSize.Level1) -{ - sptr cbObj = nullptr; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RegExtraParamObserver(cbObj, 0)); -} - -/** - * @tc.name: RegExtraParamObserver_002 - * @tc.desc: Verify the RegExtraParamObserver function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RegExtraParamObserver_002, TestSize.Level1) -{ - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - sptr cbObj = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RegExtraParamObserver(cbObj, 0)); -} - -/** - * @tc.name: GetAdapterDesc_002 - * @tc.desc: Verify the GetAdapterDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAdapterDesc_002, TestSize.Level1) -{ - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AudioPort port; - port.dir = PORT_OUT_IN; - port.portId = 64; - port.portName = ""; - AdapterTest_->GetAdapterDesc(); - EXPECT_EQ(PORT_OUT_IN, AdapterTest_->adpDescriptor_.ports[0].dir); -} - -/** - * @tc.name: GetDeviceCapabilitys_001 - * @tc.desc: Verify the GetDeviceCapabilitys function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceCapabilitys_001, TestSize.Level1) -{ - uint32_t devId = 88; - std::string caps = "worldcup"; - AdapterTest_->AddAudioDevice(devId, caps); - - EXPECT_EQ(caps, AdapterTest_->GetDeviceCapabilitys(devId)); -} - -/** - * @tc.name: GetDeviceCapabilitys_002 - * @tc.desc: Verify the GetDeviceCapabilitys function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceCapabilitys_002, TestSize.Level1) -{ - uint32_t devId = 88; - std::string caps = "worldcup"; - AdapterTest_->RemoveAudioDevice(devId); - - EXPECT_EQ("", AdapterTest_->GetDeviceCapabilitys(devId)); -} - -/** - * @tc.name: AdapterLoad_001 - * @tc.desc: Verify the AdapterLoad function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AdapterLoad_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AdapterLoad()); -} - -/** - * @tc.name: AdapterUnload_001 - * @tc.desc: Verify the AdapterUnload function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AdapterUnload_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AdapterUnload()); - - std::string adpterName = "adbcef"; - AudioDeviceDescriptor descSpk; - AudioSampleAttributes attrsSpk; - int32_t dhId = 1; - sptr callbackSpk = new MockIDAudioCallback(); - AdapterTest_->SetSpeakerCallback(dhId, callbackSpk); - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, descSpk, attrsSpk, callbackSpk)); - EXPECT_EQ(HDF_ERR_DEVICE_BUSY, AdapterTest_->AdapterUnload()); - - AudioDeviceDescriptor devDescMic; - AudioSampleAttributes attrsMic; - dhId = DEFAULT_CAPTURE_ID; - sptr callbackMic = new MockIDAudioCallback(); - AdapterTest_->SetMicCallback(dhId, callbackMic); - AdapterTest_->captureDevs_[0] = std::make_pair(dhId, - new AudioCaptureInterfaceImpl(adpterName, devDescMic, attrsMic, callbackMic)); - EXPECT_EQ(HDF_ERR_DEVICE_BUSY, AdapterTest_->AdapterUnload()); - - AdapterTest_->renderDevs_[0].first = 0; - AdapterTest_->renderDevs_[0].second = nullptr; - EXPECT_EQ(HDF_ERR_DEVICE_BUSY, AdapterTest_->AdapterUnload()); - - AdapterTest_->captureDevs_[0].first = 0; - AdapterTest_->captureDevs_[0].second = nullptr; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AdapterUnload()); -} - -/** - * @tc.name: Notify_001 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_001, TestSize.Level1) -{ - DAudioEvent event; - event.type = 3; - event.content = "VOLUME_LEVEL"; - uint32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: Notify_002 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_002, TestSize.Level1) -{ - DAudioEvent event; - event.type = 10; - event.content = "FOCUS_CHANGE"; - uint32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 11; - event.content = "RENDER_STATE_CHANG"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 7; - event.content = "CLOSE_MIC_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 9; - event.content = "MIC_CLOSED_STATE"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: Notify_003 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_003, TestSize.Level1) -{ - DAudioEvent event; - event.type = 4; - event.content = "OPEN_SPK_RESULT"; - uint32_t devId = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 5; - event.content = "CLOSE_SPK_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 6; - event.content = "OPEN_MIC_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 8; - event.content = "SPK_CLOSED"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: AddAudioDevice_001 - * @tc.desc: Verify the AddAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AddAudioDevice_001, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps; - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AddAudioDevice(devId, caps)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: AddAudioDevice_002 - * @tc.desc: Verify the AddAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AddAudioDevice_002, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps = "hello"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AddAudioDevice(devId, caps)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: RemoveAudioDevice_001 - * @tc.desc: Verify the RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RemoveAudioDevice_001, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps; - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AdapterTest_->spkPinInUse_ = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AdapterTest_->spkPinInUse_ = 0; - AdapterTest_->micPinInUse_ = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: OpenRenderDevice_001 - * @tc.desc: Verify the OpenRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenRenderDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs, - AdapterTest_->extCallbackMap_[dhId], dhId)); - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs, - AdapterTest_->extCallbackMap_[dhId], dhId)); -} -/** - * @tc.name: OpenRenderDevice_002 - * @tc.desc: Verify the OpenRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenRenderDevice_002, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - AdapterTest_->extCallbackMap_[dhId] = new MockRevertIDAudioCallback(); - AdapterTest_->isSpkOpened_ = false; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs, - AdapterTest_->extCallbackMap_[dhId], dhId)); -} - -/** - * @tc.name: CloseRenderDevice_001 - * @tc.desc: Verify the CloseRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CloseRenderDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - int32_t dhId = 1; - sptr callback(nullptr); - AdapterTest_->spkPinInUse_ = 0; - EXPECT_EQ(ERR_DH_AUDIO_HDF_NULLPTR, AdapterTest_->CloseRenderDevice(devDesc, callback, dhId)); - AdapterTest_->spkPinInUse_ = 1; - callback = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseRenderDevice(devDesc, callback, dhId)); - callback = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseRenderDevice(devDesc, callback, dhId)); -} - -/** - * @tc.name: OpenCaptureDevice_001 - * @tc.desc: Verify the OpenCaptureDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenCaptureDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - int32_t dhId = DEFAULT_CAPTURE_ID; - sptr callback(new MockIDAudioCallback()); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenCaptureDevice(devDesc, attrs, callback, dhId)); - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->OpenCaptureDevice(devDesc, attrs, callback, dhId)); -} - -/** - * @tc.name: CloseCaptureDevice_001 - * @tc.desc: Verify the CloseCaptureDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CloseCaptureDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - int32_t dhId = DEFAULT_CAPTURE_ID; - sptr callback(new MockIDAudioCallback()); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseCaptureDevice(devDesc, callback, dhId)); - AdapterTest_->micPinInUse_ = 1; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseCaptureDevice(devDesc, callback, dhId)); -} - -/** - * @tc.name: GetVolumeGroup_001 - * @tc.desc: Verify the GetVolumeGroup function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetVolumeGroup_001, TestSize.Level1) -{ - uint32_t devId = 88; - int32_t dhId = DEFAULT_CAPTURE_ID; - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_EQ(0, AdapterTest_->GetVolumeGroup(devId)); -} - -/** - * @tc.name: GetInterruptGroup_001 - * @tc.desc: Verify the GetInterruptGroup function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetInterruptGroup_001, TestSize.Level1) -{ - uint32_t devId = 88; - int32_t dhId = 1; - - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_EQ(0, AdapterTest_->GetInterruptGroup(devId)); -} - -/** - * @tc.name: SetAudioVolume_001 - * @tc.desc: Verify the SetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetAudioVolume_001, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=4;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - int32_t dhId = 1; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - AdapterTest_->extCallbackMap_[dhId] = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - param = "0"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - param = "-66"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_001 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_001, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_002 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_002, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - - std::string condition = "EVENT_TYPE=3;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_003 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_003, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - - std::string condition = "EVENT_TYPE=2;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_004 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_004, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - - std::string condition = "EVENT_TYPE=4;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - - -/** - * @tc.name: GetAudioVolume_005 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_005, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 0; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - - std::string condition = "EVENT_TYPE=66;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); - EXPECT_EQ("0", param); -} - -/** - * @tc.name: GetAudioVolume_006 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_006, TestSize.Level1) -{ - AdapterTest_->renderDevs_[0] = std::make_pair(1, nullptr); - - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); - EXPECT_EQ("1", param); -} - -/** - * @tc.name: getEventTypeFromCondition_001 - * @tc.desc: Verify the getEventTypeFromCondition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, getEventTypeFromCondition_001, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - auto actualValue = AdapterTest_->getEventTypeFromCondition(condition); - EXPECT_EQ(1, actualValue); -} - -/** - * @tc.name: getEventTypeFromCondition_002 - * @tc.desc: Verify the getEventTypeFromCondition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, getEventTypeFromCondition_002, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=12;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - auto actualValue = AdapterTest_->getEventTypeFromCondition(condition); - EXPECT_EQ(12, actualValue); -} - -/** - * @tc.name: HandleVolumeChangeEvent_001 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, - "VOLUME_CHANAGE;AUDIO_STREAM_TYPE=1;VOLUME_LEVEL=1;IS_UPDATEUI=1;VOLUME_GROUP_ID=1;"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, nullptr); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleVolumeChangeEvent_002 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, "V"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleVolumeChangeEvent_003 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, "V"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - int32_t dhId = 1; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->renderDevs_[0] = std::make_pair(dhId, - new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback)); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleFocusChangeEvent_001 - * @tc.desc: Verify the HandleFocusChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleFocusChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_FOCUS_CHANGE, - "INTERRUPT_EVENT;EVENT_TYPE=1;VOLUME_LEVEL=1;FORCE_TYPE=1;HINT_TYPE=1;"}; - - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); -} - -/** - * @tc.name: HandleFocusChangeEvent_002 - * @tc.desc: Verify the HandleFocusChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleFocusChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_FOCUS_CHANGE, - "INTERRUPT_EVENT;EVENT_TYPE=1;VOLUME_LEVEL=1;FORCE_TYPE=1;HINT_TYPE=1;"}; - - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); -} - -/** - * @tc.name: HandleRenderStateChangeEvent_001 - * @tc.desc: Verify the HandleRenderStateChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleRenderStateChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_RENDER_STATE_CHANGE, - "RENDER_STATE_CHANGE_EVENT;STATE=0;"}; - - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); -} - -/** - * @tc.name: HandleRenderStateChangeEvent_002 - * @tc.desc: Verify the HandleRenderStateChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleRenderStateChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_RENDER_STATE_CHANGE, - "RENDER_STATE_CHANGE_EVENT;STATE=0;"}; - - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_001 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, "RENDER_STATE_CHANGE_EVENT"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_002 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_003 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_CLOSE_SPK_RESULT, - HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_CLOSE_SPK_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_004 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_004, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_MIC_RESULT, - HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_OPEN_MIC_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_005 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_005, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_CLOSE_MIC_RESULT, HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_CLOSE_MIC_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_006 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_006, TestSize.Level1) -{ - using namespace DistributedHardware; - DAudioEvent event = {-1, "ddd"}; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: WaitForSANotify_001 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_001, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->spkNotifyFlag_ = true; - AdapterTest_->spkWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_SPK; - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(DH_SUCCESS, AdapterTest_->WaitForSANotify(event)); - AudioDeviceEvent event1 = EVENT_CLOSE_SPK ; - AdapterTest_->isSpkOpened_ = false; - EXPECT_EQ(DH_SUCCESS, AdapterTest_->WaitForSANotify(event1)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_002 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_002, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->spkNotifyFlag_ = true; - AdapterTest_->spkWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_SPK; - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_003 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_003, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->micNotifyFlag_ = true; - AdapterTest_->micWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_MIC; - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); - - AudioDeviceEvent event1 = EVENT_CLOSE_MIC; - AdapterTest_->isMicOpened_ = false; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event1)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_004 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_004, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->micNotifyFlag_ = true; - AdapterTest_->micWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_MIC; - AdapterTest_->isMicOpened_ = true;; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_005 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_005, TestSize.Level1) -{ - AudioDeviceEvent event = EVENT_DEV_CLOSED; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); -} - -/** - * @tc.name: HandleDeviceClosed_001 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); -} - -/** - * @tc.name: HandleDeviceClosed_002 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - DAudioEvent event1 = {HDF_AUDIO_EVENT_MIC_CLOSED, "gmock"}; - AdapterTest_->paramCallback_ = nullptr; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - - AdapterTest_->isSpkOpened_ = true; - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event1)); -} - -/** - * @tc.name: HandleDeviceClosed_001 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn deleted file mode 100644 index e746cff22b9c904bcc854bd6e198b9cd4760d4b1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceCaptureTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_capture_test") { - testonly = true - deps = [ ":HDIServiceCaptureTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h deleted file mode 100644 index 8a2d56253bd824759d6310960340c1367e4f296d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H - -#include - -#include -#include - -#include "audio_test_utils.h" -#define private public -#include "audio_capture_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioCaptureInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::string adpName_; - AudioDeviceDescriptor desc_; - AudioSampleAttributes attrs_; - sptr callback_; - std::shared_ptr audioCaptureInterfaceImpl_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp deleted file mode 100644 index d23237d34f5c37ea955eecaa4c9c5b9a173a444a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "audio_capture_interface_impl_test.h" - -#include -#include -#include "sys/time.h" - -#include "daudio_constants.h" -#include "daudio_log.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioCaptureInterfaceImplTest::SetUpTestCase(void) {} - -void AudioCaptureInterfaceImplTest::TearDownTestCase(void) {} - -void AudioCaptureInterfaceImplTest::SetUp(void) -{ - std::string adpName; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback; - audioCaptureInterfaceImpl_ = std::make_shared(adpName, desc, attrs, callback); -} - -void AudioCaptureInterfaceImplTest::TearDown(void) -{ - audioCaptureInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetCapturePosition_001 - * @tc.desc: Verify the GetCapturePosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCapturePosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetCapturePosition(frames, time)); -} - -/** - * @tc.name: CaptureFrame_001 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_001, TestSize.Level1) -{ - vector frame; - uint64_t requestBytes = 0; - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: CaptureFrame_002 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_002, TestSize.Level1) -{ - vector frame{1, 1, 1, 1, 1}; - uint64_t requestBytes = 0; - audioCaptureInterfaceImpl_->captureStatus_ = CAPTURE_STATUS_START; - audioCaptureInterfaceImpl_->audioExtCallback_ = nullptr; - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); - audioCaptureInterfaceImpl_->audioExtCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: CaptureFrame_003 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_003, TestSize.Level1) -{ - vector frame; - uint64_t requestBytes = 0; - audioCaptureInterfaceImpl_->captureStatus_ = CAPTURE_STATUS_START; - audioCaptureInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: Start_001 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Start_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->Start()); -} - -/** - * @tc.name: Stop_001 - * @tc.desc: Verify the Stop function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Stop_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->Stop()); -} - -/** - * @tc.name: Pause_001 - * @tc.desc: Verify the Pause function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Pause_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Pause()); -} - -/** - * @tc.name: Resume_001 - * @tc.desc: Verify the Resume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Resume_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Resume()); -} - -/** - * @tc.name: Flush_001 - * @tc.desc: Verify the Flush function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Flush_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Flush()); -} - -/** - * @tc.name: TurnStandbyMode_001 - * @tc.desc: Verify the TurnStandbyMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, TurnStandbyMode_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->TurnStandbyMode()); -} - -/** - * @tc.name: AudioDevDump_001 - * @tc.desc: Verify the AudioDevDump function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, AudioDevDump_001, TestSize.Level1) -{ - int32_t range = 0; - int32_t fd = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->AudioDevDump(range, fd)); -} - -/** - * @tc.name: IsSupportsPauseAndResume_001 - * @tc.desc: Verify the IsSupportsPauseAndResume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, IsSupportsPauseAndResume_001, TestSize.Level1) -{ - bool supportPause = true; - bool supportResume = true; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_-> - IsSupportsPauseAndResume(supportPause, supportResume)); -} - -/** - * @tc.name: CheckSceneCapability_001 - * @tc.desc: Verify the CheckSceneCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CheckSceneCapability_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - bool support = false; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->CheckSceneCapability(scene, support)); -} - -/** - * @tc.name: SelectScene_001 - * @tc.desc: Verify the SelectScene function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SelectScene_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SelectScene(scene)); -} - -/** - * @tc.name: SetMute_001 - * @tc.desc: Verify the SetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetMute(mute)); -} - -/** - * @tc.name: GetMute_001 - * @tc.desc: Verify the GetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetMute_001, TestSize.Level1) -{ - bool mute = true; - - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetMute(mute)); -} - -/** - * @tc.name: SetVolume_001 - * @tc.desc: Verify the SetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetVolume(volume)); -} - -/** - * @tc.name: GetVolume_001 - * @tc.desc: Verify the GetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetVolume_001, TestSize.Level1) -{ - float volume = 0; - - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetVolume(volume)); -} - -/** - * @tc.name: GetGainThreshold_001 - * @tc.desc: Verify the GetGainThreshold function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetGainThreshold_001, TestSize.Level1) -{ - float min = 0; - float max = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetGainThreshold(min, max)); -} - -/** - * @tc.name: SetGain_001 - * @tc.desc: Verify the SetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetGain(gain)); -} - -/** - * @tc.name: GetGain_001 - * @tc.desc: Verify the GetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetGain(gain)); -} - - -/** - * @tc.name: GetFrameSize_001 - * @tc.desc: Verify the GetFrameSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameSize_001, TestSize.Level1) -{ - uint64_t size = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameSize(size)); -} - -/** - * @tc.name: GetFrameCount_001 - * @tc.desc: Verify the GetFrameCount function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameCount_001, TestSize.Level1) -{ - uint64_t count = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameCount(count)); -} - -/** - * @tc.name: SetSampleAttributes_001 - * @tc.desc: Verify the SetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetSampleAttributes_001 - * @tc.desc: Verify the GetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetCurrentChannelId_001 - * @tc.desc: Verify the GetCurrentChannelId function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCurrentChannelId_001, TestSize.Level1) -{ - uint32_t channelId = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetCurrentChannelId(channelId)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetExtraParams(keyValueList)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetExtraParams(keyValueList)); -} - -/** - * @tc.name: ReqMmapBuffer_001 - * @tc.desc: Verify the ReqMmapBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, ReqMmapBuffer_001, TestSize.Level1) -{ - int32_t reqSize = 0; - AudioMmapBufferDescriptor desc; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->ReqMmapBuffer(reqSize, desc)); -} - -/** - * @tc.name: GetMmapPosition_001 - * @tc.desc: Verify the GetMmapPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetMmapPosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetMmapPosition(frames, time)); -} - -/** - * @tc.name: AddAudioEffect_001 - * @tc.desc: Verify the AddAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, AddAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->AddAudioEffect(effectid)); -} - -/** - * @tc.name: RemoveAudioEffect_001 - * @tc.desc: Verify the RemoveAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, RemoveAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->RemoveAudioEffect(effectid)); -} - -/** - * @tc.name: GetFrameBufferSize_001 - * @tc.desc: Verify the GetFrameBufferSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameBufferSize_001, TestSize.Level1) -{ - uint64_t bufferSize = 6; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameBufferSize(bufferSize)); -} - -/** - * @tc.name: GetCaptureDesc_001 - * @tc.desc: Verify the GetCaptureDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCaptureDesc_001, TestSize.Level1) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - auto audioCaptureInterfaceImplTmp = std::make_shared(adpName_, desc_, attrs_, callback_); - AudioDeviceDescriptor descriptorTmp = audioCaptureInterfaceImplTmp->GetCaptureDesc(); - - EXPECT_EQ(desc_.portId, descriptorTmp.portId); - EXPECT_EQ(desc_.pins, descriptorTmp.pins); - EXPECT_EQ(desc_.desc, descriptorTmp.desc); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn deleted file mode 100644 index 246aa584bf992359a0b755ecae5676677d6d2be2..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceManagerTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_manager_test") { - testonly = true - deps = [ ":HDIServiceManagerTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h deleted file mode 100644 index 2e56f26b0c4537a0e256552a2bbe46879b912d63..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H - -#include - -#include "hdf_device_desc.h" -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "audio_test_utils.h" - -#define private public -#include "audio_manager_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioManagerInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr audioManagerInterfaceImpl_; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp deleted file mode 100644 index 2a8396ae26c4747446f555257e03cdec8071841e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "audio_manager_interface_impl_test.h" - -#include -#include "hdf_device_object.h" -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -using namespace testing::ext; -using namespace OHOS::DistributedHardware; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioManagerInterfaceImplTest::SetUpTestCase(void) {} - -void AudioManagerInterfaceImplTest::TearDownTestCase(void) {} - -void AudioManagerInterfaceImplTest::SetUp(void) -{ - audioManagerInterfaceImpl_ = std::make_shared(); -} - -void AudioManagerInterfaceImplTest::TearDown(void) -{ - audioManagerInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetAllAdapters_001 - * @tc.desc: Verify the GetAllAdapters function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, GetAllAdapters_001, TestSize.Level1) -{ - std::vector descriptors; - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->GetAllAdapters(descriptors)); -} - -/** - * @tc.name: LoadAdapter_001 - * @tc.desc: Verify the LoadAdapter and UnloadAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, LoadAdapter_001, TestSize.Level1) -{ - std::string adpName = "adpName"; - AudioAdapterDescriptor descriptor; - descriptor.adapterName = adpName; - AudioPort audioPort = { - .dir = PORT_OUT_IN, - .portId = 0, - .portName = "world", - }; - descriptor.ports.push_back(audioPort); - sptr adapter = nullptr; - EXPECT_EQ(HDF_FAILURE, audioManagerInterfaceImpl_->LoadAdapter(descriptor, adapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->UnloadAdapter(adpName)); -} - -/** - * @tc.name: ReleaseAudioManagerObject_001 - * @tc.desc: Verify the ReleaseAudioManagerObject function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, ReleaseAudioManagerObject_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->ReleaseAudioManagerObject()); -} - -/** - * @tc.name: LoadAdapter_002 - * @tc.desc: Verify the LoadAdapter and UnloadAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, LoadAdapter_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - AudioAdapterDescriptor descriptor; - descriptor.adapterName = adpName; - AudioPort audioPort = { - .dir = PORT_OUT_IN, - .portId = 0, - .portName = "world", - }; - descriptor.ports.push_back(audioPort); - sptr adapter = nullptr; - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->LoadAdapter(descriptor, adapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->UnloadAdapter(adpName)); -} - -/** - * @tc.name: AddAudioDevice_001 - * @tc.desc: Verify the AddAudioDevice and RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, AddAudioDevice_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - std::string caps; - sptr callback = nullptr; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->AddAudioDevice(adpName, devId, caps, callback)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_INVALID_OPERATION, audioManagerInterfaceImpl_->RemoveAudioDevice(adpName, devId)); -} - -/** - * @tc.name: AddAudioDevice_002 - * @tc.desc: Verify the AddAudioDevice and RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, AddAudioDevice_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = 1; - std::string caps = "world"; - sptr callback = new MockIDAudioCallback(); - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->AddAudioDevice(adpName, devId, caps, callback)); - EXPECT_EQ(DH_SUCCESS, audioManagerInterfaceImpl_->RemoveAudioDevice(adpName, devId)); -} - -/** - * @tc.name: Notify_001 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, Notify_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - DAudioEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_INVALID_OPERATION, audioManagerInterfaceImpl_->Notify(adpName, devId, event)); -} - -/** - * @tc.name: Notify_002 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, Notify_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = 0; - DAudioEvent event; - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->Notify(adpName, devId, event)); -} - -/** - * @tc.name: NotifyFwk_001 - * @tc.desc: Verify the NotifyFwk function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, NotifyFwk_001, TestSize.Level1) -{ - DAudioDevEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->NotifyFwk(event)); -} - -/** - * @tc.name: CreateAdapter_001 - * @tc.desc: Verify the CreateAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, CreateAdapter_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - sptr callback = nullptr; - EXPECT_EQ(ERR_DH_AUDIO_HDF_NULLPTR, audioManagerInterfaceImpl_->CreateAdapter(adpName, devId, callback)); -} - -/** - * @tc.name: CreateAdapter_002 - * @tc.desc: Verify the CreateAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, CreateAdapter_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = static_cast(PIN_OUT_DAUDIO_DEFAULT); - sptr callback = new MockIDAudioCallback(); - EXPECT_EQ(DH_SUCCESS, audioManagerInterfaceImpl_->CreateAdapter(adpName, devId, callback)); -} - -/** - * @tc.name: SetDeviceObject_002 - * @tc.desc: Verify the SetDeviceObject function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, SetDeviceObject_002, TestSize.Level1) -{ - struct HdfDeviceObject deviceObject; - audioManagerInterfaceImpl_->SetDeviceObject(&deviceObject); - DAudioDevEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->NotifyFwk(event)); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn deleted file mode 100644 index 3b872ee1bd1bbacd90dc003f21dca401a01eca0c..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/audio/v1_0/test/unittest/audio_test_utils", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceRenderTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_render_test") { - testonly = true - deps = [ ":HDIServiceRenderTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h deleted file mode 100644 index 5045b0a76753416bf808d19b96575dc21ac70424..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H - -#include -#include -#include - -#include -#include -#include - -#define private public -#include "audio_render_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioRenderInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::string adpName_; - AudioDeviceDescriptor desc_; - AudioSampleAttributes attrs_; - sptr callback_ = new MockIDAudioCallback(); - std::shared_ptr audioRenderInterfaceImpl_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp deleted file mode 100644 index 03962b7a2f89882fded94ba373395a3b71b82ac0..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "audio_render_interface_impl_test.h" - -#include -#include -#include "sys/time.h" - -#include "daudio_constants.h" -#include "daudio_log.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioRenderInterfaceImplTest::SetUpTestCase(void) {} - -void AudioRenderInterfaceImplTest::TearDownTestCase(void) {} - -void AudioRenderInterfaceImplTest::SetUp(void) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - audioRenderInterfaceImpl_ = std::make_shared(adpName_, desc_, attrs_, callback_); -} - -void AudioRenderInterfaceImplTest::TearDown(void) -{ - audioRenderInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetLatency_001 - * @tc.desc: Verify the GetLatency function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetLatency_001, TestSize.Level1) -{ - uint32_t ms = 12; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetLatency(ms)); -} - -/** - * @tc.name: RenderFrame_001 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_001, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: RenderFrame_002 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_002, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - audioRenderInterfaceImpl_->renderStatus_ = RENDER_STATUS_START; - audioRenderInterfaceImpl_->audioExtCallback_ = nullptr; - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: RenderFrame_003 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_003, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - audioRenderInterfaceImpl_->renderStatus_ = RENDER_STATUS_START; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: GetRenderPosition_001 - * @tc.desc: Verify the GetRenderPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderPosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetRenderPosition(frames, time)); -} - -/** - * @tc.name: SetRenderSpeedr_001 - * @tc.desc: Verify the SetRenderSpeed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetRenderSpeed_001, TestSize.Level1) -{ - float speed = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetRenderSpeed(speed)); -} - -/** - * @tc.name: GetRenderSpeed_001 - * @tc.desc: Verify the GetRenderSpeed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderSpeed_001, TestSize.Level1) -{ - float speed; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetRenderSpeed(speed)); -} - -/** - * @tc.name: SetChannelMode_001 - * @tc.desc: Verify the SetChannelMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetChannelMode_001, TestSize.Level1) -{ - AudioChannelMode mode = AudioChannelMode::AUDIO_CHANNEL_NORMAL; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetChannelMode(mode)); -} - -/** - * @tc.name: GetChannelMode_001 - * @tc.desc: Verify the GetChannelMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetChannelMode_001, TestSize.Level1) -{ - AudioChannelMode mode = AudioChannelMode::AUDIO_CHANNEL_MIX; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetChannelMode(mode)); -} - -/** - * @tc.name: RegCallback_001 - * @tc.desc: Verify the RegCallback function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RegCallback_001, TestSize.Level1) -{ - sptr cbObj = nullptr; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->RegCallback(cbObj, 0)); -} - -/** - * @tc.name: DrainBuffer_001 - * @tc.desc: Verify the DrainBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, DrainBuffer_001, TestSize.Level1) -{ - AudioDrainNotifyType type = AudioDrainNotifyType::AUDIO_DRAIN_EARLY_MODE; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->DrainBuffer(type)); -} - -/** - * @tc.name: IsSupportsDrain_001 - * @tc.desc: Verify the IsSupportsDrain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, IsSupportsDrain_001, TestSize.Level1) -{ - bool support = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->IsSupportsDrain(support)); -} - -/** - * @tc.name: Start_001 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Start_002 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_002, TestSize.Level1) -{ - audioRenderInterfaceImpl_->firstOpenFlag_ = false; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Start_003 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_003, TestSize.Level1) -{ - audioRenderInterfaceImpl_->firstOpenFlag_ = false; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Stop_001 - * @tc.desc: Verify the Stop function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Stop_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Stop()); - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Stop()); -} - -/** - * @tc.name: Pause_001 - * @tc.desc: Verify the Pause function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Pause_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Pause()); -} - -/** - * @tc.name: Resume_001 - * @tc.desc: Verify the Resume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Resume_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Resume()); -} - -/** - * @tc.name: Flush_001 - * @tc.desc: Verify the Flush function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Flush_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Flush()); -} - -/** - * @tc.name: TurnStandbyMode_001 - * @tc.desc: Verify the TurnStandbyMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, TurnStandbyMode_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->TurnStandbyMode()); -} - -/** - * @tc.name: AudioDevDump_001 - * @tc.desc: Verify the AudioDevDump function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, AudioDevDump_001, TestSize.Level1) -{ - int32_t range = 0; - int32_t fd = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->AudioDevDump(range, fd)); -} - -/** - * @tc.name: IsSupportsPauseAndResume_001 - * @tc.desc: Verify the IsSupportsPauseAndResume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, IsSupportsPauseAndResume_001, TestSize.Level1) -{ - bool supportPause = true; - bool supportResume = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->IsSupportsPauseAndResume(supportPause, supportResume)); -} - -/** - * @tc.name: CheckSceneCapability_001 - * @tc.desc: Verify the CheckSceneCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, CheckSceneCapability_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - bool support = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->CheckSceneCapability(scene, support)); -} - -/** - * @tc.name: SelectScene_001 - * @tc.desc: Verify the SelectScene function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SelectScene_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SelectScene(scene)); -} - -/** - * @tc.name: SetMute_001 - * @tc.desc: Verify the SetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetMute(mute)); -} - -/** - * @tc.name: GetMute_001 - * @tc.desc: Verify the GetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetMute(mute)); -} - -/** - * @tc.name: SetVolume_001 - * @tc.desc: Verify the SetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetVolume(volume)); -} - -/** - * @tc.name: GetVolume_001 - * @tc.desc: Verify the GetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetVolume(volume)); -} - -/** - * @tc.name: GetGainThreshold_001 - * @tc.desc: Verify the GetGainThreshold function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetGainThreshold_001, TestSize.Level1) -{ - float min = 0; - float max = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetGainThreshold(min, max)); -} - -/** - * @tc.name: SetGain_001 - * @tc.desc: Verify the SetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetGain(gain)); -} - -/** - * @tc.name: GetGain_001 - * @tc.desc: Verify the GetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetGain(gain)); -} - -/** - * @tc.name: GetFrameSize_001 - * @tc.desc: Verify the GetFrameSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameSize_001, TestSize.Level1) -{ - uint64_t size = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameSize(size)); -} - -/** - * @tc.name: GetFrameCount_001 - * @tc.desc: Verify the GetFrameCount function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameCount_001, TestSize.Level1) -{ - uint64_t count = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameCount(count)); -} - -/** - * @tc.name: SetSampleAttributes_001 - * @tc.desc: Verify the SetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs = { - .type = AUDIO_IN_MEDIA, - .interleaved = true, - .format = AUDIO_FORMAT_TYPE_PCM_16_BIT, - .sampleRate = 44100, - .channelCount = 2, - .period = 1, - .frameSize = 1, - .isBigEndian = true, - .isSignedData = true, - .startThreshold = 1, - .stopThreshold = 1, - .silenceThreshold = 1, - .streamId = 1, - }; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetSampleAttributes_001 - * @tc.desc: Verify the GetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetCurrentChannelId_001 - * @tc.desc: Verify the GetCurrentChannelId function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetCurrentChannelId_001, TestSize.Level1) -{ - uint32_t channelId = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetCurrentChannelId(channelId)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList = "hello"; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetExtraParams(keyValueList)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetExtraParams(keyValueList)); -} - -/** - * @tc.name: ReqMmapBuffer_001 - * @tc.desc: Verify the ReqMmapBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, ReqMmapBuffer_001, TestSize.Level1) -{ - int32_t reqSize = 1; - AudioMmapBufferDescriptor desc; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->ReqMmapBuffer(reqSize, desc)); -} - -/** - * @tc.name: GetMmapPosition_001 - * @tc.desc: Verify the GetMmapPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMmapPosition_001, TestSize.Level1) -{ - uint64_t frame = 0; - AudioTimeStamp time = {1, 1}; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetMmapPosition(frame, time)); -} - -/** - * @tc.name: GetFrameBufferSize_001 - * @tc.desc: Verify the GetFrameBufferSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameBufferSize_001, TestSize.Level1) -{ - uint64_t bufferSize = 6; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameBufferSize(bufferSize)); -} - -/** - * @tc.name: RemoveAudioEffect_001 - * @tc.desc: Verify the RemoveAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RemoveAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->RemoveAudioEffect(effectid)); -} - - -/** - * @tc.name: AddAudioEffect_001 - * @tc.desc: Verify the AddAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, AddAudioEffect_001, TestSize.Level1) -{ - uint64_t id = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->AddAudioEffect(id)); -} - -/** - * @tc.name: GetRenderDesc_001 - * @tc.desc: Verify the GetRenderDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderDesc_001, TestSize.Level1) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - auto audioRenderInterfaceImplTmp = std::make_shared(adpName_, desc_, attrs_, callback_); - AudioDeviceDescriptor descriptorTmp = audioRenderInterfaceImplTmp->GetRenderDesc(); - - EXPECT_EQ(desc_.portId, descriptorTmp.portId); - EXPECT_EQ(desc_.pins, descriptorTmp.pins); - EXPECT_EQ(desc_.desc, descriptorTmp.desc); -} - -/** - * @tc.name: GetVolumeInner_001 - * @tc.desc: Verify the GetVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmp = 2; - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeInner(volTmp); - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->vol_, audioRenderInterfaceImpl_->GetVolumeInner()); -} - -/** - * @tc.name: GetMaxVolumeInner_001 - * @tc.desc: Verify the GetMaxVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMaxVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->volMax_, audioRenderInterfaceImpl_->GetMaxVolumeInner()); -} - -/** - * @tc.name: GetMinVolumeInner_001 - * @tc.desc: Verify the GetMinVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMinVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->volMin_, audioRenderInterfaceImpl_->GetMinVolumeInner()); -} - -/** - * @tc.name: GetFadeRate_001 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_001, TestSize.Level1) -{ - uint32_t currentIndex = 2; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_LE(0, fadeRate); - EXPECT_GE(0.5f, fadeRate); -} - -/** - * @tc.name: GetFadeRate_002 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_002, TestSize.Level1) -{ - uint32_t currentIndex = 3; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_LE(0.5f, fadeRate); - EXPECT_GE(1.0f, fadeRate); -} - -/** - * @tc.name: GetFadeRate_002 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_003, TestSize.Level1) -{ - uint32_t currentIndex = 6; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_EQ(1.0f, fadeRate); -} - -/** - * @tc.name: FadeInProcess_001 - * @tc.desc: Verify the FadeInProcess function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, FadeInProcess_001, TestSize.Level1) -{ - const uint32_t durationFrame = 10; - const size_t frameLength = 4096; - int8_t* frameData = new int8_t[frameLength]; - - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->FadeInProcess(durationFrame, frameData, frameLength)); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h deleted file mode 100644 index c67d95828f5acb046a6e52bbbfea49ef350f10e0..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#ifndef OHOS_DAUDIO_TEST_UTILS_H -#define OHOS_DAUDIO_TEST_UTILS_H - -#include -#include - -#include -#include -#include -#include - -#include "daudio_errcode.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::CurrentTime; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -using OHOS::HDI::DistributedAudio::Audio::V1_0::IAudioCallback; -class MockIDAudioCallback : public IDAudioCallback { -public: - MockIDAudioCallback() {} - ~MockIDAudioCallback() {} - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioRender : public IAudioRender { -public: - MockIAudioRender() {} - ~MockIAudioRender() {} - - int32_t GetLatency(uint32_t &ms) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RenderFrame(const std::vector &frame, uint64_t &replyBytes) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetRenderSpeed(float speed) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetRenderSpeed(float &speed) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetChannelMode(AudioChannelMode mode) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetChannelMode(AudioChannelMode &mode) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RegCallback(const sptr &audioCallback, int8_t cookie) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t DrainBuffer(AudioDrainNotifyType &type) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsDrain(bool &support) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SelectScene(const AudioSceneDescriptor &scene) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetMute(bool mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMute(bool &mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetVolume(float volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetVolume(float &volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGainThreshold(float &min, float &max) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetGain(float gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGain(float &gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameSize(uint64_t &size) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameCount(uint64_t &count) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCurrentChannelId(uint32_t &channelId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetExtraParams(const std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetExtraParams(std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AddAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RemoveAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameBufferSize(uint64_t &bufferSize) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Start() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Stop() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Pause() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Resume() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Flush() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t TurnStandbyMode() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AudioDevDump(int32_t range, int32_t fd) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioCapture : public IAudioCapture { -public: - MockIAudioCapture() {} - ~MockIAudioCapture() {} - - int32_t CaptureFrame(std::vector &frame, uint64_t &replyBytes) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SelectScene(const AudioSceneDescriptor &scene) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetMute(bool mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMute(bool &mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetVolume(float volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetVolume(float &volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGainThreshold(float &min, float &max) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGain(float &gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetGain(float gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameSize(uint64_t &size) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameCount(uint64_t &count) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCurrentChannelId(uint32_t &channelId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetExtraParams(const std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetExtraParams(std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AddAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RemoveAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameBufferSize(uint64_t &bufferSize) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Start() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Stop() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Pause() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Resume() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Flush() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t TurnStandbyMode() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AudioDevDump(int32_t range, int32_t fd) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioParamCallback : public IAudioCallback { -public: - MockIAudioParamCallback() {} - ~MockIAudioParamCallback() {} - - int32_t RenderCallback(AudioCallbackType type, int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ParamCallback(AudioExtParamKey key, const std::string& condition, const std::string& value, - int8_t &reserved, int8_t cookie) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockRevertIAudioParamCallback : public IAudioCallback { -public: - MockRevertIAudioParamCallback() {} - ~MockRevertIAudioParamCallback() {} - - int32_t RenderCallback(AudioCallbackType type, int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ParamCallback(AudioExtParamKey key, const std::string& condition, const std::string& value, - int8_t &reserved, int8_t cookie) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } -}; - -class MockRevertIDAudioCallback : public IDAudioCallback { -public: - MockRevertIDAudioCallback() {} - ~MockRevertIDAudioCallback() {} - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return DistributedHardware::DH_SUCCESS; - } -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_TEST_UTILS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn deleted file mode 100644 index 7661955ff9309e90980f620f8c61a6f5f1d753e8..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../distributedaudio.gni") - -ohos_shared_library("libdaudio_manager_daudio_ext_service_1.0") { - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - sources = [ "./src/daudio_manager_interface_impl.cpp" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "ipc:ipc_single", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - install_images = [ chipset_base_dir ] - subsystem_name = "distributedhardware" - part_name = "drivers_peripheral_distributed_audio" -} - -ohos_shared_library("libdaudio_ext_driver") { - include_dirs = [ "${hdf_ser_aud_ext_path}/include" ] - - sources = [ "./src/daudio_manager_driver.cpp" ] - - deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "hdf_core:libhdf_ipc_adapter", - "hdf_core:libhdf_utils", - "hdf_core:libhdi", - "hilog:libhilog", - "ipc:ipc_single", - ] - - shlib_type = "hdi" - install_images = [ chipset_base_dir ] - subsystem_name = "distributedhardware" - part_name = "drivers_peripheral_distributed_audio" -} - -group("hdf_daudio_ext_service") { - deps = [ - ":libdaudio_ext_driver", - ":libdaudio_manager_daudio_ext_service_1.0", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h deleted file mode 100644 index f2592ad5d2eaf66010c1879968ac1c86b39e8823..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H -#define OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H - -#include - -#include - -#include "audio_manager_interface_impl.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; - -class DAudioManagerInterfaceImpl : public IDAudioManager { -public: - static DAudioManagerInterfaceImpl *GetDAudioManager() - { - if (dAudioMgr_ == nullptr) { - std::unique_lock mgr_mutex(mgrMtx_); - if (dAudioMgr_ == nullptr) { - dAudioMgr_ = new DAudioManagerInterfaceImpl(); - } - } - return dAudioMgr_; - } - - ~DAudioManagerInterfaceImpl() override; - - int32_t RegisterAudioDevice(const std::string &adpName, int32_t devId, const std::string &capability, - const sptr &callbackObj) override; - - int32_t UnRegisterAudioDevice(const std::string &adpName, int32_t devId) override; - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override; - -private: - DAudioManagerInterfaceImpl(); - - DAudioManagerInterfaceImpl(const DAudioManagerInterfaceImpl &); - - DAudioManagerInterfaceImpl &operator = (const DAudioManagerInterfaceImpl &); - -private: - class Deletor { - public: - ~Deletor() - { - if (DAudioManagerInterfaceImpl::dAudioMgr_ != nullptr) { - delete DAudioManagerInterfaceImpl::dAudioMgr_; - } - }; - }; - static Deletor deletor; - -private: - OHOS::HDI::DistributedAudio::Audio::V1_0::AudioManagerInterfaceImpl *audioMgr_; - static DAudioManagerInterfaceImpl *dAudioMgr_; - static std::mutex mgrMtx_; -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp deleted file mode 100644 index 0ee8fef662747c3f6f1310a7f2cf498e7f4bebf4..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include -#include -#include -#include -#include - -using namespace OHOS::HDI::DistributedAudio::Audioext::V1_0; - -struct HdfDAudioManagerHost { - struct IDeviceIoService ioService; - OHOS::sptr stub; -}; - -static int32_t DAudioManagerDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, - struct HdfSBuf *reply) -{ - auto *hdfDAudioManagerHost = CONTAINER_OF(client->device->service, struct HdfDAudioManagerHost, ioService); - - OHOS::MessageParcel *dataParcel = nullptr; - OHOS::MessageParcel *replyParcel = nullptr; - OHOS::MessageOption option; - - if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - return hdfDAudioManagerHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); -} - -int HdfDAudioManagerDriverInit(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver init."); - HdfDeviceSetClass(deviceObject, DEVICE_CLASS_AUDIO); - return HDF_SUCCESS; -} - -int HdfDAudioManagerDriverBind(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver bind."); - - auto *hdfDAudioManagerHost = new (std::nothrow) HdfDAudioManagerHost; - if (hdfDAudioManagerHost == nullptr) { - HDF_LOGE("%{public}s: failed to create create HdfDAudioManagerHost object", __func__); - return HDF_FAILURE; - } - - hdfDAudioManagerHost->ioService.Dispatch = DAudioManagerDriverDispatch; - hdfDAudioManagerHost->ioService.Open = NULL; - hdfDAudioManagerHost->ioService.Release = NULL; - - auto serviceImpl = IDAudioManager::Get("daudio_ext_service", true); - if (serviceImpl == nullptr) { - HDF_LOGE("%{public}s: failed to get of implement service", __func__); - delete hdfDAudioManagerHost; - return HDF_FAILURE; - } - - hdfDAudioManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, - IDAudioManager::GetDescriptor()); - if (hdfDAudioManagerHost->stub == nullptr) { - HDF_LOGE("%{public}s: failed to get stub object", __func__); - delete hdfDAudioManagerHost; - return HDF_FAILURE; - } - - deviceObject->service = &hdfDAudioManagerHost->ioService; - return HDF_SUCCESS; -} - -void HdfDAudioManagerDriverRelease(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver release."); - if (deviceObject->service == nullptr) { - HDF_LOGE("HdfDAudioManagerDriverRelease not initted"); - return; - } - - auto *hdfDAudioManagerHost = CONTAINER_OF(deviceObject->service, struct HdfDAudioManagerHost, ioService); - delete hdfDAudioManagerHost; -} - -struct HdfDriverEntry g_daudiomanagerDriverEntry = { - .moduleVersion = 1, - .moduleName = "daudioext", - .Bind = HdfDAudioManagerDriverBind, - .Init = HdfDAudioManagerDriverInit, - .Release = HdfDAudioManagerDriverRelease, -}; - -#ifndef __cplusplus -extern "C" { -#endif -HDF_INIT(g_daudiomanagerDriverEntry); -#ifndef __cplusplus -} -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp deleted file mode 100644 index 9a492118de65d9818494d5f21d8f7c60a6f11159..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "daudio_manager_interface_impl.h" - -#include - -#include "daudio_errcode.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "DAudioManagerInterfaceImpl" - -using namespace OHOS::DistributedHardware; -using namespace OHOS::HDI::DistributedAudio::Audio::V1_0; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -DAudioManagerInterfaceImpl *DAudioManagerInterfaceImpl::dAudioMgr_ = nullptr; -std::mutex DAudioManagerInterfaceImpl::mgrMtx_; -extern "C" IDAudioManager *DAudioManagerImplGetInstance(void) -{ - return DAudioManagerInterfaceImpl::GetDAudioManager(); -} - -DAudioManagerInterfaceImpl::DAudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio ext manager constructed."); - audioMgr_ = AudioManagerInterfaceImpl::GetAudioManager(); -} - -DAudioManagerInterfaceImpl::~DAudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio ext manager destructed."); -} - -int32_t DAudioManagerInterfaceImpl::RegisterAudioDevice(const std::string &adpName, int32_t devId, - const std::string &capability, const sptr &callbackObj) -{ - DHLOGI("Register audio device, name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - - int32_t ret = audioMgr_->AddAudioDevice(adpName, devId, capability, callbackObj); - if (ret != DH_SUCCESS) { - DHLOGE("Register audio device failed, ret = %d", ret); - return HDF_FAILURE; - } - - DHLOGI("Register audio device success."); - return HDF_SUCCESS; -} - -int32_t DAudioManagerInterfaceImpl::UnRegisterAudioDevice(const std::string &adpName, int32_t devId) -{ - DHLOGI("UnRegister audio device, name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - - int32_t ret = audioMgr_->RemoveAudioDevice(adpName, devId); - if (ret != DH_SUCCESS) { - DHLOGE("UnRegister audio devcie failed. ret = %d", ret); - return HDF_FAILURE; - } - - DHLOGI("UnRegister audio device success."); - return HDF_SUCCESS; -} - -int32_t DAudioManagerInterfaceImpl::NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) -{ - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - DHLOGI("Notify event. event type = %d", event.type); - int32_t ret = audioMgr_->Notify(adpName, devId, event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio event failed. ret = %d", ret); - return HDF_FAILURE; - } - - return HDF_SUCCESS; -} -} // V1_0 -} // AudioExt -} // Daudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn deleted file mode 100644 index d790b56512f1c646d735b269eb0089139158d24a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("NotifyEventFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/notifyevent_fuzzer" - fuzz_config_file = "${hdf_ser_aud_ext_path}/test/fuzztest/notifyevent_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "notifyevent_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"NotifyEventFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":NotifyEventFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp deleted file mode 100644 index 3dcd510b8d048636ed37d008718cd1e34e12f225..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "notifyevent_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void NotifyEventFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - DAudioEvent event = { - .type = *(reinterpret_cast(data)), - .content = std::string(reinterpret_cast(data), size), - }; - - DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::NotifyEventFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h deleted file mode 100644 index 6bf2cbcce55e48e27e573764b13e350bd4df5314..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef NOTIFYEVENT_FUZZER_H -#define NOTIFYEVENT_FUZZER_H - -#define FUZZ_PROJECT_NAME "notifyevent_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn deleted file mode 100644 index 8d0f4724c7c9ebe9c17c94d00e3a7fe6c8034be2..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("RegisterAudioDeviceFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/registeraudiodevice_fuzzer" - fuzz_config_file = - "${hdf_ser_aud_ext_path}/test/fuzztest/registeraudiodevice_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "registeraudiodevice_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"RegisterAudioDeviceFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":RegisterAudioDeviceFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp deleted file mode 100644 index 5f20565b5adcc20b96bbc3702e986658fb5ca010..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "registeraudiodevice_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void RegisterAudioDeviceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - std::string capability(reinterpret_cast(data), size); - sptr callbackObj = nullptr; - - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::RegisterAudioDeviceFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h deleted file mode 100644 index 4fa65886db9c37f7e7f68fb82a251a6d594da850..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef REGISTERAUDIODEVICE_FUZZER_H -#define REGISTERAUDIODEVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "registeraudiodevice_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn deleted file mode 100644 index 0cb4c330e867f93486483647cecd1746b16c9cff..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2022 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("UnRegisterAudioDeviceFuzzTest") { - module_out_path = "${distributedaudio_fuzz_path}/unregisteraudiodevice_fuzzer" - fuzz_config_file = - "${hdf_ser_aud_ext_path}/test/fuzztest/unregisteraudiodevice_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "unregisteraudiodevice_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"UnRegisterAudioDeviceFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":UnRegisterAudioDeviceFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp deleted file mode 100644 index d64a5dd75950879345e111b5da5e59cf0686b6a1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "unregisteraudiodevice_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void UnRegisterAudioDeviceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::UnRegisterAudioDeviceFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h deleted file mode 100644 index 03b8e4fdd3cedbfb90171640e926effc557088f6..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef UNREGISTERAUDIODEVICE_FUZZER_H -#define UNREGISTERAUDIODEVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "unregisteraudiodevice_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn deleted file mode 100644 index e966cc5eaecea87d2c0c88ea1a3659bedd4b0d4f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio_ext" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_ext_path}/test/unittest/include", - "${hdf_ser_aud_ext_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_ext_v1_0_test -ohos_unittest("HDIServiceDaudioExtTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_ext_path}/test/unittest/src/daudio_manager_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_distributed_audio:libdaudio_stub_1.0", - "drivers_interface_distributed_audio:libdaudioext_stub_1.0", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_ext_test") { - testonly = true - deps = [ ":HDIServiceDaudioExtTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h deleted file mode 100644 index 3ac3bb496fa55c2cd5dbc7cbd2aa5c0e39ea1000..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H -#define OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H - -#include - -#include "daudio_test_utils.h" -#define private public -#include "daudio_manager_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -class DAudioManagerInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - sptr callbackObj_ = nullptr; -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h deleted file mode 100644 index e54fc355038c100f01d8063df9c9fc263f35b3a3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_DAUDIO_TEST_UTILS_H -#define OHOS_DAUDIO_TEST_UTILS_H - -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -class MockIDAudioCallback : public IDAudioCallback { -public: - virtual ~MockIDAudioCallback() = default; - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return 0; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return 0; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return 0; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return 0; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return 0; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return 0; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return 0; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return 0; - } -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_TEST_UTILS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp deleted file mode 100644 index 81516e178a1a0a46119182635b7836908fef6be7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "daudio_manager_interface_impl_test.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void DAudioManagerInterfaceImplTest::SetUpTestCase(void) {} - -void DAudioManagerInterfaceImplTest::TearDownTestCase(void) {} - -void DAudioManagerInterfaceImplTest::SetUp(void) -{ - callbackObj_ = new MockIDAudioCallback; -} - -void DAudioManagerInterfaceImplTest::TearDown(void) {} - -/** - * @tc.name: RegisterAudioDevice_001 - * @tc.desc: Verify the RegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, RegisterAudioDevice_001, TestSize.Level1) -{ - std::string adpName; - std::string capability; - int32_t devId = 11; - EXPECT_NE(HDF_SUCCESS, - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj_)); - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId)); -} - -/** - * @tc.name: RegisterAudioDevice_002 - * @tc.desc: Verify the RegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, RegisterAudioDevice_002, TestSize.Level1) -{ - std::string adpName = "hello"; - std::string capability = "world"; - int32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj_)); - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId)); -} - -/** - * @tc.name: UnRegisterAudioDevice_001 - * @tc.desc: Verify the UnRegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, UnRegisterAudioDevice_001, TestSize.Level1) -{ - std::string unadpName; - int32_t devId = 11; - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(unadpName, devId)); -} - -/** - * @tc.name: NotifyEvent_001 - * @tc.desc: Verify the NotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, NotifyEvent_001, TestSize.Level1) -{ - std::string adpName = "hello"; - int32_t devId = 11; - DAudioEvent event; - EXPECT_EQ(HDF_FAILURE, DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event)); -} - -/** - * @tc.name: NotifyEvent_002 - * @tc.desc: Verify the NotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, NotifyEvent_002, TestSize.Level1) -{ - std::string adpName = "hello"; - int32_t devId = 64; - DAudioEvent event; - event.type = 15; - event.content = "hello_world"; - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event)); -} -} // V1_0 -} // AudioExt -} // Daudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/common/BUILD.gn b/hdf_service/distributed_audio/hdi_service/common/BUILD.gn deleted file mode 100644 index f9b893abf3000e9b24991a8328e0a2a052cb328a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/BUILD.gn +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2022 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/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") - -ohos_shared_library("libdaudio_hdf_utils") { - include_dirs = [ - "include", - "log/include", - "utils/include", - "//third_party/cJSON", - ] - - sources = [ - "log/src/daudio_log.cpp", - "utils/src/daudio_utils.cpp", - ] - - deps = [ "//third_party/cJSON:cjson" ] - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_utils", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - install_images = [ chipset_base_dir ] - subsystem_name = "distributedhardware" - part_name = "drivers_peripheral_distributed_audio" -} diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h deleted file mode 100644 index d11b29114f84e08c1afd3e99f8b9a4e48e30e038..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_CONSTANTS_H -#define OHOS_DAUDIO_CONSTANTS_H - -#include - -namespace OHOS { -namespace DistributedHardware { -// Distributed Auido Parameters -const std::string KEY_AUDIOPORT_DIR = "portdir"; -const std::string KEY_AUDIOFORMAT = "format"; -const std::string KEY_AUDIOCHANNELMASK = "channel"; -const std::string KEY_AUDIOSAMPLERATE = "samplerate"; - -const std::string VALUE_AUDIOPORT_DIR_IN = "portdirin"; -const std::string VALUE_AUDIOPORT_DIR_OUT = "portdirout"; -const std::string VALUE_AUDIOPORT_DIR_INOUT = "portdirinout"; - -const std::string DEVICE_TYPE_OUTPUT_DEFAULT = "0"; -const std::string DEVICE_TYPE_INPUT_DEFAULT = "1"; - -const std::string VOLUME_GROUP_ID = "VOLUME_GROUP_ID"; -const std::string INTERRUPT_GROUP_ID = "INTERRUPT_GROUP_ID"; - -// Distributed Auido Parameters -const std::string VOLUME_LEVEL = "VOLUME_LEVEL"; -const std::string VOLUME_EVENT_TYPE = "EVENT_TYPE"; -const std::string MAX_VOLUME_LEVEL = "MAX_VOLUME_LEVEL"; -const std::string MIN_VOLUME_LEVEL = "MIN_VOLUME_LEVEL"; -const std::string STREAM_MUTE_STATUS = "STREAM_MUTE_STATUS"; - -const std::string HDF_EVENT_RESULT_SUCCESS = "DH_SUCCESS"; -const std::string HDF_EVENT_INIT_ENGINE_FAILED = "ERR_DH_AUDIO_INIT_ENGINE_FAILED"; -const std::string HDF_EVENT_NOTIFY_SINK_FAILED = "ERR_DH_AUDIO_NOTIFY_SINK_FAILED"; -const std::string HDF_EVENT_TRANS_SETUP_FAILED = "ERR_DH_AUDIO_TRANS_SETUP_FAILED"; -const std::string HDF_EVENT_TRANS_START_FAILED = "ERR_DH_AUDIO_TRANS_START_FAILED"; -const std::string HDF_EVENT_RESULT_FAILED = "DH_FAILED"; - -const std::string HDF_EVENT_RESTART = "restart"; -const std::string HDF_EVENT_PAUSE = "pause"; - -constexpr int32_t AUDIO_DEVICE_TYPE_UNKNOWN = 0; -constexpr int32_t AUDIO_DEVICE_TYPE_SPEAKER = 1; -constexpr int32_t AUDIO_DEVICE_TYPE_MIC = 2; - -constexpr uint32_t DAUDIO_FADE_NORMALIZATION_FACTOR = 2; -constexpr uint32_t DAUDIO_FADE_POWER_NUM = 2; -constexpr uint32_t DAUDIO_FADE_MAXIMUM_VALUE = 2; - -constexpr uint32_t VOLUME_GROUP_ID_DEFAULT = 0; -constexpr uint32_t INTERRUPT_GROUP_ID_DEFAULT = 0; - -constexpr uint32_t AUDIO_SAMPLE_RATE_DEFAULT = 4800; -constexpr uint32_t AUDIO_CHANNEL_COUNT_DEFAULT = 2; -constexpr uint32_t AUDIO_FORMAT_DEFAULT = 16; - -constexpr int32_t MILLISECOND_PER_SECOND = 1000; -constexpr uint32_t DEFAULT_AUDIO_DATA_SIZE = 4096; -constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; -constexpr int64_t MAX_TIME_INTERVAL_US = 23000; - -constexpr uint32_t AUDIO_DEFAULT_MAX_VOLUME_LEVEL = 15; -constexpr uint32_t AUDIO_DEFAULT_MIN_VOLUME_LEVEL = 0; - -constexpr int32_t DAUDIO_MAX_ASHMEM_LEN = 100000; -constexpr int32_t DAUDIO_MIN_ASHMEM_LEN = 10; - -constexpr const char *KEY_DH_ID = "dhId"; -constexpr int32_t LOW_LATENCY_RENDER_ID = 1 << 1 | 1 << 0; -constexpr int32_t DEFAULT_RENDER_ID = 1; -constexpr int32_t DEFAULT_CAPTURE_ID = 1 << 27 | 1 << 0; -} // DistributeHardware -} // OHOS -#endif // OHOS_DAUDIO_CONSTANTS_H diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h deleted file mode 100644 index b408d5698a2d3f11714dbbd41da4308ff327a447..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_ERRCODE_H -#define OHOS_DAUDIO_ERRCODE_H - -namespace OHOS { -namespace DistributedHardware { -enum DAudioErrorCode { - DH_SUCCESS = 0, - // Distributed Audio HDF Error Code - ERR_DH_AUDIO_HDF_FAIL = -46001, - ERR_DH_AUDIO_HDF_NULLPTR = -46002, - ERR_DH_AUDIO_HDF_INVALID_PARAM = -46003, - ERR_DH_AUDIO_HDF_REPEAT_OPERATION = -46004, - ERR_DH_AUDIO_HDF_INVALID_OPERATION = -46005, - ERR_DH_AUDIO_HDF_SET_PARAM_FAIL = -46006, - ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL = -46007, - ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL = -46008, - ERR_DH_AUDIO_COMMON_NOT_FOUND_KEY = -46009, - ERR_DH_AUDIO_HDF_WAIT_TIMEOUT = -46010, - - ERR_DH_AUDIO_HDF_INIT_ENGINE_FAILED = -46011, - ERR_DH_AUDIO_HDF_NOTIFY_SINK_FAILED = -46012, - ERR_DH_AUDIO_HDF_TRANS_SETUP_FAILED = -46013, - ERR_DH_AUDIO_HDF_TRANS_START_FAILED = -46014, - ERR_DH_AUDIO_HDF_RESULT_FAILED = -46015, -}; -} // Distributedaudio -} // OHOS -#endif diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h deleted file mode 100644 index c4355bfe8383ffd1640f15c1b4c4603a44bb294c..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_EVENTS_H -#define OHOS_DAUDIO_EVENTS_H - -namespace OHOS { -namespace DistributedHardware { -typedef enum AudioEventType { - HDF_AUDIO_DEVICE_ADD = 0x1, - HDF_AUDIO_DEVICE_REMOVE = 0x2, - HDF_AUDIO_LOAD_SUCCESS = 0x3, - HDF_AUDIO_LOAD_FAILURE = 0x4, - HDF_AUDIO_UNLOAD = 0x5, - HDF_AUDIO_SERVICE_VALID = 0x7, - HDF_AUDIO_SERVICE_INVALID = 0x8, - HDF_AUDIO_CAPTURE_THRESHOLD = 0x9, - HDF_AUDIO_EVENT_TYPE_UNKNOWN, -} EVENT_TYPE; - -typedef enum AudioDeviceType { - HDF_AUDIO_LINEOUT = 0x1, - HDF_AUDIO_HEADPHONE = 0x2, - HDF_AUDIO_HEADSET = 0x4, - HDF_AUDIO_USB_HEADSET = 0x8, - HDF_AUDIO_USB_HEADPHONE = 0x10, - HDF_AUDIO_USBA_HEADSET = 0x20, - HDF_AUDIO_USBA_HEADPHONE = 0x40, - HDF_AUDIO_PRIMARY_DEVICE = 0x80, - HDF_AUDIO_USB_DEVICE = 0x100, - HDF_AUDIO_A2DP_DEVICE = 0x200, - HDF_AUDIO_DEVICE_UNKNOWN, -} DEVICE_TYPE; - -typedef enum AudioExtParamEvent { - HDF_AUDIO_EVENT_PARAM_UNKNOWN = 0, - HDF_AUDIO_EVENT_VOLUME_SET = 1, - HDF_AUDIO_EVENT_VOLUME_GET = 2, - HDF_AUDIO_EVENT_VOLUME_CHANGE = 3, - HDF_AUDIO_EVENT_OPEN_SPK_RESULT = 4, - HDF_AUDIO_EVENT_CLOSE_SPK_RESULT = 5, - HDF_AUDIO_EVENT_OPEN_MIC_RESULT = 6, - HDF_AUDIO_EVENT_CLOSE_MIC_RESULT = 7, - HDF_AUDIO_EVENT_SPK_CLOSED = 8, - HDF_AUDIO_EVENT_MIC_CLOSED = 9, - HDF_AUDIO_EVENT_FOCUS_CHANGE = 10, - HDF_AUDIO_EVENT_RENDER_STATE_CHANGE = 11, - HDF_AUDIO_EVNET_MUTE_SET = 12, - HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS = 13, - HDF_AUDIO_EVENT_MMAP_START = 14, - HDF_AUDIO_EVENT_MMAP_STOP = 15, - HDF_AUDIO_EVENT_MMAP_START_MIC = 16, - HDF_AUDIO_EVENT_MMAP_STOP_MIC = 17, - HDF_AUDIO_EVENT_START = 18, - HDF_AUDIO_EVENT_STOP = 19, - HDF_AUDIO_EVENT_SPK_DUMP = 20, - HDF_AUDIO_EVENT_MIC_DUMP = 21, -} EXT_PARAM_EVENT; - -typedef enum AudioVolumeEvent { - VOLUME_EVENT_UNKNOWN = 0, - VOLUME_EVENT_BASE = 1, - VOLUME_EVENT_MIN = 2, - VOLUME_EVENT_MAX = 3, - VOLUME_EVENT_MUTE = 4, -} VOL_EVENT; -} // DistributedHardware -} // OHOS -#endif // OHOS_DAUDIO_EVENTS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h b/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h deleted file mode 100644 index 8edac1e71e1977b14eaf07dc5fc87b0bb977c718..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef OHOS_DAUDIO_LOG_H -#define OHOS_DAUDIO_LOG_H - -#include - -namespace OHOS { -namespace DistributedHardware { -typedef enum { - DH_LOG_DEBUG, - DH_LOG_INFO, - DH_LOG_WARN, - DH_LOG_ERROR, -} DHLogLevel; - -void DHLog(DHLogLevel logLevel, const char *fmt, ...); - -#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -} // Distributedaudio -} // OHOS -#endif diff --git a/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp b/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp deleted file mode 100644 index d690b231108d376298316759231f0b416cc2abce..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "daudio_log.h" - -#include -#include -#include "securec.h" - -#ifdef HI_LOG_ENABLE -#include "hilog/log.h" -#else -#endif - -namespace OHOS { -namespace DistributedHardware { -const std::string DAUDIO_LOG_TITLE_TAG = "DAUDIO"; - -static void DHLogOut(DHLogLevel logLevel, const char *logBuf) -{ -#ifdef HI_LOG_ENABLE - LogLevel hiLogLevel = LOG_INFO; - switch (logLevel) { - case DH_LOG_DEBUG: - hiLogLevel = LOG_DEBUG; - break; - case DH_LOG_INFO: - hiLogLevel = LOG_INFO; - break; - case DH_LOG_WARN: - hiLogLevel = LOG_WARN; - break; - case DH_LOG_ERROR: - hiLogLevel = LOG_ERROR; - break; - default: - break; - } - (void)HiLogPrint(LOG_CORE, hiLogLevel, LOG_DOMAIN, DAUDIO_LOG_TITLE_TAG.c_str(), "%{public}s", logBuf); -#else - switch (logLevel) { - case DH_LOG_DEBUG: - printf("[D]%s\n", logBuf); - break; - case DH_LOG_INFO: - printf("[I]%s\n", logBuf); - break; - case DH_LOG_WARN: - printf("[W]%s\n", logBuf); - break; - case DH_LOG_ERROR: - printf("[E]%s\n", logBuf); - break; - default: - break; - } -#endif -} - -void DHLog(DHLogLevel logLevel, const char *fmt, ...) -{ - constexpr int32_t logMaxLen = 4096; - char logBuf[logMaxLen] = {0}; - va_list arg; - va_start(arg, fmt); - - int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); - va_end(arg); - if (ret < 0) { - DHLogOut(logLevel, "DH log length error."); - return; - } - DHLogOut(logLevel, logBuf); -} -} // Distributedaudio -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h b/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h deleted file mode 100644 index 4d87892aeae77aeb6827bb585b57737440fcb4c1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#ifndef OHOS_DAUDIO_UTILS_H -#define OHOS_DAUDIO_UTILS_H - -#include -#include - -#define AUDIO_MS_PER_SECOND 1000 -#define AUDIO_US_PER_SECOND 1000000 -#define AUDIO_NS_PER_SECOND ((int64_t)1000000000) -namespace OHOS { -namespace DistributedHardware { -std::string GetAnonyString(const std::string &value); - -int32_t GetAudioParamStr(const std::string ¶ms, const std::string &key, std::string &value); - -int32_t GetAudioParamInt(const std::string ¶ms, const std::string &key, int32_t &value); - -int32_t GetAudioParamUInt(const std::string ¶ms, const std::string &key, uint32_t &value); - -int32_t GetAudioParamBool(const std::string ¶ms, const std::string &key, bool &value); - -int32_t SetAudioParamStr(std::string ¶ms, const std::string &key, const std::string &value); - -int32_t GetDevTypeByDHId(int32_t dhId); - -int64_t GetNowTimeUs(); - -uint32_t CalculateFrameSize(uint32_t sampleRate, uint32_t channelCount, - int32_t format, uint32_t timeInterval, bool isMMAP); - -int32_t CalculateSampleNum(uint32_t sampleRate, uint32_t timems); - -int64_t GetCurNano(); - -int32_t AbsoluteSleep(int64_t nanoTime); - -int64_t CalculateOffset(const int64_t frameindex, const int64_t framePeriodNs, const int64_t startTime); - -int64_t UpdateTimeOffset(const int64_t frameIndex, const int64_t framePeriodNs, int64_t &startTime); - -bool IsOutDurationRange(int64_t startTime, int64_t endTime, int64_t lastStartTime); - -void SaveFile(std::string fileName, uint8_t *audioData, int32_t size); - -int32_t WrapCJsonItem(const std::initializer_list> &keys, std::string &content); - -bool CheckIsNum(const std::string &jsonString); -} // DistributedHardware -} // OHOS -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp b/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp deleted file mode 100644 index 2c1d231c3c28abd606fa46505867dd922c252ef9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -#include "daudio_utils.h" - -#include - -#include "cJSON.h" - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "DAudioUtils" - -namespace OHOS { -namespace DistributedHardware { -constexpr size_t INT32_SHORT_ID_LENGTH = 20; -constexpr size_t INT32_PLAINTEXT_LENGTH = 4; -constexpr size_t INT32_MIN_ID_LENGTH = 3; -constexpr uint8_t MAX_KEY_DH_ID_LEN = 20; - -std::string GetAnonyString(const std::string &value) -{ - std::string res; - std::string tmpStr("******"); - size_t strLen = value.length(); - if (strLen < INT32_MIN_ID_LENGTH) { - return tmpStr; - } - - if (strLen <= INT32_SHORT_ID_LENGTH) { - res += value[0]; - res += tmpStr; - res += value[strLen - 1]; - } else { - res.append(value, 0, INT32_PLAINTEXT_LENGTH); - res += tmpStr; - res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); - } - - return res; -} - -int32_t GetAudioParamStr(const std::string ¶ms, const std::string &key, std::string &value) -{ - size_t step = key.size(); - if (step >= params.size()) { - return ERR_DH_AUDIO_HDF_FAIL; - } - size_t pos = params.find(key); - if (pos == params.npos || params.at(pos + step) != '=') { - return ERR_DH_AUDIO_COMMON_NOT_FOUND_KEY; - } - size_t splitPosEnd = params.find(';', pos); - if (splitPosEnd != params.npos) { - value = params.substr(pos + step + 1, splitPosEnd - pos - step - 1); - } else { - value = params.substr(pos + step + 1); - } - return DH_SUCCESS; -} - -int32_t GetAudioParamInt(const std::string ¶ms, const std::string &key, int32_t &value) -{ - std::string val = "-1"; - int32_t ret = GetAudioParamStr(params, key, val); - if (!CheckIsNum(val)) { - DHLOGE("String is not number. str:%s.", val.c_str()); - return -1; - } - value = std::stoi(val); - return ret; -} - -bool CheckIsNum(const std::string &jsonString) -{ - if (jsonString.empty() || jsonString.size() > MAX_KEY_DH_ID_LEN) { - DHLOGE("Json string size %d, is zero or too long.", jsonString.size()); - return false; - } - for (char const &c : jsonString) { - if (!std::isdigit(c)) { - DHLOGE("Json string is not number."); - return false; - } - } - return true; -} - -int32_t GetAudioParamUInt(const std::string ¶ms, const std::string &key, uint32_t &value) -{ - value = 0; - return DH_SUCCESS; -} - -int32_t GetAudioParamBool(const std::string ¶ms, const std::string &key, bool &value) -{ - std::string val; - GetAudioParamStr(params, key, val); - value = (val != "0"); - return DH_SUCCESS; -} - -int32_t SetAudioParamStr(std::string ¶ms, const std::string &key, const std::string &value) -{ - params = params + key + '=' + value + ';'; - return DH_SUCCESS; -} - -int32_t GetDevTypeByDHId(int32_t dhId) -{ - if ((uint32_t)dhId & 0x8000000) { - return AUDIO_DEVICE_TYPE_MIC; - } else if ((uint32_t)dhId & 0x7ffffff) { - return AUDIO_DEVICE_TYPE_SPEAKER; - } - return AUDIO_DEVICE_TYPE_UNKNOWN; -} - -int64_t GetNowTimeUs() -{ - std::chrono::microseconds nowUs = - std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); - return nowUs.count(); -} - -uint32_t CalculateFrameSize(uint32_t sampleRate, uint32_t channelCount, - int32_t format, uint32_t timeInterval, bool isMMAP) -{ - return isMMAP ? (sampleRate * channelCount * static_cast(format) * timeInterval) / - AUDIO_MS_PER_SECOND : DEFAULT_AUDIO_DATA_SIZE; -} - -int32_t CalculateSampleNum(uint32_t sampleRate, uint32_t timems) -{ - return (sampleRate * timems) / AUDIO_MS_PER_SECOND; -} - -int64_t GetCurNano() -{ - int64_t result = -1; - struct timespec time; - clockid_t clockId = CLOCK_MONOTONIC; - int ret = clock_gettime(clockId, &time); - if (ret < 0) { - return result; - } - result = (time.tv_sec * AUDIO_NS_PER_SECOND) + time.tv_nsec; - return result; -} - -int32_t AbsoluteSleep(int64_t nanoTime) -{ - int32_t ret = -1; - if (nanoTime <= 0) { - return ret; - } - struct timespec time; - time.tv_sec = nanoTime / AUDIO_NS_PER_SECOND; - time.tv_nsec = nanoTime - (time.tv_sec * AUDIO_NS_PER_SECOND); - - clockid_t clockId = CLOCK_MONOTONIC; - ret = clock_nanosleep(clockId, TIMER_ABSTIME, &time, nullptr); - return ret; -} - -int64_t CalculateOffset(const int64_t frameIndex, const int64_t framePeriodNs, const int64_t startTime) -{ - int64_t totalOffset = GetCurNano() - startTime; - return totalOffset - frameIndex * framePeriodNs; -} - -int64_t UpdateTimeOffset(const int64_t frameIndex, const int64_t framePeriodNs, int64_t &startTime) -{ - int64_t timeOffset = 0; - if (frameIndex == 0) { - startTime = GetCurNano(); - } else if (frameIndex % AUDIO_OFFSET_FRAME_NUM == 0) { - timeOffset = CalculateOffset(frameIndex, framePeriodNs, startTime); - } - return timeOffset; -} - -bool IsOutDurationRange(int64_t startTime, int64_t endTime, int64_t lastStartTime) -{ - int64_t currentInterval = endTime - startTime; - int64_t twiceInterval = startTime - lastStartTime; - return (currentInterval > MAX_TIME_INTERVAL_US || twiceInterval > MAX_TIME_INTERVAL_US) ? true : false; -} - -void SaveFile(std::string fileName, uint8_t *audioData, int32_t size) -{ - std::ofstream ofs(fileName, std::ios::binary | std::ios::out | std::ios::app); - if (!ofs.is_open()) { - return; - } - ofs.write(reinterpret_cast(audioData), size); - ofs.close(); -} - -int32_t WrapCJsonItem(const std::initializer_list> &keys, std::string &content) -{ - cJSON *jParam = cJSON_CreateObject(); - if (jParam == nullptr) { - return ERR_DH_AUDIO_HDF_FAIL; - } - for (auto item : keys) { - cJSON_AddStringToObject(jParam, item.first.c_str(), item.second.c_str()); - } - char *jsonData = cJSON_PrintUnformatted(jParam); - if (jsonData == nullptr) { - cJSON_Delete(jParam); - return ERR_DH_AUDIO_HDF_FAIL; - } - content = std::string(jsonData); - cJSON_Delete(jParam); - cJSON_free(jsonData); - return DH_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h deleted file mode 100644 index dccb1f8ed4b617739309170ff512fe4f4ccda756..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_ADAPTER_H -#define HDF_I_AUDIO_ADAPTER_H - -#include -#include - -#include "i_audio_capture.h" -#include "i_audio_render.h" -#include "i_audio_param_callback.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -using RenderHandle = uint64_t; -using CaptureHandle = uint64_t; -using RouteHandle = int32_t; - -class IAudioAdapter { -public: - virtual int32_t InitAllPorts() = 0; - - virtual int32_t CreateRender(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, - RenderHandle &handle, IAudioRender &render) = 0; - - virtual int32_t DestoryRender(const RenderHandle handle) = 0; - - virtual int32_t CreateCapture(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, - CaptureHandle &handle, IAudioCapture &capture) = 0; - - virtual int32_t DestoryCapture(const CaptureHandle handle) = 0; - - virtual int32_t GetPortCapability(const AudioPortHAL &port, AudioPortCapabilityHAL &capability) = 0; - - virtual int32_t SetPassthroughMode(const AudioPortHAL &port, const AudioPortPassthroughModeHAL mode) = 0; - - virtual int32_t GetPassthroughMode(const AudioPortHAL &port, AudioPortPassthroughModeHAL &mode) = 0; - - virtual int32_t UpdateAudioRoute(const AudioRouteHAL &route, RouteHandle &handle) = 0; - - virtual int32_t ReleaseAudioRoute(const RouteHandle handle) = 0; - - virtual int32_t SetAudioParameters(const std::vector ¶m) = 0; - - virtual int32_t GetAudioParameters(std::vector ¶m) = 0; - - virtual int32_t RegAudioParamObserver(IAudioParamCallback &cbObj) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_ADAPTER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h deleted file mode 100644 index bdd42446dc54a6cd197d7d58b9122b09d4e4f9a2..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_ATTRIBUTE_H -#define HDF_I_AUDIO_ATTRIBUTE_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioAttribute { - virtual int32_t GetFrameSize(uint64_t &size) = 0; - - virtual int32_t GetFrameCount(uint64_t &count) = 0; - - virtual int32_t SetSampleAttributes(const AudioSampleAttributesHAL &attrs) = 0; - - virtual int32_t GetSampleAttributes(AudioSampleAttributesHAL &attrs) = 0; - - virtual int32_t GetCurrentChannelId(uint32_t &channelId) = 0; - - virtual int32_t SetExtraParams(const std::string &keyValueList) = 0; - - virtual int32_t GetExtraParams(std::string &keyValueList) = 0; - - virtual int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptorHAL &desc) = 0; - - virtual int32_t GetMmapPosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_ATTRIBUTE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h deleted file mode 100644 index 77466e0f68235d2269d3019d064b0b42eb38ce93..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_CAPTURE_H -#define HDF_I_AUDIO_CAPTURE_H - -#include -#include - -#include "i_audio_attribute.h" -#include "i_audio_control.h" -#include "i_audio_scene.h" -#include "i_audio_volume.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioCapture : public IAudioControl, public IAudioAttribute, public IAudioScene, public IAudioVolume { -public: - virtual int32_t GetCapturePosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; - - virtual int32_t CaptureFrame(std::vector &frame, const uint64_t requestBytes, uint64_t &replyBytes) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_CAPTURE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h deleted file mode 100644 index e0efb5dbf2ba5238fd1b158c976d0ee609b22e80..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_CONTROL_H -#define HDF_I_AUDIO_CONTROL_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioControl { -public: - virtual int32_t Start() = 0; - - virtual int32_t Stop() = 0; - - virtual int32_t Pause() = 0; - - virtual int32_t Resume() = 0; - - virtual int32_t Flush() = 0; - - virtual int32_t TurnStandbyMode() = 0; - - virtual int32_t AudioDevDump(const int32_t range, const int32_t fd) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_CONTROL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h deleted file mode 100644 index 6b7f9b8bae60a25e53fa2a58ea9eb31b8cdd1593..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_MANAGER_H -#define HDF_I_AUDIO_MANAGER_H - -#include -#include - -#include "i_audio_adapter.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -using AdapterHandler = uint64_t; - -class IAudioManager { -public: - virtual int32_t GetAllAdapters(std::vector &descriptors) = 0; - - virtual int32_t LoadAdapter(const AudioAdapterDescriptorHAL &descriptor, AdapterHandler &handler, - IAudioAdapter &adapter) = 0; - - virtual int32_t UnloadAdapter(const AdapterHandler &handler) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_MANAGER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h deleted file mode 100644 index 47f761a728cc00d57669c91d872d1bd255f1d7da..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_PARAM_CALLBACK_H -#define HDF_I_AUDIO_PARAM_CALLBACK_H - -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioParamCallback { -public: - virtual int32_t OnAudioParamNotify(const AudioParameter ¶m) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_PARAM_CALLBACK_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h deleted file mode 100644 index 5a077e30f02b790a1040f2b321bfa615370a9386..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_RENDER_H -#define HDF_I_AUDIO_RENDER_H - -#include -#include - -#include "i_audio_attribute.h" -#include "i_audio_control.h" -#include "i_audio_scene.h" -#include "i_audio_render_callback.h" -#include "i_audio_volume.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioRender : public IAudioControl, public IAudioAttribute, public IAudioScene, public IAudioVolume { -public: - virtual int32_t GetLatency(uint32_t &ms) = 0; - - virtual int32_t RenderFrame(const std::vector &frame, const uint64_t requestBytes, - uint64_t &replyBytes) = 0; - - virtual int32_t GetRenderPosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; - - virtual int32_t SetRenderSpeed(const float speed) = 0; - - virtual int32_t GetRenderSpeed(float &speed) = 0; - - virtual int32_t SetChannelMode(const AudioChannelModeHAL &mode) = 0; - - virtual int32_t GetChannelMode(AudioChannelModeHAL &mode) = 0; - - virtual int32_t RegCallback(IAudioRenderCallback &cbObj) = 0; - - virtual int32_t DrainBuffer(const AudioDrainNotifyTypeHAL &type) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_RENDER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h deleted file mode 100644 index 8c330efde177022b97d466e08af6a47452aaaf92..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_RENDER_CALLBACK_H -#define HDF_I_AUDIO_RENDER_CALLBACK_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioRenderCallback { -public: - virtual int32_t OnAudioWriteCompleted() = 0; - - virtual int32_t OnAudioDrainCompleted() = 0; - - virtual int32_t OnAudioFlushCompleted() = 0; - - virtual int32_t OnAudioRenderFull() = 0; - - virtual int32_t OnAudioErrorOccur() = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_RENDER_CALLBACK_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h deleted file mode 100644 index bc647bc93b93d6aae82f910c68e0caafb9171f5d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_SCENE_H -#define HDF_I_AUDIO_SCENE_H - -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioScene { -public: - virtual int32_t CheckSceneCapability(const AudioSceneDescriptorHAL &scene, bool &support) = 0; - - virtual int32_t SelectScene(const AudioSceneDescriptorHAL &scene) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_SCENE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h deleted file mode 100644 index 0dae40c23976435486217269693badb5a09463d1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_VOLUME_H -#define HDF_I_AUDIO_VOLUME_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioVolume { -public: - virtual int32_t SetMute(const bool mute) = 0; - - virtual int32_t GetMute(bool &mute) = 0; - - virtual int32_t SetVolume(const float volume) = 0; - - virtual int32_t GetVolume(float &volume) = 0; - - virtual int32_t GetGainThreshold(float &min, float &max) = 0; - - virtual int32_t SetGain(const float gain) = 0; - - virtual int32_t GetGain(float &gain) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_VOLUME_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/types.h b/hdf_service/distributed_audio/interface/audio/v1_0/types.h deleted file mode 100644 index 8c43331f1834971fc684a5cc0eca2e03b31757cc..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/types.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_AUDIO_TYPES_H -#define HDF_I_AUDIO_TYPES_H - -#include -#include - -namespace OHOS { -namespace DistributedHardware { -enum AudioChannelModeHAL { - AUDIO_CHANNEL_NORMAL = 0, - AUDIO_CHANNEL_BOTH_LEFT, - AUDIO_CHANNEL_BOTH_RIGHT, - AUDIO_CHANNEL_EXCHANGE, - - AUDIO_CHANNEL_MIX, - AUDIO_CHANNEL_LEFT_MUTE, - AUDIO_CHANNEL_RIGHT_MUTE, - AUDIO_CHANNEL_BOTH_MUTE, -}; - -enum AudioDrainNotifyTypeHAL { - AUDIO_DRAIN_NORMAL_MODE, - AUDIO_DRAIN_EARLY_MODE, -}; - -enum AudioPortPassthroughModeHAL { - PORT_PASSTHROUGH_LPCM = 0x1, - PORT_PASSTHROUGH_RAW = 0x2, - PORT_PASSTHROUGH_HBR2LBR = 0x4, - PORT_PASSTHROUGH_AUTO = 0x8, -}; - -struct AudioDeviceDescriptorHAL { - uint32_t portId; - uint32_t pins; - std::string desc; -}; - -struct AudioSceneDescriptorHAL { - uint32_t id; - AudioDeviceDescriptorHAL desc; -}; - -struct AudioPortHAL { - uint32_t dir; - uint32_t portId; - std::string portName; -}; - -struct AudioAdapterDescriptorHAL { - std::string adapterName; - std::vector ports; -}; - -struct AudioTimeStampHAL { - uint64_t tvSec; - uint64_t tvNSec; -}; - -struct AudioSampleAttributesHAL { - uint32_t type; - uint32_t interleaved; - uint32_t format; - uint32_t sampleRate; - uint32_t channelCount; - - uint32_t period; - uint32_t frameSize; - uint32_t isBigEndian; - uint32_t isSignedData; - uint32_t startThreshold; - uint32_t stopThreshold; - uint32_t silenceThreshold; - uint32_t streamId; -}; - -struct AudioSubPortCapabilityHAL { - uint32_t portId; - uint32_t mask; - std::string desc; -}; - -struct AudioPortCapabilityHAL { - uint32_t deviceType; - uint32_t deviceId; - uint32_t hardwareMode; - uint32_t formatNum; - std::vector formats; - uint32_t sampleRateMasks; - uint32_t channelMasks; - uint32_t channelCount; - uint32_t subPortsNum; - AudioSubPortCapabilityHAL subPorts; -}; - -struct AudioDevExtInfoHAL { - int32_t moduleId; - uint32_t type; - uint8_t desc[32]; -}; - -struct AudioMixExtInfoHAL { - int32_t moduleId; - int32_t streamId; -}; - -struct AudioSessionInfoHAL { - uint32_t sessionType; -}; - -struct AudioRouteNodeHAL { - int32_t portId; - uint32_t role; - uint32_t type; - struct AudioDevExtInfoHAL device; - struct AudioMixExtInfoHAL mix; - struct AudioSessionInfoHAL session; -}; - -struct AudioRouteHAL { - std::vector sources; - std::vector sinks; -}; - -struct AudioParameter { - uint32_t paramType; - uint32_t value; - std::string content; -}; - -struct AudioMmapBufferDescriptorHAL { - int32_t memoryFd; - int32_t totalBufferFrames; - int32_t transferFrameSize; - int32_t isShareable; -}; - -} // namespace DistributedHardware -} // namespace OHOS -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h deleted file mode 100644 index c5fb27a00b7593db46d339cebdd374af0ad4c7b8..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_DAUDIO_HDF_CALLBACK_H -#define HDF_I_DAUDIO_HDF_CALLBACK_H - -#include -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IDAudioHDFCallback { -public: - virtual int32_t OpenDevice(int32_t devId, int32_t dhId) = 0; - virtual int32_t CloseDevice(int32_t devId, int32_t dhId = 0; - virtual int32_t SetParameters(int32_t devId, int32_t dhId, struct AudioParameter ¶m) = 0; - virtual int32_t NotifyEvent(int32_t devId, int32_t dhId, struct DAudioEvent &event) = 0; - virtual int32_t WriteStreamData(int32_t devId, int32_t dhId, struct AudioStreamData &data) = 0; - virtual struct AudioStreamData* ReadStreamData(int32_t devId, int32_t dhId) = 0; - virtual int32_t ReadMmapPosition(int32_t devId, int32_t dhId, - uint64_t &frames, struct CurrentTime &time) = 0; - virtual int32_t RefreshAshmemInfo(int32_t devId, int32_t dhId, - int32_t fd, int32_t ashmemLength, int32_t lengthPerTrans) = 0; -} // namespace DistributedHardware -} // namespace OHOS -} // HDF_I_DAUDIO_HDF_CALLBACK_H -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h deleted file mode 100644 index 330fe73be4ac196dd03299dcef6b01742a80ffa9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#ifndef HDF_I_DAUDIO_MANGER_H -#define HDF_I_DAUDIO_MANGER_H - -#include - -#include "i_daudio_hdf_callback.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IDAudioManager { -public: - virtual int32_t RegisterAudioDevice(std::string devId, std::string dhId, struct AudioParameter ¶m, - IDAudioHDFCallback callback) = 0; - - virtual int32_t UnRegisterAudioDevice(std::string devId, std::string dhId) = 0; - - virtual int32_t NotifyEvent(std::string devId, std::string dhId, struct DAudioEvent &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_DAUDIO_MANGER_H diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h deleted file mode 100644 index 209739307e0983c526bfce3c4c551b828ca485af..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include - -struct AudioParameter { - uint32_t paramType; - uint32_t value; - std::string content; -} - -struct AudioStreamData { - std::string data; -} - -typedef struct { - int type; - std::string content; -} DAudioEvent; diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn index de881de9cef80c3ac8751d08a1d7cd490ffc22ff..5e3e3b7b6859d75dc3d3670704ccadac450f11f2 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn @@ -19,20 +19,6 @@ group("fuzztest") { testonly = true deps = [ - "${hdf_ser_aud_ext_path}/test/fuzztest/notifyevent_fuzzer:fuzztest", - "${hdf_ser_aud_ext_path}/test/fuzztest/registeraudiodevice_fuzzer:fuzztest", - "${hdf_ser_aud_ext_path}/test/fuzztest/unregisteraudiodevice_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/captureframe_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/createcapture_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/createrender_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/destroycapture_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/destroyrender_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/getalladapters_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/getextraparams_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/loadadapter_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/renderframe_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/setextraparams_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/unloadadapter_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkservicedaudionotify_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkserviceinitsink_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkservicereleasesink_fuzzer:fuzztest", diff --git a/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn index 5a38bac4a76db8a2012fca293b739692e5c26df6..0e901571e8b65106d8ca0a9b940613d1011f6872 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn @@ -20,8 +20,6 @@ group("unittest") { deps = [ "${common_path}/test/unittest:daudio_utils_test", "${distributedaudio_path}/audiohandler/test/unittest:audio_handler_test", - "${hdf_service_path}/hdi_service/audio/v1_0/test/unittest:hdi_service_audio_test", - "${hdf_service_path}/hdi_service/audio_ext/v1_0/test/unittest:hdi_service_audio_ext_test", "${interfaces_path}/inner_kits/native_cpp/test/unittest/audiosinktest:audio_sink_test", "${interfaces_path}/inner_kits/native_cpp/test/unittest/audiosourcetest:audio_source_test", "${services_path}/audioclient/test/unittest:daudio_client_test", diff --git a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/BUILD.gn b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/BUILD.gn index 7f07e30b0984e134437f14987d5bfa7948e393dd..a0ca7982e9db40118c452bb0f8633031ff35adfd 100644 --- a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/BUILD.gn +++ b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/BUILD.gn @@ -42,7 +42,6 @@ ohos_unittest("DAudioHdiHandlerTest") { configs = [ ":module_private_config" ] deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/audiomanager/servicesource:distributed_audio_source", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", @@ -50,6 +49,7 @@ ohos_unittest("DAudioHdiHandlerTest") { external_deps = [ "c_utils:utils", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "ipc:ipc_core", ] } diff --git a/services/audiohdiproxy/test/unittest/daudio_manager_callback/BUILD.gn b/services/audiohdiproxy/test/unittest/daudio_manager_callback/BUILD.gn index 64312074c072f698ade5cbd2f1a83c36d7859450..62d278e2e348ff76e656e34f4ac402f48f0d0ab8 100644 --- a/services/audiohdiproxy/test/unittest/daudio_manager_callback/BUILD.gn +++ b/services/audiohdiproxy/test/unittest/daudio_manager_callback/BUILD.gn @@ -46,7 +46,6 @@ ohos_unittest("DAudioManagerCallbackTest") { configs = [ ":module_private_config" ] deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/audiomanager/servicesource:distributed_audio_source", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gmock", @@ -55,6 +54,7 @@ ohos_unittest("DAudioManagerCallbackTest") { external_deps = [ "c_utils:utils", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "ipc:ipc_core", ] } diff --git a/services/audiomanager/servicesource/BUILD.gn b/services/audiomanager/servicesource/BUILD.gn index b055f8ffd8cc8a7a8141dc5fb691a6e3d29861f2..9f9354e3cf2edfdda6278751cdb3bd511a2cfe3f 100755 --- a/services/audiomanager/servicesource/BUILD.gn +++ b/services/audiomanager/servicesource/BUILD.gn @@ -94,7 +94,6 @@ ohos_shared_library("distributed_audio_source") { "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", "${distributedaudio_path}/audiohandler:distributed_audio_handler", - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/common:distributed_audio_utils", "${services_path}/hdfaudioclient:daudio_client", "//third_party/cJSON:cjson", @@ -107,6 +106,7 @@ ohos_shared_library("distributed_audio_source") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", "drivers_interface_audio:libaudio_proxy_1.0", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hdf_core:libhdi", diff --git a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn index ca946248db604f1ed4ac30c99a06006e6da17d09..471bd43054fc427a5e23d7483355459f1d1b4a5a 100644 --- a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn +++ b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("DaudioSourceDevTest") { deps = [ "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/audiomanager/servicesource:distributed_audio_source", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gmock", @@ -83,6 +82,7 @@ ohos_unittest("DaudioSourceDevTest") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", "drivers_interface_audio:libaudio_proxy_1.0", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "dsoftbus:softbus_client", "ipc:ipc_core", "samgr:samgr_proxy", @@ -99,7 +99,6 @@ ohos_unittest("DMicDevTest") { deps = [ "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/audiomanager/servicesource:distributed_audio_source", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", @@ -108,6 +107,7 @@ ohos_unittest("DMicDevTest") { external_deps = [ "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "ipc:ipc_core", "samgr:samgr_proxy", ] @@ -123,7 +123,6 @@ ohos_unittest("DSpeakerDevTest") { deps = [ "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${services_path}/audiomanager/servicesource:distributed_audio_source", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", @@ -132,6 +131,7 @@ ohos_unittest("DSpeakerDevTest") { external_deps = [ "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/services/audiomanager/test/unittest/sourcemanager/BUILD.gn b/services/audiomanager/test/unittest/sourcemanager/BUILD.gn index fe5139cf0615eb9ca4550e9491d40487ddd8b111..2acf745d2f7f476c515739d2d2d08f603c00b757 100644 --- a/services/audiomanager/test/unittest/sourcemanager/BUILD.gn +++ b/services/audiomanager/test/unittest/sourcemanager/BUILD.gn @@ -67,7 +67,6 @@ ohos_unittest("DaudioSourceMgrTest") { configs = [ ":module_private_config" ] deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_proxy_1.0", "${innerkits_path}/native_cpp/audio_source:distributed_audio_source_sdk", "${services_path}/audiomanager/servicesource:distributed_audio_source", "${services_path}/common:distributed_audio_utils", @@ -80,6 +79,7 @@ ohos_unittest("DaudioSourceMgrTest") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", "drivers_interface_audio:libaudio_proxy_1.0", + "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "dsoftbus:softbus_client", "hdf_core:libhdi", "ipc:ipc_core", diff --git a/services/hdfaudioclient/BUILD.gn b/services/hdfaudioclient/BUILD.gn index b90f5aa907d75edac3b0bdcc69d96fa31461e95c..29c08e25d51cfc3e476a108bf467648319adf8e0 100644 --- a/services/hdfaudioclient/BUILD.gn +++ b/services/hdfaudioclient/BUILD.gn @@ -40,14 +40,11 @@ ohos_shared_library("daudio_client") { "./src/distributed_audio_client.cpp", ] - public_deps = [ - "${hdf_interfaces_path}/audio/v1_0:libdaudio_proxy_1.0", - "${services_path}/common:distributed_audio_utils", - ] + public_deps = [ "${services_path}/common:distributed_audio_utils" ] external_deps = [ "c_utils:utils", - "drivers_interface_audio:libaudio_proxy_1.0", + "drivers_interface_distributed_audio:libdaudio_proxy_1.0", "hdf_core:libhdf_utils", "hilog:libhilog", "ipc:ipc_single", diff --git a/services/hdfaudioclient/test/unittest/BUILD.gn b/services/hdfaudioclient/test/unittest/BUILD.gn index 449fa0805c709f5f77256dd1950271bb48d6d393..75bcfe4eab16762a33d070084e3b98c5d6681dd7 100644 --- a/services/hdfaudioclient/test/unittest/BUILD.gn +++ b/services/hdfaudioclient/test/unittest/BUILD.gn @@ -41,7 +41,7 @@ ohos_unittest("AudioAdapterHdiTest") { ] external_deps = [ - "drivers_interface_audio:libaudio_proxy_1.0", + "drivers_interface_distributed_audio:libdaudio_proxy_1.0", "ipc:ipc_core", ] @@ -73,6 +73,7 @@ ohos_unittest("AudioRenderInternalTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] + external_deps = [ "drivers_interface_distributed_audio:libdaudio_proxy_1.0" ] defines = [ "HI_LOG_ENABLE", @@ -102,6 +103,7 @@ ohos_unittest("AudioCaptureInternalTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] + external_deps = [ "drivers_interface_distributed_audio:libdaudio_proxy_1.0" ] defines = [ "HI_LOG_ENABLE", @@ -127,13 +129,15 @@ ohos_unittest("AudioAdapterInternalTest") { sources = [ "audio_adapter_internal/audio_adapter_internal_test.cpp" ] deps = [ - "${hdf_interfaces_path}/audio/v1_0:libdaudio_proxy_1.0", "${services_path}/hdfaudioclient:daudio_client", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "drivers_interface_distributed_audio:libdaudio_proxy_1.0", + ] defines = [ "HI_LOG_ENABLE",