• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 on input SourceType.
94  *
95  * @param streamManager the {@link OH_AudioStreamManager} handle returned by
96  * {@link OH_GetAudioManager}.
97  * @param supported query result.
98  * @param sourceType SourceType to be queried.
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 param of streamManager is nullptr;
103  *                                                    2.The param of supported is nullptr.
104  * @since 20
105  */
106 OH_AudioCommon_Result OH_AudioStreamManager_IsAcousticEchoCancelerSupported(
107     OH_AudioStreamManager *streamManager,
108     OH_AudioStream_SourceType sourceType,
109     bool *supported);
110 
111 /**
112  * @brief Return if fast playback is supported for the specific audio stream info and usage type
113  *     in current device situation.
114  *
115  * @param streamManager {@link OH_AudioStreamManager} handle
116  *     provided by {@link OH_AudioManager_GetAudioStreamManager}.
117  * @param streamInfo reference of stream info structure to describe basic audio format.
118  * @param usage stream usage type used to decide the audio device and pipe type selection result.
119  * @return {@code true} if fast playback is supported in this situation.
120  * @since 20
121  */
122 bool OH_AudioStreamManager_IsFastPlaybackSupported(
123     OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_Usage usage);
124 
125 /**
126  * @brief Return if fast recording is supported for the specific audio stream info and source type
127  *     in current device situation.
128  *
129  * @param streamManager {@link OH_AudioStreamManager} handle
130  *     provided by {@link OH_AudioManager_GetAudioStreamManager}.
131  * @param streamInfo reference of stream info structure to describe basic audio format.
132  * @param source stream source type used to decide the audio device and pipe type selection result.
133  * @return {@code true} if fast recording is supported in this situation.
134  * @since 20
135  */
136 bool OH_AudioStreamManager_IsFastRecordingSupported(
137     OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_SourceType source);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif // NATIVE_AUDIO_STREAM_MANAGER_H
144 /** @} */
145