2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_MEDIA_VIDEO_UTIL_H__
18 #define __TIZEN_MEDIA_VIDEO_UTIL_H__
20 #include <video_util_type.h>
24 #endif /* __cplusplus */
31 * @addtogroup CAPI_MEDIA_VIDEO_UTIL_MODULE
36 * @brief Creates a handle to video util.
39 * @details This function creates a handle to video util.
41 * @remarks You must release the @a video util handle using video_util_destroy().\n
42 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
43 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
45 * @param[out] handle A handle to video util
47 * @return @c 0 on success,
48 * otherwise a negative error value
50 * @retval #VIDEO_UTIL_ERROR_NONE Successful
51 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
52 * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory
53 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
54 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
56 * @see video_util_destroy()
59 int video_util_create(video_util_h *handle);
62 * @brief Destroys a handle to video util.
65 * @details The function frees all resources related to the video util handle. The video util
66 * handle no longer can be used to perform any operation. A new video util handle
67 * has to be created before the next usage.
69 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
70 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
72 * @param[in] handle The handle to video util
74 * @return @c 0 on success,
75 * otherwise a negative error value
77 * @retval #VIDEO_UTIL_ERROR_NONE Successful
78 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
79 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
80 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
82 * @see video_util_create()
85 int video_util_destroy(video_util_h handle);
88 * @brief Sets the video util's file path.
91 * @details This function sets the source @a path to transcode.
93 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
94 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
96 * @param[in] handle The handle to video util
97 * @param[in] path The source file path
99 * @return @c 0 on success,
100 * otherwise a negative error value
102 * @retval #VIDEO_UTIL_ERROR_NONE Successful
103 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
104 * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory
105 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
107 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
109 * @see video_util_create()
110 * @see video_util_destroy()
112 int video_util_set_file_path(video_util_h handle, const char *path);
115 * @brief Sets the video util's accurate mode.
118 * @remarks If you do not set this, the default value is @c false.\n
119 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
120 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
122 * @param[in] handle The handle to video util
123 * @param[in] mode Set @c true if the user can get an accurated frame for given the duration in video_util_start_transcoding(),
124 * otherwise set @c false if user can only get the nearest i-frame
126 * @return @c 0 on success,
127 * otherwise a negative error value
129 * @retval #VIDEO_UTIL_ERROR_NONE Successful
130 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
131 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
132 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
134 * @see video_util_create()
135 * @see video_util_destroy()
137 int video_util_set_accurate_mode(video_util_h handle, bool mode);
140 * @brief Sets the video codec for encoding video stream.
143 * @remarks You can get available list of video codec by using video_util_foreach_supported_video_codec().\n
144 * If you do not set this, the default codec is #VIDEO_UTIL_VIDEO_CODEC_MPEG4.\n
145 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
146 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
148 * @param[in] handle The handle to video util
149 * @param[in] codec The video codec
151 * @return @c 0 on success,
152 * otherwise a negative error value
153 * @retval #VIDEO_UTIL_ERROR_NONE Successful
154 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
155 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
156 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
157 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
159 * @see video_util_create()
160 * @see video_util_destroy()
161 * @see video_util_foreach_supported_video_codec()
163 int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec);
166 * @brief Sets the audio codec for encoding audio stream.
169 * @remarks You can get available list of audio codec by using video_util_foreach_supported_audio_codec().\n
170 * If you do not set this, the default codec is #VIDEO_UTIL_AUDIO_CODEC_AAC.\n
171 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
172 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
174 * @param[in] handle The handle to video util
175 * @param[in] codec The audio codec
177 * @return @c 0 on success,
178 * otherwise a negative error value
180 * @retval #VIDEO_UTIL_ERROR_NONE Successful
181 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
182 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
183 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
184 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
186 * @see video_util_create()
187 * @see video_util_destroy()
188 * @see video_util_foreach_supported_audio_codec()
190 int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec);
193 * @brief Sets the file format for transcoding media stream.
196 * @remarks You can get available list of media formats by using video_util_foreach_supported_file_format().\n
197 * If you do not set this, the default file format is #VIDEO_UTIL_FILE_FORMAT_3GP.\n
198 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
199 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
201 * @param[in] handle The handle to video util
202 * @param[in] format The media file format
204 * @return @c 0 on success,
205 * otherwise a negative error value
207 * @retval #VIDEO_UTIL_ERROR_NONE Successful
208 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
209 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
210 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
212 * @see video_util_create()
213 * @see video_util_destroy()
214 * @see video_util_foreach_supported_file_format()
216 int video_util_set_file_format(video_util_h handle, video_util_file_format_e format);
219 * @brief Sets the resolution(width and height).
222 * @remarks If you do not set, the default resolution is original size.\n
223 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
224 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
226 * @param[in] handle The handle to video util
227 * @param[in] width The media's width \n
228 * If the width is 0, it set original size.(minimum value is 128)
229 * @param[in] height The media's height \n
230 * If the height is 0, it set original size.(minimum value is 96)
232 * @return @c 0 on success,
233 * otherwise a negative error value
235 * @retval #VIDEO_UTIL_ERROR_NONE Successful
236 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
237 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
238 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
240 * @see video_util_create()
241 * @see video_util_destroy()
243 int video_util_set_resolution(video_util_h handle, int width, int height);
246 * @brief Sets the frame rate.
249 * @remarks If fps is set @c 0, the default is original fps from source.\n
250 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
251 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
253 * @param[in] handle The handle to video util
255 * @param[in] fps The frame rate(minimum value is 5, maximum value is 30)
256 * @return @c 0 on success,
257 * otherwise a negative error value
259 * @retval #VIDEO_UTIL_ERROR_NONE Successful
260 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
261 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
262 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
264 * @see video_util_create()
265 * @see video_util_destroy()
267 int video_util_set_fps(video_util_h handle, int fps);
270 * @brief Transcodes the video for given video util handle.
273 * @details This function starts the transcoding from start time and for given duration.\n
274 * #video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.\n
275 * #video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished.
277 * @remarks If there already exists same file in file system, then old file will be overwritten.\n
278 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
279 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
281 * @param[in] handle The handle to video util
282 * @param[in] start The start position to transcode
283 * @param[in] duration The duration in seconds \n
284 * if duration is @c 0, transcoding happens until end of the video.
285 * @param[out] out_path The file path to save
286 * @param[in] progress_cb The callback function to be invoked
287 * @param[in] completed_cb The callback function to be invoked
288 * @param[in] user_data The user data to be passed to the callback function
290 * @return @c 0 on success,
291 * otherwise a negative error value
293 * @retval #VIDEO_UTIL_ERROR_NONE Successful
294 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
295 * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
296 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
297 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
299 * @see video_util_create()
300 * @see video_util_destroy()
301 * @see video_util_transcoding_progress_cb()
302 * @see video_util_transcoding_completed_cb()
303 * @see video_util_get_progress_transcoding()
304 * @see video_util_cancel_transcoding()
306 int video_util_start_transcoding(video_util_h handle, unsigned long start, unsigned long duration, const char *out_path, video_util_transcoding_progress_cb progress_cb, video_util_transcoding_completed_cb completed_cb, void *user_data);
309 * @brief Cancels transcoding the video for given video util handle.
313 * @details This function cancels the transcoding for given video util handle.\n.
315 * @remarks If this function is invoked during transcoding, the data transcoded is discard.\n
316 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
317 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
319 * @param[in] handle The handle to video util
321 * @return @c 0 on success,
322 * otherwise a negative error value
324 * @retval #VIDEO_UTIL_ERROR_NONE Successful
325 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
326 * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
327 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
328 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
330 * @see video_util_create()
331 * @see video_util_destroy()
332 * @see video_util_start_transcoding()
334 int video_util_cancel_transcoding(video_util_h handle);
337 * @brief Retreives the current position and duration of the video transcoding.
341 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
342 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
344 * @param[in] handle The handle to video util
345 * @param[out] current_position Current position of transcoding
346 * @param[out] duration The duration is in seconds.\n
347 If duration is 0, transcoding happens until end of the video
349 * @return @c 0 on success,
350 * otherwise a negative error value
351 * @retval #VIDEO_UTIL_ERROR_NONE Successful
352 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
353 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
354 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
356 * @pre video_util_start_transcoding().
358 * @see video_util_create()
359 * @see video_util_destroy()
361 int video_util_get_progress_transcoding(video_util_h handle, unsigned long *current_position, unsigned long *duration);
364 * @brief Retrieves all supported media formats by invoking a specific callback for each supported media format.
367 * @remarks The callback invocation depends on the codec.\n
368 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
369 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
371 * @param[in] handle The handle to video util
372 * @param[in] callback The callback function to invoke
373 * @param[in] user_data The user data to be passed to the callback function
375 * @return @c 0 on success,
376 * otherwise a negative error value
378 * @retval #VIDEO_UTIL_ERROR_NONE Successful
379 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
380 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
381 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
382 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
383 * @post video_util_supported_file_format_cb() will be invoked.
385 * @see video_util_set_file_format()
386 * @see video_util_supported_file_format_cb()
388 int video_util_foreach_supported_file_format(video_util_h handle, video_util_supported_file_format_cb callback, void *user_data);
391 * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder.
394 * @remarks The callback invocation depends on the file format.\n
395 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
396 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
398 * @param[in] handle The handle to video util
399 * @param[in] callback The callback function to be invoked
400 * @param[in] user_data The user data to be passed to the callback function
402 * @return @c 0 on success,
403 * otherwise a negative error value
405 * @retval #VIDEO_UTIL_ERROR_NONE Successful
406 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
407 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
408 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
409 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
410 * @post video_util_supported_video_encoder_cb() will be invoked.
411 * @see video_util_set_video_codec()
412 * @see video_util_supported_video_encoder_cb()
414 int video_util_foreach_supported_video_codec(video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data);
417 * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder.
420 * @remarks The callback invocation depends on the file format.\n
421 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
422 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
424 * @param[in] handle The handle to video util
425 * @param[in] callback The callback function to be invoked
426 * @param[in] user_data The user data to be passed to the callback function
428 * @return @c 0 on success,
429 * otherwise a negative error value
431 * @retval #VIDEO_UTIL_ERROR_NONE Successful
432 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
433 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
434 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
435 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
436 * @post video_util_supported_audio_encoder_cb() will be invoked.
437 * @see video_util_supported_audio_encoder_cb()
439 int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data);
447 #endif /* __cplusplus */
449 #endif /* __TIZEN_MEDIA_VIDEO_UTIL_H__ */