diff --git a/multimedia/audio_framework/audio_manager/native_audio_session_manager.h b/multimedia/audio_framework/audio_manager/native_audio_session_manager.h index c3b40731777332b5da0450e97416cdc03773aacb..da3462639095757461d54d48e1e9fbc3bb793651 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_session_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_session_manager.h @@ -244,6 +244,41 @@ typedef void (*OH_AudioSession_CurrentOutputDeviceChangedCallback) ( OH_AudioStream_DeviceChangeReason changeReason, OH_AudioSession_OutputDeviceChangeRecommendedAction recommendedAction); +/** + * @brief This function pointer will point to the callback function that + * is used to return the changing audio device descriptors. + * There may be more than one audio device descriptor returned. + * + * @param type the {@link OH_AudioDevice_ChangeType} is connect or disconnect. + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value. + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioSessionManager_ReleaseDevices} to release the DeviceDescriptor array + * when it is no use anymore. + * @since 21 + */ +typedef int32_t (*OH_AudioSession_AvailableDeviceChangedCallback) ( + OH_AudioDevice_ChangeType type, + OH_AudioDeviceDescriptorArray *audioDeviceDescriptorArray +); + +/** + * @brief This function pointer will point to the callback function that + * is used to return the audio session input device change event. + * + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio input device descriptors value. + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioSessionManager_ReleaseDevices} + * to release the DeviceDescriptor array when it is no use anymore. + * @param changeReason the {@link #OH_AudioStream_DeviceChangeReason} indicates + * that why does the input device changes. + * @since 21 + */ +typedef void (*OH_AudioSession_CurrentInputDeviceChangedCallback) ( + OH_AudioDeviceDescriptorArray *devices, + OH_AudioStream_DeviceChangeReason changeReason); + /** * @brief This function pointer will point to the callback function that * is used to return the audio session deactivated event. @@ -467,6 +502,187 @@ OH_AudioCommon_Result OH_AudioSessionManager_UnregisterCurrentOutputDeviceChange OH_AudioSessionManager *audioSessionManager, OH_AudioSession_CurrentOutputDeviceChangedCallback callback); +/** + * @brief Get available devices by device usage. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param deviceUsage the {@link OH_AudioDevice_Usage}. + * @param audioDeviceDescriptorArray the {@link OH_AudioDeviceDescriptorArray} + * pointer variable which will be set the audio device descriptors value + * Do not release the audioDeviceDescriptorArray pointer separately + * instead call {@link OH_AudioRoutingManager_ReleaseDevices} to release the DeviceDescriptor array + * when it is no use anymore. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetAvailableDevices( + OH_AudioSessionManager *audioSessionManager, + OH_AudioDevice_Usage deviceUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray); + +/** + * @brief Register available device change event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param deviceUsage the {@link OH_AudioDevice_Usage}. + * @param callback the {@link #OH_AudioSession_AvailableDeviceChangedCallback} which is used + * to receive the device change event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * or {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_RegisterAvailableDevicesChangeCallback( + OH_AudioSessionManager *audioSessionManager, OH_AudioDevice_Usage deviceUsage, + OH_AudioSession_AvailableDeviceChangedCallback callback); + +/** + * @brief Unregister available device change event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param callback the {@link #OH_AudioSession_AvailableDeviceChangedCallback} which is used + * to receive the device change event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_UnRegisterAvailableDevicesChangeCallback( + OH_AudioSessionManager *audioSessionManager, + OH_AudioSession_AvailableDeviceChangedCallback callback); + +/** + * @brief Sets the input device. + * This function applys on audiocapturers whose SourceType are + * AUDIOSTREAM_SOURCE_TYPE_MIC/AUDIOSTREAM_SOURCE_TYPE_CAMCORDER/AUDIOSTREAM_SOURCE_TYPE_LIVE. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param deviceType The target device. The available deviceType must be in the array returned + * by {@link OH_AudioSessionManager_GetAvailableDevices}. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_SelectInputDevice( + OH_AudioSessionManager *audioSessionManager, H_AudioDevice_Type deviceType); + +/** + * @brief Gets the selected input device. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param deviceType The input device type set by + * {@link OH_AudioSessionManager_SelectInputDevice} or AUDIO_DEVICE_TYPE_INVALID if + * not set yet. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * or {@link #AUDIOCOMMON_RESULT_ERROR_ILLEGAL_STATE} if system illegal state + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetSelectedInputDevice( + OH_AudioSessionManager *audioSessionManager, OH_AudioDevice_Type *deviceType); + +/** + * @brief Prefer wireless device to record, such as BLUETOOTH_SCO or NEARLINK. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param enable Indicates whether prefer wireless device to record. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_SetPreferWirelessRecord( + OH_AudioSessionManager *audioSessionManager, bool enable); + +/** + * @brief Gets whether prefer wireless device to record. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param enable Indicates whether prefer wireless device to record. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetPreferWirelessRecord( + OH_AudioSessionManager *audioSessionManager, bool *enable); + +/** + * @brief Prefer full-bandwidth audio, if the wireless device support it. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param enable Indicates whether prefer full-bandwidth audio. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_SetPreferWirelessHighQualityRecord( + OH_AudioSessionManager *audioSessionManager, bool enable); + +/** + * @brief Gets whether prefer full-bandwidth audio, if the wireless device support it. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param enable Indicates whether prefer full-bandwidth audio. + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds. + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails. + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetPreferWirelessHighQualityRecord( + OH_AudioSessionManager *audioSessionManager, bool *enable); + +/** + * @brief Register the audio session input device change event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param sourceType the {@link OH_AudioStream_SourceType}. + * @param callback the {@link #OH_AudioSession_CurrentInputDeviceChangedCallback} which is used + * to receive the input device change event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * or {@link AUDIOCOMMON_RESULT_ERROR_NO_MEMORY} No memory error + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback( + OH_AudioSessionManager *audioSessionManager, + OH_AudioStream_SourceType sourceType, + OH_AudioSession_CurrentInputDeviceChangedCallback callback); + +/** + * @brief Unregister the audio session input device change event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param sourceType the {@link OH_AudioStream_SourceType}. + * @param callback the {@link #OH_AudioSession_CurrentInputDeviceChangedCallback} which is used + * to receive the input device change event + * @return {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds + * or {@link #AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * or {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_UnregisterCurrentInputDeviceChangeCallback( + OH_AudioSessionManager *audioSessionManager, + OH_AudioStream_SourceType sourceType, + OH_AudioSession_CurrentInputDeviceChangedCallback callback); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 858a405ccc3ce5403e73550e770a5889ef7e7db3..f6a634d6803bfb5aced2e85ccccb47737430c0e2 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -379,6 +379,50 @@ "first_introduced": "12", "name":"OH_AudioSessionManager_UnregisterCurrentOutputDeviceChangeCallback" }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_GetAvailableDevices" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_RegisterAvailableDevicesChangeCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_UnRegisterAvailableDevicesChangeCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_SelectInputDevice" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_GetSelectedInputDevice" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_SetPreferWirelessRecord" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_GetPreferWirelessRecord" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_SetPreferWirelessHighQualityRecord" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_GetPreferWirelessHighQualityRecord" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioSessionManager_UnregisterCurrentInputDeviceChangeCallback" + }, { "first_introduced": "12", "name": "OH_GetAudioManager"