• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_NativeBuffer
2
3## Overview
4
5The OH_NativeBuffer module provides the capabilities of **NativeBuffer**. Using the functions provided by this module, you can apply for, use, and release the shared memory, and query its properties.
6
7**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
8
9**Since**: 9
10
11
12## Summary
13
14
15### Files
16
17| Name| Description|
18| -------- | -------- |
19| [buffer_common.h](buffer__common_8h.md) | Declares the common types used in the NativeBuffer module.<br>Since API version 12, certain type definitions have been relocated from **native_buffer.h** to this header file for a more cohesive presentation. These types were available prior to API version 12 and can be used seamlessly across all versions.|
20| [native_buffer.h](native__buffer_8h.md) | Declares the functions for obtaining and using **NativeBuffer**. |
21
22
23### Structs
24
25| Name| Description|
26| -------- | -------- |
27| struct  [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | Describes the **OH_NativeBuffer** property configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the properties of an existing instance.|
28| struct  [OH_NativeBuffer_Plane](_o_h___native_buffer___plane.md) | Describes the plane information of an image.|
29| struct  [OH_NativeBuffer_Planes](_o_h___native_buffer___planes.md) | Describes the plane information of images in an **OH_NativeBuffer** instance.|
30| struct  [OH_NativeBuffer_ColorXY](_o_h___native_buffer___color_x_y.md) | Describes the X and Y coordinates of the primary color.|
31| struct  [OH_NativeBuffer_Smpte2086](_o_h___native_buffer___smpte2086.md) | Describes the SMPTE ST 2086 static metadata.|
32| struct  [OH_NativeBuffer_Cta861](_o_h___native_buffer___cta861.md) | Describes the CTA-861.3 static metadata.|
33| struct  [OH_NativeBuffer_StaticMetadata](_o_h___native_buffer___static_metadata.md) | Describes the HDR static metadata.|
34
35
36### Types
37
38| Name| Description|
39| -------- | -------- |
40| typedef struct [OH_NativeBuffer](#oh_nativebuffer)  [OH_NativeBuffer](#oh_nativebuffer) | Provides the declaration of an **OH_NativeBuffer** struct.|
41| typedef enum [OH_NativeBuffer_Usage](#oh_nativebuffer_usage-1)  [OH_NativeBuffer_Usage](#oh_nativebuffer_usage) | Defines an enum for the **OH_NativeBuffer** usages.|
42| typedef enum [OH_NativeBuffer_Format](#oh_nativebuffer_format-1)  [OH_NativeBuffer_Format](#oh_nativebuffer_format) | Defines an enum for the **OH_NativeBuffer** formats.|
43| typedef enum [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace-1)  [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace) | Defines an enum for the color spaces of an **OH_NativeBuffer** instance.|
44| typedef enum [OH_NativeBuffer_TransformType](#oh_nativebuffer_transformtype-1)  [OH_NativeBuffer_TransformType](#oh_nativebuffer_transformtype) | Defines an enum for the transform types of an **OH_NativeBuffer** instance.|
45| typedef enum [OH_NativeBuffer_ColorGamut](#oh_nativebuffer_colorgamut-1)  [OH_NativeBuffer_ColorGamut](#oh_nativebuffer_colorgamut) | Defines an enum for the color gamuts of an **OH_NativeBuffer** instance.|
46| typedef enum [OHNativeErrorCode](_native_window.md#ohnativeerrorcode-1)  [OHNativeErrorCode](#ohnativeerrorcode) | Defines an enum for the error codes.|
47| typedef struct [OH_NativeBuffer_Config](_o_h___native_buffer___config.md)  [OH_NativeBuffer_Config](#oh_nativebuffer_config) | Defines the **OH_NativeBuffer** property configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the properties of an existing instance.|
48| typedef struct [OH_NativeBuffer_Plane](_o_h___native_buffer___plane.md)  [OH_NativeBuffer_Plane](#oh_nativebuffer_plane) | Defines a struct for the plane information of an image.|
49| typedef struct [OH_NativeBuffer_Planes](_o_h___native_buffer___planes.md)  [OH_NativeBuffer_Planes](#oh_nativebuffer_planes) | Defines a struct for the plane information of images in an **OH_NativeBuffer** instance.|
50| typedef enum [OH_NativeBuffer_MetadataType](#oh_nativebuffer_metadatatype)  [OH_NativeBuffer_MetadataType](#oh_nativebuffer_metadatatype) | Defines an enum for the **OH_NativeBuffer** image standards.|
51| typedef struct [OH_NativeBuffer_ColorXY](_o_h___native_buffer___color_x_y.md)  [OH_NativeBuffer_ColorXY](#oh_nativebuffer_colorxy) | Defines a struct for the X and Y coordinates of the primary color.|
52| typedef struct [OH_NativeBuffer_Smpte2086](_o_h___native_buffer___smpte2086.md)  [OH_NativeBuffer_Smpte2086](#oh_nativebuffer_smpte2086) | Defines a struct for the SMPTE ST 2086 static metadata.|
53| typedef struct [OH_NativeBuffer_Cta861](_o_h___native_buffer___cta861.md)  [OH_NativeBuffer_Cta861](#oh_nativebuffer_cta861) | Defines a struct for the CTA-861.3 static metadata.|
54| typedef struct [OH_NativeBuffer_StaticMetadata](_o_h___native_buffer___static_metadata.md)  [OH_NativeBuffer_StaticMetadata](#oh_nativebuffer_staticmetadata) | Defines a struct for the HDR static metadata.|
55| typedef enum [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1)  [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey) | Defines an enum for the keys that specify the HDR metadata of an **OH_NativeBuffer** instance.|
56
57
58### Enums
59
60| Name| Description|
61| -------- | -------- |
62| [OH_NativeBuffer_Usage](#oh_nativebuffer_usage-1) {<br>NATIVEBUFFER_USAGE_CPU_READ = (1ULL &lt;&lt; 0), NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL &lt;&lt; 1), NATIVEBUFFER_USAGE_MEM_DMA = (1ULL &lt;&lt; 3), NATIVEBUFFER_USAGE_HW_RENDER = (1ULL &lt;&lt; 8),<br>NATIVEBUFFER_USAGE_HW_TEXTURE = (1ULL &lt;&lt; 9), NATIVEBUFFER_USAGE_CPU_READ_OFTEN = (1ULL &lt;&lt; 16), NATIVEBUFFER_USAGE_ALIGNMENT_512 = (1ULL &lt;&lt; 18)<br>} | Enumerates the **OH_NativeBuffer** usages.|
63| [OH_NativeBuffer_Format](#oh_nativebuffer_format-1) {<br>NATIVEBUFFER_PIXEL_FMT_CLUT8 = 0, NATIVEBUFFER_PIXEL_FMT_CLUT1, NATIVEBUFFER_PIXEL_FMT_CLUT4, NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3,<br>NATIVEBUFFER_PIXEL_FMT_RGBA_5658, NATIVEBUFFER_PIXEL_FMT_RGBX_4444, NATIVEBUFFER_PIXEL_FMT_RGBA_4444, NATIVEBUFFER_PIXEL_FMT_RGB_444,<br>NATIVEBUFFER_PIXEL_FMT_RGBX_5551, NATIVEBUFFER_PIXEL_FMT_RGBA_5551, NATIVEBUFFER_PIXEL_FMT_RGB_555, NATIVEBUFFER_PIXEL_FMT_RGBX_8888,<br>NATIVEBUFFER_PIXEL_FMT_RGBA_8888, NATIVEBUFFER_PIXEL_FMT_RGB_888, NATIVEBUFFER_PIXEL_FMT_BGR_565, NATIVEBUFFER_PIXEL_FMT_BGRX_4444,<br>NATIVEBUFFER_PIXEL_FMT_BGRA_4444, NATIVEBUFFER_PIXEL_FMT_BGRX_5551, NATIVEBUFFER_PIXEL_FMT_BGRA_5551, NATIVEBUFFER_PIXEL_FMT_BGRX_8888,<br>NATIVEBUFFER_PIXEL_FMT_BGRA_8888, NATIVEBUFFER_PIXEL_FMT_YUV_422_I, NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP, NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP,<br>NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP, NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP, NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P, NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P,<br>NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P, NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P, NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG, NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG,<br>NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG, NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG, NATIVEBUFFER_PIXEL_FMT_RGBA_1010102, NATIVEBUFFER_PIXEL_FMT_YCBCR_P010,<br>NATIVEBUFFER_PIXEL_FMT_YCRCB_P010, NATIVEBUFFER_PIXEL_FMT_RAW10, NATIVEBUFFER_PIXEL_FMT_BLOB, NATIVEBUFFER_PIXEL_FMT_RGBA16_FLOAT, NATIVEBUFFER_PIXEL_FMT_VENDER_MASK = 0X7FFF0000, NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF<br>} | Enumerates the **OH_NativeBuffer** formats.|
64| [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace-1) {<br>OH_COLORSPACE_NONE, OH_COLORSPACE_BT601_EBU_FULL, OH_COLORSPACE_BT601_SMPTE_C_FULL, OH_COLORSPACE_BT709_FULL,<br>OH_COLORSPACE_BT2020_HLG_FULL, OH_COLORSPACE_BT2020_PQ_FULL, OH_COLORSPACE_BT601_EBU_LIMIT, OH_COLORSPACE_BT601_SMPTE_C_LIMIT,<br>OH_COLORSPACE_BT709_LIMIT, OH_COLORSPACE_BT2020_HLG_LIMIT, OH_COLORSPACE_BT2020_PQ_LIMIT, OH_COLORSPACE_SRGB_FULL,<br>OH_COLORSPACE_P3_FULL, OH_COLORSPACE_P3_HLG_FULL, OH_COLORSPACE_P3_PQ_FULL, OH_COLORSPACE_ADOBERGB_FULL,<br>OH_COLORSPACE_SRGB_LIMIT, OH_COLORSPACE_P3_LIMIT, OH_COLORSPACE_P3_HLG_LIMIT, OH_COLORSPACE_P3_PQ_LIMIT,<br>OH_COLORSPACE_ADOBERGB_LIMIT, OH_COLORSPACE_LINEAR_SRGB, OH_COLORSPACE_LINEAR_BT709, OH_COLORSPACE_LINEAR_P3,<br>OH_COLORSPACE_LINEAR_BT2020, OH_COLORSPACE_DISPLAY_SRGB, OH_COLORSPACE_DISPLAY_P3_SRGB, OH_COLORSPACE_DISPLAY_P3_HLG,<br>OH_COLORSPACE_DISPLAY_P3_PQ, OH_COLORSPACE_DISPLAY_BT2020_SRGB, OH_COLORSPACE_DISPLAY_BT2020_HLG, OH_COLORSPACE_DISPLAY_BT2020_PQ<br>} | Enumerates the color spaces of an **OH_NativeBuffer** instance.|
65| [OH_NativeBuffer_TransformType](#oh_nativebuffer_transformtype-1) {<br>NATIVEBUFFER_ROTATE_NONE = 0, NATIVEBUFFER_ROTATE_90, NATIVEBUFFER_ROTATE_180, NATIVEBUFFER_ROTATE_270,<br>NATIVEBUFFER_FLIP_H, NATIVEBUFFER_FLIP_V, NATIVEBUFFER_FLIP_H_ROT90, NATIVEBUFFER_FLIP_V_ROT90,<br>NATIVEBUFFER_FLIP_H_ROT180, NATIVEBUFFER_FLIP_V_ROT180, NATIVEBUFFER_FLIP_H_ROT270, NATIVEBUFFER_FLIP_V_ROT270<br>} | Enumerates the transform types of an **OH_NativeBuffer** instance.|
66| [OH_NativeBuffer_ColorGamut](#oh_nativebuffer_colorgamut-1) {<br>NATIVEBUFFER_COLOR_GAMUT_NATIVE = 0, NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 = 1, NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 = 2, NATIVEBUFFER_COLOR_GAMUT_DCI_P3 = 3,<br>NATIVEBUFFER_COLOR_GAMUT_SRGB = 4, NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB = 5, NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 = 6, NATIVEBUFFER_COLOR_GAMUT_BT2020 = 7,<br>NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ = 8, NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG = 9, NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 = 10<br>} | Enumerates the color gamuts of an **OH_NativeBuffer** instance.|
67| [OHNativeErrorCode](#ohnativeerrorcode-1) {<br>NATIVE_ERROR_OK = 0,NATIVE_ERROR_MEM_OPERATION_ERROR = 30001000, NATIVE_ERROR_INVALID_ARGUMENTS = 40001000, NATIVE_ERROR_NO_PERMISSION = 40301000, NATIVE_ERROR_NO_BUFFER = 40601000,<br>NATIVE_ERROR_NO_CONSUMER = 41202000, NATIVE_ERROR_NOT_INIT = 41203000, NATIVE_ERROR_CONSUMER_CONNECTED = 41206000, NATIVE_ERROR_BUFFER_STATE_INVALID = 41207000,<br>NATIVE_ERROR_BUFFER_IN_CACHE = 41208000, NATIVE_ERROR_BUFFER_QUEUE_FULL = 41209000, NATIVE_ERROR_BUFFER_NOT_IN_CACHE = 41210000,NATIVE_ERROR_CONSUMER_DISCONNECTED = 41211000,NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED = 41212000, NATIVE_ERROR_UNSUPPORTED = 50102000,<br>NATIVE_ERROR_UNKNOWN = 50002000,NATIVE_ERROR_HDI_ERROR = 50007000,NATIVE_ERROR_BINDER_ERROR = 50401000, NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, NATIVE_ERROR_EGL_API_FAILED = 60002000<br>} | Enumerates the error codes. |
68| [OH_NativeBuffer_MetadataType](#oh_nativebuffer_metadatatype-1) { OH_VIDEO_HDR_HLG, OH_VIDEO_HDR_HDR10, OH_VIDEO_HDR_VIVID,OH_VIDEO_NONE = -1 } | Enumerates the **OH_NativeBuffer** image standards.|
69| [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1) { OH_HDR_METADATA_TYPE, OH_HDR_STATIC_METADATA, OH_HDR_DYNAMIC_METADATA } | Enumerates the keys that specify the HDR metadata of an **OH_NativeBuffer** instance.|
70
71
72### Functions
73
74| Name| Description|
75| -------- | -------- |
76| [OH_NativeBuffer](#oh_nativebuffer) \* [OH_NativeBuffer_Alloc](#oh_nativebuffer_alloc) (const [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called.|
77| int32_t [OH_NativeBuffer_Reference](#oh_nativebuffer_reference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Increases the reference count of an **OH_NativeBuffer** instance by 1.|
78| int32_t [OH_NativeBuffer_Unreference](#oh_nativebuffer_unreference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.|
79| void [OH_NativeBuffer_GetConfig](#oh_nativebuffer_getconfig) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | Obtains the properties of an **OH_NativeBuffer** instance.|
80| int32_t [OH_NativeBuffer_Map](#oh_nativebuffer_map) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, void \*\*virAddr) | Maps the ION memory allocated to an **OH_NativeBuffer** instance to the process address space.|
81| int32_t [OH_NativeBuffer_Unmap](#oh_nativebuffer_unmap) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Unmaps the ION memory allocated to an **OH_NativeBuffer** instance from the process address space.|
82| uint32_t [OH_NativeBuffer_GetSeqNum](#oh_nativebuffer_getseqnum) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | Obtains the sequence number of an **OH_NativeBuffer** instance.|
83| int32_t [OH_NativeBuffer_SetColorSpace](#oh_nativebuffer_setcolorspace) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace) colorSpace) | Sets the color space for an **OH_NativeBuffer** instance.|
84| int32_t [OH_NativeBuffer_MapPlanes](#oh_nativebuffer_mapplanes) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, void \*\*virAddr, [OH_NativeBuffer_Planes](_o_h___native_buffer___planes.md) \*outPlanes) | Maps the multi-channel ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.|
85| int32_t [OH_NativeBuffer_FromNativeWindowBuffer](#oh_nativebuffer_fromnativewindowbuffer) ([OHNativeWindowBuffer](_native_window.md#ohnativewindowbuffer) \*nativeWindowBuffer, [OH_NativeBuffer](#oh_nativebuffer) \*\*buffer) | Converts an **OHNativeWindowBuffer** instance to an **OH_NativeBuffer** instance.|
86| int32_t [OH_NativeBuffer_GetColorSpace](#oh_nativebuffer_getcolorspace) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace) \*colorSpace) | Obtains the color space of an **OH_NativeBuffer** instance.|
87| int32_t [OH_NativeBuffer_SetMetadataValue](#oh_nativebuffer_setmetadatavalue) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey) metadataKey, int32_t size, uint8_t \*metaData) | Sets a metadata value for an **OH_NativeBuffer** instance.|
88| int32_t [OH_NativeBuffer_GetMetadataValue](#oh_nativebuffer_getmetadatavalue) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey) metadataKey, int32_t \*size, uint8_t \*\*metaData) | Obtains the metadata value of an **OH_NativeBuffer** instance.|
89
90
91## Type Description
92
93
94### OH_NativeBuffer
95
96```
97typedef struct OH_NativeBuffer OH_NativeBuffer
98```
99
100**Description**
101
102Provides the declaration of an **OH_NativeBuffer** struct.
103
104**Since**: 9
105
106
107### OH_NativeBuffer_ColorGamut
108
109```
110typedef enum OH_NativeBuffer_ColorGamut OH_NativeBuffer_ColorGamut
111```
112
113**Description**
114
115Defines an enum for the color gamuts of an **OH_NativeBuffer** instance.
116
117**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
118
119**Since**: 12
120
121
122### OH_NativeBuffer_ColorSpace
123
124```
125typedef enum OH_NativeBuffer_ColorSpace OH_NativeBuffer_ColorSpace
126```
127
128**Description**
129
130Defines an enum for the color spaces of an **OH_NativeBuffer** instance.
131
132**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
133
134**Since**: 11
135
136
137### OH_NativeBuffer_ColorXY
138
139```
140typedef struct OH_NativeBuffer_ColorXY OH_NativeBuffer_ColorXY
141```
142
143**Description**
144
145Defines a struct for the X and Y coordinates of the primary color.
146
147**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
148
149**Since**: 12
150
151
152### OH_NativeBuffer_Config
153
154```
155typedef struct OH_NativeBuffer_Config OH_NativeBuffer_Config
156```
157
158**Description**
159
160Defines the **OH_NativeBuffer** property configuration, which is used when you apply for a new **OH_NativeBuffer** instance or query the properties of an existing instance.
161
162**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
163
164**Since**: 9
165
166
167### OH_NativeBuffer_Cta861
168
169```
170typedef struct OH_NativeBuffer_Cta861 OH_NativeBuffer_Cta861
171```
172
173**Description**
174
175Defines a struct for the CTA-861.3 static metadata.
176
177**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
178
179**Since**: 12
180
181
182### OH_NativeBuffer_Format
183
184```
185typedef enum OH_NativeBuffer_Format OH_NativeBuffer_Format
186```
187
188**Description**
189
190Defines an enum for the **OH_NativeBuffer** formats.
191
192**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
193
194**Since**: 10
195
196
197### OH_NativeBuffer_MetadataKey
198
199```
200typedef enum OH_NativeBuffer_MetadataKey OH_NativeBuffer_MetadataKey
201```
202
203**Description**
204
205Defines an enum for the keys that specify the HDR metadata of an **OH_NativeBuffer** instance.
206
207**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
208
209**Since**: 12
210
211
212### OH_NativeBuffer_MetadataType
213
214```
215typedef enum OH_NativeBuffer_MetadataType OH_NativeBuffer_MetadataType
216```
217
218**Description**
219
220Defines an enum for the **OH_NativeBuffer** image standards.
221
222**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
223
224**Since**: 12
225
226
227### OH_NativeBuffer_Plane
228
229```
230typedef struct OH_NativeBuffer_Plane OH_NativeBuffer_Plane
231```
232
233**Description**
234
235Defines a struct for the plane information of an image.
236
237**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
238
239**Since**: 12
240
241
242### OH_NativeBuffer_Planes
243
244```
245typedef struct OH_NativeBuffer_Planes OH_NativeBuffer_Planes
246```
247
248**Description**
249
250Defines a struct for the plane information of images in an **OH_NativeBuffer** instance.
251
252**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
253
254**Since**: 12
255
256
257### OH_NativeBuffer_Smpte2086
258
259```
260typedef struct OH_NativeBuffer_Smpte2086 OH_NativeBuffer_Smpte2086
261```
262
263**Description**
264
265Defines a struct for the SMPTE ST 2086 static metadata.
266
267**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
268
269**Since**: 12
270
271
272### OH_NativeBuffer_StaticMetadata
273
274```
275typedef struct OH_NativeBuffer_StaticMetadata OH_NativeBuffer_StaticMetadata
276```
277
278**Description**
279
280Defines a struct for the HDR static metadata.
281
282**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
283
284**Since**: 12
285
286
287### OH_NativeBuffer_TransformType
288
289```
290typedef enum OH_NativeBuffer_TransformType OH_NativeBuffer_TransformType
291```
292
293**Description**
294
295Defines an enum for the transform types of an **OH_NativeBuffer** instance.
296
297**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
298
299**Since**: 12
300
301
302### OH_NativeBuffer_Usage
303
304```
305typedef enum OH_NativeBuffer_Usage OH_NativeBuffer_Usage
306```
307
308**Description**
309
310Defines an enum for the **OH_NativeBuffer** usages.
311
312**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
313
314**Since**: 10
315
316
317### OHNativeErrorCode
318
319```
320typedef enum OHNativeErrorCodeOHNativeErrorCode
321```
322
323**Description**
324
325Defines an enum for the error codes.
326
327**Since**: 12
328
329
330## Enum Description
331
332
333### OH_NativeBuffer_ColorGamut
334
335```
336enum OH_NativeBuffer_ColorGamut
337```
338
339**Description**
340
341Enumerates the color gamuts of an **OH_NativeBuffer** instance.
342
343**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
344
345**Since**: 12
346
347| Value| Description|
348| -------- | -------- |
349| NATIVEBUFFER_COLOR_GAMUT_NATIVE | Default gamut.|
350| NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 | Standard BT.601 color gamut.|
351| NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 | Standard BT.709 color gamut.|
352| NATIVEBUFFER_COLOR_GAMUT_DCI_P3 | DCI P3 color gamut.|
353| NATIVEBUFFER_COLOR_GAMUT_SRGB | SRGB color gamut.|
354| NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB | Adobe RGB color gamut.|
355| NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 | Display P3 color gamut.|
356| NATIVEBUFFER_COLOR_GAMUT_BT2020 | BT.2020 color gamut.|
357| NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ | BT.2100 PQ color gamut.|
358| NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG | BT.2100 HLG color gamut format|
359| NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 | Display BT.2020 color gamut.|
360
361
362### OH_NativeBuffer_ColorSpace
363
364```
365enum OH_NativeBuffer_ColorSpace
366```
367
368**Description**
369
370Enumerates the color spaces of an **OH_NativeBuffer** instance.
371
372**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
373
374**Since**: 11
375
376| Value| Description|
377| -------- | -------- |
378| OH_COLORSPACE_NONE | No color space is available.|
379| OH_COLORSPACE_BT601_EBU_FULL | The color gamut is BT601_P, the transfer function is BT709, the conversion matrix is BT601_P, and the data range is RANGE_FULL.|
380| OH_COLORSPACE_BT601_SMPTE_C_FULL | The color gamut is BT601_N, the transfer function is BT709, the conversion matrix is BT601_N, and the data range is RANGE_FULL.|
381| OH_COLORSPACE_BT709_FULL | The color gamut is BT709, the transfer function is BT709, the conversion matrix is BT709, and the data range is RANGE_FULL.|
382| OH_COLORSPACE_BT2020_HLG_FULL | The color gamut is BT2020, the transfer function is HLG, the conversion matrix is BT2020, and the data range is RANGE_FULL.|
383| OH_COLORSPACE_BT2020_PQ_FULL | The color gamut is BT2020, the transfer function is PQ, the conversion matrix is BT2020, and the data range is RANGE_FULL.|
384| OH_COLORSPACE_BT601_EBU_LIMIT | The color gamut is BT601_P, the transfer function is BT709, the conversion matrix is BT601_P, and the data range is RANGE_LIMITED.|
385| OH_COLORSPACE_BT601_SMPTE_C_LIMIT | The color gamut is BT601_N, the transfer function is BT709, the conversion matrix is BT601_N, and the data range is RANGE_LIMITED.|
386| OH_COLORSPACE_BT709_LIMIT | The color gamut is BT709, the transfer function is BT709, the conversion matrix is BT709, and the data range is RANGE_LIMITED.|
387| OH_COLORSPACE_BT2020_HLG_LIMIT | The color gamut is BT2020, the transfer function is HLG, the conversion matrix is BT2020, and the data range is RANGE_LIMITED.|
388| OH_COLORSPACE_BT2020_PQ_LIMIT | The color gamut is BT2020, the transfer function is PQ, the conversion matrix is BT2020, and the data range is RANGE_LIMITED.|
389| OH_COLORSPACE_SRGB_FULL | The color gamut is SRGB, the transfer function is SRGB, the conversion matrix is BT601_N, and the data range is RANGE_FULL.|
390| OH_COLORSPACE_P3_FULL | The color gamut is P3_D65, the transfer function is SRGB, the conversion matrix is P3, and the data range is RANGE_FULL.|
391| OH_COLORSPACE_P3_HLG_FULL | The color gamut is P3_D65, the transfer function is HLG, the conversion matrix is P3, and the data range is RANGE_FULL.|
392| OH_COLORSPACE_P3_PQ_FULL | The color gamut is P3_D65, the transfer function is PQ, the conversion matrix is P3, and the data range is RANGE_FULL.|
393| OH_COLORSPACE_ADOBERGB_FULL | The color gamut is ADOBERGB, the transfer function is ADOBERGB, the conversion matrix is ADOBERGB, and the data range is RANGE_FULL.|
394| OH_COLORSPACE_SRGB_LIMIT | The color gamut is SRGB, the transfer function is SRGB, the conversion matrix is BT601_N, and the data range is RANGE_LIMITED.|
395| OH_COLORSPACE_P3_LIMIT | The color gamut is P3_D65, the transfer function is SRGB, the conversion matrix is P3, and the data range is RANGE_LIMITED.|
396| OH_COLORSPACE_P3_HLG_LIMIT | The color gamut is P3_D65, the transfer function is HLG, the conversion matrix is P3, and the data range is RANGE_LIMITED.|
397| OH_COLORSPACE_P3_PQ_LIMIT | The color gamut is P3_D65, the transfer function is PQ, the conversion matrix is P3, and the data range is RANGE_LIMITED.|
398| OH_COLORSPACE_ADOBERGB_LIMIT | The color gamut is ADOBERGB, the transfer function is ADOBERGB, the conversion matrix is ADOBERGB, and the data range is RANGE_LIMITED.|
399| OH_COLORSPACE_LINEAR_SRGB | The color gamut is SRGB, and the transfer function is LINEAR.|
400| OH_COLORSPACE_LINEAR_BT709 | It is equivalent to **OH_COLORSPACE_LINEAR_SRGB**.|
401| OH_COLORSPACE_LINEAR_P3 | The color gamut is P3_D65, and the transfer function is LINEAR.|
402| OH_COLORSPACE_LINEAR_BT2020 | The color gamut is BT2020, and the transfer function is LINEAR.|
403| OH_COLORSPACE_DISPLAY_SRGB | It is equivalent to **OH_COLORSPACE_SRGB_FULL**.|
404| OH_COLORSPACE_DISPLAY_P3_SRGB | It is equivalent to **OH_COLORSPACE_P3_FULL**.|
405| OH_COLORSPACE_DISPLAY_P3_HLG | It is equivalent to **OH_COLORSPACE_P3_HLG_FULL**.|
406| OH_COLORSPACE_DISPLAY_P3_PQ | It is equivalent to **OH_COLORSPACE_P3_PQ_FULL**.|
407| OH_COLORSPACE_DISPLAY_BT2020_SRGB | The color gamut is BT2020, the transfer function is SRGB, the conversion matrix is BT2020, and the data range is RANGE_FULL.|
408| OH_COLORSPACE_DISPLAY_BT2020_HLG | It is equivalent to **OH_COLORSPACE_BT2020_HLG_FULL**.|
409| OH_COLORSPACE_DISPLAY_BT2020_PQ | It is equivalent to **OH_COLORSPACE_BT2020_PQ_FULL**.|
410
411
412### OH_NativeBuffer_Format
413
414```
415enum OH_NativeBuffer_Format
416```
417
418**Description**
419
420Enumerates the **OH_NativeBuffer** formats.
421
422**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
423
424**Since**: 10
425
426| Value| Description|
427| -------- | -------- |
428| NATIVEBUFFER_PIXEL_FMT_CLUT8<sup>12+</sup> | CLUT8.|
429| NATIVEBUFFER_PIXEL_FMT_CLUT1<sup>12+</sup> | CLUT1.|
430| NATIVEBUFFER_PIXEL_FMT_CLUT4<sup>12+</sup> | CLUT4.|
431| NATIVEBUFFER_PIXEL_FMT_RGB_565 | RGB565.|
432| NATIVEBUFFER_PIXEL_FMT_RGBA_5658 | RGBA5658.|
433| NATIVEBUFFER_PIXEL_FMT_RGBX_4444 | RGBX4444.|
434| NATIVEBUFFER_PIXEL_FMT_RGBA_4444 | RGBA4444.|
435| NATIVEBUFFER_PIXEL_FMT_RGB_444 | RGB444.|
436| NATIVEBUFFER_PIXEL_FMT_RGBX_5551 | RGBX5551.|
437| NATIVEBUFFER_PIXEL_FMT_RGBA_5551 | RGBA5551.|
438| NATIVEBUFFER_PIXEL_FMT_RGB_555 | RGB555.|
439| NATIVEBUFFER_PIXEL_FMT_RGBX_8888 | RGBX8888.|
440| NATIVEBUFFER_PIXEL_FMT_RGBA_8888 | RGBA8888.|
441| NATIVEBUFFER_PIXEL_FMT_RGB_888 | RGB888.|
442| NATIVEBUFFER_PIXEL_FMT_BGR_565 | BGR565.|
443| NATIVEBUFFER_PIXEL_FMT_BGRX_4444 | BGRX4444.|
444| NATIVEBUFFER_PIXEL_FMT_BGRA_4444 | BGRA4444.|
445| NATIVEBUFFER_PIXEL_FMT_BGRX_5551 | BGRX5551.|
446| NATIVEBUFFER_PIXEL_FMT_BGRA_5551 | BGRA5551.|
447| NATIVEBUFFER_PIXEL_FMT_BGRX_8888 | BGRX8888.|
448| NATIVEBUFFER_PIXEL_FMT_BGRA_8888 | BGRA8888.|
449| NATIVEBUFFER_PIXEL_FMT_YUV_422_I<sup>12+</sup> | YUV422 interleaved.|
450| NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP<sup>12+</sup> | YCbCr422 semi-planar.|
451| NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP<sup>12+</sup> | YCrCb422 semi-planar.|
452| NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP<sup>12+</sup> | YCbCr420 semi-planar.|
453| NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP<sup>12+</sup> | YCrCb420 semi-planar.|
454| NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P<sup>12+</sup> | YCbCr422 planar.|
455| NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P<sup>12+</sup> | YCrCb422 planar.|
456| NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P<sup>12+</sup> | YCbCr420 planar.|
457| NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P<sup>12+</sup> | YCrCb420 planar.|
458| NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG<sup>12+</sup> | YUYV422 packed.|
459| NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG<sup>12+</sup> | UYVY422 packed.|
460| NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG<sup>12+</sup> | YVYU422 packed.|
461| NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG<sup>12+</sup> | VYUY422 packed.|
462| NATIVEBUFFER_PIXEL_FMT_RGBA_1010102<sup>12+</sup> | RGBA_1010102 packed.|
463| NATIVEBUFFER_PIXEL_FMT_YCBCR_P010<sup>12+</sup> | YCBCR420 semi-planar 10-bit packed.|
464| NATIVEBUFFER_PIXEL_FMT_YCRCB_P010<sup>12+</sup> | YCRCB420 semi-planar 10-bit packed.|
465| NATIVEBUFFER_PIXEL_FMT_RAW10<sup>12+</sup> | Raw 10-bit packed.|
466| NATIVEBUFFER_PIXEL_FMT_BLOB<sup>15+</sup> | BLOB.|
467| NATIVEBUFFER_PIXEL_FMT_RGBA16_FLOAT<sup>15+</sup> | RGBA16 float.|
468| NATIVEBUFFER_PIXEL_FMT_VENDER_MASK<sup>12+</sup> | Vendor mask.|
469| NATIVEBUFFER_PIXEL_FMT_BUTT | Invalid format.|
470
471
472### OH_NativeBuffer_MetadataKey
473
474```
475enum OH_NativeBuffer_MetadataKey
476```
477
478**Description**
479
480Enumerates the keys that specify the HDR metadata of an **OH_NativeBuffer** instance.
481
482**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
483
484**Since**: 12
485
486| Value| Description|
487| -------- | -------- |
488| OH_HDR_METADATA_TYPE | Metadata type. For details about the available options, see [OH_NativeBuffer_MetadataType](#oh_nativebuffer_metadatatype). **size** indicates the size of **OH_NativeBuffer_MetadataType**.|
489| OH_HDR_STATIC_METADATA | Static metadata. For details about the available options, see [OH_NativeBuffer_StaticMetadata](_o_h___native_buffer___static_metadata.md). **size** indicates the size of **OH_NativeBuffer_StaticMetadata**.|
490| OH_HDR_DYNAMIC_METADATA | Dynamic metadata. For details about the available options, see the SEI byte stream in the video stream. The value range of **size** is 1-3000.|
491
492
493### OH_NativeBuffer_MetadataType
494
495```
496enum OH_NativeBuffer_MetadataType
497```
498
499**Description**
500
501Enumerates the **OH_NativeBuffer** image standards.
502
503**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
504
505**Since**: 12
506
507| Value| Description|
508| -------- | -------- |
509| OH_VIDEO_HDR_HLG | Video HLG.|
510| OH_VIDEO_HDR_HDR10 | Video HDR10.|
511| OH_VIDEO_HDR_VIVID | Video HDR Vivid.|
512| OH_VIDEO_NONE<sup>13+</sup> | No metadata.|
513
514
515### OH_NativeBuffer_TransformType
516
517```
518enum OH_NativeBuffer_TransformType
519```
520
521**Description**
522
523Enumerates the transform types of an **OH_NativeBuffer** instance.
524
525**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
526
527**Since**: 12
528
529| Value| Description|
530| -------- | -------- |
531| NATIVEBUFFER_ROTATE_NONE | No rotation.|
532| NATIVEBUFFER_ROTATE_90 | Rotates by 90 degrees.|
533| NATIVEBUFFER_ROTATE_180 | Rotates by 180 degrees.|
534| NATIVEBUFFER_ROTATE_270 | Rotates by 270 degrees.|
535| NATIVEBUFFER_FLIP_H | Flips horizontally.|
536| NATIVEBUFFER_FLIP_V | Flips vertically.|
537| NATIVEBUFFER_FLIP_H_ROT90 | Flips horizontally and rotates by 90 degrees.|
538| NATIVEBUFFER_FLIP_V_ROT90 | Flips vertically and rotates by 90 degrees.|
539| NATIVEBUFFER_FLIP_H_ROT180 | Flips horizontally and rotates by 180 degrees.|
540| NATIVEBUFFER_FLIP_V_ROT180 | Flips vertically and rotates by 180 degrees.|
541| NATIVEBUFFER_FLIP_H_ROT270 | Flips horizontally and rotates by 270 degrees.|
542| NATIVEBUFFER_FLIP_V_ROT270 | Flips vertically and rotates by 270 degrees.|
543
544
545### OH_NativeBuffer_Usage
546
547```
548enum OH_NativeBuffer_Usage
549```
550
551**Description**
552
553Enumerates the **OH_NativeBuffer** usages.
554
555**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
556
557**Since**: 10
558
559| Value| Description|
560| -------- | -------- |
561| NATIVEBUFFER_USAGE_CPU_READ | CPU readable.|
562| NATIVEBUFFER_USAGE_CPU_WRITE | CPU writable.|
563| NATIVEBUFFER_USAGE_MEM_DMA | Direct memory access to the buffer.|
564| NATIVEBUFFER_USAGE_HW_RENDER<sup>12+</sup> | GPU writable.|
565| NATIVEBUFFER_USAGE_HW_TEXTURE<sup>12+</sup> | GPU readable.|
566| NATIVEBUFFER_USAGE_CPU_READ_OFTEN<sup>12+</sup> | Direct mapping of CPU.|
567| NATIVEBUFFER_USAGE_ALIGNMENT_512<sup>12+</sup> | 512-byte alignment.|
568
569
570### OHNativeErrorCode
571
572```
573enum OHNativeErrorCode
574```
575
576**Description**
577
578Enumerates the error codes.
579
580**Since**: 12
581
582| Value| Description|
583| -------- | -------- |
584| NATIVE_ERROR_OK | The operation is successful.|
585| NATIVE_ERROR_MEM_OPERATION_ERROR<sup>15+</sup> | An error occurs during memory manipulation.|
586| NATIVE_ERROR_INVALID_ARGUMENTS | An input parameter is invalid.|
587| NATIVE_ERROR_NO_PERMISSION | You do not have the permission to perform the operation.|
588| NATIVE_ERROR_NO_BUFFER | No buffer is available.|
589| NATIVE_ERROR_NO_CONSUMER | The consumer does not exist.|
590| NATIVE_ERROR_NOT_INIT | Not initialized.|
591| NATIVE_ERROR_CONSUMER_CONNECTED | The consumer is connected.|
592| NATIVE_ERROR_BUFFER_STATE_INVALID | The buffer status does not meet the expectation.|
593| NATIVE_ERROR_BUFFER_IN_CACHE | The buffer is already in the buffer queue.|
594| NATIVE_ERROR_BUFFER_QUEUE_FULL | The queue is full.|
595| NATIVE_ERROR_BUFFER_NOT_IN_CACHE | The buffer is not in the buffer queue.|
596| NATIVE_ERROR_CONSUMER_DISCONNECTED | The consumer is disconnected.|
597| NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED | No listener is registered on the consumer side.|
598| NATIVE_ERROR_UNSUPPORTED | The device or platform does not support the operation.|
599| NATIVE_ERROR_UNKNOWN | Unknown error. Check the log.|
600| NATIVE_ERROR_HDI_ERROR  | Failed to call the HDI.  |
601| NATIVE_ERROR_BINDER_ERROR  | Cross-process communication failed.  |
602| NATIVE_ERROR_EGL_STATE_UNKNOWN | The EGL environment is abnormal.|
603| NATIVE_ERROR_EGL_API_FAILED | Failed to call the EGL APIs.|
604
605
606## Function Description
607
608
609### OH_NativeBuffer_Alloc()
610
611```
612OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config* config)
613```
614
615**Description**
616
617Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called.
618
619This function must be used in pair with **OH_NativeBuffer_Unreference**. Otherwise, memory leak occurs.
620
621This function is not thread-safe.
622
623**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
624
625**Since**: 9
626
627**Parameters**
628
629| Name| Description|
630| -------- | -------- |
631| config | Pointer to an **OH_NativeBuffer_Config** instance.|
632
633**Returns**
634
635Returns the pointer to the **OH_NativeBuffer** instance created if the operation is successful; returns **NULL** otherwise.
636
637
638### OH_NativeBuffer_FromNativeWindowBuffer()
639
640```
641int32_t OH_NativeBuffer_FromNativeWindowBuffer (OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer )
642```
643
644**Description**
645
646Converts an **OHNativeWindowBuffer** instance to an **OH_NativeBuffer** instance.
647
648This function is not thread-safe.
649
650**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
651
652**Since**: 12
653
654**Parameters**
655
656| Name| Description|
657| -------- | -------- |
658| nativeWindowBuffer | Pointer to an **OHNativeWindowBuffer** instance.|
659| buffer | Pointer to an **OH_NativeBuffer** instance.|
660
661**Returns**
662
663Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
664
665
666### OH_NativeBuffer_GetColorSpace()
667
668```
669int32_t OH_NativeBuffer_GetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace )
670```
671
672**Description**
673
674Obtains the color space of an **OH_NativeBuffer** instance.
675
676This function is not thread-safe.
677
678**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
679
680**Since**: 12
681
682**Parameters**
683
684| Name| Description|
685| -------- | -------- |
686| buffer | Pointer to an **OH_NativeBuffer** instance.|
687| colorSpace | Pointer to the color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace).|
688
689**Returns**
690
691Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
692
693
694### OH_NativeBuffer_GetConfig()
695
696```
697void OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config )
698```
699
700**Description**
701
702Obtains the properties of an **OH_NativeBuffer** instance.
703
704This function is not thread-safe.
705
706**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
707
708**Since**: 9
709
710**Parameters**
711
712| Name| Description|
713| -------- | -------- |
714| buffer | Pointer to an **OH_NativeBuffer** instance.|
715| config | Pointer to an **OH_NativeBuffer_Config** instance, which is used to receive the properties of **OH_NativeBuffer**.|
716
717
718### OH_NativeBuffer_GetMetadataValue()
719
720```
721int32_t OH_NativeBuffer_GetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData )
722```
723
724**Description**
725
726Obtains the metadata value of an **OH_NativeBuffer** instance.
727
728This function is not thread-safe.
729
730**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
731
732**Since**: 12
733
734**Parameters**
735
736| Name| Description|
737| -------- | -------- |
738| buffer | Pointer to an **OH_NativeBuffer** instance.|
739| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey).|
740| size | Pointer to the size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey).|
741| metaData | Double pointer to the uint8_t vector.|
742
743**Returns**
744
745Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
746
747
748### OH_NativeBuffer_GetSeqNum()
749
750```
751uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer)
752```
753
754**Description**
755
756Obtains the sequence number of an **OH_NativeBuffer** instance.
757
758This function is not thread-safe.
759
760**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
761
762**Since**: 9
763
764**Parameters**
765
766| Name| Description|
767| -------- | -------- |
768| buffer | Pointer to an **OH_NativeBuffer** instance.|
769
770**Returns**
771
772Returns the unique sequence number of the **OH_NativeBuffer** instance.
773
774
775### OH_NativeBuffer_Map()
776
777```
778int32_t OH_NativeBuffer_Map (OH_NativeBuffer *buffer, void **virAddr )
779```
780
781**Description**
782
783Maps the ION memory allocated to an **OH_NativeBuffer** instance to the process address space.
784
785This function must be used in pair with **OH_NativeBuffer_Unmap**.
786
787This function is not thread-safe.
788
789**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
790
791**Since**: 9
792
793**Parameters**
794
795| Name| Description|
796| -------- | -------- |
797| buffer | Pointer to an **OH_NativeBuffer** instance.|
798| virAddr | Double pointer to the address of the virtual memory.|
799
800**Returns**
801
802Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
803
804
805### OH_NativeBuffer_MapPlanes()
806
807```
808int32_t OH_NativeBuffer_MapPlanes (OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes )
809```
810
811**Description**
812
813Maps the multi-channel ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.
814
815This function is not thread-safe.
816
817**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
818
819**Since**: 12
820
821**Parameters**
822
823| Name| Description|
824| -------- | -------- |
825| buffer | Pointer to an **OH_NativeBuffer** instance.|
826| virAddr | Double pointer to the address of the virtual memory.|
827| outPlanes | Pointer to the plane information of all images.|
828
829**Returns**
830
831Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
832
833
834### OH_NativeBuffer_Reference()
835
836```
837int32_t OH_NativeBuffer_Reference (OH_NativeBuffer *buffer)
838```
839
840**Description**
841
842Increases the reference count of an **OH_NativeBuffer** instance by 1.
843
844This function must be used in pair with **OH_NativeBuffer_Unreference**. Otherwise, memory leak occurs.
845
846This function is not thread-safe.
847
848**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
849
850**Since**: 9
851
852**Parameters**
853
854| Name| Description|
855| -------- | -------- |
856| buffer | Pointer to an **OH_NativeBuffer** instance.|
857
858**Returns**
859
860Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
861
862
863### OH_NativeBuffer_SetColorSpace()
864
865```
866int32_t OH_NativeBuffer_SetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace )
867```
868
869**Description**
870
871Sets the color space for an **OH_NativeBuffer** instance.
872
873This function is not thread-safe.
874
875**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
876
877**Since**: 11
878
879**Parameters**
880
881| Name| Description|
882| -------- | -------- |
883| buffer | Pointer to an **OH_NativeBuffer** instance.|
884| colorSpace | Color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace).|
885
886**Returns**
887
888Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
889
890
891### OH_NativeBuffer_SetMetadataValue()
892
893```
894int32_t OH_NativeBuffer_SetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t *metaData )
895```
896
897**Description**
898
899Sets a metadata value for an **OH_NativeBuffer** instance.
900
901This function is not thread-safe.
902
903**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
904
905**Since**: 12
906
907**Parameters**
908
909| Name| Description|
910| -------- | -------- |
911| buffer | Pointer to an **OH_NativeBuffer** instance.|
912| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1).|
913| size | Size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1).|
914| metaDate | Pointer to the uint8_t vector.|
915
916**Returns**
917
918Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
919
920
921### OH_NativeBuffer_Unmap()
922
923```
924int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer)
925```
926
927**Description**
928
929Unmaps the ION memory allocated to an **OH_NativeBuffer** instance from the process address space.
930
931This function is not thread-safe.
932
933**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
934
935**Since**: 9
936
937**Parameters**
938
939| Name| Description|
940| -------- | -------- |
941| buffer | Pointer to an **OH_NativeBuffer** instance.|
942
943**Returns**
944
945Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
946
947
948### OH_NativeBuffer_Unreference()
949
950```
951int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer *buffer)
952```
953
954**Description**
955
956Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.
957
958This function is not thread-safe.
959
960**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
961
962**Since**: 9
963
964**Parameters**
965
966| Name| Description|
967| -------- | -------- |
968| buffer | Pointer to an **OH_NativeBuffer** instance.|
969
970**Returns**
971
972Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
973