• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# video_processing_types.h
2<!--Kit: Media Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @wang-haizhou6-->
5<!--Designer: @HmQQQ-->
6<!--Tester: @xchaosioda-->
7<!--Adviser: @zengyawen-->
8
9## Overview
10
11The file declares the video processing types.
12
13**File to include**: <multimedia/video_processing_engine/video_processing_types.h>
14
15**Library**: libvideo_processing.so
16
17**System capability**: SystemCapability.Multimedia.VideoProcessingEngine
18
19**Since**: 12
20
21**Related module**: [VideoProcessing](capi-videoprocessing.md)
22
23## Summary
24
25### Structs
26
27| Name| typedef Keyword| Description|
28| -- | -- | -- |
29| [VideoProcessing_ColorSpaceInfo](capi-videoprocessing-videoprocessing-colorspaceinfo.md) | VideoProcessing_ColorSpaceInfo | Describes the color space information of video processing.|
30| [OH_VideoProcessing](capi-videoprocessing-oh-videoprocessing.md) | OH_VideoProcessing | Describes an object for video processing.<br>You should define a null pointer for **OH_VideoProcessing** and use [OH_VideoProcessing_Create](capi-video-processing-h.md#oh_videoprocessing_create) to create a video processing instance. Before creation, ensure that the pointer is null. You can create different video processing instances with different processing types.|
31| [NativeWindow](capi-videoprocessing-nativewindow.md) | OHNativeWindow | Describes the NativeWindow object.|
32| [OH_AVFormat](capi-videoprocessing-oh-avformat.md) | OH_AVFormat | Describes the OH_AVFormat object.|
33| [VideoProcessing_Callback](capi-videoprocessing-videoprocessing-callback.md) | VideoProcessing_Callback | Describes a callback object for handling video processing events.<br>You should define a null pointer for **VideoProcessing_Callback** and use [OH_VideoProcessingCallback_Create](capi-video-processing-h.md#oh_videoprocessingcallback_create) to create a callback object. Before creation, ensure that the pointer is null. After creating the callback object, call [OH_VideoProcessing_RegisterCallback](capi-video-processing-h.md#oh_videoprocessing_registercallback) to register it with the video processing instance.|
34
35### Enums
36
37| Name| typedef Keyword| Description|
38| -- | -- | -- |
39| [VideoDetailEnhancer_QualityLevel](#videodetailenhancer_qualitylevel) | VideoDetailEnhancer_QualityLevel | Enumerates the quality levels for detail enhancement.|
40| [VideoProcessing_ErrorCode](#videoprocessing_errorcode) | VideoProcessing_ErrorCode | Enumerates the video processing error codes.|
41| [VideoProcessing_State](#videoprocessing_state) | VideoProcessing_State | Enumerates the video processing states.<br>The video processing state is reported through the callback function [OH_VideoProcessingCallback_OnState](#oh_videoprocessingcallback_onstate).|
42
43### Functions
44
45| Name| typedef Keyword| Description|
46| -- | -- | -- |
47| [typedef void (\*OH_VideoProcessingCallback_OnError)(OH_VideoProcessing* videoProcessor,VideoProcessing_ErrorCode error, void* userData)](#oh_videoprocessingcallback_onerror) | OH_VideoProcessingCallback_OnError | Called when an error occurs during video processing.|
48| [typedef void (\*OH_VideoProcessingCallback_OnState)(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, void* userData)](#oh_videoprocessingcallback_onstate) | OH_VideoProcessingCallback_OnState | Called when the video processing state changes.<br>After [OH_VideoProcessing_Start](capi-video-processing-h.md#oh_videoprocessing_start) is called, the video processing state changes to [VideoProcessing_State](#videoprocessing_state).VIDEO_PROCESSING_STATE_RUNNING. After [OH_VideoProcessing_Stop](capi-video-processing-h.md#oh_videoprocessing_stop) is called, the video processing state changes to [VideoProcessing_State](#videoprocessing_state).VIDEO_PROCESSING_STATE_STOPPED after all buffers are processed.|
49| [typedef void (\*OH_VideoProcessingCallback_OnNewOutputBuffer)(OH_VideoProcessing* videoProcessor, uint32_t index, void* userData)](#oh_videoprocessingcallback_onnewoutputbuffer) | OH_VideoProcessingCallback_OnNewOutputBuffer | Called when the output buffer is filled with data.<br>After data is filled in each new output buffer, the index of the buffer is reported. Call [OH_VideoProcessing_RenderOutputBuffer](capi-video-processing-h.md#oh_videoprocessing_renderoutputbuffer) to process rendering based on the index and output the buffer. If this callback function is not registered, the data filled in the output buffer is not reported. Instead, the data is directly processed, rendered, and output.|
50
51### Variables
52
53| Name| Description|
54| -- | -- |
55| const int32_t VIDEO_PROCESSING_TYPE_COLOR_SPACE_CONVERSION | Instance created for color space conversion during video processing.<br>Call [OH_VideoProcessing_Create](capi-video-processing-h.md#oh_videoprocessing_create) to create such an instance for color space conversion. If color space conversion is not supported, [VideoProcessing_ErrorCode](#videoprocessing_errorcode).VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING is returned.<br>**Since**: 12|
56| const int32_t VIDEO_PROCESSING_TYPE_METADATA_GENERATION | Instance created for metadata generation during video processing.<br>Call [OH_VideoProcessing_Create](capi-video-processing-h.md#oh_videoprocessing_create) to create such an instance for metadata generation. If metadata generation is not supported, [VideoProcessing_ErrorCode](#videoprocessing_errorcode).VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING is returned.<br>**Since**: 12|
57| const int32_t VIDEO_PROCESSING_TYPE_DETAIL_ENHANCER | Instance for detail enhancement during video processing.<br>Call [OH_VideoProcessing_Create](capi-video-processing-h.md#oh_videoprocessing_create) to create such an instance for detail enhancement. If detail enhancement is not supported, [VideoProcessing_ErrorCode](#videoprocessing_errorcode).VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING is returned.<br>**Since**: 12|
58| const char* VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL | Pointer to the quality level of video detail enhancement. For details, see [VideoDetailEnhancer_QualityLevel](#videodetailenhancer_qualitylevel).<br>You can call [OH_VideoProcessing_SetParameter](capi-video-processing-h.md#oh_videoprocessing_setparameter) to set the quality level,<br>and call [OH_VideoProcessing_GetParameter](capi-video-processing-h.md#oh_videoprocessing_getparameter) to obtain the quality level.<br>**Since**: 12|
59
60## Enum Description
61
62### VideoDetailEnhancer_QualityLevel
63
64```
65enum VideoDetailEnhancer_QualityLevel
66```
67
68**Description**
69
70Enumerates the quality levels for detail enhancement. For details about the enumerated values, see **VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL**. For details about how to set the quality level, see the development guide.
71
72**Since**: 12
73
74| Enum Item| Description|
75| -- | -- |
76| VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_NONE | No detail enhancement.|
77| VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_LOW | Low-quality detail enhancement, which features fast speed. This is the default value.|
78| VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM | Medium-quality detail enhancement, which features moderate speed.|
79| VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH | High-quality detail enhancement, which features slow speed.|
80
81**See also**
82
83[OH_VideoProcessing_SetParameter](capi-video-processing-h.md#oh_videoprocessing_setparameter)
84
85[OH_VideoProcessing_GetParameter](capi-video-processing-h.md#oh_videoprocessing_getparameter)
86
87### VideoProcessing_ErrorCode
88
89```
90enum VideoProcessing_ErrorCode
91```
92
93**Description**
94
95Enumerates the video processing error codes.
96
97**Since**: 12
98
99| Enum Item| Description|
100| -- | -- |
101| VIDEO_PROCESSING_SUCCESS | The processing is successful.|
102| VIDEO_PROCESSING_ERROR_INVALID_PARAMETER = 401 | An input parameter is invalid. This error code is returned in the following cases:<br>1. The input or output video buffer is either invalid or empty.<br>2. The provided parameter is invalid or missing.<br>3. The requested processing type is invalid.|
103| VIDEO_PROCESSING_ERROR_UNKNOWN = 29210001 | An unknown error occurs. For example, the GPU computing or memcpy fails.|
104| VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED | The global video processing environment, for example, the GPU environment, fails to be initialized.|
105| VIDEO_PROCESSING_ERROR_CREATE_FAILED | Creating the video processing instance fails. For example, the total number of instances exceeds the upper limit.|
106| VIDEO_PROCESSING_ERROR_PROCESS_FAILED | The processing fails. For example, the processing times out.|
107| VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING | The processing type is not supported. You can call **OH_VideoProcessing_Is*XXX*Supported** to check whether a specific processing type is supported.|
108| VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED | The operation is not allowed. For example, the function is called in an incorrect running state.|
109| VIDEO_PROCESSING_ERROR_NO_MEMORY | Insufficient memory.|
110| VIDEO_PROCESSING_ERROR_INVALID_INSTANCE | The video processing instance is invalid, for example, a null instance.|
111| VIDEO_PROCESSING_ERROR_INVALID_VALUE | The input value is invalid. This error code is returned in the following cases:<br>1. The width and height of the video buffer are inappropriate or the color space is incorrect.<br>2. The parameter contains an invalid value. For example, the quality level of detail enhancement is incorrect.|
112
113### VideoProcessing_State
114
115```
116enum VideoProcessing_State
117```
118
119**Description**
120
121Enumerates the video processing states.
122
123The video processing state is reported through the callback function [OH_VideoProcessingCallback_OnState](#oh_videoprocessingcallback_onstate).
124
125**Since**: 12
126
127| Enum Item| Description|
128| -- | -- |
129| VIDEO_PROCESSING_STATE_RUNNING | Video processing is in progress.|
130| VIDEO_PROCESSING_STATE_STOPPED | Video processing stopped.|
131
132
133## Function Description
134
135### OH_VideoProcessingCallback_OnError()
136
137```
138typedef void (*OH_VideoProcessingCallback_OnError)(OH_VideoProcessing* videoProcessor,VideoProcessing_ErrorCode error, void* userData)
139```
140
141**Description**
142
143Called when an error occurs during video processing.
144
145The following error codes are defined in [VideoProcessing_ErrorCode](#videoprocessing_errorcode):
146
147**VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING**: unsupported processing. For example, conversion between the color space types for input and output is not supported.
148
149**VIDEO_PROCESSING_ERROR_INVALID_VALUE**: invalid video property. For example, the video color space is invalid.
150
151**VIDEO_PROCESSING_ERROR_NO_MEMORY**: out of memory.
152
153**VIDEO_PROCESSING_ERROR_PROCESS_FAILED**: An error occurs during the processing.
154
155**Since**: 12
156
157
158**Parameters**
159
160| Parameter| Description|
161| -- | -- |
162| [OH_VideoProcessing](capi-videoprocessing-oh-videoprocessing.md)* videoProcessor | Pointer to the video processing instance.|
163| [VideoProcessing_ErrorCode](#videoprocessing_errorcode) error | Error code reported.|
164|  void* userData | Pointer to user-defined data.|
165
166### OH_VideoProcessingCallback_OnState()
167
168```
169typedef void (*OH_VideoProcessingCallback_OnState)(OH_VideoProcessing* videoProcessor, VideoProcessing_State state,void* userData)
170```
171
172**Description**
173
174Called when the video processing state changes.
175
176After [OH_VideoProcessing_Start](capi-video-processing-h.md#oh_videoprocessing_start) is called, the video processing state changes to [VideoProcessing_State](#videoprocessing_state).VIDEO_PROCESSING_STATE_RUNNING. After [OH_VideoProcessing_Stop](capi-video-processing-h.md#oh_videoprocessing_stop) is called, the video processing state changes to [VideoProcessing_State](#videoprocessing_state).VIDEO_PROCESSING_STATE_STOPPED after all buffers are processed.
177
178**Since**: 12
179
180
181**Parameters**
182
183| Parameter| Description|
184| -- | -- |
185| [OH_VideoProcessing](capi-videoprocessing-oh-videoprocessing.md)* videoProcessor | Pointer to the video processing instance.|
186|  [VideoProcessing_State](#videoprocessing_state) state | Video processing state.|
187| void* userData | Pointer to user-defined data.|
188
189### OH_VideoProcessingCallback_OnNewOutputBuffer()
190
191```
192typedef void (*OH_VideoProcessingCallback_OnNewOutputBuffer)(OH_VideoProcessing* videoProcessor, uint32_t index,void* userData)
193```
194
195**Description**
196
197Called when the output buffer is filled with data.
198
199After data is filled in each new output buffer, the index of the buffer is reported. Call [OH_VideoProcessing_RenderOutputBuffer](capi-video-processing-h.md#oh_videoprocessing_renderoutputbuffer) to process rendering based on the index and output the buffer. If this callback function is not registered, the data filled in the output buffer is not reported. Instead, the data is directly processed, rendered, and output.
200
201**Since**: 12
202
203
204**Parameters**
205
206| Parameter| Description|
207| -- | -- |
208| [OH_VideoProcessing](capi-videoprocessing-oh-videoprocessing.md)* videoProcessor | Pointer to the video processing instance.|
209|  uint32_t index | Index of the output buffer.|
210| void* userData | Pointer to user-defined data.|
211