Modify param to avoid build warning
[platform/core/api/mediacodec.git] / include / media_codec.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __TIZEN_MEDIA_CODEC_H__
18 #define __TIZEN_MEDIA_CODEC_H__
19
20 #include <tizen.h>
21 #include <stdint.h>
22 #include <media_packet.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29 * @file media_codec.h
30 * @brief This file contains the capi media codec API.
31 */
32
33 /**
34 * @addtogroup CAPI_MEDIA_CODEC_MODULE
35 * @{
36 */
37
38 /**
39  * @brief Media Codec type handle.
40  * @since_tizen 2.3
41  */
42 typedef struct mediacodec_s *mediacodec_h;
43
44 /**
45  * @brief Enumeration of  media codec support  type
46  * @since_tizen 2.3
47  * @remarks If this codec is to be used as an encoder or decoder, the codec flag must be set to #MEDIACODEC_ENCODER or
48  *          #MEDIACODEC_DECODER. If user doesn't set optional flag, default flags will be set to #MEDIACODEC_SUPPORT_TYPE_SW.
49  */
50 typedef enum
51 {
52     MEDIACODEC_ENCODER          = 0x1,      /**< This flag is for using the encoder */
53     MEDIACODEC_DECODER          = 0x2,      /**< This flag is for using the decoder */
54     MEDIACODEC_SUPPORT_TYPE_HW  = 0x4,      /**< This is an optional flag for using the h/w codec */
55     MEDIACODEC_SUPPORT_TYPE_SW  = 0x8,      /**< This is an optional flag for using the s/w codec */
56 } mediacodec_support_type_e;
57
58 /**
59  * @brief Enumerations of  media codec type
60  * @since_tizen 2.3
61  */
62 typedef enum
63 {
64     MEDIACODEC_NONE         = 0x0,      /**< NONE*/
65     MEDIACODEC_L16          = 0x1010,   /**< L16*/
66     MEDIACODEC_ALAW         = 0x1020,   /**< ALAW*/
67     MEDIACODEC_ULAW         = 0x1030,   /**< ULAW*/
68     MEDIACODEC_AMR          = 0x1040,   /**< MEDIACDEC_AMR indicates AMR-NB (Since 2.4)*/
69     MEDIACODEC_AMR_NB       = 0x1040,   /**< AMR-NB (Since 2.4)*/
70     MEDIACODEC_AMR_WB       = 0x1041,   /**< AMR-WB (Since 2.4)*/
71     MEDIACODEC_G729         = 0x1050,   /**< G729*/
72     MEDIACODEC_AAC          = 0x1060,   /**< MEDIACDEC_AAC indicates AAC-LC (Since 2.4)*/
73     MEDIACODEC_AAC_LC       = 0x1060,   /**< AAC-LC (Since 2.4)*/
74     MEDIACODEC_AAC_HE       = 0x1061,   /**< HE-AAC (Since 2.4)*/
75     MEDIACODEC_AAC_HE_PS    = 0x1062,   /**< HE-AAC-PS (Since 2.4)*/
76     MEDIACODEC_MP3          = 0x1070,   /**< MP3*/
77     MEDIACODEC_VORBIS       = 0x1080,   /**< VORBIS (Since 2.4)*/
78     MEDIACODEC_FLAC         = 0x1090,   /**< FLAC (Since 2.4)*/
79     MEDIACODEC_WMAV1        = 0x10A0,   /**< WMA version 1 (Since 2.4)*/
80     MEDIACODEC_WMAV2        = 0x10A1,   /**< WMA version 2  (Since 2.4)*/
81     MEDIACODEC_WMAPRO       = 0x10A2,   /**< WMA Professional (Since 2.4)*/
82     MEDIACODEC_WMALSL       = 0x10A3,   /**< WMA Lossless (Since 2.4)*/
83
84     MEDIACODEC_H261         = 0x2010,   /**< H.261*/
85     MEDIACODEC_H263         = 0x2020,   /**< H.263*/
86     MEDIACODEC_H264         = 0x2030,   /**< H.264*/
87     MEDIACODEC_MJPEG        = 0x2040,   /**< MJPEG*/
88     MEDIACODEC_MPEG1        = 0x2050,   /**< MPEG1*/
89     MEDIACODEC_MPEG2        = 0x2060,   /**< MPEG2*/
90     MEDIACODEC_MPEG4        = 0x2070,   /**< MPEG4*/
91     MEDIACODEC_HEVC         = 0x2080,   /**< HEVC (Since 2.4)*/
92     MEDIACODEC_VP8          = 0x2090,   /**< VP8 (Since 2.4)*/
93     MEDIACODEC_VP9          = 0x20A0,   /**< VP9 (Since 2.4)*/
94     MEDIACODEC_VC1          = 0x20B0,   /**< VC1 (Since 2.4)*/
95 } mediacodec_codec_type_e;
96
97 /**
98  * @brief Enumeration of  media codec error
99  * @since_tizen 2.3
100  */
101 typedef enum
102 {
103     MEDIACODEC_ERROR_NONE                       = TIZEN_ERROR_NONE,                     /**< Successful */
104     MEDIACODEC_ERROR_OUT_OF_MEMORY              = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
105     MEDIACODEC_ERROR_INVALID_PARAMETER          = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
106     MEDIACODEC_ERROR_INVALID_OPERATION          = TIZEN_ERROR_INVALID_OPERATION,        /**< Invalid operation */
107     MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE    = TIZEN_ERROR_NOT_SUPPORTED,            /**< Not supported */
108     MEDIACODEC_ERROR_PERMISSION_DENIED          = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
109     MEDIACODEC_ERROR_INVALID_STATE              = TIZEN_ERROR_MEDIACODEC | 0x01,        /**< Invalid state */
110     MEDIACODEC_ERROR_INVALID_INBUFFER           = TIZEN_ERROR_MEDIACODEC | 0x02,        /**< Invalid input buffer */
111     MEDIACODEC_ERROR_INVALID_OUTBUFFER          = TIZEN_ERROR_MEDIACODEC | 0x03,        /**< Invalid output buffer */
112     MEDIACODEC_ERROR_INTERNAL                   = TIZEN_ERROR_MEDIACODEC | 0x04,        /**< Internal error */
113     MEDIACODEC_ERROR_NOT_INITIALIZED            = TIZEN_ERROR_MEDIACODEC | 0x05,        /**< Not initialized mediacodec */
114     MEDIACODEC_ERROR_INVALID_STREAM             = TIZEN_ERROR_MEDIACODEC | 0x06,        /**< Invalid stream */
115     MEDIACODEC_ERROR_CODEC_NOT_FOUND            = TIZEN_ERROR_MEDIACODEC | 0x07,        /**< Not supported format */
116     MEDIACODEC_ERROR_DECODE                     = TIZEN_ERROR_MEDIACODEC | 0x08,        /**< Error while decoding data */
117     MEDIACODEC_ERROR_NO_FREE_SPACE              = TIZEN_ERROR_MEDIACODEC | 0x09,        /**< Out of storage */
118     MEDIACODEC_ERROR_STREAM_NOT_FOUND           = TIZEN_ERROR_MEDIACODEC | 0x0a,        /**< Cannot find stream */
119     MEDIACODEC_ERROR_NOT_SUPPORTED_FORMAT       = TIZEN_ERROR_MEDIACODEC | 0x0b,        /**< Not supported format */
120     MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE       = TIZEN_ERROR_MEDIACODEC | 0x0c,        /**< Not available buffer */
121     MEDIACODEC_ERROR_OVERFLOW_INBUFFER          = TIZEN_ERROR_MEDIACODEC | 0x0d,        /**< Overflow input buffer (Since 2.4)*/
122     MEDIACODEC_ERROR_RESOURCE_OVERLOADED        = TIZEN_ERROR_MEDIACODEC | 0x0e,        /**< Exceed the instance limits (Since 2.4)*/
123 } mediacodec_error_e;
124
125 /**
126  * @brief Enumeration of buffer status
127  * @since_tizen 2.4
128  */
129 typedef enum
130 {
131     MEDIACODEC_NEED_DATA,
132     MEDIACODEC_ENOUGH_DATA
133 } mediacodec_status_e;
134
135 /**
136  * @brief Called when the input buffer(pkt) used up.
137  * @since_tizen 2.3
138  * @details It will be invoked when mediacodec has used input buffer.
139  * @param[in] pkt  The media packet handle
140  * @param[in] user_data  The user data passed from the callback registration function
141  * @pre It will be invoked when input buffer process completed if you register this callback using mediacodec_set_input_buffer_used_cb().
142  * @see mediacodec_set_input_buffer_used_cb()
143  * @see mediacodec_unset_input_buffer_used_cb()
144  */
145 typedef void (*mediacodec_input_buffer_used_cb)(media_packet_h pkt, void *user_data);
146
147 /**
148  * @brief Called when the output buffer is available.
149  * @since_tizen 2.3
150  * @details It will be invoked when mediacodec has output buffer.
151  * @param[in] pkt  The media packet handle
152  * @param[in] user_data  The user data passed from the callback registration function
153  * @pre It will be invoked when mediacodec process completed(had output buffer) if you register this callback using mediacodec_set_fill_buffer_cb().
154  * @see mediacodec_set_output_buffer_available_cb()
155  * @see mediacodec_unset_output_buffer_available_cb()
156  */
157 typedef void (*mediacodec_output_buffer_available_cb)(media_packet_h pkt, void *user_data);
158
159 /**
160  * @brief Called when the error has occured
161  * @since_tizen 2.3
162  * @details It will be invoked when the error has occured.
163  * @param[in] error_code  The error code
164  * @param[in] user_data  The user data passed from the callback registration function
165  * @pre It will be invoked when the error has occured if you register this callback using mediacodec_set_error_cb().
166  * @see mediacodec_set_error_cb()
167  * @see mediacodec_unset_error_cb()
168  */
169 typedef void (*mediacodec_error_cb)(mediacodec_error_e error, void *user_data);
170
171 /**
172  * @brief Called when there is no data to decode/encode
173  * @since_tizen 2.3
174  * @details It will be invoked when the end-of-stream is reached.
175  * @param[in] user_data  The user data passed from the callback registration function
176  * @pre It will be invoked when the eos event generate if you register this callback using mediacodec_set_eos_cb().
177  * @see mediacodec_set_eos_cb()
178  * @see mediacodec_unset_eos_cb()
179  */
180 typedef void (*mediacodec_eos_cb)(void *user_data);
181
182 /**
183  * @brief Called when the mediacodec needs more data or has enough data.
184  * @since_tizen 2.4
185  * @details It is recommended that the application stops calling mediacodec_process_input() when MEDIACODEC_ENOUGH_DATA
186  * is invoked.
187  * @param[in] user_data  The user data passed from the callback registration function
188  * @see mediacodec_set_buffer_status_cb()
189  * @see mediacodec_unset_buffer_status_cb()
190  */
191 typedef void (*mediacodec_buffer_status_cb)(mediacodec_status_e status, void *user_data);
192
193 /**
194  * @brief Called once for each supported codec types.
195  * @since_tizen 2.4
196  * @param[in] codec_type  The codec type
197  * @param[in] user_data   The user data passed from the foreach function
198  * @return  @c true to continue with the next iteration of the loop, @c false to break out of the loop.
199  * @pre mediacodec_foreach_supported_codec() will invoke this callback.
200  * @see mediacodec_foreach_supported_codec()
201  */
202 typedef bool (*mediacodec_supported_codec_cb)(mediacodec_codec_type_e codec_type, void *user_data);
203
204 /**
205  * @brief Creates a mediacodec handle for decoding/encoding
206  * @since_tizen 2.3
207  * @remarks you must release @a mediacodec using mediacodec_destroy().\n
208  *          Although you can create multiple mediacodec handles at the same time,
209  *          the mediacodec cannot guarantee proper operation because of limited resources, like
210  *          audio or display device.
211  *
212  * @param[out]  mediacodec  A new handle to mediacodec
213  * @return @c 0 on success, otherwise a negative error value
214  * @retval #MEDIACODEC_ERROR_NONE Successful
215  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
216  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
217  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
218  */
219 int mediacodec_create(mediacodec_h *mediacodec);
220
221 /**
222  * @brief Destroys the mediacodec handle and releases all its resources.
223  * @since_tizen 2.3
224  * @remarks To completely shutdown the mediacodec operation, call this function with a valid player handle from any
225  *          mediacodec
226  *
227  * @param[in]  mediacodec  The handle to mediacodec to be destroyed.
228  * @return @c 0 on success, otherwise a negative error value
229  * @retval #MEDIACODEC_ERROR_NONE Successful
230  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
231  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
232  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
233  */
234 int mediacodec_destroy(mediacodec_h mediacodec);
235
236 /**
237  * @brief Sets the codec type and decoder/encoder.
238  * @since_tizen 2.3
239  * @remarks If this codec is to be used as a decoder, pass the #MEDIACODEC_DECODER flag.
240  *          If this codec is to be used as an encoder, pass the #MEDIACODEC_ENCODER flag.\n
241  *          The software codec is used as default setting(#MEDIACODEC_SUPPORT_TYPE_SW) if user doesn't set hardware flag.
242  *          If user wants to use h/w decoder, user needs to pass the #MEDIACODEC_DECODER | #MEDIACODEC_SUPPORT_TYPE_HW.
243  * @param[in] mediacodec  The handle of mediacodec
244  * @param[in] codec_type  The identifier of the codec type of the decoder/encoder
245  * @param[in] flags  The encoding/decoding scheme, defined by #mediacodec_support_type_e
246  * @return @c 0 on success, otherwise a negative error value
247  * @retval #MEDIACODEC_ERROR_NONE Successful
248  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
249  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
250  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
251  * @retval #MEDIACODEC_ERROR_CODEC_NOT_FOUND Codec not found
252  */
253 int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_type, int flags);
254
255 /**
256  * @brief Sets the default info for the video decoder
257  * @since_tizen 2.3
258  * @param[in] mediacodec  The handle to mediacodec
259  * @param[in] width  The width for video decoding.
260  * @param[in] height  The height for video decoding.
261  * @return @c 0 on success, otherwise a negative error value
262  * @retval #MEDIACODEC_ERROR_NONE Successful
263  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
264  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
265  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
266  */
267 int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height);
268
269 /**
270  * @brief Sets the default info for the video encoder
271  * @since_tizen 2.3
272  * @remarks The frame rate is the speed of recording and the speed of playback.
273  *          If user wants the default setting for ratecontrol, set @a target_bits to @c 0.
274  * @param[in] mediacodec  The handle to mediacodec
275  * @param[in] width  The width for video encoding.
276  * @param[in] height  The height for video encoding.
277  * @param[in] fps  The frame rate in frames per second.
278  * @param[in] target_bits The target bitrates in bits per second.(a unit of kbit)
279  * @return @c 0 on success, otherwise a negative error value
280  * @retval #MEDIACODEC_ERROR_NONE Successful
281  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
282  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
283  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
284  */
285 int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int fps, int target_bits);
286
287 /**
288  * @brief Sets the default info for the audio decoder
289  * @since_tizen 2.3
290  * @param[in] mediacodec  The handle to mediacodec
291  * @param[in] samplerate  The samplerate for audio decoding.
292  * @param[in] channel  The channels for audio decoding.
293   * @param[in] bit  The bits resolution for audio decoding.
294  * @return @c 0 on success, otherwise a negative error value
295  * @retval #MEDIACODEC_ERROR_NONE Successful
296  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
297  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
298  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
299  */
300 int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit);
301
302 /**
303  * @brief Sets the default info for the audio encdoer
304  * @since_tizen 2.3
305  * @param[in] mediacodec  The handle to mediacodec
306  * @param[in] samplerate  The samplerate for audio encoding.
307  * @param[in] channel  The channels for audio encoding.
308  * @param[in] bit  The bits resolution for audio encoding.
309  * @param[in] bitrate  The bitrate for audio encoding.
310  * @return @c 0 on success, otherwise a negative error value
311  * @retval #MEDIACODEC_ERROR_NONE Successful
312  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
313  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
314  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
315  */
316 int mediacodec_set_aenc_info(mediacodec_h mediacodec, int samplerate, int channel, int bit, int bitrate);
317
318 /**
319  * @brief Prepares @a mediacodec for encoding/decoding.
320  * @since_tizen 2.3
321  * @param[in] mediacodec  The handle to mediacodec
322  * @return @c 0 on success, otherwise a negative error value
323  * @retval #MEDIACODEC_ERROR_NONE Successful
324  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
325  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
326  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
327  * @pre The mediacodec should call mediacodec_set_codec()and mediacodec_set_vdec_info()/mediacodec_set_venc_info() before calling mediacodec_prepare()
328  *      If the decoder is set by mediacodec_set_codec(), mediacodec_set_vdec_info() should be called. If the encoder is set by
329  *      mediacodec_set_codec(), mediacodec_set_venc_info() should be called.
330  */
331 int mediacodec_prepare(mediacodec_h mediacodec);
332
333 /**
334  * @brief Unprepares @a mediacodec for encoding/decoding.
335  * @since_tizen 2.3
336  * @param[in] mediacodec  The handle to mediacodec
337  * @return @c 0 on success, otherwise a negative error value
338  * @retval #MEDIACODEC_ERROR_NONE Successful
339  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
340  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
341  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
342  */
343 int mediacodec_unprepare(mediacodec_h mediacodec);
344
345 /**
346  * @brief Decodes/Encodes a packet. The function passed undecoded/unencoded packet to the input queue and decode/encode a
347  *          frame sequentially.
348  * @since_tizen 2.3
349  * @param[in] mediacodec  The handle to mediacodec
350  * @param[in] inbuf  The current input format for the decoder/encoder
351  * @param[in] timeOutUs  The timeout in microseconds. \n
352  *                       The input buffer wait up to "timeOutUs" microseconds.
353  * @return @c 0 on success, otherwise a negative error value
354  * @retval #MEDIACODEC_ERROR_NONE Successful
355  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
356  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
357  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
358  * @retval #MEDIACODEC_ERROR_OVERFLOW_INBUFFER Overflow inputbuffer
359  */
360 int mediacodec_process_input (mediacodec_h mediacodec, media_packet_h inbuf, uint64_t timeOutUs);
361
362 /**
363  * @brief Gets the decoded or encoded packet from the output queue.
364  * @since_tizen 2.3
365  * @param[in] mediacodec  The handle to mediacodec
366  * @param[out] outbuf  The current output of the decoder/encoder. this function passed decoded/encoded frame to output
367  *                    queue.
368  * @param[in] timeOutUs  The timeout in microseconds. \n
369  *                       The input buffer wait up to "timeOutUs" microseconds.
370  * @return @c 0 on success, otherwise a negative error value
371  * @retval #MEDIACODEC_ERROR_NONE Successful
372  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
373  * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
374  * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
375  */
376 int mediacodec_get_output (mediacodec_h mediacodec, media_packet_h *outbuf, uint64_t timeOutUs);
377
378 /**
379  * @brief Flushes both input and output buffers.
380  * @since_tizen 2.4
381  * @param[in] mediacodec  The handle to mediacodec
382  * @return @c 0 on success, otherwise a negative error value
383  * @retval #MEDIACODEC_ERROR_NONE Successful
384  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
385  */
386 int mediacodec_flush_buffers (mediacodec_h mediacodec);
387
388 /**
389  * @brief set empty buffer callback the media codec for process, asynchronously.
390  * @since_tizen 2.3
391  * @param[in] mediacodec  The handle to mediacodec
392  * @param[in] callback  The callback function to register
393  * @param[in] user_data  The user data to be passed to the callback function
394  * @return @c 0 on success, otherwise a negative error value
395  * @retval #MEDIACODEC_ERROR_NONE Successful
396  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
397  * @pre mediacodec_set_input_buffer_used_cb should be called before mediacodec_preare().
398  * @post mediacodec_input_buffer_used_cb will be invoked.
399  * @see mediacodec_set_input_buffer_used_cb()
400  * @see mediacodec_unset_input_buffer_used_cb()
401  */
402 int mediacodec_set_input_buffer_used_cb(mediacodec_h mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data);
403
404 /**
405  * @brief unset input buffer used callback the media codec for process, asynchronously.
406  * @since_tizen 2.3
407  * @param[in] mediacodec  The handle to mediacodec
408  * @return @c 0 on success, otherwise a negative error value
409  * @retval #MEDIACODEC_ERROR_NONE Successful
410  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
411  * @see mediacodec_set_input_buffer_used_cb()
412  */
413 int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec);
414
415 /**
416  * @brief set output buffer available callback the media codec for process, asynchronously.
417  * @since_tizen 2.3
418  * @param[in] mediacodec  The handle to mediacodec
419  * @param[in] callback  The callback function to register
420  * @param[in] user_data  The user data to be passed to the callback function
421  * @return @c 0 on success, otherwise a negative error value
422  * @retval #MEDIACODEC_ERROR_NONE Successful
423  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
424  * @pre mediacodec_set_output_buffer_available_cb should be called before mediacodec_preare().
425  * @post mediacodec_output_buffer_available_cb will be invoked.
426  * @see mediacodec_set_output_buffer_available_cb()
427  * @see mediacodec_unset_output_buffer_available_cb()
428  */
429 int mediacodec_set_output_buffer_available_cb(mediacodec_h mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data);
430
431 /**
432  * @brief unset output buffer available callback the media codec for process, asynchronously.
433  * @since_tizen 2.3
434  * @param[in] mediacodec  The handle to mediacodec
435  * @return @c 0 on success, otherwise a negative error value
436  * @retval #MEDIACODEC_ERROR_NONE Successful
437  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
438  * @see mediacodec_set_output_buffer_available_cb()
439  */
440 int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec);
441
442 /**
443  * @brief set error callback the media codec for process, asynchronously.
444  * @since_tizen 2.3
445  * @param[in] mediacodec  The handle to mediacodec
446  * @param[in] callback  The callback function to register
447  * @param[in] user_data  The user data to be passed to the callback function
448  * @return @c 0 on success, otherwise a negative error value
449  * @retval #MEDIACODEC_ERROR_NONE Successful
450  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
451  * @pre mediacodec_set_error_cb should be called before mediacodec_preare().
452  * @post mediacodec_error_cb will be invoked.
453  * @see mediacodec_set_error_cb()
454  * @see mediacodec_unset_error_cb()
455  */
456 int mediacodec_set_error_cb(mediacodec_h mediacodec, mediacodec_error_cb callback, void* user_data);
457
458 /**
459  * @brief unset error callback the media codec for process, asynchronously.
460  * @since_tizen 2.3
461  * @param[in] mediacodec  The handle to mediacodec
462  * @return @c 0 on success, otherwise a negative error value
463  * @retval #MEDIACODEC_ERROR_NONE Successful
464  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
465  * @see mediacodec_set_error_cb()
466  */
467 int mediacodec_unset_error_cb(mediacodec_h mediacodec);
468
469 /**
470  * @brief set eos callback the media codec for process, asynchronously.
471  * @since_tizen 2.3
472  * @param[in] mediacodec  The handle to mediacodec
473  * @param[in] callback  The callback function to register
474  * @param[in] user_data  The user data to be passed to the callback function
475  * @return @c 0 on success, otherwise a negative error value
476  * @retval #MEDIACODEC_ERROR_NONE Successful
477  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
478  * @pre mediacodec_set_eos_cb should be called before mediacodec_preare().
479  * @post mediacodec_eos_cb will be invoked.
480  * @see mediacodec_set_eos_cb()
481  * @see mediacodec_unset_eos_cb()
482  */
483 int mediacodec_set_eos_cb(mediacodec_h mediacodec, mediacodec_eos_cb callback, void* user_data);
484
485 /**
486  * @brief unset eos callback the media codec for process, asynchronously.
487  * @since_tizen 2.3
488  * @param[in] mediacodec  The handle to mediacodec
489  * @return @c 0 on success, otherwise a negative error value
490  * @retval #MEDIACODEC_ERROR_NONE Successful
491  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
492  * @see mediacodec_set_event_handler_cb()
493  */
494 int mediacodec_unset_eos_cb(mediacodec_h mediacodec);
495
496 /**
497  * @brief Registers a callback function to be invoked when the mediacodec needs more data or has enough data.
498  * @since_tizen 2.4
499  * @param[in] mediacodec  The handle to mediacodec
500  * @param[in] callback  The callback function to register
501  * @param[in] user_data  The user data to be passed to the callback function
502  * @return @c 0 on success, otherwise a negative error value
503  * @retval #MEDIACODEC_ERROR_NONE Successful
504  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
505  * @pre mediacodec_set_buffer_status_cb should be called before mediacodec_preare().
506  * @post mediacodec_buffer_status_cb will be invoked.
507  * @see mediacodec_set_buffer_status_cb()
508  * @see mediacodec_unset_buffer_status_cb()
509  */
510 int mediacodec_set_buffer_status_cb(mediacodec_h mediacodec, mediacodec_buffer_status_cb callback, void* user_data);
511
512 /**
513  * @brief Unregisters the callback function.
514  * @since_tizen 2.4
515  * @param[in] mediacodec  The handle to mediacodec
516  * @return @c 0 on success, otherwise a negative error value
517  * @retval #MEDIACODEC_ERROR_NONE Successful
518  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
519  */
520 int mediacodec_unset_buffer_status_cb(mediacodec_h mediacodec);
521
522 /**
523  * @brief Retrieves all supported codecs by invoking callback function once for each supported codecs.
524  * @since_tizen 2.4
525  * @param[in] mediacodec  The handle to mediacodec
526  * @param[in] callback  The callback function to invoke
527  * @param[in] user_data The user data to be passed to the callback function
528  * @return @c 0 on success, otherwise a negative error value
529  * @retval #MEDIACODEC_ERROR_NONE Successful
530  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
531  * @see mediacodec_foreach_supported_codec()
532  */
533 int mediacodec_foreach_supported_codec(mediacodec_h mediacodec, mediacodec_supported_codec_cb callback, void *user_data);
534
535 /**
536  * @brief Verifies whether encoding can be performed with codec_type or not.
537  * @since_tizen 2.4
538  * @param[in] mediacodec  The handle to mediacodec
539  * @param[in]  codec_type  The identifier of the codec type of the encoder.
540  * @param[in]  encoder  Whether the encoder or decoder : (@c true = encoder, @c false = decoder).
541  * @param[out]  support_type  (@c MEDIACODEC_SUPPORT_TYPE_HW = mediacodec can be performed with hardware codec, @c MEDIACODEC_SUPPORT_TYPE_SW = mediacodec can be performed with software codec)
542  * @return @c 0 on success, otherwise a negative error value
543  * @retval #MEDIACODEC_ERROR_NONE Successful
544  * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
545  @code
546  #include <media_codec.h>
547  mediacodec_h mediacodec;
548  mediacodec_support_type_e type;
549  mediacodec_codec_type_e codec_type = MEDIACODEC_H264;
550
551  mediacodec_create(&mediacodec);
552  mediacodec_get_supported_type(mediacodec, codec_type, 1, &type);
553
554  if(type == MEDIACODEC_SUPPORT_TYPE_HW)
555      // only h/w supported
556  else if (type == MEDIACODEC_SUPPORT_TYPE_SW)
557      // only s/w supported
558  else if (type == (MEDIACODEC_SUPPORT_TYPE_HW|MEDIACODEC_SUPPORT_TYPE_SW)
559      // both supported
560
561  mediacodec_set_codec(mediacodec, codec_type, MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_HW);
562  @endcode
563  */
564 int mediacodec_get_supported_type(mediacodec_h mediacodec, mediacodec_codec_type_e codec_type, bool encoder, int *support_type);
565
566
567 /**
568  * @}
569  */
570
571 #ifdef __cplusplus
572 }
573 #endif
574
575 #endif /* __TIZEN_MEDIA_CODEC_H__ */
576