0b78069863f906eb76b843c16dfb27d3e94c6d7d
[platform/core/api/video-util.git] / include / video_util.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_VIDEO_UTIL_H__
18 #define __TIZEN_MEDIA_VIDEO_UTIL_H__
19
20 #include <video_util_type.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25
26 /**
27  * @file video_util.h
28  */
29
30 /**
31  * @addtogroup CAPI_MEDIA_VIDEO_UTIL_MODULE
32  * @{
33  */
34
35 /**
36  * @deprecated Deprecated since 5.0
37  * @brief Creates a handle to video util.
38  * @since_tizen 2.3
39  *
40  * @details This function creates a handle to video util.
41  *
42  * @remarks You must release the @a video util handle using video_util_destroy().\n
43  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
44  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
45  *
46  * @param[out] handle A handle to video util
47  *
48  * @return @c 0 on success,
49  *               otherwise a negative error value
50  *
51  * @retval #VIDEO_UTIL_ERROR_NONE Successful
52  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
53  * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory
54  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
55  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
56  *
57  * @see video_util_destroy()
58  *
59  */
60 int video_util_create(video_util_h *handle) TIZEN_DEPRECATED_API;
61
62 /**
63  * @deprecated Deprecated since 5.0
64  * @brief Destroys a handle to video util.
65  * @since_tizen 2.3
66  *
67  * @details The function frees all resources related to the video util handle. The video util
68  *               handle no longer can be used to perform any operation. A new video util handle
69  *               has to be created before the next usage.
70  *
71  * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
72  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
73  *
74  * @param[in] handle The handle to video util
75  *
76  * @return @c 0 on success,
77  *               otherwise a negative error value
78  *
79  * @retval #VIDEO_UTIL_ERROR_NONE Successful
80  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
81  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
82  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
83  *
84  * @see video_util_create()
85  *
86  */
87 int video_util_destroy(video_util_h handle) TIZEN_DEPRECATED_API;
88
89 /**
90  * @deprecated Deprecated since 5.0
91  * @brief Sets the video util's file path.
92  * @since_tizen 2.3
93  *
94  * @details This function sets the source @a path to transcode.
95  *
96  * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
97  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
98  *
99  * @param[in] handle The handle to video util
100  * @param[in] path The source file path
101  *
102  * @return @c 0 on success,
103  *               otherwise a negative error value
104  *
105  * @retval #VIDEO_UTIL_ERROR_NONE Successful
106  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
107  * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory
108  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
109  *
110  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
111  *
112  * @see video_util_create()
113  * @see video_util_destroy()
114  */
115 int video_util_set_file_path(video_util_h handle, const char *path) TIZEN_DEPRECATED_API;
116
117 /**
118  * @deprecated Deprecated since 5.0
119  * @brief Sets the video util's accurate mode.
120  * @since_tizen 2.3
121  *
122  * @remarks If you do not set this, the default value is @c false.\n
123  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
124  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
125  *
126  * @param[in] handle The handle to video util
127  * @param[in] mode Set @c true if the user can get an accurated frame for given the duration in video_util_start_transcoding(),
128  *                              otherwise set @c false if user can only get the nearest i-frame
129  *
130  * @return @c 0 on success,
131  *               otherwise a negative error value
132  *
133  * @retval #VIDEO_UTIL_ERROR_NONE Successful
134  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
135  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
136  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
137  *
138  * @see video_util_create()
139  * @see video_util_destroy()
140  */
141 int video_util_set_accurate_mode(video_util_h handle, bool mode) TIZEN_DEPRECATED_API;
142
143 /**
144  * @deprecated Deprecated since 5.0
145  * @brief Sets the video codec for encoding video stream.
146  * @since_tizen 2.3
147  *
148  * @remarks You can get available list of video codec by using video_util_foreach_supported_video_codec().\n
149  *                 If you do not set this, the default codec is #VIDEO_UTIL_VIDEO_CODEC_MPEG4.\n
150  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
151  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
152  *
153  * @param[in] handle The handle to video util
154  * @param[in] codec The video codec
155  *
156  * @return @c 0 on success,
157  *               otherwise a negative error value
158  * @retval #VIDEO_UTIL_ERROR_NONE Successful
159  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
160  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
161  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
162  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
163  *
164  * @see video_util_create()
165  * @see video_util_destroy()
166  * @see video_util_foreach_supported_video_codec()
167  */
168 int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec) TIZEN_DEPRECATED_API;
169
170 /**
171  * @deprecated Deprecated since 5.0
172  * @brief Sets the audio codec for encoding audio stream.
173  * @since_tizen 2.3
174  *
175  * @remarks You can get available list of audio codec by using video_util_foreach_supported_audio_codec().\n
176  *                  If you do not set this, the default codec is #VIDEO_UTIL_AUDIO_CODEC_AAC.\n
177  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
178  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
179  *
180  * @param[in] handle The handle to video util
181  * @param[in] codec The audio codec
182  *
183  * @return @c 0 on success,
184  *               otherwise a negative error value
185  *
186  * @retval #VIDEO_UTIL_ERROR_NONE Successful
187  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
188  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
189  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
190  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
191  *
192  * @see video_util_create()
193  * @see video_util_destroy()
194  * @see video_util_foreach_supported_audio_codec()
195  */
196 int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec) TIZEN_DEPRECATED_API;
197
198 /**
199  * @deprecated Deprecated since 5.0
200  * @brief Sets the file format for transcoding media stream.
201  * @since_tizen 2.3
202  *
203  * @remarks You can get available list of media formats by using video_util_foreach_supported_file_format().\n
204  *                 If you do not set this, the default file format is #VIDEO_UTIL_FILE_FORMAT_3GP.\n
205  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
206  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
207  *
208  * @param[in] handle The handle to video util
209  * @param[in] format The media file format
210  *
211  * @return @c 0 on success,
212  *               otherwise a negative error value
213  *
214  * @retval #VIDEO_UTIL_ERROR_NONE Successful
215  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
216  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
217  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
218  *
219  * @see video_util_create()
220  * @see video_util_destroy()
221  * @see video_util_foreach_supported_file_format()
222  */
223 int video_util_set_file_format(video_util_h handle, video_util_file_format_e format) TIZEN_DEPRECATED_API;
224
225 /**
226  * @deprecated Deprecated since 5.0
227  * @brief Sets the resolution(width and height).
228  * @since_tizen 2.3
229  *
230  * @remarks If you do not set, the default resolution is original size.\n
231  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
232  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
233  *
234  * @param[in] handle The handle to video util
235  * @param[in] width The media's width \n
236  *                              If the width is 0, it set original size.(minimum value is 128)
237  * @param[in] height The media's height \n
238  *                    If the height is 0, it set original size.(minimum value is 96)
239  *
240  * @return @c 0 on success,
241  *               otherwise a negative error value
242  *
243  * @retval #VIDEO_UTIL_ERROR_NONE Successful
244  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
245  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
246  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
247  *
248  * @see video_util_create()
249  * @see video_util_destroy()
250  */
251 int video_util_set_resolution(video_util_h handle, int width, int height) TIZEN_DEPRECATED_API;
252
253 /**
254  * @deprecated Deprecated since 5.0
255  * @brief Sets the frame rate.
256  * @since_tizen 2.3
257  *
258  * @remarks If fps is set @c 0, the default is original fps from source.\n
259  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
260  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
261  *
262  * @param[in] handle The handle to video util
263  *
264  * @param[in] fps The frame rate(minimum value is 5, maximum value is 30)
265  * @return @c 0 on success,
266  *               otherwise a negative error value
267  *
268  * @retval #VIDEO_UTIL_ERROR_NONE Successful
269  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
270  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
271  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
272  *
273  * @see video_util_create()
274  * @see video_util_destroy()
275  */
276 int video_util_set_fps(video_util_h handle, int fps) TIZEN_DEPRECATED_API;
277
278 /**
279  * @deprecated Deprecated since 5.0
280  * @brief Transcodes the video for given video util handle.
281  * @since_tizen 2.3
282  *
283  * @details This function starts the transcoding from start time and for given duration.\n
284  *              #video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.\n
285  *              #video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished.
286  *
287  * @remarks If there already exists same file in file system, then old file will be overwritten.\n
288  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
289  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
290  *
291  * @param[in] handle The handle to video util
292  * @param[in] start The start position to transcode
293  * @param[in] duration The duration in seconds \n
294  *                                  if duration is @c 0, transcoding happens until end of the video.
295  * @param[out] out_path The file path to save
296  * @param[in] progress_cb The callback function to be invoked
297  * @param[in] completed_cb The callback function to be invoked
298  * @param[in] user_data The user data to be passed to the callback function
299  *
300  * @return @c 0 on success,
301  *               otherwise a negative error value
302  *
303  * @retval #VIDEO_UTIL_ERROR_NONE Successful
304  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
305  * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
306  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
307  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
308  *
309  * @see video_util_create()
310  * @see video_util_destroy()
311  * @see video_util_transcoding_progress_cb()
312  * @see video_util_transcoding_completed_cb()
313  * @see video_util_get_progress_transcoding()
314  * @see video_util_cancel_transcoding()
315  */
316 int video_util_start_transcoding(video_util_h handle, unsigned long start,
317                                                                         unsigned long duration, const char *out_path,
318                                                                         video_util_transcoding_progress_cb progress_cb,
319                                                                         video_util_transcoding_completed_cb completed_cb,
320                                                                         void *user_data) TIZEN_DEPRECATED_API;
321
322 /**
323  * @deprecated Deprecated since 5.0
324  * @brief Cancels transcoding the video for given video util handle.
325  * @since_tizen 2.3
326  *
327  * @details This function cancels the transcoding for given video util handle.\n.
328  *
329  * @remarks If this function is invoked during transcoding, the data transcoded is discard.\n
330  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
331  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
332  *
333  * @param[in] handle The handle to video util
334  *
335  * @return @c 0 on success,
336  *               otherwise a negative error value
337  *
338  * @retval #VIDEO_UTIL_ERROR_NONE Successful
339  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
340  * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
341  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
342  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
343  *
344  * @see video_util_create()
345  * @see video_util_destroy()
346  * @see video_util_start_transcoding()
347  */
348 int video_util_cancel_transcoding(video_util_h handle) TIZEN_DEPRECATED_API;
349
350 /**
351  * @deprecated Deprecated since 5.0
352  * @brief Retrieves the current position and duration of the video transcoding.
353  * @since_tizen 2.3
354
355  *
356  * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
357  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
358  *
359  * @param[in] handle The handle to video util
360  * @param[out] current_position Current position of transcoding
361  * @param[out] duration The duration is in seconds.\n
362  If duration is 0, transcoding happens until end of the video
363  *
364  * @return @c 0 on success,
365  *               otherwise a negative error value
366  * @retval #VIDEO_UTIL_ERROR_NONE Successful
367  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
368  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
369  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
370  *
371  * @pre video_util_start_transcoding().
372  *
373  * @see video_util_create()
374  * @see video_util_destroy()
375  */
376 int video_util_get_progress_transcoding(video_util_h handle,
377                                                                                 unsigned long *current_position,
378                                                                                 unsigned long *duration) TIZEN_DEPRECATED_API;
379
380 /**
381  * @deprecated Deprecated since 5.0
382  * @brief Retrieves all supported media formats by invoking a specific callback for each supported media format.
383  * @since_tizen 2.3
384  *
385  * @remarks The callback invocation depends on the codec.\n
386  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
387  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
388  *
389  * @param[in] handle The handle to video util
390  * @param[in] callback The callback function to invoke
391  * @param[in] user_data The user data to be passed to the callback function
392  *
393  * @return @c 0 on success,
394  *               otherwise a negative error value
395  *
396  * @retval #VIDEO_UTIL_ERROR_NONE Successful
397  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
398  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
399  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
400  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
401  * @post  video_util_supported_file_format_cb() will be invoked.
402  *
403  * @see video_util_set_file_format()
404  * @see video_util_supported_file_format_cb()
405  */
406 int video_util_foreach_supported_file_format(video_util_h handle,
407                                                                                         video_util_supported_file_format_cb callback,
408                                                                                         void *user_data) TIZEN_DEPRECATED_API;
409
410 /**
411  * @deprecated Deprecated since 5.0
412  * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder.
413  * @since_tizen 2.3
414  *
415  * @remarks The callback invocation depends on the file format.\n
416  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
417  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
418  *
419  * @param[in] handle The handle to video util
420  * @param[in] callback The callback function to be invoked
421  * @param[in] user_data The user data to be passed to the callback function
422  *
423  * @return @c 0 on success,
424  *               otherwise a negative error value
425  *
426  * @retval #VIDEO_UTIL_ERROR_NONE Successful
427  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
428  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
429  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
430  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
431  * @post  video_util_supported_video_encoder_cb() will be invoked.
432  * @see video_util_set_video_codec()
433  * @see video_util_supported_video_encoder_cb()
434  */
435 int video_util_foreach_supported_video_codec(video_util_h handle,
436                                                                                         video_util_supported_video_encoder_cb callback,
437                                                                                         void *user_data) TIZEN_DEPRECATED_API;
438
439 /**
440  * @deprecated Deprecated since 5.0
441  * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder.
442  * @since_tizen 2.3
443  *
444  * @remarks The callback invocation depends on the file format.\n
445  *                 http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
446  *                 http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
447  *
448  * @param[in] handle The handle to video util
449  * @param[in] callback The callback function to be invoked
450  * @param[in] user_data The user data to be passed to the callback function
451  *
452  * @return @c 0 on success,
453  *               otherwise a negative error value
454  *
455  * @retval #VIDEO_UTIL_ERROR_NONE Successful
456  * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
457  * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
458  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
459  * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
460  * @post  video_util_supported_audio_encoder_cb() will be invoked.
461  * @see video_util_supported_audio_encoder_cb()
462  */
463 int video_util_foreach_supported_audio_codec(video_util_h handle,
464                                                                                         video_util_supported_audio_encoder_cb callback,
465                                                                                         void *user_data) TIZEN_DEPRECATED_API;
466
467 /**
468  * @}
469  */
470
471 #ifdef __cplusplus
472 }
473 #endif /* __cplusplus */
474
475 #endif /* __TIZEN_MEDIA_VIDEO_UTIL_H__ */