ohos-video-processing-engine-sys 0.1.0

Raw bindings to the multimedia VideoProcessingEngine (video_processing / image_processing) 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
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
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::video_processing_types::{
    OH_VideoProcessing, OH_VideoProcessingCallback_OnError,
    OH_VideoProcessingCallback_OnNewOutputBuffer, OH_VideoProcessingCallback_OnState,
    VideoProcessing_Callback, VideoProcessing_ColorSpaceInfo, VideoProcessing_ErrorCode,
};
use ohos_sys_opaque_types::{OHNativeWindow, OH_AVFormat};

extern "C" {
    /// Initialize global environment for video processing.
    ///
    /// This function is optional.
    ///
    /// Typically, this function is called once when the host process is started to initialize the global environment for
    /// video processing, which can reduce the time of [`OH_VideoProcessing_Create`].
    ///
    /// To deinitialize global environment, call [`OH_VideoProcessing_DeinitializeEnvironment`].
    ///
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if initialization is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED`] if initialization is failed.
    ///
    /// You can check if the device GPU is working properly.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_InitializeEnvironment() -> VideoProcessing_ErrorCode;
    /// Deinitialize global environment for video processing.
    ///
    /// This function is required if [`OH_VideoProcessing_InitializeEnvironment`] is called. Typically, this
    /// function is called when the host process is about to exit to deinitialize the global environment, which is
    /// initialized by calling [`OH_VideoProcessing_InitializeEnvironment`].
    ///
    /// If there is some video processing instance existing, this function should not be called.
    ///
    /// If the [`OH_VideoProcessing_InitializeEnvironment`] is not called, this function should not be called.
    ///
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if deinitialization is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if some video processing instance is not destroyed or
    /// [`OH_VideoProcessing_InitializeEnvironment`] is not called.
    ///
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_DeinitializeEnvironment() -> VideoProcessing_ErrorCode;
    /// Query if the video color space conversion is supported.
    ///
    /// # Arguments
    ///
    /// * `sourceVideoInfo` - Source video color space information.
    ///
    /// * `destinationVideoInfo` - Destination video color space information.
    ///
    /// # Returns
    ///
    /// * <b>true</b> if the video color space conversion is supported.
    ///
    /// <b>false</b> if the video color space conversion is not supported.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_IsColorSpaceConversionSupported(
        sourceVideoInfo: *const VideoProcessing_ColorSpaceInfo,
        destinationVideoInfo: *const VideoProcessing_ColorSpaceInfo,
    ) -> bool;
    /// Query if the video metadata generation is supported.
    ///
    /// # Arguments
    ///
    /// * `sourceVideoInfo` - Source video color space information.
    ///
    /// # Returns
    ///
    /// * <b>true</b> if the video metadata generation is supported.
    ///
    /// <b>false</b> if the video metadata generation is not supported.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_IsMetadataGenerationSupported(
        sourceVideoInfo: *const VideoProcessing_ColorSpaceInfo,
    ) -> bool;
    /// Create a video processing instance.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - Output parameter. The *videoProcessor points to a new video processing object.
    /// The *videoProcessor must be null before passed in.
    ///
    /// * `type` - Use VIDEO_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not
    /// be changed.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if creating a video processing instance successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the type is not supported. For example, if metadata
    /// generation is not supported by vendor, it returns unsupported processing.
    ///
    /// [`VIDEO_PROCESSING_ERROR_CREATE_FAILED`] if failed to create a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or <b>*</b>instance is <b>not</b> null.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if type is invalid.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_Create(
        videoProcessor: *mut *mut OH_VideoProcessing,
        type_: ::core::ffi::c_int,
    ) -> VideoProcessing_ErrorCode;
    /// Destroy the video processing instance.
    ///
    /// Stop the instance before destroying it. see [`OH_VideoProcessing_Stop`].
    ///
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - The video processing instance pointer to be destroyed. It is recommended setting the
    /// instance pointer to null after the instance is destroyed.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the instance is destroyed successfully .
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if the instance is still running.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_Destroy(
        videoProcessor: *mut OH_VideoProcessing,
    ) -> VideoProcessing_ErrorCode;
    /// Register callback object.
    ///
    /// Register the callback object before starting video processing.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// * `callback` - Callback pointer to be registered.
    ///
    /// * `userData` - User's custom data pointer.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if callback is registered successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if video processing instance is running.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_RegisterCallback(
        videoProcessor: *mut OH_VideoProcessing,
        callback: *const VideoProcessing_Callback,
        userData: *mut ::core::ffi::c_void,
    ) -> VideoProcessing_ErrorCode;
    /// Set the output surface for video processing.
    ///
    /// Set the output surface before starting video processing.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// * `window` - The output surface pointer.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if setting output surface successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if window is null.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_SetSurface(
        videoProcessor: *mut OH_VideoProcessing,
        window: *const OHNativeWindow,
    ) -> VideoProcessing_ErrorCode;
    /// Create an input surface.
    ///
    /// Create the input surface before starting video processing.
    /// Call [`OH_NativeWindow_DestroyNativeWindow`] to destroy the input surface.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// * `window` - The input surface pointer. For example, it is the output surface of a video decoder.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if operation is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if window is null or <b>*</b>window is <b>not</b> null.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if creating surface failed, input surface is already created
    /// or video processing instance is running.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_GetSurface(
        videoProcessor: *mut OH_VideoProcessing,
        window: *mut *mut OHNativeWindow,
    ) -> VideoProcessing_ErrorCode;
    /// Set parameter for video processing.
    ///
    /// Add parameter identified by the specified parameter key.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - An video processing instance pointer.
    ///
    /// * `parameter` - The parameter for video processing.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if setting parameter is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_VALUE`] if some property of the parameter is invalid. For example, the parameter
    /// contains unsupported parameter key or value.
    ///
    /// [`VIDEO_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_SetParameter(
        videoProcessor: *mut OH_VideoProcessing,
        parameter: *const OH_AVFormat,
    ) -> VideoProcessing_ErrorCode;
    /// Get parameter of video processing.
    ///
    /// Get parameter identified by the specified parameter key.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - An video processing instance pointer.
    ///
    /// * `parameter` - The parameter used by the video processing instance.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if getting parameter is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
    ///
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_GetParameter(
        videoProcessor: *mut OH_VideoProcessing,
        parameter: *mut OH_AVFormat,
    ) -> VideoProcessing_ErrorCode;
    /// Start video processing instance.
    ///
    /// After successfully calling this function, the state [`VIDEO_PROCESSING_STATE_RUNNING`] is reported by callback
    /// function [`OH_VideoProcessingCallback_OnState`].
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if output surface is not set, input surface is not created or
    /// instance is already running.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_Start(
        videoProcessor: *mut OH_VideoProcessing,
    ) -> VideoProcessing_ErrorCode;
    /// To stop video processing instance.
    ///
    /// After the video processing instance is stopped successfully, the state [`VIDEO_PROCESSING_STATE_STOPPED`] is
    /// reported by callback function [`OH_VideoProcessing_OnState`].
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if instance is already stopped.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_Stop(
        videoProcessor: *mut OH_VideoProcessing,
    ) -> VideoProcessing_ErrorCode;
    /// Send the output buffer out.
    ///
    /// If the callback function [`OH_VideoProcessingCallback_OnNewOutputBuffer`] is set, the buffer's index is reported
    /// to user by the callback function when an output buffer is ready.
    ///
    /// # Arguments
    ///
    /// * `videoProcessor` - A video processing instance pointer.
    ///
    /// * `index` - The output buffer's index.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the operation is successful.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not a video processing instance.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if index is invalid.
    ///
    /// [`VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if callback [`OH_VideoProcessing_OnNewOutputBuffer`] is
    /// not set or instance is stopped.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessing_RenderOutputBuffer(
        videoProcessor: *mut OH_VideoProcessing,
        index: u32,
    ) -> VideoProcessing_ErrorCode;
    /// Create a video processing callback object.
    ///
    /// # Arguments
    ///
    /// * `callback` - Output parameter. The *callback points to a new callback object. The *callback should be null before
    /// creating the callback object.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if callback object is created successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null or <b>*</b>callback is <b>not</b> null.
    ///
    /// [`VIDEO_PROCESSING_ERROR_NO_MEMORY`] if out of memory.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessingCallback_Create(
        callback: *mut *mut VideoProcessing_Callback,
    ) -> VideoProcessing_ErrorCode;
    /// Destroy the callback object.
    ///
    /// The callback object can be destroyed after it is registered to video processing instance.
    ///
    /// # Arguments
    ///
    /// * `callback` - The callback object pointer. It is recommended setting the callback pointer to null after the
    /// callback object is destroyed.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if callback is successfully destroyed.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if callback is null.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessingCallback_Destroy(
        callback: *mut VideoProcessing_Callback,
    ) -> VideoProcessing_ErrorCode;
    /// Bind the [`OH_VideoProcessingCallback_OnError`] callback function to callback object.
    ///
    /// # Arguments
    ///
    /// * `callback` - A callback object pointer.
    ///
    /// * `onError` - The callback function.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null or onError is null.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessingCallback_BindOnError(
        callback: *mut VideoProcessing_Callback,
        onError: OH_VideoProcessingCallback_OnError,
    ) -> VideoProcessing_ErrorCode;
    /// Bind the [`OH_VideoProcessingCallback_OnState`] callback function to callback object.
    ///
    /// # Arguments
    ///
    /// * `callback` - A callback object pointer.
    ///
    /// * `onState` - The callback function.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null or onState is null.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessingCallback_BindOnState(
        callback: *mut VideoProcessing_Callback,
        onState: OH_VideoProcessingCallback_OnState,
    ) -> VideoProcessing_ErrorCode;
    /// Bind the [`OH_VideoProcessingCallback_OnNewOutputBuffer`] callback function to callback object.
    ///
    /// # Arguments
    ///
    /// * `callback` - A callback object pointer.
    ///
    /// * `onNewOutputBuffer` - The callback function.
    ///
    /// # Returns
    ///
    /// * [`VIDEO_PROCESSING_SUCCESS`] if the function is bound to callback object successfully.
    ///
    /// [`VIDEO_PROCESSING_ERROR_INVALID_PARAMETER`] if the callback is null.
    ///
    /// Available since API-level: 12
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_VideoProcessingCallback_BindOnNewOutputBuffer(
        callback: *mut VideoProcessing_Callback,
        onNewOutputBuffer: OH_VideoProcessingCallback_OnNewOutputBuffer,
    ) -> VideoProcessing_ErrorCode;
}