ohos_video_processing_engine_sys/video_processing/video_processing_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)]
6use crate::video_processing_types::{
7 OH_VideoProcessing, OH_VideoProcessingCallback_OnError,
8 OH_VideoProcessingCallback_OnNewOutputBuffer, OH_VideoProcessingCallback_OnState,
9 VideoProcessing_Callback, VideoProcessing_ColorSpaceInfo, VideoProcessing_ErrorCode,
10};
11use ohos_sys_opaque_types::{OHNativeWindow, OH_AVFormat};
12
13extern "C" {
14 /// Initialize global environment for video processing.
15 ///
16 /// This function is optional.
17 ///
18 /// Typically, this function is called once when the host process is started to initialize the global environment for
19 /// video processing, which can reduce the time of [`OH_VideoProcessing_Create`].
20 ///
21 /// To deinitialize global environment, call [`OH_VideoProcessing_DeinitializeEnvironment`].
22 ///
23 ///
24 /// # Returns
25 ///
26 /// * [`VIDEO_PROCESSING_SUCCESS`] if initialization is successful.
27 ///
28 /// [`VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED`] if initialization is failed.
29 ///
30 /// You can check if the device GPU is working properly.
31 ///
32 /// Available since API-level: 12
33 #[cfg(feature = "api-12")]
34 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
35 pub fn OH_VideoProcessing_InitializeEnvironment() -> VideoProcessing_ErrorCode;
36 /// Deinitialize global environment for video processing.
37 ///
38 /// This function is required if [`OH_VideoProcessing_InitializeEnvironment`] is called. Typically, this
39 /// function is called when the host process is about to exit to deinitialize the global environment, which is
40 /// initialized by calling [`OH_VideoProcessing_InitializeEnvironment`].
41 ///
42 /// If there is some video processing instance existing, this function should not be called.
43 ///
44 /// If the [`OH_VideoProcessing_InitializeEnvironment`] is not called, this function should not be called.
45 ///
46 ///
47 /// # Returns
48 ///
49 /// * [`VIDEO_PROCESSING_SUCCESS`] if deinitialization is successful.
50 ///
51 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if some video processing instance is not destroyed or
52 /// [`OH_VideoProcessing_InitializeEnvironment`] is not called.
53 ///
54 ///
55 /// Available since API-level: 12
56 #[cfg(feature = "api-12")]
57 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
58 pub fn OH_VideoProcessing_DeinitializeEnvironment() -> VideoProcessing_ErrorCode;
59 /// Query if the video color space conversion is supported.
60 ///
61 /// # Arguments
62 ///
63 /// * `sourceVideoInfo` - Source video color space information.
64 ///
65 /// * `destinationVideoInfo` - Destination video color space information.
66 ///
67 /// # Returns
68 ///
69 /// * <b>true</b> if the video color space conversion is supported.
70 ///
71 /// <b>false</b> if the video color space conversion is not supported.
72 ///
73 /// Available since API-level: 12
74 #[cfg(feature = "api-12")]
75 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
76 pub fn OH_VideoProcessing_IsColorSpaceConversionSupported(
77 sourceVideoInfo: *const VideoProcessing_ColorSpaceInfo,
78 destinationVideoInfo: *const VideoProcessing_ColorSpaceInfo,
79 ) -> bool;
80 /// Query if the video metadata generation is supported.
81 ///
82 /// # Arguments
83 ///
84 /// * `sourceVideoInfo` - Source video color space information.
85 ///
86 /// # Returns
87 ///
88 /// * <b>true</b> if the video metadata generation is supported.
89 ///
90 /// <b>false</b> if the video metadata generation is not supported.
91 ///
92 /// Available since API-level: 12
93 #[cfg(feature = "api-12")]
94 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
95 pub fn OH_VideoProcessing_IsMetadataGenerationSupported(
96 sourceVideoInfo: *const VideoProcessing_ColorSpaceInfo,
97 ) -> bool;
98 /// Create a video processing instance.
99 ///
100 /// # Arguments
101 ///
102 /// * `videoProcessor` - Output parameter. The *videoProcessor points to a new video processing object.
103 /// The *videoProcessor must be null before passed in.
104 ///
105 /// * `type` - Use VIDEO_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not
106 /// be changed.
107 ///
108 /// # Returns
109 ///
110 /// * [`VIDEO_PROCESSING_SUCCESS`] if creating a video processing instance successfully.
111 ///
112 /// [`VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the type is not supported. For example, if metadata
113 /// generation is not supported by vendor, it returns unsupported processing.
114 ///
115 /// [`VIDEO_PROCESSING_ERROR_CREATE_FAILED`] if failed to create a video processing instance.
116 ///
117 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or <b>*</b>instance is <b>not</b> null.
118 ///
119 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if type is invalid.
120 ///
121 /// Available since API-level: 12
122 #[cfg(feature = "api-12")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
124 pub fn OH_VideoProcessing_Create(
125 videoProcessor: *mut *mut OH_VideoProcessing,
126 type_: ::core::ffi::c_int,
127 ) -> VideoProcessing_ErrorCode;
128 /// Destroy the video processing instance.
129 ///
130 /// Stop the instance before destroying it. see [`OH_VideoProcessing_Stop`].
131 ///
132 ///
133 /// # Arguments
134 ///
135 /// * `videoProcessor` - The video processing instance pointer to be destroyed. It is recommended setting the
136 /// instance pointer to null after the instance is destroyed.
137 ///
138 /// # Returns
139 ///
140 /// * [`VIDEO_PROCESSING_SUCCESS`] if the instance is destroyed successfully .
141 ///
142 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
143 ///
144 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if the instance is still running.
145 ///
146 /// Available since API-level: 12
147 #[cfg(feature = "api-12")]
148 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
149 pub fn OH_VideoProcessing_Destroy(
150 videoProcessor: *mut OH_VideoProcessing,
151 ) -> VideoProcessing_ErrorCode;
152 /// Register callback object.
153 ///
154 /// Register the callback object before starting video processing.
155 ///
156 /// # Arguments
157 ///
158 /// * `videoProcessor` - A video processing instance pointer.
159 ///
160 /// * `callback` - Callback pointer to be registered.
161 ///
162 /// * `userData` - User's custom data pointer.
163 ///
164 /// # Returns
165 ///
166 /// * [`VIDEO_PROCESSING_SUCCESS`] if callback is registered successfully.
167 ///
168 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
169 ///
170 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null.
171 ///
172 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if video processing instance is running.
173 ///
174 /// Available since API-level: 12
175 #[cfg(feature = "api-12")]
176 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
177 pub fn OH_VideoProcessing_RegisterCallback(
178 videoProcessor: *mut OH_VideoProcessing,
179 callback: *const VideoProcessing_Callback,
180 userData: *mut ::core::ffi::c_void,
181 ) -> VideoProcessing_ErrorCode;
182 /// Set the output surface for video processing.
183 ///
184 /// Set the output surface before starting video processing.
185 ///
186 /// # Arguments
187 ///
188 /// * `videoProcessor` - A video processing instance pointer.
189 ///
190 /// * `window` - The output surface pointer.
191 ///
192 /// # Returns
193 ///
194 /// * [`VIDEO_PROCESSING_SUCCESS`] if setting output surface successfully.
195 ///
196 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
197 ///
198 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if window is null.
199 ///
200 /// Available since API-level: 12
201 #[cfg(feature = "api-12")]
202 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
203 pub fn OH_VideoProcessing_SetSurface(
204 videoProcessor: *mut OH_VideoProcessing,
205 window: *const OHNativeWindow,
206 ) -> VideoProcessing_ErrorCode;
207 /// Create an input surface.
208 ///
209 /// Create the input surface before starting video processing.
210 /// Call [`OH_NativeWindow_DestroyNativeWindow`] to destroy the input surface.
211 ///
212 /// # Arguments
213 ///
214 /// * `videoProcessor` - A video processing instance pointer.
215 ///
216 /// * `window` - The input surface pointer. For example, it is the output surface of a video decoder.
217 ///
218 /// # Returns
219 ///
220 /// * [`VIDEO_PROCESSING_SUCCESS`] if operation is successful.
221 ///
222 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
223 ///
224 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if window is null or <b>*</b>window is <b>not</b> null.
225 ///
226 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if creating surface failed, input surface is already created
227 /// or video processing instance is running.
228 ///
229 /// Available since API-level: 12
230 #[cfg(feature = "api-12")]
231 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
232 pub fn OH_VideoProcessing_GetSurface(
233 videoProcessor: *mut OH_VideoProcessing,
234 window: *mut *mut OHNativeWindow,
235 ) -> VideoProcessing_ErrorCode;
236 /// Set parameter for video processing.
237 ///
238 /// Add parameter identified by the specified parameter key.
239 ///
240 /// # Arguments
241 ///
242 /// * `videoProcessor` - An video processing instance pointer.
243 ///
244 /// * `parameter` - The parameter for video processing.
245 ///
246 /// # Returns
247 ///
248 /// * [`VIDEO_PROCESSING_SUCCESS`] if setting parameter is successful.
249 ///
250 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an video processing instance.
251 ///
252 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
253 ///
254 /// [`VIDEO_PROCESSING_ERROR_INVALID_VALUE`] if some property of the parameter is invalid. For example, the parameter
255 /// contains unsupported parameter key or value.
256 ///
257 /// [`VIDEO_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
258 ///
259 /// Available since API-level: 12
260 #[cfg(feature = "api-12")]
261 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
262 pub fn OH_VideoProcessing_SetParameter(
263 videoProcessor: *mut OH_VideoProcessing,
264 parameter: *const OH_AVFormat,
265 ) -> VideoProcessing_ErrorCode;
266 /// Get parameter of video processing.
267 ///
268 /// Get parameter identified by the specified parameter key.
269 ///
270 /// # Arguments
271 ///
272 /// * `videoProcessor` - An video processing instance pointer.
273 ///
274 /// * `parameter` - The parameter used by the video processing instance.
275 ///
276 /// # Returns
277 ///
278 /// * [`VIDEO_PROCESSING_SUCCESS`] if getting parameter is successful.
279 ///
280 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an video processing instance.
281 ///
282 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
283 ///
284 ///
285 /// Available since API-level: 12
286 #[cfg(feature = "api-12")]
287 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
288 pub fn OH_VideoProcessing_GetParameter(
289 videoProcessor: *mut OH_VideoProcessing,
290 parameter: *mut OH_AVFormat,
291 ) -> VideoProcessing_ErrorCode;
292 /// Start video processing instance.
293 ///
294 /// After successfully calling this function, the state [`VIDEO_PROCESSING_STATE_RUNNING`] is reported by callback
295 /// function [`OH_VideoProcessingCallback_OnState`].
296 ///
297 /// # Arguments
298 ///
299 /// * `videoProcessor` - A video processing instance pointer.
300 ///
301 /// # Returns
302 ///
303 /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
304 ///
305 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
306 ///
307 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if output surface is not set, input surface is not created or
308 /// instance is already running.
309 ///
310 /// Available since API-level: 12
311 #[cfg(feature = "api-12")]
312 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
313 pub fn OH_VideoProcessing_Start(
314 videoProcessor: *mut OH_VideoProcessing,
315 ) -> VideoProcessing_ErrorCode;
316 /// To stop video processing instance.
317 ///
318 /// After the video processing instance is stopped successfully, the state [`VIDEO_PROCESSING_STATE_STOPPED`] is
319 /// reported by callback function [`OH_VideoProcessing_OnState`].
320 ///
321 /// # Arguments
322 ///
323 /// * `videoProcessor` - A video processing instance pointer.
324 ///
325 /// # Returns
326 ///
327 /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
328 ///
329 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
330 ///
331 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if instance is already stopped.
332 ///
333 /// Available since API-level: 12
334 #[cfg(feature = "api-12")]
335 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
336 pub fn OH_VideoProcessing_Stop(
337 videoProcessor: *mut OH_VideoProcessing,
338 ) -> VideoProcessing_ErrorCode;
339 /// Send the output buffer out.
340 ///
341 /// If the callback function [`OH_VideoProcessingCallback_OnNewOutputBuffer`] is set, the buffer's index is reported
342 /// to user by the callback function when an output buffer is ready.
343 ///
344 /// # Arguments
345 ///
346 /// * `videoProcessor` - A video processing instance pointer.
347 ///
348 /// * `index` - The output buffer's index.
349 ///
350 /// # Returns
351 ///
352 /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
353 ///
354 /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
355 ///
356 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if index is invalid.
357 ///
358 /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if callback [`OH_VideoProcessing_OnNewOutputBuffer`] is
359 /// not set or instance is stopped.
360 ///
361 /// Available since API-level: 12
362 #[cfg(feature = "api-12")]
363 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
364 pub fn OH_VideoProcessing_RenderOutputBuffer(
365 videoProcessor: *mut OH_VideoProcessing,
366 index: u32,
367 ) -> VideoProcessing_ErrorCode;
368 /// Create a video processing callback object.
369 ///
370 /// # Arguments
371 ///
372 /// * `callback` - Output parameter. The *callback points to a new callback object. The *callback should be null before
373 /// creating the callback object.
374 ///
375 /// # Returns
376 ///
377 /// * [`VIDEO_PROCESSING_SUCCESS`] if callback object is created successfully.
378 ///
379 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null or <b>*</b>callback is <b>not</b> null.
380 ///
381 /// [`VIDEO_PROCESSING_ERROR_NO_MEMORY`] if out of memory.
382 ///
383 /// Available since API-level: 12
384 #[cfg(feature = "api-12")]
385 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
386 pub fn OH_VideoProcessingCallback_Create(
387 callback: *mut *mut VideoProcessing_Callback,
388 ) -> VideoProcessing_ErrorCode;
389 /// Destroy the callback object.
390 ///
391 /// The callback object can be destroyed after it is registered to video processing instance.
392 ///
393 /// # Arguments
394 ///
395 /// * `callback` - The callback object pointer. It is recommended setting the callback pointer to null after the
396 /// callback object is destroyed.
397 ///
398 /// # Returns
399 ///
400 /// * [`VIDEO_PROCESSING_SUCCESS`] if callback is successfully destroyed.
401 ///
402 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null.
403 ///
404 /// Available since API-level: 12
405 #[cfg(feature = "api-12")]
406 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
407 pub fn OH_VideoProcessingCallback_Destroy(
408 callback: *mut VideoProcessing_Callback,
409 ) -> VideoProcessing_ErrorCode;
410 /// Bind the [`OH_VideoProcessingCallback_OnError`] callback function to callback object.
411 ///
412 /// # Arguments
413 ///
414 /// * `callback` - A callback object pointer.
415 ///
416 /// * `onError` - The callback function.
417 ///
418 /// # Returns
419 ///
420 /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
421 ///
422 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null or onError is null.
423 ///
424 /// Available since API-level: 12
425 #[cfg(feature = "api-12")]
426 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
427 pub fn OH_VideoProcessingCallback_BindOnError(
428 callback: *mut VideoProcessing_Callback,
429 onError: OH_VideoProcessingCallback_OnError,
430 ) -> VideoProcessing_ErrorCode;
431 /// Bind the [`OH_VideoProcessingCallback_OnState`] callback function to callback object.
432 ///
433 /// # Arguments
434 ///
435 /// * `callback` - A callback object pointer.
436 ///
437 /// * `onState` - The callback function.
438 ///
439 /// # Returns
440 ///
441 /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
442 ///
443 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null or onState is null.
444 ///
445 /// Available since API-level: 12
446 #[cfg(feature = "api-12")]
447 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
448 pub fn OH_VideoProcessingCallback_BindOnState(
449 callback: *mut VideoProcessing_Callback,
450 onState: OH_VideoProcessingCallback_OnState,
451 ) -> VideoProcessing_ErrorCode;
452 /// Bind the [`OH_VideoProcessingCallback_OnNewOutputBuffer`] callback function to callback object.
453 ///
454 /// # Arguments
455 ///
456 /// * `callback` - A callback object pointer.
457 ///
458 /// * `onNewOutputBuffer` - The callback function.
459 ///
460 /// # Returns
461 ///
462 /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
463 ///
464 /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null.
465 ///
466 /// Available since API-level: 12
467 #[cfg(feature = "api-12")]
468 #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
469 pub fn OH_VideoProcessingCallback_BindOnNewOutputBuffer(
470 callback: *mut VideoProcessing_Callback,
471 onNewOutputBuffer: OH_VideoProcessingCallback_OnNewOutputBuffer,
472 ) -> VideoProcessing_ErrorCode;
473}