• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 10
25  * @version 1.0
26  */
27 
28 /**
29  * @file native_audiostreambuilder.h
30  *
31  * @brief Declare audio stream builder related interfaces.
32  *
33  * @syscap SystemCapability.Multimedia.Audio.Core
34  * @since 10
35  * @version 1.0
36  */
37 
38 #ifndef NATIVE_AUDIOSTREAM_BUILDER_H
39 #define NATIVE_AUDIOSTREAM_BUILDER_H
40 
41 #include "native_audiostream_base.h"
42 #include "native_audiorenderer.h"
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**
48  * Create a stremBuilder can be used to open a renderer or capturer client.
49  *
50  * OH_AudioStreamBuilder_Destroy() must be called when you are done using the builder.
51  *
52  * @since 10
53  *
54  * @param builder The builder reference to the created result.
55  * @param type The stream type to be created. {@link #AUDIOSTREAM_TYPE_RENDERER} or {@link #AUDIOSTREAM_TYPE_CAPTURER}
56  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
57  */
58 OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder** builder, OH_AudioStream_Type type);
59 
60 /**
61  * Destroy a streamBulder.
62  *
63  * This function must be called when you are done using the builder.
64  *
65  * @since 10
66  *
67  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
68  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
69  */
70 OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder* builder);
71 
72 /*
73  * Set the channel count of the capturer client
74  *
75  * @since 10
76  *
77  * @param capturer Reference created by OH_AudioStreamBuilder
78  * @param channelCount Pointer to a variable that will be set for the channel count.
79  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
80  */
81 OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder* builder, int32_t rate);
82 
83 /*
84  * Set the channel count of the stream client
85  *
86  * @since 10
87  *
88  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
89  * @param channelCount The channel count.
90  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
91  */
92 OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder* builder, int32_t channelCount);
93 
94 /*
95  * Set the sample format of the stream client
96  *
97  * @since 10
98  *
99  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
100  * @param format Sample data format.
101  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
102  */
103 OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder* builder,
104     OH_AudioStream_SampleFormat format);
105 
106 /*
107  * Set the encoding type of the stream client
108  *
109  * @since 10
110  *
111  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
112  * @param encodingType Encoding type for the stream client, {@link #AUDIOSTREAM_ENCODING_PCM}
113  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
114  */
115 OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder* builder,
116     OH_AudioStream_EncodingType encodingType);
117 
118 /*
119  * Set the latency mode of the stream client
120  *
121  * @since 10
122  *
123  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
124  * @param latencyMode Latency mode for the stream client.
125  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
126  */
127 OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder* builder,
128     OH_AudioStream_LatencyMode latencyMode);
129 
130 /*
131  * Set the renderer information of the stream client
132  *
133  * @since 10
134  *
135  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
136  * @param usage Set the stream usage for the renderer client.
137  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
138  */
139 OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder* builder,
140     OH_AudioStream_Usage usage);
141 
142 /*
143  * Set the capturer information of the stream client
144  *
145  * @since 10
146  *
147  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
148  * @param sourceType Set the source type for the capturer client.
149  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
150  */
151 OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder* builder,
152     OH_AudioStream_SourceType sourceType);
153 
154 /*
155  * Set the callbacks for the renderer client
156  *
157  * @since 10
158  *
159  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
160  * @param callbacks Callbacks to the functions that will process renderer stream.
161  * @param userData Pointer to an application data structure that will be passed to the callback functions.
162  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
163  */
164 OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder* builder,
165     OH_AudioRenderer_Callbacks callbacks, void* userData);
166 
167 /*
168  * Set the callbacks for the capturer client
169  *
170  * @since 10
171  *
172  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
173  * @param callbacks Callbacks to the functions that will process capturer stream.
174  * @param userData Pointer to an application data structure that will be passed to the callback functions.
175  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
176  */
177 OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder* builder,
178     OH_AudioCapturer_Callbacks callbacks, void* userData);
179 
180 /*
181  * Create the audio renderer client.
182  *
183  * @since 10
184  *
185  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
186  * @param audioRenderer Pointer to a viriable to receive the stream client.
187  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
188  */
189 OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder* builder,
190     OH_AudioRenderer** audioRenderer);
191 /*
192  * Create the audio capturer client.
193  *
194  * @since 10
195  *
196  * @param builder Reference provided by OH_AudioStreamBuilder_Create()
197  * @param audioCapturer Pointer to a viriable to receive the stream client.
198  * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error.
199  */
200 OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder,
201     OH_AudioCapturer** audioCapturer);
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif // NATIVE_AUDIOSTREAM_BUILDER_H
207