ohos-media-sys 0.1.0

Raw Bindings to the media framework on OpenHarmony
Documentation
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
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)]
#[allow(unused_imports)]
use crate::avcodec_base::OH_AVOutputFormat;
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;
#[allow(unused_imports)]
use crate::avtranscoder_base::{
    OH_AVTranscoder, OH_AVTranscoder_Config, OH_AVTranscoder_OnError,
    OH_AVTranscoder_OnProgressUpdate, OH_AVTranscoder_OnStateChange,
};

extern "C" {
    /// Create a transcoder config
    ///
    /// # Returns
    ///
    /// * Returns a pointer to an OH_AVTranscoder_Config instance for success, nullptr for failure
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_Create() -> *mut OH_AVTranscoder_Config;
    /// release a transcoder config instance.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance.
    ///
    /// # Returns
    ///
    /// *
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_Release(config: *mut OH_AVTranscoder_Config) -> OH_AVErrCode;
    /// Set Source file descriptor for transcoding.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance.
    ///
    /// {int32_t} srcFd Source file descriptor.
    ///
    /// {int64_t} srcOffset The offset into the file where the data to be read, in bytes.
    ///
    /// {int64_t} length The length in bytes of the data to be read
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or file related parameter error.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetSrcFD(
        config: *mut OH_AVTranscoder_Config,
        srcFd: i32,
        srcOffset: i64,
        length: i64,
    ) -> OH_AVErrCode;
    /// Set destination file descriptor for transcoding.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {int32_t} dstFd Destination file descriptor
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or dstFd is invalid.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstFD(
        config: *mut OH_AVTranscoder_Config,
        dstFd: i32,
    ) -> OH_AVErrCode;
    /// Set destination video mime type.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {const char*} mimeType Destination video mime type. See native_avcodec_base.h
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is unrecognized.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstVideoType(
        config: *mut OH_AVTranscoder_Config,
        mimeType: *const ::core::ffi::c_char,
    ) -> OH_AVErrCode;
    /// Set destination audio mime type.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {const char*} mimeType Destination audio mime type. See native_avcodec_base.h
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is unrecognized.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstAudioType(
        config: *mut OH_AVTranscoder_Config,
        mimeType: *const ::core::ffi::c_char,
    ) -> OH_AVErrCode;
    /// Set destination file type.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {OH_AVOutputFormat} mimeType Destination file type. See native_avcodec_base.h
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is invalid.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstFileType(
        config: *mut OH_AVTranscoder_Config,
        mimeType: OH_AVOutputFormat,
    ) -> OH_AVErrCode;
    /// Set destination audio bitrate.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {int32_t} bitrate Destination audio bitrate.
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or bitrate value is invalid.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstAudioBitrate(
        config: *mut OH_AVTranscoder_Config,
        bitrate: i32,
    ) -> OH_AVErrCode;
    /// Set destination video bitrate.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {int32_t} bitrate Destination video bitrate.
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or bitrate value is invalid.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstVideoBitrate(
        config: *mut OH_AVTranscoder_Config,
        bitrate: i32,
    ) -> OH_AVErrCode;
    /// Set destination video resolution.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {int32_t} width Destination for video width.
    ///
    /// {int32_t} height Destination for video height.
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or width/height value is invalid.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_SetDstVideoResolution(
        config: *mut OH_AVTranscoder_Config,
        width: i32,
        height: i32,
    ) -> OH_AVErrCode;
    /// Create a transcoder
    ///
    /// # Returns
    ///
    /// * {OH_AVTranscoder*} Returns a pointer to an OH_AVTranscoder instance for success, nullptr for failure
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Create() -> *mut OH_AVTranscoder;
    /// Prepare for transcoding with a config.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance,
    /// see [`OH_AVTranscoder_Config`]
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder Prepare failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Prepare not allowed.
    /// [`AV_ERR_IO`] if Errors related to IO access
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if unsupported format.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Prepare(
        transcoder: *mut OH_AVTranscoder,
        config: *mut OH_AVTranscoder_Config,
    ) -> OH_AVErrCode;
    /// Start AVTranscoder.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder start failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
    /// [`AV_ERR_IO`] if errors related to IO access.
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Start(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
    /// Pause AVTranscoder.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder pause failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
    /// [`AV_ERR_IO`] if errors related to IO access.
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Pause(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
    /// Resume AVTranscoder.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder resume failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
    /// [`AV_ERR_IO`] if errors related to IO access.
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Resume(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
    /// Cancel AVTranscoder.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder stop failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
    /// [`AV_ERR_IO`] if errors related to IO access.
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Cancel(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
    /// Release AVTranscoder.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder release failed.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
    /// [`AV_ERR_IO`] if errors related to IO access.
    /// [`AV_ERR_SERVICE_DIED`] if media service died.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_Release(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
    /// Set the state callback function so that your application can respond to the
    /// state change events generated by the avtranscoder. This interface must be called before Start is called.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// {OH_AVTranscoder_OnStateChange} callback State callback function, see [`OH_AVTranscoder_OnStateChange`]
    ///
    /// {void*} userData Pointer to user specific data
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_SetStateCallback(
        transcoder: *mut OH_AVTranscoder,
        callback: OH_AVTranscoder_OnStateChange,
        userData: *mut ::core::ffi::c_void,
    ) -> OH_AVErrCode;
    /// Set the error callback function so that your application can respond to the
    /// error events generated by the avtranscoder. This interface must be called before Start is called.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// {OH_AVTranscoder_OnError} callback Error callback function, see [`OH_AVTranscoder_OnError`]
    ///
    /// {void*} userData Pointer to user specific data
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_SetErrorCallback(
        transcoder: *mut OH_AVTranscoder,
        callback: OH_AVTranscoder_OnError,
        userData: *mut ::core::ffi::c_void,
    ) -> OH_AVErrCode;
    /// Set the progress updating callback function so that your application can respond to the
    /// progress updating events generated by the avtranscoder. This interface must be called before Start is called.
    /// # Arguments
    ///
    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
    ///
    /// {OH_AVTranscoder_OnProgressUpdate} callback Uri callback function,
    /// see [`OH_AVTranscoder_OnProgressUpdate`]
    ///
    /// {void*} userData Pointer to user specific data
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoder_SetProgressUpdateCallback(
        transcoder: *mut OH_AVTranscoder,
        callback: OH_AVTranscoder_OnProgressUpdate,
        userData: *mut ::core::ffi::c_void,
    ) -> OH_AVErrCode;
    /// Enable B frame in destination video.
    /// # Arguments
    ///
    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
    ///
    /// {bool} enabled Whecher enable B Frame. If this function is not called, B Frame is disabled.
    ///
    /// # Returns
    ///
    /// * Function result code.
    /// [`AV_ERR_OK`] if the execution is successful.
    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_AVTranscoderConfig_EnableBFrame(
        config: *mut OH_AVTranscoder_Config,
        enabled: bool,
    ) -> OH_AVErrCode;
}