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