1da853ecaSopenharmony_ci/*
2da853ecaSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License.
5da853ecaSopenharmony_ci * You may obtain a copy of the License at
6da853ecaSopenharmony_ci *
7da853ecaSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8da853ecaSopenharmony_ci *
9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and
13da853ecaSopenharmony_ci * limitations under the License.
14da853ecaSopenharmony_ci */
15da853ecaSopenharmony_ci
16da853ecaSopenharmony_ci#ifndef NATIVE_AVCODEC_VIDEOENCODER_H
17da853ecaSopenharmony_ci#define NATIVE_AVCODEC_VIDEOENCODER_H
18da853ecaSopenharmony_ci
19da853ecaSopenharmony_ci#include <stdint.h>
20da853ecaSopenharmony_ci#include <stdio.h>
21da853ecaSopenharmony_ci#include "native_avcodec_base.h"
22da853ecaSopenharmony_ci
23da853ecaSopenharmony_ci#ifdef __cplusplus
24da853ecaSopenharmony_ciextern "C" {
25da853ecaSopenharmony_ci#endif
26da853ecaSopenharmony_ci
27da853ecaSopenharmony_ci/**
28da853ecaSopenharmony_ci * @brief When OH_AVCodec needs new input parameter during the running process, the function pointer will be called and
29da853ecaSopenharmony_ci * carry an available OH_AVFormat to fill in the new input parameter. This parameter takes effect immediately with the
30da853ecaSopenharmony_ci * frame.
31da853ecaSopenharmony_ci *
32da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
33da853ecaSopenharmony_ci * @param codec OH_AVCodec instance
34da853ecaSopenharmony_ci * @param index The index corresponding to the new OH_AVFormat instance
35da853ecaSopenharmony_ci * @param parameter Parameter containing the new OH_AVFormat instance
36da853ecaSopenharmony_ci * @param userData specified data
37da853ecaSopenharmony_ci * @since 12
38da853ecaSopenharmony_ci */
39da853ecaSopenharmony_citypedef void (*OH_VideoEncoder_OnNeedInputParameter)(OH_AVCodec *codec, uint32_t index, OH_AVFormat *parameter,
40da853ecaSopenharmony_ci                                                     void *userData);
41da853ecaSopenharmony_ci
42da853ecaSopenharmony_ci/**
43da853ecaSopenharmony_ci * @brief Creates a video encoder instance from the mime type, which is recommended in most cases.
44da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
45da853ecaSopenharmony_ci * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE}
46da853ecaSopenharmony_ci * @return Returns a Pointer to an OH_AVCodec instance.
47da853ecaSopenharmony_ci * Return nullptr if memory ran out or the mime type is not supported.
48da853ecaSopenharmony_ci * @since 9
49da853ecaSopenharmony_ci * @version 1.0
50da853ecaSopenharmony_ci */
51da853ecaSopenharmony_ciOH_AVCodec *OH_VideoEncoder_CreateByMime(const char *mime);
52da853ecaSopenharmony_ci
53da853ecaSopenharmony_ci/**
54da853ecaSopenharmony_ci * @brief Create a video encoder instance through the video encoder name. The premise of using this interface is to
55da853ecaSopenharmony_ci * know the exact name of the encoder.
56da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
57da853ecaSopenharmony_ci * @param name Video encoder name
58da853ecaSopenharmony_ci * @return Returns a Pointer to an OH_AVCodec instance.
59da853ecaSopenharmony_ci * Return nullptr if memory ran out or the encoder name is not supported.
60da853ecaSopenharmony_ci * @since 9
61da853ecaSopenharmony_ci * @version 1.0
62da853ecaSopenharmony_ci */
63da853ecaSopenharmony_ciOH_AVCodec *OH_VideoEncoder_CreateByName(const char *name);
64da853ecaSopenharmony_ci
65da853ecaSopenharmony_ci/**
66da853ecaSopenharmony_ci * @brief Clear the internal resources of the encoder and destroy the encoder instance
67da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
68da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
69da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
70da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
71da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
72da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
73da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
74da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
75da853ecaSopenharmony_ci * @since 9
76da853ecaSopenharmony_ci * @version 1.0
77da853ecaSopenharmony_ci */
78da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec);
79da853ecaSopenharmony_ci
80da853ecaSopenharmony_ci/**
81da853ecaSopenharmony_ci * @brief Set the asynchronous callback function so that your application can respond to the events generated by the
82da853ecaSopenharmony_ci * video encoder. This interface must be called before Prepare is called.
83da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
84da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
85da853ecaSopenharmony_ci * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback}
86da853ecaSopenharmony_ci * @param userData User specific data
87da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
88da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
89da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
90da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
91da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
92da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
93da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
94da853ecaSopenharmony_ci * @deprecated since 11
95da853ecaSopenharmony_ci * @useinstead OH_VideoEncoder_RegisterCallback
96da853ecaSopenharmony_ci * @since 9
97da853ecaSopenharmony_ci * @version 1.0
98da853ecaSopenharmony_ci */
99da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData);
100da853ecaSopenharmony_ci
101da853ecaSopenharmony_ci/**
102da853ecaSopenharmony_ci * @brief Set the asynchronous callback function so that your application can respond to the events generated by the
103da853ecaSopenharmony_ci * video encoder. This interface must be called before Prepare is called.
104da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
105da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
106da853ecaSopenharmony_ci * @param callback A collection of all callback functions, see {@link OH_AVCodecCallback}
107da853ecaSopenharmony_ci * @param userData User specific data
108da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
109da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
110da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
111da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
112da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
113da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
114da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
115da853ecaSopenharmony_ci * @since 11
116da853ecaSopenharmony_ci */
117da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_RegisterCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData);
118da853ecaSopenharmony_ci
119da853ecaSopenharmony_ci/**
120da853ecaSopenharmony_ci * @brief Set the asynchronous callback function so that your application can respond to the events generated by the
121da853ecaSopenharmony_ci * video encoder. This interface is optional only for input surface. If this interface is used, it must be invoked
122da853ecaSopenharmony_ci * before {@link OH_VideoEncoder_Configure}.
123da853ecaSopenharmony_ci *
124da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
125da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
126da853ecaSopenharmony_ci * @param onInputParameter A callback functions, see {@link OH_VideoEncoder_OnNeedInputParameter}
127da853ecaSopenharmony_ci * @param userData User specific data
128da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
129da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
130da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
131da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
132da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
133da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
134da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
135da853ecaSopenharmony_ci * @since 12
136da853ecaSopenharmony_ci */
137da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_RegisterParameterCallback(OH_AVCodec *codec,
138da853ecaSopenharmony_ci                                                       OH_VideoEncoder_OnNeedInputParameter onInputParameter,
139da853ecaSopenharmony_ci                                                       void *userData);
140da853ecaSopenharmony_ci
141da853ecaSopenharmony_ci/**
142da853ecaSopenharmony_ci * @brief To configure the video encoder, typically, you need to configure the description information of the
143da853ecaSopenharmony_ci * encoded video track. This interface must be called before Prepare is called.
144da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
145da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
146da853ecaSopenharmony_ci * @param format A pointer to an OH_AVFormat that gives the description of the video track to be encoded
147da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
148da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
149da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
150da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. Invalid param in format.
151da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
152da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
153da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
154da853ecaSopenharmony_ci * @since 9
155da853ecaSopenharmony_ci * @version 1.0
156da853ecaSopenharmony_ci */
157da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format);
158da853ecaSopenharmony_ci
159da853ecaSopenharmony_ci/**
160da853ecaSopenharmony_ci * @brief To prepare the internal resources of the encoder, the Configure interface must be called before
161da853ecaSopenharmony_ci * calling this interface.
162da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
163da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
164da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
165da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
166da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
167da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
168da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
169da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
170da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
171da853ecaSopenharmony_ci * @since 9
172da853ecaSopenharmony_ci * @version 1.0
173da853ecaSopenharmony_ci */
174da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Prepare(OH_AVCodec *codec);
175da853ecaSopenharmony_ci
176da853ecaSopenharmony_ci/**
177da853ecaSopenharmony_ci * @brief Start the encoder, this interface must be called after the Prepare is successful. After being
178da853ecaSopenharmony_ci * successfully started, the encoder will start reporting NeedInputData events.
179da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
180da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
181da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
182da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
183da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
184da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
185da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
186da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
187da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
188da853ecaSopenharmony_ci * @since 9
189da853ecaSopenharmony_ci * @version 1.0
190da853ecaSopenharmony_ci */
191da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Start(OH_AVCodec *codec);
192da853ecaSopenharmony_ci
193da853ecaSopenharmony_ci/**
194da853ecaSopenharmony_ci * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start.
195da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
196da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
197da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
198da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
199da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
200da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
201da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
202da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
203da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
204da853ecaSopenharmony_ci * @since 9
205da853ecaSopenharmony_ci * @version 1.0
206da853ecaSopenharmony_ci */
207da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Stop(OH_AVCodec *codec);
208da853ecaSopenharmony_ci
209da853ecaSopenharmony_ci/**
210da853ecaSopenharmony_ci * @brief Clear the input and output data buffered in the encoder. After this interface is called, all the Buffer
211da853ecaSopenharmony_ci * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access the
212da853ecaSopenharmony_ci * Buffers corresponding to these indexes.
213da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
214da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
215da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
216da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
217da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
218da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
219da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
220da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
221da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
222da853ecaSopenharmony_ci * @since 9
223da853ecaSopenharmony_ci * @version 1.0
224da853ecaSopenharmony_ci */
225da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Flush(OH_AVCodec *codec);
226da853ecaSopenharmony_ci
227da853ecaSopenharmony_ci/**
228da853ecaSopenharmony_ci * @brief Reset the encoder. To continue coding, you need to call the Configure interface again to
229da853ecaSopenharmony_ci * configure the encoder instance.
230da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
231da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
232da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
233da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
234da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
235da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
236da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
237da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
238da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
239da853ecaSopenharmony_ci * @since 9
240da853ecaSopenharmony_ci * @version 1.0
241da853ecaSopenharmony_ci */
242da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_Reset(OH_AVCodec *codec);
243da853ecaSopenharmony_ci
244da853ecaSopenharmony_ci/**
245da853ecaSopenharmony_ci * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details.
246da853ecaSopenharmony_ci * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to
247da853ecaSopenharmony_ci * be manually released by the caller.
248da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
249da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
250da853ecaSopenharmony_ci * @return Returns a pointer to an OH_AVFormat instance.
251da853ecaSopenharmony_ci * Return nullptr if the codec is nullptr or invaild.
252da853ecaSopenharmony_ci * @since 9
253da853ecaSopenharmony_ci * @version 1.0
254da853ecaSopenharmony_ci */
255da853ecaSopenharmony_ciOH_AVFormat *OH_VideoEncoder_GetOutputDescription(OH_AVCodec *codec);
256da853ecaSopenharmony_ci
257da853ecaSopenharmony_ci/**
258da853ecaSopenharmony_ci * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started.
259da853ecaSopenharmony_ci * At the same time, incorrect parameter settings may cause the encoding to fail.
260da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
261da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
262da853ecaSopenharmony_ci * @param format OH_AVFormat handle pointer
263da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
264da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
265da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
266da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid. Invalid param in format.
267da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
268da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
269da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
270da853ecaSopenharmony_ci * @since 9
271da853ecaSopenharmony_ci * @version 1.0
272da853ecaSopenharmony_ci */
273da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format);
274da853ecaSopenharmony_ci
275da853ecaSopenharmony_ci/**
276da853ecaSopenharmony_ci * @brief Get the input Surface from the video encoder, this interface must be called before Prepare is called.
277da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
278da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
279da853ecaSopenharmony_ci * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}, the application is responsible for
280da853ecaSopenharmony_ci * managing the life cycle of the window, call OH_NativeWindow_DestroyNativeWindow() when done.
281da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
282da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
283da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, inner resource has already released.
284da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
285da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
286da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
287da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
288da853ecaSopenharmony_ci * @since 9
289da853ecaSopenharmony_ci * @version 1.0
290da853ecaSopenharmony_ci */
291da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **window);
292da853ecaSopenharmony_ci
293da853ecaSopenharmony_ci/**
294da853ecaSopenharmony_ci * @brief Return the processed output Buffer to the encoder.
295da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
296da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
297da853ecaSopenharmony_ci * @param index The index value corresponding to the output Buffer
298da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
299da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
300da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
301da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
302da853ecaSopenharmony_ci * Buffer index should be given by {@link OH_AVCodecOnNewOutputData}.
303da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
304da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
305da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
306da853ecaSopenharmony_ci * @deprecated since 11
307da853ecaSopenharmony_ci * @useinstead OH_VideoEncoder_FreeOutputBuffer
308da853ecaSopenharmony_ci * @since 9
309da853ecaSopenharmony_ci * @version 1.0
310da853ecaSopenharmony_ci */
311da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index);
312da853ecaSopenharmony_ci
313da853ecaSopenharmony_ci/**
314da853ecaSopenharmony_ci * @brief Notifies the video encoder that the input stream has ended. It is recommended to use this interface to notify
315da853ecaSopenharmony_ci * the encoder of the end of the stream in surface mode
316da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
317da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
318da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
319da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
320da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
321da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
322da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
323da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
324da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
325da853ecaSopenharmony_ci * @since 9
326da853ecaSopenharmony_ci * @version 1.0
327da853ecaSopenharmony_ci */
328da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec);
329da853ecaSopenharmony_ci
330da853ecaSopenharmony_ci/**
331da853ecaSopenharmony_ci * @brief Submit the input buffer filled with data to the video encoder.
332da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
333da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
334da853ecaSopenharmony_ci * @param index Enter the index value corresponding to the Buffer
335da853ecaSopenharmony_ci * @param attr Information describing the data contained in the Buffer
336da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
337da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
338da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
339da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
340da853ecaSopenharmony_ci * Buffer index should be given by {@link OH_AVCodecOnNeedInputData}.
341da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
342da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
343da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
344da853ecaSopenharmony_ci * @deprecated since 11
345da853ecaSopenharmony_ci * @useinstead OH_VideoEncoder_PushInputBuffer
346da853ecaSopenharmony_ci * @since 10
347da853ecaSopenharmony_ci */
348da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr);
349da853ecaSopenharmony_ci
350da853ecaSopenharmony_ci/**
351da853ecaSopenharmony_ci * @brief Submit the input buffer filled with data to the video encoder.
352da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
353da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
354da853ecaSopenharmony_ci * @param index Enter the index value corresponding to the Buffer
355da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
356da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
357da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
358da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
359da853ecaSopenharmony_ci * Buffer index should be given by {@link OH_AVCodecOnNeedInputBuffer}.
360da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
361da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
362da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
363da853ecaSopenharmony_ci
364da853ecaSopenharmony_ci * @since 11
365da853ecaSopenharmony_ci */
366da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index);
367da853ecaSopenharmony_ci
368da853ecaSopenharmony_ci/**
369da853ecaSopenharmony_ci * @brief Submit the input parameter filled with data to the video encoder.
370da853ecaSopenharmony_ci *
371da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
372da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
373da853ecaSopenharmony_ci * @param index Enter the index value corresponding to the input parameter
374da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
375da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
376da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
377da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
378da853ecaSopenharmony_ci * Index should be given by {@link OH_VideoEncoder_OnNeedInputParameter}.
379da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
380da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
381da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
382da853ecaSopenharmony_ci * @since 12
383da853ecaSopenharmony_ci */
384da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputParameter(OH_AVCodec *codec, uint32_t index);
385da853ecaSopenharmony_ci
386da853ecaSopenharmony_ci/**
387da853ecaSopenharmony_ci * @brief Return the processed output Buffer to the encoder.
388da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
389da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
390da853ecaSopenharmony_ci * @param index The index value corresponding to the output Buffer
391da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
392da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
393da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
394da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
395da853ecaSopenharmony_ci * Buffer index should be given by {@link OH_AVCodecOnNewOutputBuffer}.
396da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
397da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
398da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state.
399da853ecaSopenharmony_ci * @since 11
400da853ecaSopenharmony_ci */
401da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_FreeOutputBuffer(OH_AVCodec *codec, uint32_t index);
402da853ecaSopenharmony_ci
403da853ecaSopenharmony_ci/**
404da853ecaSopenharmony_ci * @brief Get the input data description of the encoder after call {@OH_VideoEncoder_Configure},
405da853ecaSopenharmony_ci * refer to {@link OH_AVFormat} for details. It should be noted that the life cycle of the OH_AVFormat
406da853ecaSopenharmony_ci * instance pointed to by the return value needs to be manually released by the caller.
407da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
408da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
409da853ecaSopenharmony_ci * @return Returns a pointer to an OH_AVFormat instance.
410da853ecaSopenharmony_ci * Return nullptr if the encoder is nullptr or invaild.
411da853ecaSopenharmony_ci * @since 10
412da853ecaSopenharmony_ci */
413da853ecaSopenharmony_ciOH_AVFormat *OH_VideoEncoder_GetInputDescription(OH_AVCodec *codec);
414da853ecaSopenharmony_ci
415da853ecaSopenharmony_ci/**
416da853ecaSopenharmony_ci * @brief Check whether the current codec instance is valid. It can be used fault recovery or app
417da853ecaSopenharmony_ci * switchback from the background
418da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
419da853ecaSopenharmony_ci * @param codec Pointer to an OH_AVCodec instance
420da853ecaSopenharmony_ci * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid,
421da853ecaSopenharmony_ci * false if the codec instance is invalid
422da853ecaSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful,
423da853ecaSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode}.
424da853ecaSopenharmony_ci * {@link AV_ERR_NO_MEMORY}, instance has already released.
425da853ecaSopenharmony_ci * {@link AV_ERR_INVALID_VAL}, the encoder is nullptr or invalid.
426da853ecaSopenharmony_ci * {@link AV_ERR_UNKNOWN}, unknown error.
427da853ecaSopenharmony_ci * {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
428da853ecaSopenharmony_ci * @since 10
429da853ecaSopenharmony_ci */
430da853ecaSopenharmony_ciOH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec *codec, bool *isValid);
431da853ecaSopenharmony_ci
432da853ecaSopenharmony_ci/**
433da853ecaSopenharmony_ci * @brief The bitrate mode of video encoder.
434da853ecaSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.VideoEncoder
435da853ecaSopenharmony_ci * @since 9
436da853ecaSopenharmony_ci * @version 1.0
437da853ecaSopenharmony_ci */
438da853ecaSopenharmony_citypedef enum OH_VideoEncodeBitrateMode {
439da853ecaSopenharmony_ci    /* constant bit rate mode. */
440da853ecaSopenharmony_ci    CBR = 0,
441da853ecaSopenharmony_ci    /* variable bit rate mode. */
442da853ecaSopenharmony_ci    VBR = 1,
443da853ecaSopenharmony_ci    /* constant quality mode. */
444da853ecaSopenharmony_ci    CQ = 2,
445da853ecaSopenharmony_ci} OH_VideoEncodeBitrateMode;
446da853ecaSopenharmony_ci
447da853ecaSopenharmony_ci#ifdef __cplusplus
448da853ecaSopenharmony_ci}
449da853ecaSopenharmony_ci#endif
450da853ecaSopenharmony_ci
451da853ecaSopenharmony_ci#endif // NATIVE_AVCODEC_VIDEOENCODER_H