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
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)]
#[cfg(feature = "api-11")]
#[allow(unused_imports)]
use crate::avbuffer::OH_AVBuffer;
#[allow(unused_imports)]
use crate::avbuffer_info::OH_AVCodecBufferAttr;
#[cfg(feature = "api-11")]
#[allow(unused_imports)]
use crate::avcodec_base::OH_AVCodecCallback;
#[allow(unused_imports)]
use crate::avcodec_base::{OH_AVCodec, OH_AVCodecAsyncCallback};
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;
#[allow(unused_imports)]
use crate::avformat::OH_AVFormat;
use ohos_sys_opaque_types::OHNativeWindow;
/// Forward declaration of MediaKeySession.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
#[repr(C)]
pub struct MediaKeySession {
_unused: [u8; 0],
}
extern "C" {
/// Creates a video decoder instance from the mime type, which is recommended in most cases.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `mime` - mime type description string, refer to [`AVCODEC_MIME_TYPE`]
///
/// # Returns
///
/// * Returns a Pointer to an OH_AVCodec instance.
/// Return nullptr if memory ran out or the mime type is not supported.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_CreateByMime(mime: *const ::core::ffi::c_char) -> *mut OH_AVCodec;
/// Create a video decoder instance through the video decoder name.
/// The premise of using this interface is to know the exact name of the decoder.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `name` - video codec name
///
/// # Returns
///
/// * Returns a Pointer to an OH_AVCodec instance.
/// Return nullptr if memory ran out or the decoder name is not supported.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_CreateByName(name: *const ::core::ffi::c_char) -> *mut OH_AVCodec;
/// Clear the internal resources of the decoder and destroy the decoder instance
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if succeed,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], inner resource has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Destroy(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Set the asynchronous callback function so that your application can respond to the events
/// generated by the video decoder. This interface must be called before Prepare is called.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `callback` - A collection of all callback functions, see [`OH_AVCodecAsyncCallback`]
///
/// * `userData` - User specific data
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], inner resource has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state, must be called before Prepare.
///
/// **Deprecated** since 11
/// OH_VideoDecoder_RegisterCallback
///
/// Available since API-level: 9
#[deprecated(since = "11")]
pub fn OH_VideoDecoder_SetCallback(
codec: *mut OH_AVCodec,
callback: OH_AVCodecAsyncCallback,
userData: *mut ::core::ffi::c_void,
) -> OH_AVErrCode;
/// Set the asynchronous callback function so that your application can respond to the events
/// generated by the video decoder. This interface must be called before Prepare is called.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `callback` - A collection of all callback functions, see [`OH_AVCodecCallback`]
///
/// * `userData` - User specific data
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], inner resource has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state, must be called before Prepare.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_VideoDecoder_RegisterCallback(
codec: *mut OH_AVCodec,
callback: OH_AVCodecCallback,
userData: *mut ::core::ffi::c_void,
) -> OH_AVErrCode;
/// Specify the output Surface to provide video decoding output,
/// this interface must be called before Prepare is called
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `window` - A pointer to a OHNativeWindow instance, see [`OHNativeWindow`]
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], inner resource has already released.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface in buffer mode.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_SetSurface(
codec: *mut OH_AVCodec,
window: *mut OHNativeWindow,
) -> OH_AVErrCode;
/// To configure the video decoder, typically, you need to configure the description information of the decoded
/// video track, which can be extracted from the OH_AVSource. This interface must be called before Prepare is called.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `format` - A pointer to an OH_AVFormat to give the description of the video track to be decoded
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid. Invalid param in format.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state, must be called before Prepare.
/// [`AV_ERR_UNSUPPORT`], unsupported features.
/// [`AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION`], video unsupported color space conversion.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Configure(
codec: *mut OH_AVCodec,
format: *mut OH_AVFormat,
) -> OH_AVErrCode;
/// To prepare the internal resources of the decoder, the Configure interface must be called before
/// calling this interface.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], decoder is in buffer mode and color space conversion is configured.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Prepare(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Start the decoder, this interface must be called after the Prepare is successful.
/// After being successfully started, the decoder will start reporting NeedInputData events.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], video color space conversion is configured but decoder is not prepared.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Start(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Stop the decoder. After stopping, you can re-enter the Started state through Start,
/// but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Stop(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer
/// indexes previously reported through the asynchronous callback will be invalidated, make sure not to access
/// the Buffers corresponding to these indexes.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Flush(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Reset the decoder. To continue decoding, you need to call the Configure interface again
/// to configure the decoder instance.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_Reset(codec: *mut OH_AVCodec) -> OH_AVErrCode;
/// Get the description information of the output data of the decoder, refer to [`OH_AVFormat`]
/// It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs
/// to be manually released by the caller.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// # Returns
///
/// * Returns a pointer to an OH_AVFormat instance.
/// Return nullptr if the decoder is nullptr or invaild.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_GetOutputDescription(codec: *mut OH_AVCodec) -> *mut OH_AVFormat;
/// Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started.
/// At the same time, incorrect parameter settings may cause decoding failure.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `format` - pointer to an OH_AVFormat instance
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid. Invalid param in format.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 9
pub fn OH_VideoDecoder_SetParameter(
codec: *mut OH_AVCodec,
format: *mut OH_AVFormat,
) -> OH_AVErrCode;
/// Submit the input buffer filled with data to the video decoder. The [`OH_AVCodecOnNeedInputData`] callback
/// will report the available input buffer and the corresponding index value. Once the buffer with the specified index
/// is submitted to the video decoder, the buffer cannot be accessed again until the [`OH_AVCodecOnNeedInputData`]
/// callback is received again reporting that the buffer with the same index is available. In addition, for some
/// decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding
/// process of the decoder, such as PPS/SPS data in H264 format.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - Enter the index value corresponding to the Buffer
///
/// * `attr` - Information describing the data contained in the Buffer
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNeedInputData`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// **Deprecated** since 11
/// OH_VideoDecoder_PushInputBuffer
///
/// Available since API-level: 9
#[deprecated(since = "11")]
pub fn OH_VideoDecoder_PushInputData(
codec: *mut OH_AVCodec,
index: u32,
attr: OH_AVCodecBufferAttr,
) -> OH_AVErrCode;
/// Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the
/// decoded data contained in the Buffer on the output Surface. If the output surface is not configured before,
/// calling this interface only returns the output buffer corresponding to the specified index to the decoder.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index value corresponding to the output Buffer
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNewOutputData`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// **Deprecated** since 11
/// OH_VideoDecoder_RenderOutputBuffer
///
/// Available since API-level: 9
#[deprecated(since = "11")]
pub fn OH_VideoDecoder_RenderOutputData(codec: *mut OH_AVCodec, index: u32) -> OH_AVErrCode;
/// Return the processed output Buffer to the decoder.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index value corresponding to the output Buffer
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNewOutputData`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// **Deprecated** since 11
/// OH_VideoDecoder_FreeOutputBuffer
///
/// Available since API-level: 9
#[deprecated(since = "11")]
pub fn OH_VideoDecoder_FreeOutputData(codec: *mut OH_AVCodec, index: u32) -> OH_AVErrCode;
/// Submit the input buffer filled with data to the video decoder. The [`OH_AVCodecOnNeedInputBuffer`]
/// callback will report the available input buffer and the corresponding index value. Once the buffer with the
/// specified index is submitted to the video decoder, the buffer cannot be accessed again until the
/// [`OH_AVCodecOnNeedInputBuffer`] callback is received again reporting that the buffer with the same index is
/// available. In addition, for some decoders, it is required to input Codec-Specific-Data to the decoder at the
/// beginning to initialize the decoding process of the decoder, such as PPS/SPS data in H264 format.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index of the input buffer.
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNeedInputBuffer`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
/// [`AV_ERR_DRM_DECRYPT_FAILED`], the drm-protected video buffer is decrypted failed,
/// it is recommended to check the logs.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_VideoDecoder_PushInputBuffer(codec: *mut OH_AVCodec, index: u32) -> OH_AVErrCode;
/// Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the
/// decoded data contained in the Buffer on the output Surface. If the output surface is not configured before,
/// calling this interface only returns the output buffer corresponding to the specified index to the decoder.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index value corresponding to the output Buffer
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNewOutputBuffer`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_VideoDecoder_RenderOutputBuffer(codec: *mut OH_AVCodec, index: u32) -> OH_AVErrCode;
/// Return the processed output buffer with render timestamp to the decoder, and notify the decoder to finish
/// rendering the decoded data contained in the buffer on the output surface. If the output surface is not configured
/// before, calling this interface only returns the output buffer corresponding to the specified index to the decoder.
/// The timestamp may have special meaning depending on the destination surface.
/// Invoker can use the timestamp to render the buffer at a specific time (at the VSYNC at or after the buffer
/// timestamp). For this to work, the timestamp needs to be reasonably close to the current SystemNanoTime. A few notes:
/// 1. The buffer will not be returned to the codec until the timestamp has passed and the buffer is no longer used by
/// the surface.
/// 2. Buffers are processed sequentially, so you may block subsequent buffers to be displayed on the surface.
/// This is important if you want to react to user action, e.g. stop the video or seek.
/// 3. If multiple buffers are sent to the surface to be rendered at the same VSYNC, the last one will be shown, and the
/// other ones will be dropped.
/// 4. If the timestamp is not "reasonably close" to the current system time, the Surface will
/// ignore the timestamp, and display the buffer at the earliest feasible time. In this mode it will not drop frames.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index value corresponding to the output buffer, should be given by [`OH_AVCodecOnNewOutputBuffer`]
///
/// * `renderTimestampNs` - The timestamp is associated with the output buffer when it is sent to the surface. The unit
/// is nanosecond
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], the codec has already released.
/// [`AV_ERR_INVALID_VAL`], the parameter is invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 12
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub fn OH_VideoDecoder_RenderOutputBufferAtTime(
codec: *mut OH_AVCodec,
index: u32,
renderTimestampNs: i64,
) -> OH_AVErrCode;
/// Return the processed output Buffer to the decoder.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index value corresponding to the output Buffer
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// Buffer index should be given by [`OH_AVCodecOnNewOutputBuffer`].
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_VideoDecoder_FreeOutputBuffer(codec: *mut OH_AVCodec, index: u32) -> OH_AVErrCode;
/// Queries the index of the next available input buffer.
///
/// This API must be followed by calling [`OH_VideoDecoder_GetInputBuffer`] to obtain the buffer handle,
/// which should then be passed to the decoder via [`OH_VideoDecoder_PushInputBuffer`].
///
/// Note: This operation is only supported in synchronous mode.
///
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance.
///
/// * `index` - The index of the input buffer.
///
/// * `timeoutUs` - Timeout duration in microseconds, negative value indicates infinite wait.
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], internal errors in the input decode instance, such as an abnormal NULL.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
///
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permitted in asynchronous mode.
/// [`AV_ERR_TRY_AGAIN_LATER`], query failed, recommended retry after delay.
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub fn OH_VideoDecoder_QueryInputBuffer(
codec: *mut OH_AVCodec,
index: *mut u32,
timeoutUs: i64,
) -> OH_AVErrCode;
/// Acquires the handle of an available input buffer.
///
/// Note: It's only applicable in synchronous mode.
///
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - Buffer index obtained via [`OH_VideoDecoder_QueryInputBuffer`].
///
/// # Returns
///
/// * Returns a Pointer to an OH_AVBuffer instance.
/// Return nullptr if no buffer available.
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub fn OH_VideoDecoder_GetInputBuffer(codec: *mut OH_AVCodec, index: u32) -> *mut OH_AVBuffer;
/// Queries the index of the next available output buffer.
///
/// The obtained buffer handle through [`OH_VideoDecoder_GetOutputBuffer`] must be:
/// - Return to the decoder via [`OH_VideoDecoder_FreeOutputBuffer`], or
/// - Rendered using [`OH_VideoDecoder_RenderOutputBuffer`], or
/// - Scheduled for rendering with [`OH_VideoDecoder_RenderOutputBufferAtTime`]
///
/// Note: This operation is only supported in synchronous mode.
///
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - The index of the output buffer
///
/// * `timeoutUs` - Timeout duration in microseconds, negative value indicates infinite wait.
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], internal errors in the input decode instance, such as an abnormal NULL.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
/// [`AV_ERR_INVALID_STATE`], this interface was called in invalid state.
/// [`AV_ERR_OPERATE_NOT_PERMIT`], not permitted in asynchronous mode.
/// [`AV_ERR_STREAM_CHANGED`], stream format changed, call [`OH_VideoDecoder_GetOutputDescription`] to
/// retrieve new steam information.
/// [`AV_ERR_TRY_AGAIN_LATER`], query failed, recommended retry after delay.
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub fn OH_VideoDecoder_QueryOutputBuffer(
codec: *mut OH_AVCodec,
index: *mut u32,
timeoutUs: i64,
) -> OH_AVErrCode;
/// Acquires the handle of an available output buffer.
///
/// Note: It's only applicable in synchronous mode.
///
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `index` - Buffer index obtained via [`OH_VideoDecoder_QueryOutputBuffer`].
///
/// # Returns
///
/// * Returns a Pointer to an OH_AVBuffer instance.
/// Return nullptr if no buffer available.
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub fn OH_VideoDecoder_GetOutputBuffer(codec: *mut OH_AVCodec, index: u32) -> *mut OH_AVBuffer;
/// Check whether the current codec instance is valid. It can be used fault recovery or app
/// switchback from the background.
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `isValid` - Output parameter. A pointer to a boolean instance, it is true if the codec instance is valid,
/// false if the codec instance is invalid
///
/// # Returns
///
/// * Returns AV_ERR_OK if the execution is successful,
/// otherwise returns a specific error code, refer to [`OH_AVErrCode`].
/// [`AV_ERR_NO_MEMORY`], instance has already released.
/// [`AV_ERR_INVALID_VAL`], the decoder is nullptr or invalid.
/// [`AV_ERR_UNKNOWN`], unknown error.
/// [`AV_ERR_SERVICE_DIED`], avcodec service is died.
///
/// Available since API-level: 10
pub fn OH_VideoDecoder_IsValid(codec: *mut OH_AVCodec, isValid: *mut bool) -> OH_AVErrCode;
/// Set decryption info.
///
///
/// Required System Capabilities: SystemCapability.Multimedia.Media.VideoDecoder
/// # Arguments
///
/// * `codec` - Pointer to an OH_AVCodec instance
///
/// * `mediaKeySession` - A media key session instance with decryption function.
///
/// * `secureVideoPath` - Require secure decoder or not.
///
/// # Returns
///
/// * [`AV_ERR_OK`] 0 - Success
/// [`AV_ERR_OPERATE_NOT_PERMIT`] 2 - If the codec service or the media key session
/// service is in wrong status.
/// [`AV_ERR_NO_MEMORY`], instance has already released or no memory.
/// [`AV_ERR_INVALID_VAL`] 3 - If the codec instance is nullptr or invalid,
/// the mediaKeySession is nullptr or invalid.
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_VideoDecoder_SetDecryptionConfig(
codec: *mut OH_AVCodec,
mediaKeySession: *mut MediaKeySession,
secureVideoPath: bool,
) -> OH_AVErrCode;
}