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.
18 #ifndef __TIZEN_MEDIA_VIDEO_UTIL_H__
19 #define __TIZEN_MEDIA_VIDEO_UTIL_H__
22 #include <video_util_type.h>
27 #endif /* __cplusplus */
34 * @addtogroup CAPI_MEDIA_VIDEO_UTIL_MODULE
39 * @brief Creates a handle to video util.
42 * @details This function creates a handle to video util.
44 * @remarks You must release the @a video util handle using video_util_destroy().\n
45 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
46 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
48 * @param[out] handle A handle to video util
50 * @return @c 0 on success,
51 * otherwise a negative error value
53 * @retval #VIDEO_UTIL_ERROR_NONE Successful
54 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
55 * @retval #VIDEO_UTIL_ERROR_OUT_OF_MEMORY Out of memory
56 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
57 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
59 * @see video_util_destroy()
62 int video_util_create(video_util_h *handle);
65 * @brief Destroys a handle to video util.
68 * @details The function frees all resources related to the video util handle. The video util
69 * handle no longer can be used to perform any operation. A new video util handle
70 * has to be created before the next usage.
72 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
73 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
75 * @param[in] handle The handle to video util
77 * @return @c 0 on success,
78 * otherwise a negative error value
80 * @retval #VIDEO_UTIL_ERROR_NONE Successful
81 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
82 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
83 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
85 * @see video_util_create()
88 int video_util_destroy(video_util_h handle);
91 * @brief Sets the video util's file path.
94 * @details This function sets the source @a path to transcode.
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.
99 * @param[in] handle The handle to video util
100 * @param[in] path The source file path
102 * @return @c 0 on success,
103 * otherwise a negative error value
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
110 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
112 * @see video_util_create()
113 * @see video_util_destroy()
115 int video_util_set_file_path(video_util_h handle, const char *path);
118 * @brief Sets the video util's accurate mode.
121 * @remarks If you do not set this, the default value is @c false.\n
122 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
123 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
125 * @param[in] handle The handle to video util
126 * @param[in] mode Set @c true if the user can get an accurated frame for given the duration in video_util_start_transcoding(),
127 * otherwise set @c false if user can only get the nearest i-frame
129 * @return @c 0 on success,
130 * otherwise a negative error value
132 * @retval #VIDEO_UTIL_ERROR_NONE Successful
133 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
134 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
135 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
137 * @see video_util_create()
138 * @see video_util_destroy()
140 int video_util_set_accurate_mode(video_util_h handle, bool mode);
143 * @brief Sets the video codec for encoding video stream.
146 * @remarks You can get available list of video codec by using video_util_foreach_supported_video_codec().\n
147 * If you do not set this, the default codec is #VIDEO_UTIL_VIDEO_CODEC_MPEG4.\n
148 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
149 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
151 * @param[in] handle The handle to video util
152 * @param[in] codec The video codec
154 * @return @c 0 on success,
155 * otherwise a negative error value
156 * @retval #VIDEO_UTIL_ERROR_NONE Successful
157 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
158 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
159 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
160 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
162 * @see video_util_create()
163 * @see video_util_destroy()
164 * @see video_util_foreach_supported_video_codec()
166 int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec);
169 * @brief Sets the audio codec for encoding audio stream.
172 * @remarks You can get available list of audio codec by using video_util_foreach_supported_audio_codec().\n
173 * If you do not set this, the default codec is #VIDEO_UTIL_AUDIO_CODEC_AAC.\n
174 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
175 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
177 * @param[in] handle The handle to video util
178 * @param[in] codec The audio codec
180 * @return @c 0 on success,
181 * otherwise a negative error value
183 * @retval #VIDEO_UTIL_ERROR_NONE Successful
184 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
185 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
186 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
187 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
189 * @see video_util_create()
190 * @see video_util_destroy()
191 * @see video_util_foreach_supported_audio_codec()
193 int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec);
196 * @brief Sets the file format for transcoding media stream.
199 * @remarks You can get available list of media formats by using video_util_foreach_supported_file_format().\n
200 * If you do not set this, the default file format is #VIDEO_UTIL_FILE_FORMAT_3GP.\n
201 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
202 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
204 * @param[in] handle The handle to video util
205 * @param[in] format The media file format
207 * @return @c 0 on success,
208 * otherwise a negative error value
210 * @retval #VIDEO_UTIL_ERROR_NONE Successful
211 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
212 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
213 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
215 * @see video_util_create()
216 * @see video_util_destroy()
217 * @see video_util_foreach_supported_file_format()
219 int video_util_set_file_format(video_util_h handle, video_util_file_format_e format);
222 * @brief Sets the resolution(width and height).
225 * @remarks If you do not set, the default resolution is original size.\n
226 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
227 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
229 * @param[in] handle The handle to video util
230 * @param[in] width The media's width \n
231 * If the width is 0, it set original size.(minimum value is 128)
232 * @param[in] height The media's height \n
233 * If the height is 0, it set original size.(minimum value is 96)
235 * @return @c 0 on success,
236 * otherwise a negative error value
238 * @retval #VIDEO_UTIL_ERROR_NONE Successful
239 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
240 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
241 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
243 * @see video_util_create()
244 * @see video_util_destroy()
246 int video_util_set_resolution(video_util_h handle, int width, int height);
249 * @brief Sets the frame rate.
252 * @remarks If fps is set @c 0, the default is original fps from source.\n
253 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
254 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
256 * @param[in] handle The handle to video util
258 * @param[in] fps The frame rate(minimum value is 5, maximum value is 30)
259 * @return @c 0 on success,
260 * otherwise a negative error value
262 * @retval #VIDEO_UTIL_ERROR_NONE Successful
263 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
265 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
267 * @see video_util_create()
268 * @see video_util_destroy()
270 int video_util_set_fps(video_util_h handle, int fps);
273 * @brief Transcodes the video for given video util handle.
276 * @details This function starts the transcoding from start time and for given duration.\n
277 * #video_util_transcoding_progress_cb() function is called during the video transcoding regularly after some interval.\n
278 * #video_util_transcoding_completed_cb() function is called and the transcoded video will be saved at the given output path when transcoding is finished.
280 * @remarks If there already exists same file in file system, then old file will be overwritten.\n
281 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
282 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
284 * @param[in] handle The handle to video util
285 * @param[in] start The start position to transcode
286 * @param[in] duration The duration in seconds \n
287 * if duration is @c 0, transcoding happens until end of the video.
288 * @param[out] out_path The file path to save
289 * @param[in] progress_cb The callback function to be invoked
290 * @param[in] completed_cb The callback function to be invoked
291 * @param[in] user_data The user data to be passed to the callback function
293 * @return @c 0 on success,
294 * otherwise a negative error value
296 * @retval #VIDEO_UTIL_ERROR_NONE Successful
297 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
298 * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
299 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
300 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
302 * @see video_util_create()
303 * @see video_util_destroy()
304 * @see video_util_transcoding_progress_cb()
305 * @see video_util_transcoding_completed_cb()
306 * @see video_util_get_progress_transcoding()
307 * @see video_util_cancel_transcoding()
309 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);
312 * @brief Cancels transcoding the video for given video util handle.
316 * @details This function cancels the transcoding for given video util handle.\n.
318 * @remarks If this function is invoked during transcoding, the data transcoded is discard.\n
319 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
320 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
322 * @param[in] handle The handle to video util
324 * @return @c 0 on success,
325 * otherwise a negative error value
327 * @retval #VIDEO_UTIL_ERROR_NONE Successful
328 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
329 * @retval #VIDEO_UTIL_ERROR_INVALID_OPERATION Invalid operation
330 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
331 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
333 * @see video_util_create()
334 * @see video_util_destroy()
335 * @see video_util_start_transcoding()
337 int video_util_cancel_transcoding(video_util_h handle);
340 * @brief Retreives the current position and duration of the video transcoding.
344 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
345 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
347 * @param[in] handle The handle to video util
348 * @param[out] current_position Current position of transcoding
349 * @param[out] duration The duration is in seconds.\n
350 If duration is 0, transcoding happens until end of the video
352 * @return @c 0 on success,
353 * otherwise a negative error value
354 * @retval #VIDEO_UTIL_ERROR_NONE Successful
355 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
356 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
357 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
359 * @pre video_util_start_transcoding().
361 * @see video_util_create()
362 * @see video_util_destroy()
364 int video_util_get_progress_transcoding(video_util_h handle, unsigned long *current_position, unsigned long *duration);
367 * @brief Retrieves all supported media formats by invoking a specific callback for each supported media format.
370 * @remarks The callback invocation depends on the codec.\n
371 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
372 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
374 * @param[in] handle The handle to video util
375 * @param[in] callback The callback function to invoke
376 * @param[in] user_data The user data to be passed to the callback function
378 * @return @c 0 on success,
379 * otherwise a negative error value
381 * @retval #VIDEO_UTIL_ERROR_NONE Successful
382 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
383 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
384 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
385 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
386 * @post video_util_supported_file_format_cb() will be invoked.
388 * @see video_util_set_file_format()
389 * @see video_util_supported_file_format_cb()
391 int video_util_foreach_supported_file_format(video_util_h handle, video_util_supported_file_format_cb callback, void *user_data);
394 * @brief Retrieves all supported video encoders by invoking a specific callback for each supported video encoder.
397 * @remarks The callback invocation depends on the file format.\n
398 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
399 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
401 * @param[in] handle The handle to video util
402 * @param[in] callback The callback function to be invoked
403 * @param[in] user_data The user data to be passed to the callback function
405 * @return @c 0 on success,
406 * otherwise a negative error value
408 * @retval #VIDEO_UTIL_ERROR_NONE Successful
409 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
410 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
411 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
412 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
413 * @post video_util_supported_video_encoder_cb() will be invoked.
414 * @see video_util_set_video_codec()
415 * @see video_util_supported_video_encoder_cb()
417 int video_util_foreach_supported_video_codec(video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data);
420 * @brief Retrieves all supported audio encoders by invoking a specific callback for each supported audio encoder.
423 * @remarks The callback invocation depends on the file format.\n
424 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
425 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
427 * @param[in] handle The handle to video util
428 * @param[in] callback The callback function to be invoked
429 * @param[in] user_data The user data to be passed to the callback function
431 * @return @c 0 on success,
432 * otherwise a negative error value
434 * @retval #VIDEO_UTIL_ERROR_NONE Successful
435 * @retval #VIDEO_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
436 * @retval #VIDEO_UTIL_ERROR_PERMISSION_DENIED Permission denied
437 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
438 * @retval #VIDEO_UTIL_ERROR_NOT_SUPPORTED Not supported
439 * @post video_util_supported_audio_encoder_cb() will be invoked.
440 * @see video_util_supported_audio_encoder_cb()
442 int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data);
451 #endif /* __cplusplus */
453 #endif /*__TIZEN_MEDIA_VIDEO_UTIL_H__ */