Skip to main content

ohos_media_sys/avtranscoder/
avtranscoder_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#![allow(deprecated)]
7#[allow(unused_imports)]
8use crate::avcodec_base::OH_AVOutputFormat;
9#[allow(unused_imports)]
10use crate::averrors::OH_AVErrCode;
11#[allow(unused_imports)]
12use crate::avtranscoder_base::{
13    OH_AVTranscoder, OH_AVTranscoder_Config, OH_AVTranscoder_OnError,
14    OH_AVTranscoder_OnProgressUpdate, OH_AVTranscoder_OnStateChange,
15};
16
17extern "C" {
18    /// Create a transcoder config
19    ///
20    /// # Returns
21    ///
22    /// * Returns a pointer to an OH_AVTranscoder_Config instance for success, nullptr for failure
23    ///
24    /// Available since API-level: 20
25    #[cfg(feature = "api-20")]
26    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
27    pub fn OH_AVTranscoderConfig_Create() -> *mut OH_AVTranscoder_Config;
28    /// release a transcoder config instance.
29    /// # Arguments
30    ///
31    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance.
32    ///
33    /// # Returns
34    ///
35    /// *
36    /// * Function result code.
37    /// [`AV_ERR_OK`] if the execution is successful.
38    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr.
39    ///
40    /// Available since API-level: 20
41    #[cfg(feature = "api-20")]
42    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
43    pub fn OH_AVTranscoderConfig_Release(config: *mut OH_AVTranscoder_Config) -> OH_AVErrCode;
44    /// Set Source file descriptor for transcoding.
45    /// # Arguments
46    ///
47    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance.
48    ///
49    /// {int32_t} srcFd Source file descriptor.
50    ///
51    /// {int64_t} srcOffset The offset into the file where the data to be read, in bytes.
52    ///
53    /// {int64_t} length The length in bytes of the data to be read
54    ///
55    /// # Returns
56    ///
57    /// * Function result code.
58    /// [`AV_ERR_OK`] if the execution is successful.
59    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or file related parameter error.
60    ///
61    /// Available since API-level: 20
62    #[cfg(feature = "api-20")]
63    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
64    pub fn OH_AVTranscoderConfig_SetSrcFD(
65        config: *mut OH_AVTranscoder_Config,
66        srcFd: i32,
67        srcOffset: i64,
68        length: i64,
69    ) -> OH_AVErrCode;
70    /// Set destination file descriptor for transcoding.
71    /// # Arguments
72    ///
73    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
74    ///
75    /// {int32_t} dstFd Destination file descriptor
76    ///
77    /// # Returns
78    ///
79    /// * Function result code.
80    /// [`AV_ERR_OK`] if the execution is successful.
81    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or dstFd is invalid.
82    ///
83    /// Available since API-level: 20
84    #[cfg(feature = "api-20")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
86    pub fn OH_AVTranscoderConfig_SetDstFD(
87        config: *mut OH_AVTranscoder_Config,
88        dstFd: i32,
89    ) -> OH_AVErrCode;
90    /// Set destination video mime type.
91    /// # Arguments
92    ///
93    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
94    ///
95    /// {const char*} mimeType Destination video mime type. See native_avcodec_base.h
96    ///
97    /// # Returns
98    ///
99    /// * Function result code.
100    /// [`AV_ERR_OK`] if the execution is successful.
101    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is unrecognized.
102    ///
103    /// Available since API-level: 20
104    #[cfg(feature = "api-20")]
105    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
106    pub fn OH_AVTranscoderConfig_SetDstVideoType(
107        config: *mut OH_AVTranscoder_Config,
108        mimeType: *const ::core::ffi::c_char,
109    ) -> OH_AVErrCode;
110    /// Set destination audio mime type.
111    /// # Arguments
112    ///
113    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
114    ///
115    /// {const char*} mimeType Destination audio mime type. See native_avcodec_base.h
116    ///
117    /// # Returns
118    ///
119    /// * Function result code.
120    /// [`AV_ERR_OK`] if the execution is successful.
121    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is unrecognized.
122    ///
123    /// Available since API-level: 20
124    #[cfg(feature = "api-20")]
125    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
126    pub fn OH_AVTranscoderConfig_SetDstAudioType(
127        config: *mut OH_AVTranscoder_Config,
128        mimeType: *const ::core::ffi::c_char,
129    ) -> OH_AVErrCode;
130    /// Set destination file type.
131    /// # Arguments
132    ///
133    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
134    ///
135    /// {OH_AVOutputFormat} mimeType Destination file type. See native_avcodec_base.h
136    ///
137    /// # Returns
138    ///
139    /// * Function result code.
140    /// [`AV_ERR_OK`] if the execution is successful.
141    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or mimeType is invalid.
142    ///
143    /// Available since API-level: 20
144    #[cfg(feature = "api-20")]
145    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
146    pub fn OH_AVTranscoderConfig_SetDstFileType(
147        config: *mut OH_AVTranscoder_Config,
148        mimeType: OH_AVOutputFormat,
149    ) -> OH_AVErrCode;
150    /// Set destination audio bitrate.
151    /// # Arguments
152    ///
153    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
154    ///
155    /// {int32_t} bitrate Destination audio bitrate.
156    ///
157    /// # Returns
158    ///
159    /// * Function result code.
160    /// [`AV_ERR_OK`] if the execution is successful.
161    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or bitrate value is invalid.
162    ///
163    /// Available since API-level: 20
164    #[cfg(feature = "api-20")]
165    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
166    pub fn OH_AVTranscoderConfig_SetDstAudioBitrate(
167        config: *mut OH_AVTranscoder_Config,
168        bitrate: i32,
169    ) -> OH_AVErrCode;
170    /// Set destination video bitrate.
171    /// # Arguments
172    ///
173    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
174    ///
175    /// {int32_t} bitrate Destination video bitrate.
176    ///
177    /// # Returns
178    ///
179    /// * Function result code.
180    /// [`AV_ERR_OK`] if the execution is successful.
181    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or bitrate value is invalid.
182    ///
183    /// Available since API-level: 20
184    #[cfg(feature = "api-20")]
185    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
186    pub fn OH_AVTranscoderConfig_SetDstVideoBitrate(
187        config: *mut OH_AVTranscoder_Config,
188        bitrate: i32,
189    ) -> OH_AVErrCode;
190    /// Set destination video resolution.
191    /// # Arguments
192    ///
193    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
194    ///
195    /// {int32_t} width Destination for video width.
196    ///
197    /// {int32_t} height Destination for video height.
198    ///
199    /// # Returns
200    ///
201    /// * Function result code.
202    /// [`AV_ERR_OK`] if the execution is successful.
203    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr or width/height value is invalid.
204    ///
205    /// Available since API-level: 20
206    #[cfg(feature = "api-20")]
207    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
208    pub fn OH_AVTranscoderConfig_SetDstVideoResolution(
209        config: *mut OH_AVTranscoder_Config,
210        width: i32,
211        height: i32,
212    ) -> OH_AVErrCode;
213    /// Create a transcoder
214    ///
215    /// # Returns
216    ///
217    /// * {OH_AVTranscoder*} Returns a pointer to an OH_AVTranscoder instance for success, nullptr for failure
218    ///
219    /// Available since API-level: 20
220    #[cfg(feature = "api-20")]
221    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
222    pub fn OH_AVTranscoder_Create() -> *mut OH_AVTranscoder;
223    /// Prepare for transcoding with a config.
224    /// # Arguments
225    ///
226    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
227    ///
228    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance,
229    /// see [`OH_AVTranscoder_Config`]
230    ///
231    /// # Returns
232    ///
233    /// * Function result code.
234    /// [`AV_ERR_OK`] if the execution is successful.
235    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder Prepare failed.
236    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Prepare not allowed.
237    /// [`AV_ERR_IO`] if Errors related to IO access
238    /// [`AV_ERR_SERVICE_DIED`] if media service died.
239    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if unsupported format.
240    ///
241    /// Available since API-level: 20
242    #[cfg(feature = "api-20")]
243    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
244    pub fn OH_AVTranscoder_Prepare(
245        transcoder: *mut OH_AVTranscoder,
246        config: *mut OH_AVTranscoder_Config,
247    ) -> OH_AVErrCode;
248    /// Start AVTranscoder.
249    /// # Arguments
250    ///
251    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
252    ///
253    /// # Returns
254    ///
255    /// * Function result code.
256    /// [`AV_ERR_OK`] if the execution is successful.
257    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder start failed.
258    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
259    /// [`AV_ERR_IO`] if errors related to IO access.
260    /// [`AV_ERR_SERVICE_DIED`] if media service died.
261    ///
262    /// Available since API-level: 20
263    #[cfg(feature = "api-20")]
264    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
265    pub fn OH_AVTranscoder_Start(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
266    /// Pause AVTranscoder.
267    /// # Arguments
268    ///
269    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
270    ///
271    /// # Returns
272    ///
273    /// * Function result code.
274    /// [`AV_ERR_OK`] if the execution is successful.
275    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder pause failed.
276    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
277    /// [`AV_ERR_IO`] if errors related to IO access.
278    /// [`AV_ERR_SERVICE_DIED`] if media service died.
279    ///
280    /// Available since API-level: 20
281    #[cfg(feature = "api-20")]
282    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
283    pub fn OH_AVTranscoder_Pause(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
284    /// Resume AVTranscoder.
285    /// # Arguments
286    ///
287    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
288    ///
289    /// # Returns
290    ///
291    /// * Function result code.
292    /// [`AV_ERR_OK`] if the execution is successful.
293    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder resume failed.
294    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
295    /// [`AV_ERR_IO`] if errors related to IO access.
296    /// [`AV_ERR_SERVICE_DIED`] if media service died.
297    ///
298    /// Available since API-level: 20
299    #[cfg(feature = "api-20")]
300    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
301    pub fn OH_AVTranscoder_Resume(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
302    /// Cancel AVTranscoder.
303    /// # Arguments
304    ///
305    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
306    ///
307    /// # Returns
308    ///
309    /// * Function result code.
310    /// [`AV_ERR_OK`] if the execution is successful.
311    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder stop failed.
312    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
313    /// [`AV_ERR_IO`] if errors related to IO access.
314    /// [`AV_ERR_SERVICE_DIED`] if media service died.
315    ///
316    /// Available since API-level: 20
317    #[cfg(feature = "api-20")]
318    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
319    pub fn OH_AVTranscoder_Cancel(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
320    /// Release AVTranscoder.
321    /// # Arguments
322    ///
323    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
324    ///
325    /// # Returns
326    ///
327    /// * Function result code.
328    /// [`AV_ERR_OK`] if the execution is successful.
329    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or transcoder release failed.
330    /// [`AV_ERR_OPERATE_NOT_PERMIT`] if the operation of Start not allowed.
331    /// [`AV_ERR_IO`] if errors related to IO access.
332    /// [`AV_ERR_SERVICE_DIED`] if media service died.
333    ///
334    /// Available since API-level: 20
335    #[cfg(feature = "api-20")]
336    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
337    pub fn OH_AVTranscoder_Release(transcoder: *mut OH_AVTranscoder) -> OH_AVErrCode;
338    /// Set the state callback function so that your application can respond to the
339    /// state change events generated by the avtranscoder. This interface must be called before Start is called.
340    /// # Arguments
341    ///
342    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
343    ///
344    /// {OH_AVTranscoder_OnStateChange} callback State callback function, see [`OH_AVTranscoder_OnStateChange`]
345    ///
346    /// {void*} userData Pointer to user specific data
347    ///
348    /// # Returns
349    ///
350    /// * Function result code.
351    /// [`AV_ERR_OK`] if the execution is successful.
352    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
353    ///
354    /// Available since API-level: 20
355    #[cfg(feature = "api-20")]
356    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
357    pub fn OH_AVTranscoder_SetStateCallback(
358        transcoder: *mut OH_AVTranscoder,
359        callback: OH_AVTranscoder_OnStateChange,
360        userData: *mut ::core::ffi::c_void,
361    ) -> OH_AVErrCode;
362    /// Set the error callback function so that your application can respond to the
363    /// error events generated by the avtranscoder. This interface must be called before Start is called.
364    /// # Arguments
365    ///
366    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
367    ///
368    /// {OH_AVTranscoder_OnError} callback Error callback function, see [`OH_AVTranscoder_OnError`]
369    ///
370    /// {void*} userData Pointer to user specific data
371    ///
372    /// # Returns
373    ///
374    /// * Function result code.
375    /// [`AV_ERR_OK`] if the execution is successful.
376    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
377    ///
378    /// Available since API-level: 20
379    #[cfg(feature = "api-20")]
380    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
381    pub fn OH_AVTranscoder_SetErrorCallback(
382        transcoder: *mut OH_AVTranscoder,
383        callback: OH_AVTranscoder_OnError,
384        userData: *mut ::core::ffi::c_void,
385    ) -> OH_AVErrCode;
386    /// Set the progress updating callback function so that your application can respond to the
387    /// progress updating events generated by the avtranscoder. This interface must be called before Start is called.
388    /// # Arguments
389    ///
390    /// {OH_AVTranscoder*} transcoder Pointer to an OH_AVTranscoder instance
391    ///
392    /// {OH_AVTranscoder_OnProgressUpdate} callback Uri callback function,
393    /// see [`OH_AVTranscoder_OnProgressUpdate`]
394    ///
395    /// {void*} userData Pointer to user specific data
396    ///
397    /// # Returns
398    ///
399    /// * Function result code.
400    /// [`AV_ERR_OK`] if the execution is successful.
401    /// [`AV_ERR_INVALID_VAL`] if input transcoder is nullptr or input callback is nullptr.
402    ///
403    /// Available since API-level: 20
404    #[cfg(feature = "api-20")]
405    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
406    pub fn OH_AVTranscoder_SetProgressUpdateCallback(
407        transcoder: *mut OH_AVTranscoder,
408        callback: OH_AVTranscoder_OnProgressUpdate,
409        userData: *mut ::core::ffi::c_void,
410    ) -> OH_AVErrCode;
411    /// Enable B frame in destination video.
412    /// # Arguments
413    ///
414    /// {OH_AVTranscoder_Config*} config Pointer to an OH_AVTranscoder_Config instance
415    ///
416    /// {bool} enabled Whecher enable B Frame. If this function is not called, B Frame is disabled.
417    ///
418    /// # Returns
419    ///
420    /// * Function result code.
421    /// [`AV_ERR_OK`] if the execution is successful.
422    /// [`AV_ERR_INVALID_VAL`] if input config is nullptr.
423    ///
424    /// Available since API-level: 20
425    #[cfg(feature = "api-20")]
426    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
427    pub fn OH_AVTranscoderConfig_EnableBFrame(
428        config: *mut OH_AVTranscoder_Config,
429        enabled: bool,
430    ) -> OH_AVErrCode;
431}