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