• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 /**
17  * @addtogroup VideoEncoder
18  * @{
19  *
20  * @brief The VideoEncoder module provides interfaces for video encoding.
21  *
22  * @syscap SystemCapability.Multimedia.VideoEncoder
23  * @since 9
24  */
25 
26 /**
27  * @file native_avcodec_videoencoder.h
28  *
29  * @brief Declare the interface used for video encoding.
30  *
31  * @kit AVCodecKit
32  * @library libnative_media_venc.so
33  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
34  * @since 9
35  */
36 
37 #ifndef NATIVE_AVCODEC_VIDEOENCODER_H
38 #define NATIVE_AVCODEC_VIDEOENCODER_H
39 
40 #include <stdint.h>
41 #include <stdio.h>
42 #include "native_avcodec_base.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Configure frame parameters. This interface can be used to set the encode parameters
50  * of the frame corresponding to the index, take effect only in Surface mode.
51  * It is nedd to call {@link OH_VideoEncoder_RegisterParametercallbacks} interface to register bedfore use.
52  * In Buffer mode, OH_AVBuffer can directly carry the encoding parameters of frames.
53  * Currently, frame level QPMin/QPMax parameters are supported, and specify LTR to set the reference frame.
54  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
55  * @param codec OH_AVCodec instance
56  * @param index The index corresponding to the encode frame
57  * @param parameter Encode parameter
58  * @param userData The data that the user rely on to execute the callback
59  * @since 12
60  */
61 typedef void (*OH_VideoEncoder_OnNeedInputParameter)(OH_AVCodec *codec, uint32_t index, OH_AVFormat *parameter,
62                                                      void *userData);
63 
64 /**
65  * @brief Creates a video encoder instance from the mime type, it is recommended to use.
66  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
67  * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE}
68  * @return Returns a Pointer to an OH_AVCodec instance.
69  * Return NULL if memory ran out or the mime type is not supported.
70  * @since 9
71  * @version 1.0
72  */
73 OH_AVCodec *OH_VideoEncoder_CreateByMime(const char *mime);
74 
75 /**
76  * @brief Create a video encoder instance through the video encoder name.
77  * The premise of using this interface is to know the exact name of the encoder.
78  * The encoder name can be obtained through capability query.
79  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
80  * @param name Video encoder name
81  * @return Returns a Pointer to an OH_AVCodec instance.
82  * Return NULL if memory ran out or the encoder name is not supported.
83  * @since 9
84  * @version 1.0
85  */
86 OH_AVCodec *OH_VideoEncoder_CreateByName(const char *name);
87 
88 /**
89  * @brief Clear the internal resources of the encoder and destroy the encoder instance.
90  * Can not be destoryed repeatedly.
91  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
92  * @param codec Pointer to an OH_AVCodec instance
93  * @return Returns AV_ERR_OK if the execution is successful,
94  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
95  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
96  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
97  * {@link AV_ERR_UNKNOWN}, unknown error.
98  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
99  * @since 9
100  * @version 1.0
101  */
102 OH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec);
103 
104 /**
105  * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events
106  * generated by the video encoder. This interface must be called before Prepare is called.
107  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
108  * @param codec Pointer to an OH_AVCodec instance
109  * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback}
110  * @param userData The data that the user rely on to execute the callback
111  * @return Returns AV_ERR_OK if the execution is successful,
112  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
113  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
114  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
115  * {@link AV_ERR_UNKNOWN}, unknown error.
116  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
117  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
118  * @deprecated since 11
119  * @useinstead OH_VideoEncoder_RegisterCallback
120  * @since 9
121  * @version 1.0
122  */
123 OH_AVErrCode OH_VideoEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData);
124 
125 /**
126  * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events
127  * generated by the video encoder. This interface must be called before Prepare is called.
128  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
129  * @param codec Pointer to an OH_AVCodec instance
130  * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback}
131  * @param userData The data that the user rely on to execute the callback
132  * @return Returns AV_ERR_OK if the execution is successful,
133  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
134  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
135  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
136  * {@link AV_ERR_UNKNOWN}, unknown error.
137  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
138  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
139  * @since 11
140  */
141 OH_AVErrCode OH_VideoEncoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData);
142 
143 /**
144  * @brief Set the OH_AVCodecCallback callback function so that the application can respond to the events
145  * generated by the video encoder. In encode Surface mode, this interface is used to set frame-specific
146  * parameters. If this interface is used, it must be invoked before {@link OH_VideoEncoder_Configure}.
147  *
148  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
149  * @param codec Pointer to an OH_AVCodec instance
150  * @param onInputParameter A callback functions, see {@link OH_VideoEncoder_OnNeedInputParameter}
151  * @param userData The data that the user rely on to execute the callback
152  * @return Returns AV_ERR_OK if the execution is successful,
153  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
154  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
155  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
156  * {@link AV_ERR_UNKNOWN}, unknown error.
157  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
158  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
159  * @since 12
160  */
161 OH_AVErrCode OH_VideoEncoder_RegisterParameterCallback(OH_AVCodec *codec,
162                                                        OH_VideoEncoder_OnNeedInputParameter onInputParameter,
163                                                        void *userData);
164 
165 /**
166  * @brief To configure the encode parameters of video encoder, typically, you need to configure
167  * the description information of the encoded video track, such as the width, height, and pixel format.
168  * This interface must be called before Prepare is called.
169  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
170  * @param codec Pointer to an OH_AVCodec instance
171  * @param format A pointer to an OH_AVFormat that gives the description of the video track to be encoded
172  * @return Returns AV_ERR_OK if the execution is successful,
173  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
174  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
175  * {@link AV_ERR_INVALID_VAL}
176  * 1. the input codec pointer is non encoder instance or NULL;
177  * 2. unsupported input format parameters.
178  * {@link AV_ERR_UNKNOWN}, unknown error.
179  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
180  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
181  * @since 9
182  * @version 1.0
183  */
184 OH_AVErrCode OH_VideoEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format);
185 
186 /**
187  * @brief Prepare the internal resources of the encoder.The Configure interface must be called before
188  * calling this interface.
189  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
190  * @param codec Pointer to an OH_AVCodec instance
191  * @return Returns AV_ERR_OK if the execution is successful,
192  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
193  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
194  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
195  * @since 9
196  * @version 1.0
197  */
198 OH_AVErrCode OH_VideoEncoder_Prepare(OH_AVCodec *codec);
199 
200 /**
201  * @brief Start the encoder, this interface must be called after the Prepare is successful. After being
202  * successfully started, the encoder will start reporting NeedInputData events. In Surface mode, OnNewOutputBuffer
203  * will be triggered for each completed frame encoding after a correct input is received on the surface.
204  * In Buffer mode, the encoder trigger an input callback immediately. Each time the caller completes an input,
205  * the encoder performs encoding, OnNewOutputBuffer will be triggered for each completed frame encoding.
206  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
207  * @param codec Pointer to an OH_AVCodec instance
208  * @return Returns AV_ERR_OK if the execution is successful,
209  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
210  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
211  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
212  * {@link AV_ERR_UNKNOWN}, unknown error.
213  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
214  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
215  * @since 9
216  * @version 1.0
217  */
218 OH_AVErrCode OH_VideoEncoder_Start(OH_AVCodec *codec);
219 
220 /**
221  * @brief Stop the encoder and release the input and output buffer. After stopping,
222  * you can re-enter the Running state through Start.
223  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
224  * @param codec Pointer to an OH_AVCodec instance
225  * @return Returns AV_ERR_OK if the execution is successful,
226  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
227  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
228  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
229  * {@link AV_ERR_UNKNOWN}, unknown error.
230  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
231  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
232  * @since 9
233  * @version 1.0
234  */
235 OH_AVErrCode OH_VideoEncoder_Stop(OH_AVCodec *codec);
236 
237 /**
238  * @brief Clear the input and output data buffered and parameters in the encoder,
239  * for example, PPS/SPS in H264 format. After this interface is called,
240  * all the buffer indexes previously reported through the asynchronous callback will be invalidated,
241  * make sure not to access the buffers corresponding to these indexes. This interface cannot be called continuously.
242  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
243  * @param codec Pointer to an OH_AVCodec instance
244  * @return Returns AV_ERR_OK if the execution is successful,
245  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
246  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
247  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
248  * {@link AV_ERR_UNKNOWN}, unknown error.
249  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
250  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
251  * @since 9
252  * @version 1.0
253  */
254 OH_AVErrCode OH_VideoEncoder_Flush(OH_AVCodec *codec);
255 
256 /**
257  * @brief Reset the encoder. The encoder returns to the Initialized state. To continue encoding,
258  * you need to call the Configure interface again to configure the encoder instance.
259  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
260  * @param codec Pointer to an OH_AVCodec instance
261  * @return Returns AV_ERR_OK if the execution is successful,
262  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
263  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
264  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
265  * {@link AV_ERR_UNKNOWN}, unknown error.
266  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
267  * @since 9
268  * @version 1.0
269  */
270 OH_AVErrCode OH_VideoEncoder_Reset(OH_AVCodec *codec);
271 
272 /**
273  * @brief Get the OH_AVFormat of the output data of the encoder, refer to {@link OH_AVFormat} for details.
274  * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to
275  * be released by {@link OH_AVFormat_Destroy}.
276  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
277  * @param codec Pointer to an OH_AVCodec instance
278  * @return Returns a pointer to an OH_AVFormat instance.
279  * Return NULL if the codec is NULL or invaild.
280  * @since 9
281  * @version 1.0
282  */
283 OH_AVFormat *OH_VideoEncoder_GetOutputDescription(OH_AVCodec *codec);
284 
285 /**
286  * @brief Set encoder parameters when encoder running. Note: This interface can only be called after
287  * the encoder is started. At the same time, incorrect parameter settings may cause the encoding to fail.
288  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
289  * @param codec Pointer to an OH_AVCodec instance
290  * @param format OH_AVFormat handle pointer
291  * @return Returns AV_ERR_OK if the execution is successful,
292  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
293  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
294  * {@link AV_ERR_INVALID_VAL}
295  * 1. the input codec pointer is non encoder instance or NULL;
296  * 2. unsupported input format parameters.
297  * {@link AV_ERR_UNKNOWN}, unknown error.
298  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
299  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
300  * @since 9
301  * @version 1.0
302  */
303 OH_AVErrCode OH_VideoEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format);
304 
305 /**
306  * @brief Get the input surface from the video encoder, this interface must be called before Prepare is called.
307  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
308  * @param codec Pointer to an OH_AVCodec instance
309  * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}, the application is responsible
310  * for managing the life cycle of the window, call OH_NativeWindow_DestroyNativeWindow() when done.
311  * @return Returns AV_ERR_OK if the execution is successful,
312  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
313  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
314  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
315  * @since 9
316  * @version 1.0
317  */
318 OH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **window);
319 
320 /**
321  * @brief Return the processed output buffer to the encoder.
322  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
323  * @param codec Pointer to an OH_AVCodec instance
324  * @param index The index value corresponding to the output buffer
325  * should be given by {@link OH_AVCodecOnNewOutputData}
326  * @return Returns AV_ERR_OK if the execution is successful,
327  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
328  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
329  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
330  * {@link AV_ERR_UNKNOWN}, unknown error.
331  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
332  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
333  * @deprecated since 11
334  * @useinstead OH_VideoEncoder_FreeOutputBuffer
335  * @since 9
336  * @version 1.0
337  */
338 OH_AVErrCode OH_VideoEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index);
339 
340 /**
341  * @brief Notifies the video encoder that the input stream has ended. This interface is only used in Surface mode.
342  * In Buffer mode, the OH_AVBuffer carries the EOS information to notify the end of the stream.
343  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
344  * @param codec Pointer to an OH_AVCodec instance
345  * @return Returns AV_ERR_OK if the execution is successful,
346  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
347  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
348  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
349  * {@link AV_ERR_UNKNOWN}, unknown error.
350  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
351  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
352  * @since 9
353  * @version 1.0
354  */
355 OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec);
356 
357 /**
358  * @brief Submit the input buffer filled with data to the video encoder.
359  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
360  * @param codec Pointer to an OH_AVCodec instance
361  * @param index Enter the index value corresponding to the buffer,
362  * should be given by {@link OH_AVCodecOnNeedInputData}.
363  * @param attr Information describing the data contained in the buffer
364  * @return Returns AV_ERR_OK if the execution is successful,
365  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
366  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
367  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
368  * {@link AV_ERR_UNKNOWN}, unknown error.
369  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
370  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
371  * @deprecated since 11
372  * @useinstead OH_VideoEncoder_PushInputBuffer
373  * @since 10
374  */
375 OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr);
376 
377 /**
378  * @brief In Buffer mode, the OH_AVBuffer corresponding to the index is submited to the encoder for encoding.
379  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
380  * @param codec Pointer to an OH_AVCodec instance
381  * @param index Enter the index value corresponding to the buffer,
382  * should be given by {@link OH_AVCodecOnNeedInputBuffer}.
383  * @return Returns AV_ERR_OK if the execution is successful,
384  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
385  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
386  * {@link AV_ERR_INVALID_VAL}
387  * 1. the input codec pointer is non encoder instance or NULL;
388  * 2. unsupported input format parameters.
389  * {@link AV_ERR_UNKNOWN}, unknown error.
390  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
391  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
392 
393  * @since 11
394  */
395 OH_AVErrCode OH_VideoEncoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index);
396 
397 /**
398  * @brief In Surface mode, the encode parameters of the frame corresponding to the
399  * index is submited to the encoder for encoding.
400  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
401  * @param codec Pointer to an OH_AVCodec instance
402  * @param index Enter the index value corresponding to the input parameter,
403  * should be given by {@link OH_VideoEncoder_OnNeedInputParameter}
404  * @return Returns AV_ERR_OK if the execution is successful,
405  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
406  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
407  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
408  * {@link AV_ERR_UNKNOWN}, unknown error.
409  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
410  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
411  * @since 12
412  */
413 OH_AVErrCode OH_VideoEncoder_PushInputParameter(OH_AVCodec *codec, uint32_t index);
414 
415 /**
416  * @brief Return the OH_AVBuffer corresponding to the processed index to the encoder.
417  * Need to call this interface to release output buffer immediately after using.
418  * Otherwise, the encode process will be blocked.
419  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
420  * @param codec Pointer to an OH_AVCodec instance
421  * @param index The index value corresponding to the output buffer,
422  * should be given by {@link OH_AVCodecOnNewOutputBuffer}.
423  * @return Returns AV_ERR_OK if the execution is successful,
424  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
425  * {@link AV_ERR_NO_MEMORY}, internal errors in the input encode instance, such as an abnormal NULL.
426  * {@link AV_ERR_INVALID_VAL}
427  * 1. the input codec pointer is non encoder instance or NULL;
428  * 2. unsupported input format parameters;
429  * 3. the index is vaild or consecutively assigned to the same index,
430  * the error do not affect the subsequent encode process
431  * {@link AV_ERR_UNKNOWN}, unknown error.
432  * {@link AV_ERR_OPERATE_NOT_PERMIT}, internal execution error.
433  * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
434  * @since 11
435  */
436 OH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index);
437 
438 /**
439  * @brief Description information of the image received by the encoder after call {@OH_VideoEncoder_Configure},
440  * refer to {@link OH_AVFormat} for details. It should be noted that the life cycle of the OH_AVFormat
441  * instance pointed to by the return value needs to be released by {@link OH_AVFormat_Destroy}.
442  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
443  * @param codec Pointer to an OH_AVCodec instance
444  * @return Returns a pointer to an OH_AVFormat instance.
445  * Return NULL if the encoder is NULL or invaild.
446  * @since 10
447  */
448 OH_AVFormat *OH_VideoEncoder_GetInputDescription(OH_AVCodec *codec);
449 
450 /**
451  * @brief Check whether the current codec instance is valid.
452  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
453  * @param codec Pointer to an OH_AVCodec instance
454  * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid,
455  * false if the codec instance is invalid. It is recommend that the invoker initialize isValid to false.
456  * @return Returns AV_ERR_OK if the execution is successful,
457  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
458  * {@link AV_ERR_INVALID_VAL}, the input codec pointer is non encoder instance or NULL.
459  * @since 10
460  */
461 OH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec *codec, bool *isValid);
462 
463 /**
464  * @brief The bitrate mode of video encoder.
465  * @syscap SystemCapability.Multimedia.Media.VideoEncoder
466  * @since 9
467  * @version 1.0
468  * @useinstead OH_BitrateMode
469  */
470 typedef enum OH_VideoEncodeBitrateMode {
471     /* constant bit rate mode. */
472     CBR = 0,
473     /* variable bit rate mode. */
474     VBR = 1,
475     /* constant quality mode. */
476     CQ = 2,
477 } OH_VideoEncodeBitrateMode;
478 
479 #ifdef __cplusplus
480 }
481 #endif
482 
483 #endif // NATIVE_AVCODEC_VIDEOENCODER_H
484 /** @} */