1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup OHAudio 18 * @{ 19 * 20 * @brief Provide the definition of the C interface for the audio module. 21 * 22 * @syscap SystemCapability.Multimedia.Audio.Core 23 * 24 * @since 19 25 */ 26 27 /** 28 * @file native_audio_stream_manager.h 29 * 30 * @brief Declare audio stream manager related interfaces. 31 * 32 * This file interface is used for the creation of audioStreamManager 33 * as well as the audio stream settings and management. 34 * 35 * @library libohaudio.so 36 * @syscap SystemCapability.Multimedia.Audio.Core 37 * @kit AudioKit 38 * @since 19 39 */ 40 41 #ifndef NATIVE_AUDIO_STREAM_MANAGER_H 42 #define NATIVE_AUDIO_STREAM_MANAGER_H 43 44 #include "native_audio_common.h" 45 #include "native_audiostream_base.h" 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Declare the audio stream manager. 52 * Audio stream manager provides many functions about audio streams, like monitoring audio streams status, 53 * getting different stream types supported information and so on. 54 * 55 * @since 19 56 */ 57 typedef struct OH_AudioStreamManager OH_AudioStreamManager; 58 59 /** 60 * @brief Fetch the audio streammanager handle, which is a singleton. 61 * 62 * @param streamManager output parameter to get the {@link #OH_AudioStreamManager}. 63 * @return 64 * {@link #AUDIOCOMMON_RESULT_SUCCESS} if execution succeeds 65 * {@link #AUDIOCOMMON_RESULT_ERROR_SYSTEM} if system state error 66 * @since 19 67 */ 68 OH_AudioCommon_Result OH_AudioManager_GetAudioStreamManager(OH_AudioStreamManager **streamManager); 69 70 /** 71 * @brief Gets the mode of direct playback available for a given audio format with current active device. 72 * 73 * @param audioStreamManager the {@link OH_AudioStreamManager} handle provided by 74 * {@link OH_AudioManager_GetAudioStreamManager}. 75 * @param streamInfo the {@link OH_AudioStreamInfo}. 76 * @param usage the {@link OH_AudioStream_Usage}. 77 * @param directPlaybackMode the {@link OH_AudioStream_DirectPlaybackMode} pointer to a variable which receives the 78 * result. 79 * @return Function result code: 80 * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. 81 * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: 82 * 1.The param of audioStreamManager is nullptr; 83 * 2.The param of streamInfo is nullptr; 84 * 3.The param of usage invalid; 85 * 4.The param of directPlaybackMode is nullptr. 86 * @since 19 87 */ 88 OH_AudioCommon_Result OH_AudioStreamManager_GetDirectPlaybackSupport( 89 OH_AudioStreamManager *audioStreamManager, OH_AudioStreamInfo *streamInfo, 90 OH_AudioStream_Usage usage, OH_AudioStream_DirectPlaybackMode *directPlaybackMode); 91 92 /** 93 * @brief Query whether acoustic echo canceler is supported by input source. 94 * 95 * @param streamManager The {@link OH_AudioStreamManager} handle provided 96 * by {@link OH_AudioManager_GetAudioStreamManager}. 97 * @param sourceType Related source type. 98 * @param supported Pointer to get the result. 99 * @return Function result code: 100 * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. 101 * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: 102 * 1.The input param streamManager is nullptr; 103 * 2.Source type is invalid. 104 * 3.The input param supported is nullptr. 105 * @since 20 106 */ 107 108 OH_AudioCommon_Result OH_AudioStreamManager_IsAcousticEchoCancelerSupported( 109 OH_AudioStreamManager *streamManager, 110 OH_AudioStream_SourceType sourceType, 111 bool *supported); 112 113 /** 114 * @brief Return if fast playback is supported for the specific audio stream info and usage type 115 * in current device situation. 116 * 117 * @param streamManager {@link OH_AudioStreamManager} handle 118 * provided by {@link OH_AudioManager_GetAudioStreamManager}. 119 * @param streamInfo reference of stream info structure to describe basic audio format. 120 * @param usage stream usage type used to decide the audio device and pipe type selection result. 121 * @return {@code true} if fast playback is supported in this situation. 122 * @since 20 123 */ 124 bool OH_AudioStreamManager_IsFastPlaybackSupported( 125 OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_Usage usage); 126 127 /** 128 * @brief Return if fast recording is supported for the specific audio stream info and source type 129 * in current device situation. 130 * 131 * @param streamManager {@link OH_AudioStreamManager} handle 132 * provided by {@link OH_AudioManager_GetAudioStreamManager}. 133 * @param streamInfo reference of stream info structure to describe basic audio format. 134 * @param source stream source type used to decide the audio device and pipe type selection result. 135 * @return {@code true} if fast recording is supported in this situation. 136 * @since 20 137 */ 138 bool OH_AudioStreamManager_IsFastRecordingSupported( 139 OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_SourceType source); 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif // NATIVE_AUDIO_STREAM_MANAGER_H 146 /** @} */ 147