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..a97cca5abc819b82bc8c6785d4cd3830b1291d6f 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_session_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_session_manager.h @@ -179,6 +179,36 @@ typedef enum { DEACTIVATED_TIMEOUT = 1, } OH_AudioSession_DeactivatedReason; +/** + * @brief Enumerates the categories application prefer to use + * when recording with bluetooth and nearlink. + * + * @since 21 + */ +typedef enum { + /** + * @brief Not prefer to use bluetooth and nearlink record. + */ + PREFERRED_NONE = 0, + + /** + * @brief Prefer to use bluetooth and nearlink record. + * However, whether to use low latency or high quality recording + * depends on system. + */ + PREFERRED_DEFAULT = 1, + + /** + * @brief Prefer to use bluetooth and nearlink low latency mode to record. + */ + PREFERRED_LOW_LATENCY = 2, + + /** + * @brief Prefer to use bluetooth and nearlink high quality mode to record. + */ + PREFERRED_HIGH_QUALITY = 3, +} OH_AudioSession_BluetoothAndNearlinkPreferredRecordCategory; + /** * @brief declare the audio session strategy * @@ -225,6 +255,40 @@ typedef struct OH_AudioSession_StateChangedEvent { typedef void (*OH_AudioSession_StateChangedCallback) ( OH_AudioSession_StateChangedEvent event); +/** + * @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 void (*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 device change event. @@ -467,6 +531,185 @@ 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} which is used as + * the filter parameter for get the available devices. + * @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_SYSTEM} Audio client call audio service error, System 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} which is used as + * the filter parameter for register the available devices change event. + * @param callback the {@link #OH_AudioSession_AvailableDeviceChangedCallback} which is used + * to receive available 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} Audio client call audio service error, System 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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_UnregisterAvailableDevicesChangeCallback( + OH_AudioSessionManager *audioSessionManager, + OH_AudioSession_AvailableDeviceChangedCallback callback); + +/** + * @brief Sets the media input device. + * This function is not valid for call recording, whose SourceType is + * SOURCE_TYPE_VOICE_CALL or SOURCE_TYPE_VOICE_COMMUNICATION. + * In scenarios where there are concurrent recording streams with higher priority, + * the actual input device used by the application may differ from the selected one. + * The application can use {@link OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback} + * to register a callback to listen for the actual input device. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param deviceDescriptor The target device. The available device must be in the array returned + * by {@link OH_AudioSessionManager_GetAvailableDevices}. + * When the nullptr is passed, system will clear the last selection. + * @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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_SelectMediaInputDevice( + OH_AudioSessionManager *audioSessionManager, OH_AudioDeviceDescriptor *deviceDescriptor); + +/** + * @brief Gets the selected media input device. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager}. + * @param audioDeviceDescriptor The target device set by + * {@link OH_AudioSessionManager_SelectMediaInputDevice} or + * device with AUDIO_DEVICE_TYPE_INVALID if not set yet. + * Do not release the audioDeviceDescriptor pointer separately, + * instead call {@link OH_AudioSessionManager_ReleaseDevice} to release it + * 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_SYSTEM} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetSelectedMediaInputDevice( + OH_AudioSessionManager *audioSessionManager, OH_AudioDeviceDescriptor **audioDeviceDescriptor); + +/** + * @brief Sets the prefered record category with bluetooth and nearlink device. + * The application can set this category before bluetooth and nearlink connected, and the system will + * prefer to use bluetooth and nearlink to record when the device connected. + * In scenarios where there are concurrent recording streams with higher priority, + * the actual input device used by the application may differ from the prefered one. + * The application can use {@link OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback} + * to register a callback to listen for the actual input device. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param category The category application prefer to use when recording with bluetooth and nearlink. + * @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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_SetBluetoothAndNearlinkPreferredRecordCategory( + OH_AudioSessionManager *audioSessionManager, + OH_AudioSession_BluetoothAndNearlinkPreferredRecordCategory category); + +/** + * @brief Gets the prefered record category with bluetooth and nearlink device. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} handle returned + * by {@link OH_AudioManager_GetAudioSessionManager}. + * @param category The category application prefer to use when recording with bluetooth and nearlink. + * @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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_GetBluetoothAndNearlinkPreferredRecordCategory( + OH_AudioSessionManager *audioSessionManager, + OH_AudioSession_BluetoothAndNearlinkPreferredRecordCategory *category); + +/** + * @brief Register the audio session input device change event callback. + * + * @param audioSessionManager the {@link #OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager}. + * @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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback( + OH_AudioSessionManager *audioSessionManager, + 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 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} Audio client call audio service error, System error. + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_UnregisterCurrentInputDeviceChangeCallback( + OH_AudioSessionManager *audioSessionManager, + OH_AudioSession_CurrentInputDeviceChangedCallback callback); + +/** + * @brief Release the audio device descriptor object. + * + * @param audioSessionManager the {@link OH_AudioSessionManager} + * returned by the {@link #OH_AudioManager_GetAudioSessionManager} + * @param audioDeviceDescriptor Audio device descriptor to release. + * @return {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * or {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM} if parameter validation fails + * @since 21 + */ +OH_AudioCommon_Result OH_AudioSessionManager_ReleaseDevice( + OH_AudioSessionManager *audioSessionManager, + OH_AudioDeviceDescriptor *audioDeviceDescriptor); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 858a405ccc3ce5403e73550e770a5889ef7e7db3..b508542564fecb500b7e795966417f383186b76c 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -379,6 +379,46 @@ "first_introduced": "12", "name":"OH_AudioSessionManager_UnregisterCurrentOutputDeviceChangeCallback" }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_GetAvailableDevices" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_RegisterAvailableDevicesChangeCallback" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_UnRegisterAvailableDevicesChangeCallback" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_SelectMediaInputDevice" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_GetSelectedMediaInputDevice" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_SetBluetoothAndNearlinkPreferredRecordCategory" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_GetBluetoothAndNearlinkPreferredRecordCategory" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_RegisterCurrentInputDeviceChangeCallback" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_UnregisterCurrentInputDeviceChangeCallback" + }, + { + "first_introduced": "21", + "name":"OH_AudioSessionManager_ReleaseDevice" + }, { "first_introduced": "12", "name": "OH_GetAudioManager"