ohaudio_sys/audiostreambuilder/audiostreambuilder_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#[cfg(feature = "api-20")]
7use crate::audiocapturer::{
8 OH_AudioCapturer_OnDeviceChangeCallback, OH_AudioCapturer_OnErrorCallback,
9 OH_AudioCapturer_OnFastStatusChange, OH_AudioCapturer_OnInterruptCallback,
10 OH_AudioCapturer_OnReadDataCallback,
11};
12#[cfg(feature = "api-20")]
13use crate::audiorenderer::{
14 OH_AudioRenderer_OnErrorCallback, OH_AudioRenderer_OnFastStatusChange,
15 OH_AudioRenderer_OnInterruptCallback, OH_AudioRenderer_OnWriteDataCallbackAdvanced,
16};
17use crate::audiostream_base::*;
18
19extern "C" {
20 /// Create a stremBuilder can be used to open a renderer or capturer client.
21 ///
22 /// OH_AudioStreamBuilder_Destroy() must be called when you are done using the builder.
23 ///
24 ///
25 /// Available since API-level: 10
26 ///
27 /// # Arguments
28 ///
29 /// * `builder` - The builder reference to the created result.
30 ///
31 /// * `type` - The stream type to be created. [`#AUDIOSTREAM_TYPE_RENDERER`] or [`#AUDIOSTREAM_TYPE_CAPTURER`]
32 ///
33 /// # Returns
34 ///
35 /// * Function result code:
36 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
37 pub fn OH_AudioStreamBuilder_Create(
38 builder: *mut *mut OH_AudioStreamBuilder,
39 type_: OH_AudioStream_Type,
40 ) -> OH_AudioStream_Result;
41 /// Destroy a streamBulder.
42 ///
43 /// This function must be called when you are done using the builder.
44 ///
45 ///
46 /// Available since API-level: 10
47 ///
48 /// # Arguments
49 ///
50 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
51 ///
52 /// # Returns
53 ///
54 /// * Function result code:
55 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
56 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
57 /// [`AUDIOSTREAM_ERROR_ILLEGAL_STATE`] Execution status exception.
58 pub fn OH_AudioStreamBuilder_Destroy(
59 builder: *mut OH_AudioStreamBuilder,
60 ) -> OH_AudioStream_Result;
61 /// Set the channel count of the capturer client
62 ///
63 ///
64 /// Available since API-level: 10
65 ///
66 /// # Arguments
67 ///
68 /// * `builder` - Reference created by OH_AudioStreamBuilder
69 ///
70 /// * `rate` - Pointer to a variable that will be set for the channel count.
71 ///
72 /// # Returns
73 ///
74 /// * Function result code:
75 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
76 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
77 /// 1.The param of builder is nullptr;
78 /// 2.The param of rate invalid.
79 pub fn OH_AudioStreamBuilder_SetSamplingRate(
80 builder: *mut OH_AudioStreamBuilder,
81 rate: i32,
82 ) -> OH_AudioStream_Result;
83 /// Set the channel count of the stream client
84 ///
85 ///
86 /// Available since API-level: 10
87 ///
88 /// # Arguments
89 ///
90 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
91 ///
92 /// * `channelCount` - The channel count.
93 ///
94 /// # Returns
95 ///
96 /// * Function result code:
97 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
98 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
99 /// 1.The param of builder is nullptr;
100 /// 2.The param of channelCount invalid.
101 pub fn OH_AudioStreamBuilder_SetChannelCount(
102 builder: *mut OH_AudioStreamBuilder,
103 channelCount: i32,
104 ) -> OH_AudioStream_Result;
105 /// Set the sample format of the stream client
106 ///
107 ///
108 /// Available since API-level: 10
109 ///
110 /// # Arguments
111 ///
112 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
113 ///
114 /// * `format` - Sample data format.
115 ///
116 /// # Returns
117 ///
118 /// * Function result code:
119 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
120 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
121 pub fn OH_AudioStreamBuilder_SetSampleFormat(
122 builder: *mut OH_AudioStreamBuilder,
123 format: OH_AudioStream_SampleFormat,
124 ) -> OH_AudioStream_Result;
125 /// Set the encoding type of the stream client
126 ///
127 ///
128 /// Available since API-level: 10
129 ///
130 /// # Arguments
131 ///
132 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
133 ///
134 /// * `encodingType` - Encoding type for the stream client, [`#AUDIOSTREAM_ENCODING_PCM`]
135 ///
136 /// # Returns
137 ///
138 /// * Function result code:
139 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
140 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
141 pub fn OH_AudioStreamBuilder_SetEncodingType(
142 builder: *mut OH_AudioStreamBuilder,
143 encodingType: OH_AudioStream_EncodingType,
144 ) -> OH_AudioStream_Result;
145 /// Set the latency mode of the stream client
146 ///
147 ///
148 /// Available since API-level: 10
149 ///
150 /// # Arguments
151 ///
152 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
153 ///
154 /// * `latencyMode` - Latency mode for the stream client.
155 ///
156 /// # Returns
157 ///
158 /// * Function result code:
159 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
160 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
161 pub fn OH_AudioStreamBuilder_SetLatencyMode(
162 builder: *mut OH_AudioStreamBuilder,
163 latencyMode: OH_AudioStream_LatencyMode,
164 ) -> OH_AudioStream_Result;
165 /// Set the channel layout to the stream client
166 ///
167 ///
168 /// Available since API-level: 12
169 ///
170 /// # Arguments
171 ///
172 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
173 ///
174 /// * `channelLayout` - is the layout of the speaker.
175 ///
176 /// # Returns
177 ///
178 /// * Function result code:
179 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
180 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
181 #[cfg(feature = "api-12")]
182 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
183 pub fn OH_AudioStreamBuilder_SetChannelLayout(
184 builder: *mut OH_AudioStreamBuilder,
185 channelLayout: OH_AudioChannelLayout,
186 ) -> OH_AudioStream_Result;
187 /// Set the renderer information of the stream client
188 ///
189 ///
190 /// Available since API-level: 10
191 ///
192 /// # Arguments
193 ///
194 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
195 ///
196 /// * `usage` - Set the stream usage for the renderer client.
197 ///
198 /// # Returns
199 ///
200 /// * Function result code:
201 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
202 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
203 /// 1.The param of builder is nullptr;
204 /// 2.The param of usage invalid.
205 pub fn OH_AudioStreamBuilder_SetRendererInfo(
206 builder: *mut OH_AudioStreamBuilder,
207 usage: OH_AudioStream_Usage,
208 ) -> OH_AudioStream_Result;
209 /// Set the capturer information of the stream client
210 ///
211 ///
212 /// Available since API-level: 10
213 ///
214 /// # Arguments
215 ///
216 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
217 ///
218 /// * `sourceType` - Set the source type for the capturer client.
219 ///
220 /// # Returns
221 ///
222 /// * Function result code:
223 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
224 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
225 /// 1.The param of builder is nullptr;
226 /// 2.The param of sourceType invalid.
227 pub fn OH_AudioStreamBuilder_SetCapturerInfo(
228 builder: *mut OH_AudioStreamBuilder,
229 sourceType: OH_AudioStream_SourceType,
230 ) -> OH_AudioStream_Result;
231 /// Set the callbacks for the renderer client
232 ///
233 ///
234 /// **Deprecated** since 20
235 ///
236 /// **Use instead:** Set the callback functions separately using OH_AudioStreamBuilder_SetRendererWriteDataCallback,
237 /// OH_AudioStreamBuilder_SetRendererInterruptCallback, OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback
238 /// and OH_AudioStreamBuilder_SetRendererErrorCallback.
239 ///
240 /// Available since API-level: 10
241 ///
242 /// # Arguments
243 ///
244 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
245 ///
246 /// * `callbacks` - Callbacks to the functions that will process renderer stream.
247 ///
248 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
249 ///
250 /// # Returns
251 ///
252 /// * Function result code:
253 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
254 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
255 /// 1.The param of builder is nullptr;
256 /// 2.StreamType invalid.
257 #[deprecated(
258 since = "20",
259 note = "Use instead: Set the callback functions separately using OH_AudioStreamBuilder_SetRendererWriteDataCallback, OH_AudioStreamBuilder_SetRendererInterruptCallback…"
260 )]
261 pub fn OH_AudioStreamBuilder_SetRendererCallback(
262 builder: *mut OH_AudioStreamBuilder,
263 callbacks: OH_AudioRenderer_Callbacks,
264 userData: *mut ::core::ffi::c_void,
265 ) -> OH_AudioStream_Result;
266 /// Set the callback when the output device of an audio renderer changed.
267 ///
268 ///
269 /// Available since API-level: 11
270 ///
271 /// # Arguments
272 ///
273 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
274 ///
275 /// * `callback` - Callback to the function that will process this device change event.
276 ///
277 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
278 ///
279 /// # Returns
280 ///
281 /// * Function result code:
282 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
283 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
284 /// 1.The param of builder is nullptr;
285 /// 2.StreamType invalid.
286 #[cfg(feature = "api-11")]
287 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
288 pub fn OH_AudioStreamBuilder_SetRendererOutputDeviceChangeCallback(
289 builder: *mut OH_AudioStreamBuilder,
290 callback: OH_AudioRenderer_OutputDeviceChangeCallback,
291 userData: *mut ::core::ffi::c_void,
292 ) -> OH_AudioStream_Result;
293 /// Set the privacy of audio render.
294 ///
295 ///
296 /// Available since API-level: 12
297 ///
298 /// # Arguments
299 ///
300 /// * `builder` - Builder provided by OH_AudioStreamBuilder_Create()
301 ///
302 /// * `privacy` - Privacy type.
303 ///
304 /// # Returns
305 ///
306 /// * Function result code:
307 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
308 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
309 /// 1.The param of builder is nullptr;
310 /// 2.StreamType invalid.
311 #[cfg(feature = "api-12")]
312 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
313 pub fn OH_AudioStreamBuilder_SetRendererPrivacy(
314 builder: *mut OH_AudioStreamBuilder,
315 privacy: OH_AudioStream_PrivacyType,
316 ) -> OH_AudioStream_Result;
317 /// Set the callbacks for the capturer client
318 ///
319 ///
320 /// **Deprecated** since 20
321 ///
322 /// **Use instead:** Set the callback functions separately using OH_AudioStreamBuilder_SetCapturerReadDataCallback,
323 /// OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback, OH_AudioStreamBuilder_SetCapturerInterruptCallback
324 /// and OH_AudioStreamBuilder_SetCapturerErrorCallback.
325 ///
326 /// Available since API-level: 10
327 ///
328 /// # Arguments
329 ///
330 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
331 ///
332 /// * `callbacks` - Callbacks to the functions that will process capturer stream.
333 ///
334 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
335 ///
336 /// # Returns
337 ///
338 /// * Function result code:
339 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
340 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
341 /// 1.The param of builder is nullptr;
342 /// 2.StreamType invalid.
343 #[deprecated(
344 since = "20",
345 note = "Use instead: Set the callback functions separately using OH_AudioStreamBuilder_SetCapturerReadDataCallback, OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback…"
346 )]
347 pub fn OH_AudioStreamBuilder_SetCapturerCallback(
348 builder: *mut OH_AudioStreamBuilder,
349 callbacks: OH_AudioCapturer_Callbacks,
350 userData: *mut ::core::ffi::c_void,
351 ) -> OH_AudioStream_Result;
352 /// Create the audio renderer client.
353 ///
354 /// The AudioRenderer instance is used to play streaming audio data.
355 /// When using AudioRenderer apis, there are many instructions for application
356 /// to achieve better performance and lower power consumption:
357 /// In music or audiobook background playback situation, you can have low power
358 /// consumption by following this best practices document **Low-Power Rules in Music Playback Scenarios**.
359 /// And for navigation situation, you can follow **Low-Power Rules in Navigation and Positioning Scenarios**.
360 ///
361 /// Application developer should also be careful when app goes to background, please check if your audio playback
362 /// is still needed, see **Audio Resources** in best practices document.
363 /// And avoiding to send silence audio data continuously to waste system resources, otherwise system will take
364 /// control measures when this behavior is detected, see **Audio Playback** in best practices document.
365 ///
366 /// If you want to use AudioRenderer api to implement a music playback application, there are also many interactive
367 /// scenes to consider, see **Developing an Audio Application** in best practices document.
368 ///
369 ///
370 /// Available since API-level: 10
371 ///
372 /// # Arguments
373 ///
374 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
375 ///
376 /// * `audioRenderer` - Pointer to a viriable to receive the stream client.
377 ///
378 /// # Returns
379 ///
380 /// * Function result code:
381 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
382 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
383 /// 1.The param of builder is nullptr;
384 /// 2.StreamType invalid;
385 /// 3.Create OHAudioRenderer failed.
386 pub fn OH_AudioStreamBuilder_GenerateRenderer(
387 builder: *mut OH_AudioStreamBuilder,
388 audioRenderer: *mut *mut OH_AudioRenderer,
389 ) -> OH_AudioStream_Result;
390 /// Create the audio capturer client.
391 ///
392 ///
393 /// Available since API-level: 10
394 ///
395 /// # Arguments
396 ///
397 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
398 ///
399 /// * `audioCapturer` - Pointer to a viriable to receive the stream client.
400 ///
401 /// # Returns
402 ///
403 /// * Function result code:
404 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
405 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
406 /// 1.The param of builder is nullptr;
407 /// 2.StreamType invalid;
408 /// 3.Create OHAudioCapturer failed.
409 pub fn OH_AudioStreamBuilder_GenerateCapturer(
410 builder: *mut OH_AudioStreamBuilder,
411 audioCapturer: *mut *mut OH_AudioCapturer,
412 ) -> OH_AudioStream_Result;
413 /// Set the data frame size for each callback, use this function if the application requires a specific number
414 /// of frames for processing.
415 /// The frame size should be at least the size device process at one time, and less than half the internal
416 /// buffer capacity.
417 ///
418 ///
419 /// Available since API-level: 11
420 ///
421 /// # Arguments
422 ///
423 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
424 ///
425 /// * `frameSize` - The data frame size for each callback.
426 ///
427 /// # Returns
428 ///
429 /// * Function result code:
430 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
431 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] The param of builder is nullptr.
432 #[cfg(feature = "api-11")]
433 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
434 pub fn OH_AudioStreamBuilder_SetFrameSizeInCallback(
435 builder: *mut OH_AudioStreamBuilder,
436 frameSize: i32,
437 ) -> OH_AudioStream_Result;
438 /// Set the callback of writing metadata to the renderer client
439 ///
440 ///
441 /// Available since API-level: 12
442 ///
443 /// # Arguments
444 ///
445 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
446 ///
447 /// * `callback` - Callback to the functions that will write audio data with metadata to the renderer.
448 ///
449 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
450 ///
451 /// # Returns
452 ///
453 /// * Function result code:
454 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
455 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
456 /// 1.The param of builder is nullptr;
457 /// 2.StreamType invalid.
458 #[cfg(feature = "api-12")]
459 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
460 pub fn OH_AudioStreamBuilder_SetWriteDataWithMetadataCallback(
461 builder: *mut OH_AudioStreamBuilder,
462 callback: OH_AudioRenderer_WriteDataWithMetadataCallback,
463 userData: *mut ::core::ffi::c_void,
464 ) -> OH_AudioStream_Result;
465 /// Set the interrupt mode of the stream client
466 ///
467 ///
468 /// Available since API-level: 12
469 ///
470 /// # Arguments
471 ///
472 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
473 ///
474 /// * `mode` - The audio interrupt mode
475 ///
476 /// # Returns
477 ///
478 /// * Function result code:
479 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
480 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
481 /// 1.The param of builder is nullptr;
482 /// 2.The param of mode invalid;
483 /// 3.StreamType invalid.
484 #[cfg(feature = "api-12")]
485 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
486 pub fn OH_AudioStreamBuilder_SetRendererInterruptMode(
487 builder: *mut OH_AudioStreamBuilder,
488 mode: OH_AudioInterrupt_Mode,
489 ) -> OH_AudioStream_Result;
490 /// Set the callback of writing data to renderer client.
491 ///
492 /// This function is similar with [`OH_AudioStreamBuilder_SetRendererCallback`]. Only the last callback set by
493 /// OH_AudioStreamBuilder_SetRendererCallback or this function will become effective.
494 ///
495 /// # Arguments
496 ///
497 /// * `builder` - Builder provided by OH_AudioStreamBuilder_Create()
498 ///
499 /// * `callback` - Callback to functions that will write audio data to renderer client.
500 ///
501 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
502 ///
503 /// # Returns
504 ///
505 /// * Result code.
506 /// [`AUDIOSTREAM_SUCCESS`] Success.
507 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] Parameter is invalid, e.g. builder is nullptr, e.t.c.
508 ///
509 /// Available since API-level: 12
510 #[cfg(feature = "api-12")]
511 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
512 pub fn OH_AudioStreamBuilder_SetRendererWriteDataCallback(
513 builder: *mut OH_AudioStreamBuilder,
514 callback: OH_AudioRenderer_OnWriteDataCallback,
515 userData: *mut ::core::ffi::c_void,
516 ) -> OH_AudioStream_Result;
517 /// Set the callback of writing data to renderer client.
518 ///
519 /// This function is similar with [`OH_AudioStreamBuilder_SetRendererWriteDataCallback`]. Only the last callback set
520 /// by OH_AudioStreamBuilder_SetRendererWriteDataCallback or this function will become effective. Different with
521 /// OH_AudioStreamBuilder_SetRendererWriteDataCallback, the callback in this function can return audio data of any
522 /// length.
523 ///
524 /// # Arguments
525 ///
526 /// * `builder` - Builder provided by OH_AudioStreamBuilder_Create()
527 ///
528 /// * `callback` - Callback to functions that will write audio data to renderer client.
529 ///
530 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
531 ///
532 /// # Returns
533 ///
534 /// * Result code.
535 /// [`AUDIOSTREAM_SUCCESS`] Success.
536 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] Parameter is invalid, e.g. builder is nullptr, e.t.c.
537 ///
538 /// Available since API-level: 20
539 #[cfg(feature = "api-20")]
540 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
541 pub fn OH_AudioStreamBuilder_SetRendererWriteDataCallbackAdvanced(
542 builder: *mut OH_AudioStreamBuilder,
543 callback: OH_AudioRenderer_OnWriteDataCallbackAdvanced,
544 userData: *mut ::core::ffi::c_void,
545 ) -> OH_AudioStream_Result;
546 /// Set the renderer volume mode of the stream client
547 ///
548 /// # Arguments
549 ///
550 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create()
551 ///
552 /// * `volumeMode` - Set the volume mode for the renderer client.
553 ///
554 /// # Returns
555 ///
556 /// * Function result code:
557 /// [`AUDIOSTREAM_SUCCESS`] If the execution is successful.
558 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`]:
559 /// 1.The param of builder is nullptr;
560 /// 2.The param of volumeMode invalid.
561 ///
562 /// Available since API-level: 19
563 #[cfg(feature = "api-19")]
564 #[cfg_attr(docsrs, doc(cfg(feature = "api-19")))]
565 pub fn OH_AudioStreamBuilder_SetVolumeMode(
566 builder: *mut OH_AudioStreamBuilder,
567 volumeMode: OH_AudioStream_VolumeMode,
568 ) -> OH_AudioStream_Result;
569 /// Sets a callback to handle interrupt events for an AudioRenderer instance. This function is similar to
570 /// [`OH_AudioStreamBuilder_SetRendererCallback`]. If both OH_AudioStreamBuilder_SetRendererCallback and this
571 /// function are called, the most recently set callback takes effect.
572 ///
573 /// # Arguments
574 ///
575 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
576 ///
577 /// * `callback` - Callback used to handle the interrupt events.
578 ///
579 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
580 ///
581 /// # Returns
582 ///
583 /// * Result code.
584 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
585 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
586 /// is nullptr.
587 ///
588 /// Available since API-level: 20
589 #[cfg(feature = "api-20")]
590 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
591 pub fn OH_AudioStreamBuilder_SetRendererInterruptCallback(
592 builder: *mut OH_AudioStreamBuilder,
593 callback: OH_AudioRenderer_OnInterruptCallback,
594 userData: *mut ::core::ffi::c_void,
595 ) -> OH_AudioStream_Result;
596 /// Sets a callback to handle error events for an AudioRenderer instance.
597 /// This function is similar to [`OH_AudioStreamBuilder_SetRendererCallback`]. If both
598 /// OH_AudioStreamBuilder_SetRendererCallback and this function are called, the most recently set callback takes
599 /// effect.
600 ///
601 /// # Arguments
602 ///
603 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
604 ///
605 /// * `callback` - Callback used to handle the error events.
606 ///
607 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
608 ///
609 /// # Returns
610 ///
611 /// * Result code.
612 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
613 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
614 /// is nullptr.
615 ///
616 /// Available since API-level: 20
617 #[cfg(feature = "api-20")]
618 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
619 pub fn OH_AudioStreamBuilder_SetRendererErrorCallback(
620 builder: *mut OH_AudioStreamBuilder,
621 callback: OH_AudioRenderer_OnErrorCallback,
622 userData: *mut ::core::ffi::c_void,
623 ) -> OH_AudioStream_Result;
624 /// Sets a callback to handle audio data read events for an AudioCapturer instance. This function is
625 /// similar to [`OH_AudioStreamBuilder_SetCapturerCallback`]. If both [`OH_AudioStreamBuilder_SetCapturerCallback`] and this function are called, the most recently set callback takes
626 /// effect.
627 ///
628 /// # Arguments
629 ///
630 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
631 ///
632 /// * `callback` - Callback used to handle incoming audio data.
633 ///
634 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
635 ///
636 /// # Returns
637 ///
638 /// * Result code.
639 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
640 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
641 /// is nullptr.
642 ///
643 /// Available since API-level: 20
644 #[cfg(feature = "api-20")]
645 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
646 pub fn OH_AudioStreamBuilder_SetCapturerReadDataCallback(
647 builder: *mut OH_AudioStreamBuilder,
648 callback: OH_AudioCapturer_OnReadDataCallback,
649 userData: *mut ::core::ffi::c_void,
650 ) -> OH_AudioStream_Result;
651 /// Sets a callback to handle device change events for an AudioCapturer instance. This function is
652 /// similar to [`OH_AudioStreamBuilder_SetCapturerCallback`]. If both OH_AudioStreamBuilder_SetCapturerCallback
653 /// and this function are called, the most recently set callback takes effect.
654 ///
655 /// # Arguments
656 ///
657 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
658 ///
659 /// * `callback` - Callback used to handle the device change events.
660 ///
661 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
662 ///
663 /// # Returns
664 ///
665 /// * Result code.
666 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
667 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
668 /// is nullptr.
669 ///
670 /// Available since API-level: 20
671 #[cfg(feature = "api-20")]
672 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
673 pub fn OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback(
674 builder: *mut OH_AudioStreamBuilder,
675 callback: OH_AudioCapturer_OnDeviceChangeCallback,
676 userData: *mut ::core::ffi::c_void,
677 ) -> OH_AudioStream_Result;
678 /// Sets a callback to handle interrupt events for an AudioCapturer instance.
679 /// This function is similar to [`OH_AudioStreamBuilder_SetCapturerCallback`]. If both
680 /// OH_AudioStreamBuilder_SetCapturerCallback and this function are called, the most recently set callback takes
681 /// effect.
682 ///
683 /// # Arguments
684 ///
685 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
686 ///
687 /// * `callback` - Callback used to handle the interrupt events.
688 ///
689 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
690 ///
691 /// # Returns
692 ///
693 /// * Result code.
694 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
695 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
696 /// is nullptr.
697 ///
698 /// Available since API-level: 20
699 #[cfg(feature = "api-20")]
700 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
701 pub fn OH_AudioStreamBuilder_SetCapturerInterruptCallback(
702 builder: *mut OH_AudioStreamBuilder,
703 callback: OH_AudioCapturer_OnInterruptCallback,
704 userData: *mut ::core::ffi::c_void,
705 ) -> OH_AudioStream_Result;
706 /// Sets a callback to handle error events for an AudioCapturer instance. This function is similar to
707 /// [`OH_AudioStreamBuilder_SetCapturerCallback`]. If both OH_AudioStreamBuilder_SetCapturerCallback and this
708 /// function are called, the most recently set callback takes effect.
709 ///
710 /// # Arguments
711 ///
712 /// * `builder` - Builder instance, which is generated by OH_AudioStreamBuilder_Create().
713 ///
714 /// * `callback` - Callback used to handle the error events.
715 ///
716 /// * `userData` - Pointer to user-defined data, which will be passed back to the application in the callback.
717 ///
718 /// # Returns
719 ///
720 /// * Result code.
721 /// [`AUDIOSTREAM_SUCCESS`] is returned if the operation is successful.
722 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] is returned if a parameter is invalid, for example, if builder
723 /// is nullptr.
724 ///
725 /// Available since API-level: 20
726 #[cfg(feature = "api-20")]
727 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
728 pub fn OH_AudioStreamBuilder_SetCapturerErrorCallback(
729 builder: *mut OH_AudioStreamBuilder,
730 callback: OH_AudioCapturer_OnErrorCallback,
731 userData: *mut ::core::ffi::c_void,
732 ) -> OH_AudioStream_Result;
733 /// Set audio capturer configuration, if app want its recorder only to be muted instead of interrupted.
734 ///
735 /// # Arguments
736 ///
737 /// * `builder` - reference provided by OH_AudioStreamBuilder_Create()
738 ///
739 /// * `muteWhenInterrupted` - use `true` if application want to be muted instead of interrupted.
740 ///
741 /// # Returns
742 ///
743 /// * function result code:
744 /// [`AUDIOSTREAM_SUCCESS`] if the execution is successful.
745 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] the param of builder is nullptr.
746 ///
747 /// Available since API-level: 20
748 #[cfg(feature = "api-20")]
749 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
750 pub fn OH_AudioStreamBuilder_SetCapturerWillMuteWhenInterrupted(
751 builder: *mut OH_AudioStreamBuilder,
752 muteWhenInterrupted: bool,
753 ) -> OH_AudioStream_Result;
754 /// Set the callback of fast status change event for audio renderer.
755 ///
756 /// # Arguments
757 ///
758 /// * `builder` - Builder provided by OH_AudioStreamBuilder_Create()
759 ///
760 /// * `callback` - Callback function that will recevie the fast status change event.
761 ///
762 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
763 ///
764 /// # Returns
765 ///
766 /// * [`AUDIOSTREAM_SUCCESS`] if the execution is successful.
767 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] the param of builder or callback is nullptr.
768 ///
769 /// Available since API-level: 20
770 #[cfg(feature = "api-20")]
771 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
772 pub fn OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback(
773 builder: *mut OH_AudioStreamBuilder,
774 callback: OH_AudioRenderer_OnFastStatusChange,
775 userData: *mut ::core::ffi::c_void,
776 ) -> OH_AudioStream_Result;
777 /// Set the callback of fast status change event for audio capturer.
778 ///
779 /// # Arguments
780 ///
781 /// * `builder` - Builder provided by OH_AudioStreamBuilder_Create()
782 ///
783 /// * `callback` - Callback function that will recevie the fast status change event.
784 ///
785 /// * `userData` - Pointer to an application data structure that will be passed to the callback functions.
786 ///
787 /// # Returns
788 ///
789 /// * [`AUDIOSTREAM_SUCCESS`] if the execution is successful.
790 /// [`AUDIOSTREAM_ERROR_INVALID_PARAM`] the param of builder or callback is nullptr.
791 ///
792 /// Available since API-level: 20
793 #[cfg(feature = "api-20")]
794 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
795 pub fn OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback(
796 builder: *mut OH_AudioStreamBuilder,
797 callback: OH_AudioCapturer_OnFastStatusChange,
798 userData: *mut ::core::ffi::c_void,
799 ) -> OH_AudioStream_Result;
800 /// Sets target mode when using playback capture. Mode will decide what kind of streams to capture.
801 /// This function is only available for [`#AUDIOSTREAM_TYPE_CAPTURER`] type.
802 /// After setting playback capture mode, the [`#OH_AudioStream_SourceType`] will be ignored, so
803 /// caller do not need to use [`#OH_AudioStreamBuilder_SetCapturerInfo`] if you only want to capture
804 /// playback streams.
805 /// Note that playback capture is only available for specific system applications currently, others do
806 /// not have authorization.
807 ///
808 /// # Arguments
809 ///
810 /// * `builder` - Reference provided by OH_AudioStreamBuilder_Create().
811 ///
812 /// * `mode` - The playback capture mode to set. This can be a combination of the available
813 /// [`#OH_AudioStream_PlaybackCaptureMode`].
814 ///
815 /// # Returns
816 ///
817 /// * Function result code:
818 /// [`#AUDIOSTREAM_SUCCESS`] If the execution is successful.
819 /// [`#AUDIOSTREAM_ERROR_INVALID_PARAM`] 1.The param of builder is nullptr;
820 /// 2.The param of mode is invalid.
821 ///
822 /// Available since API-level: 23
823 #[cfg(feature = "api-23")]
824 #[cfg_attr(docsrs, doc(cfg(feature = "api-23")))]
825 pub fn OH_AudioStreamBuilder_SetPlaybackCaptureMode(
826 builder: *mut OH_AudioStreamBuilder,
827 mode: u32,
828 ) -> OH_AudioStream_Result;
829}