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-1)  [OH_NativeBuffer_Usage](#oh_nativebuffer_usage) | Defines an enum for the **OH_NativeBuffer** usages.|
41| typedef enum [OH_NativeBuffer_Format](#oh_nativebuffer_format-1)  [OH_NativeBuffer_Format](#oh_nativebuffer_format) | Defines an enum for the **OH_NativeBuffer** formats.|
42| 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.|
43| 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.|
44| 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.|
45| typedef enum [OHNativeErrorCode](_native_window.md#ohnativeerrorcode-1)  [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-1)  [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,OH_VIDEO_NONE = -1 } | 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> | Vendor 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| OH_VIDEO_NONE<sup>13+</sup> | No metadata.|
510
511
512### OH_NativeBuffer_TransformType
513
514```
515enum OH_NativeBuffer_TransformType
516```
517
518**Description**
519
520Enumerates the transform types of an **OH_NativeBuffer** instance.
521
522**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
523
524**Since**: 12
525
526| Value| Description|
527| -------- | -------- |
528| NATIVEBUFFER_ROTATE_NONE | No rotation.|
529| NATIVEBUFFER_ROTATE_90 | Rotates by 90 degrees.|
530| NATIVEBUFFER_ROTATE_180 | Rotates by 180 degrees.|
531| NATIVEBUFFER_ROTATE_270 | Rotates by 270 degrees.|
532| NATIVEBUFFER_FLIP_H | Flips horizontally.|
533| NATIVEBUFFER_FLIP_V | Flips vertically.|
534| NATIVEBUFFER_FLIP_H_ROT90 | Flips horizontally and rotates by 90 degrees.|
535| NATIVEBUFFER_FLIP_V_ROT90 | Flips vertically and rotates by 90 degrees.|
536| NATIVEBUFFER_FLIP_H_ROT180 | Flips horizontally and rotates by 180 degrees.|
537| NATIVEBUFFER_FLIP_V_ROT180 | Flips vertically and rotates by 180 degrees.|
538| NATIVEBUFFER_FLIP_H_ROT270 | Flips horizontally and rotates by 270 degrees.|
539| NATIVEBUFFER_FLIP_V_ROT270 | Flips vertically and rotates by 270 degrees.|
540
541
542### OH_NativeBuffer_Usage
543
544```
545enum OH_NativeBuffer_Usage
546```
547
548**Description**
549
550Enumerates the **OH_NativeBuffer** usages.
551
552**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
553
554**Since**: 10
555
556| Value| Description|
557| -------- | -------- |
558| NATIVEBUFFER_USAGE_CPU_READ | CPU readable.|
559| NATIVEBUFFER_USAGE_CPU_WRITE | CPU writable.|
560| NATIVEBUFFER_USAGE_MEM_DMA | Direct memory access to the buffer.|
561| NATIVEBUFFER_USAGE_HW_RENDER<sup>12+</sup> | GPU writable.|
562| NATIVEBUFFER_USAGE_HW_TEXTURE<sup>12+</sup> | GPU readable.|
563| NATIVEBUFFER_USAGE_CPU_READ_OFTEN<sup>12+</sup> | Direct mapping of CPU.|
564| NATIVEBUFFER_USAGE_ALIGNMENT_512<sup>12+</sup> | 512-byte alignment.|
565
566
567### OHNativeErrorCode
568
569```
570enum OHNativeErrorCode
571```
572
573**Description**
574
575Enumerates the error codes.
576
577**Since**: 12
578
579| Value| Description|
580| -------- | -------- |
581| NATIVE_ERROR_OK | The operation is successful.|
582| NATIVE_ERROR_INVALID_ARGUMENTS | An input parameter is invalid.|
583| NATIVE_ERROR_NO_PERMISSION | You do not have the permission to perform the operation.|
584| NATIVE_ERROR_NO_BUFFER | No buffer is available.|
585| NATIVE_ERROR_NO_CONSUMER | The consumer does not exist.|
586| NATIVE_ERROR_NOT_INIT | Not initialized.|
587| NATIVE_ERROR_CONSUMER_CONNECTED | The consumer is connected.|
588| NATIVE_ERROR_BUFFER_STATE_INVALID | The buffer status does not meet the expectation.|
589| NATIVE_ERROR_BUFFER_IN_CACHE | The buffer is already in the buffer queue.|
590| NATIVE_ERROR_BUFFER_QUEUE_FULL | The queue is full.|
591| NATIVE_ERROR_BUFFER_NOT_IN_CACHE | The buffer is not in the buffer queue.|
592| NATIVE_ERROR_CONSUMER_DISCONNECTED | The consumer is disconnected.|
593| NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED | No listener is registered on the consumer side.|
594| NATIVE_ERROR_UNSUPPORTED | The device or platform does not support the operation.|
595| NATIVE_ERROR_UNKNOWN | Unknown error. Check the log.|
596| NATIVE_ERROR_HDI_ERROR  | Failed to call the HDI.  |
597| NATIVE_ERROR_BINDER_ERROR  | Cross-process communication failed.  |
598| NATIVE_ERROR_EGL_STATE_UNKNOWN | The EGL environment is abnormal.|
599| NATIVE_ERROR_EGL_API_FAILED | Failed to call the EGL APIs.|
600
601
602## Function Description
603
604
605### OH_NativeBuffer_Alloc()
606
607```
608OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config* config)
609```
610
611**Description**
612
613Creates an **OH_NativeBuffer** instance based on an **OH_NativeBuffer_Config** struct. A new **OH_NativeBuffer** instance is created each time this function is called.
614
615This function must be used in pair with **OH_NativeBuffer_Unreference**. Otherwise, memory leak occurs.
616
617This function is not thread-safe.
618
619**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
620
621**Since**: 9
622
623**Parameters**
624
625| Name| Description|
626| -------- | -------- |
627| config | Pointer to an **OH_NativeBuffer_Config** instance.|
628
629**Returns**
630
631Returns the pointer to the **OH_NativeBuffer** instance created if the operation is successful; returns **NULL** otherwise.
632
633
634### OH_NativeBuffer_FromNativeWindowBuffer()
635
636```
637int32_t OH_NativeBuffer_FromNativeWindowBuffer (OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer )
638```
639
640**Description**
641
642Converts an **OHNativeWindowBuffer** instance to an **OH_NativeBuffer** instance.
643
644This function is not thread-safe.
645
646**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
647
648**Since**: 12
649
650**Parameters**
651
652| Name| Description|
653| -------- | -------- |
654| nativeWindowBuffer | Pointer to an **OHNativeWindowBuffer** instance.|
655| buffer | Pointer to an **OH_NativeBuffer** instance.|
656
657**Returns**
658
659Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
660
661
662### OH_NativeBuffer_GetColorSpace()
663
664```
665int32_t OH_NativeBuffer_GetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace )
666```
667
668**Description**
669
670Obtains the color space of an **OH_NativeBuffer** instance.
671
672This function is not thread-safe.
673
674**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
675
676**Since**: 12
677
678**Parameters**
679
680| Name| Description|
681| -------- | -------- |
682| buffer | Pointer to an **OH_NativeBuffer** instance.|
683| colorSpace | Pointer to the color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace).|
684
685**Returns**
686
687Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
688
689
690### OH_NativeBuffer_GetConfig()
691
692```
693void OH_NativeBuffer_GetConfig (OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config )
694```
695
696**Description**
697
698Obtains the attributes of an **OH_NativeBuffer** instance.
699
700This function is not thread-safe.
701
702**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
703
704**Since**: 9
705
706**Parameters**
707
708| Name| Description|
709| -------- | -------- |
710| buffer | Pointer to an **OH_NativeBuffer** instance.|
711| config | Pointer to an **OH_NativeBuffer_Config** instance, which is used to receive the attributes of **OH_NativeBuffer**.|
712
713
714### OH_NativeBuffer_GetMetadataValue()
715
716```
717int32_t OH_NativeBuffer_GetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t *size, uint8_t **metaData )
718```
719
720**Description**
721
722Obtains the metadata value of an **OH_NativeBuffer** instance.
723
724This function is not thread-safe.
725
726**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
727
728**Since**: 12
729
730**Parameters**
731
732| Name| Description|
733| -------- | -------- |
734| buffer | Pointer to an **OH_NativeBuffer** instance.|
735| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey).|
736| size | Pointer to the size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey).|
737| metaData | Double pointer to the uint8_t vector.|
738
739**Returns**
740
741Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
742
743
744### OH_NativeBuffer_GetSeqNum()
745
746```
747uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer *buffer)
748```
749
750**Description**
751
752Obtains the sequence number of an **OH_NativeBuffer** instance.
753
754This function is not thread-safe.
755
756**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
757
758**Since**: 9
759
760**Parameters**
761
762| Name| Description|
763| -------- | -------- |
764| buffer | Pointer to an **OH_NativeBuffer** instance.|
765
766**Returns**
767
768Returns the unique sequence number of the **OH_NativeBuffer** instance.
769
770
771### OH_NativeBuffer_Map()
772
773```
774int32_t OH_NativeBuffer_Map (OH_NativeBuffer *buffer, void **virAddr )
775```
776
777**Description**
778
779Maps the ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.
780
781This function must be used in pair with **OH_NativeBuffer_Unmap**.
782
783This function is not thread-safe.
784
785**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
786
787**Since**: 9
788
789**Parameters**
790
791| Name| Description|
792| -------- | -------- |
793| buffer | Pointer to an **OH_NativeBuffer** instance.|
794| virAddr | Double pointer to the address of the virtual memory.|
795
796**Returns**
797
798Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
799
800
801### OH_NativeBuffer_MapPlanes()
802
803```
804int32_t OH_NativeBuffer_MapPlanes (OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes )
805```
806
807**Description**
808
809Maps the multi-channel ION memory corresponding to an **OH_NativeBuffer** instance to the process address space.
810
811This function is not thread-safe.
812
813**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
814
815**Since**: 12
816
817**Parameters**
818
819| Name| Description|
820| -------- | -------- |
821| buffer | Pointer to an **OH_NativeBuffer** instance.|
822| virAddr | Double pointer to the address of the virtual memory.|
823| outPlanes | Pointer to the plane information of all images.|
824
825**Returns**
826
827Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
828
829
830### OH_NativeBuffer_Reference()
831
832```
833int32_t OH_NativeBuffer_Reference (OH_NativeBuffer *buffer)
834```
835
836**Description**
837
838Increases the reference count of an **OH_NativeBuffer** instance by 1.
839
840This function must be used in pair with **OH_NativeBuffer_Unreference**. Otherwise, memory leak occurs.
841
842This function is not thread-safe.
843
844**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
845
846**Since**: 9
847
848**Parameters**
849
850| Name| Description|
851| -------- | -------- |
852| buffer | Pointer to an **OH_NativeBuffer** instance.|
853
854**Returns**
855
856Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
857
858
859### OH_NativeBuffer_SetColorSpace()
860
861```
862int32_t OH_NativeBuffer_SetColorSpace (OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace )
863```
864
865**Description**
866
867Sets the color space for an **OH_NativeBuffer** instance.
868
869This function is not thread-safe.
870
871**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
872
873**Since**: 11
874
875**Parameters**
876
877| Name| Description|
878| -------- | -------- |
879| buffer | Pointer to an **OH_NativeBuffer** instance.|
880| colorSpace | Color space. For details about the available options, see [OH_NativeBuffer_ColorSpace](#oh_nativebuffer_colorspace).|
881
882**Returns**
883
884Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
885
886
887### OH_NativeBuffer_SetMetadataValue()
888
889```
890int32_t OH_NativeBuffer_SetMetadataValue (OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, int32_t size, uint8_t *metaData )
891```
892
893**Description**
894
895Sets a metadata value for an **OH_NativeBuffer** instance.
896
897This function is not thread-safe.
898
899**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
900
901**Since**: 12
902
903**Parameters**
904
905| Name| Description|
906| -------- | -------- |
907| buffer | Pointer to an **OH_NativeBuffer** instance.|
908| metadataKey | Key of the metadata. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1).|
909| size | Size of the uint8_t vector. For details about the available options, see [OH_NativeBuffer_MetadataKey](#oh_nativebuffer_metadatakey-1).|
910| metaDate | Pointer to the uint8_t vector.|
911
912**Returns**
913
914Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
915
916
917### OH_NativeBuffer_Unmap()
918
919```
920int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer *buffer)
921```
922
923**Description**
924
925Unmaps the ION memory corresponding to an **OH_NativeBuffer** instance from the process address space.
926
927This function is not thread-safe.
928
929**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
930
931**Since**: 9
932
933**Parameters**
934
935| Name| Description|
936| -------- | -------- |
937| buffer | Pointer to an **OH_NativeBuffer** instance.|
938
939**Returns**
940
941Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
942
943
944### OH_NativeBuffer_Unreference()
945
946```
947int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer *buffer)
948```
949
950**Description**
951
952Decreases the reference count of an **OH_NativeBuffer** instance by 1 and, when the reference count reaches 0, destroys the instance.
953
954This function is not thread-safe.
955
956**System capability**: SystemCapability.Graphic.Graphic2D.NativeBuffer
957
958**Since**: 9
959
960**Parameters**
961
962| Name| Description|
963| -------- | -------- |
964| buffer | Pointer to an **OH_NativeBuffer** instance.|
965
966**Returns**
967
968Returns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise.
969