• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NATIVE_AVFORMAT_H
17 #define NATIVE_AVFORMAT_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include <stdio.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct OH_AVFormat OH_AVFormat;
28 
29 /**
30  * @brief Enumerates AVPixel Format.
31  * @syscap SystemCapability.Multimedia.Media.Core
32  * @since 9
33  * @version 1.0
34  */
35 typedef enum OH_AVPixelFormat {
36     /**
37      * yuv 420 planar.
38      */
39     AV_PIXEL_FORMAT_YUVI420 = 1,
40     /**
41      *  NV12. yuv 420 semiplanar.
42      */
43     AV_PIXEL_FORMAT_NV12 = 2,
44     /**
45      *  NV21. yvu 420 semiplanar.
46      */
47     AV_PIXEL_FORMAT_NV21 = 3,
48     /**
49      * format from surface.
50      */
51     AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
52     /**
53      * RGBA8888
54      */
55     AV_PIXEL_FORMAT_RGBA = 5,
56 } OH_AVPixelFormat;
57 
58 /**
59  * @briefCreate an OH_AVFormat handle pointer to read and write data
60  * @syscap SystemCapability.Multimedia.Media.Core
61  * @return Returns a pointer to an OH_AVFormat instance
62  * @since 9
63  * @version 1.0
64  */
65 struct OH_AVFormat *OH_AVFormat_Create(void);
66 
67 /**
68  * @brief Destroy the specified OH_AVFormat handle resource
69  * @syscap SystemCapability.Multimedia.Media.Core
70  * @param format pointer to an OH_AVFormat instance
71  * @return void
72  * @since 9
73  * @version 1.0
74  */
75 void OH_AVFormat_Destroy(struct OH_AVFormat *format);
76 
77 /**
78  * @brief Copy OH_AVFormat handle resource
79  * @syscap SystemCapability.Multimedia.Media.Core
80  * @param to OH_AVFormat handle pointer to receive data
81  * @param from pointer to the OH_AVFormat handle of the copied data
82  * @return The return value is TRUE for success, FALSE for failure
83  * @since 9
84  * @version 1.0
85  */
86 bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from);
87 
88 /**
89  * @brief Write Int data to OH_AVFormat
90  * @syscap SystemCapability.Multimedia.Media.Core
91  * @param format pointer to an OH_AVFormat instance
92  * @param key key to write data
93  * @param value written data
94  * @return The return value is TRUE for success, FALSE for failure
95  * @since 9
96  * @version 1.0
97  */
98 bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value);
99 
100 /**
101  * @brief Write Long data to OH_AVFormat
102  * @syscap SystemCapability.Multimedia.Media.Core
103  * @param format pointer to an OH_AVFormat instance
104  * @param key key to write data
105  * @param value written data
106  * @return The return value is TRUE for success, FALSE for failure
107  * @since 9
108  * @version 1.0
109  */
110 bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value);
111 
112 /**
113  * @brief Write Float data to OH_AVFormat
114  * @syscap SystemCapability.Multimedia.Media.Core
115  * @param format pointer to an OH_AVFormat instance
116  * @param key key to write data
117  * @param value written data
118  * @return The return value is TRUE for success, FALSE for failure
119  * @since 9
120  * @version 1.0
121  */
122 bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value);
123 
124 /**
125  * @brief Write Double data to OH_AVFormat
126  * @syscap SystemCapability.Multimedia.Media.Core
127  * @param format pointer to an OH_AVFormat instance
128  * @param key key to write data
129  * @param value written data
130  * @return The return value is TRUE for success, FALSE for failure
131  * @since 9
132  * @version 1.0
133  */
134 bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value);
135 
136 /**
137  * @brief Write String data to OH_AVFormat
138  * @syscap SystemCapability.Multimedia.Media.Core
139  * @param format pointer to an OH_AVFormat instance
140  * @param key key to write data
141  * @param value written data
142  * @return The return value is TRUE for success, FALSE for failure
143  * @since 9
144  * @version 1.0
145  */
146 bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value);
147 
148 /**
149  * @brief Writes a block of data of a specified length to OH_AVFormat
150  * @syscap SystemCapability.Multimedia.Media.Core
151  * @param format pointer to an OH_AVFormat instance
152  * @param key key to write data
153  * @param addr written data addr
154  * @param size written data length
155  * @return The return value is TRUE for success, FALSE for failure
156  * @since 9
157  * @version 1.0
158  */
159 bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size);
160 
161 /**
162  * @brief Read Int data from OH_AVFormat
163  * @syscap SystemCapability.Multimedia.Media.Core
164  * @param format pointer to an OH_AVFormat instance
165  * @param key read key value
166  * @param out read data
167  * @return The return value is TRUE for success, FALSE for failure
168  * @since 9
169  * @version 1.0
170  */
171 bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out);
172 
173 /**
174  * @brief Read Long data from OH_AVFormat
175  * @syscap SystemCapability.Multimedia.Media.Core
176  * @param format pointer to an OH_AVFormat instance
177  * @param key read key value
178  * @param out read data
179  * @return The return value is TRUE for success, FALSE for failure
180  * @since 9
181  * @version 1.0
182  */
183 bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out);
184 
185 /**
186  * @brief Read Float data from OH_AVFormat
187  * @syscap SystemCapability.Multimedia.Media.Core
188  * @param format pointer to an OH_AVFormat instance
189  * @param key read key value
190  * @param out read data
191  * @return The return value is TRUE for success, FALSE for failure
192  * @since 9
193  * @version 1.0
194  */
195 bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out);
196 
197 /**
198  * @brief Read Double data from OH_AVFormat
199  * @syscap SystemCapability.Multimedia.Media.Core
200  * @param format pointer to an OH_AVFormat instance
201  * @param key read key value
202  * @param out read data
203  * @return The return value is TRUE for success, FALSE for failure
204  * @since 9
205  * @version 1.0
206  */
207 bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out);
208 
209 /**
210  * @brief Read Double data from OH_AVFormat
211  * @syscap SystemCapability.Multimedia.Media.Core
212  * @param format pointer to an OH_AVFormat instance
213  * @param key read key value
214  * @param out The read string pointer, the data life cycle pointed to is updated with GetString,
215  * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory
216  * @return The return value is TRUE for success, FALSE for failure
217  * @since 9
218  * @version 1.0
219  */
220 bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, const char **out);
221 
222 /**
223  * @brief Read a block of data of specified length from OH_AVFormat
224  * @syscap SystemCapability.Multimedia.Media.Core
225  * @param format pointer to an OH_AVFormat instance
226  * @param key Key value for reading and writing data
227  * @param addr The life cycle is held by the format, with the destruction of the format,
228  * if the caller needs to hold it for a long time, it must copy the memory
229  * @param size Length of read and write data
230  * @return The return value is TRUE for success, FALSE for failure
231  * @since 9
232  * @version 1.0
233  */
234 bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size);
235 
236 /**
237  * @brief Output the information contained in OH_AVFormat as a string.
238  * @syscap SystemCapability.Multimedia.Media.Core
239  * @param format pointer to an OH_AVFormat instance
240  * @return Returns a string consisting of key and data
241  * @since 9
242  * @version 1.0
243  */
244 const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format);
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 #endif // NATIVE_AVFORMAT_H
251