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.
21 #include <mm_transcode.h>
23 #include <video_util.h>
24 #include <video_util_private.h>
30 #define LOG_TAG "CAPI_MEDIA_VIDEO_UTIL"
32 #define UTIL_SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
33 #define UTIL_STRING_VALID(str) \
34 ((str != NULL && strlen(str) > 0) ? true : false)
36 #define VIDEO_UTIL_MINIMUM_WIDTH 128
37 #define VIDEO_UTIL_MINIMUM_HEIGHT 96
38 #define VIDEO_UTIL_MINIMUM_DURATION 1000 /*1 sec*/
39 #define VIDEO_UTIL_MINIMUM_FPS 5
40 #define VIDEO_UTIL_MAXIMUM_FPS 30
42 static int __video_util_create_transcode_handle(video_util_s *handle);
43 static int __video_util_destroy_transcode_handle(video_util_s *handle);
44 static int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy);
45 static bool __video_util_check_video_codec(video_util_video_codec_e video_codec);
46 static bool __video_util_check_audio_codec(video_util_audio_codec_e audio_codec);
47 static bool __video_util_check_file_format(video_util_file_format_e file_format);
48 static bool __video_util_check_resolution(int width, int height);
49 static bool __video_util_check_duration(int duration);
50 static bool __video_util_check_fps(int fps);
51 static video_util_error_e __video_util_error_convert(int error);
52 static void __video_util_transcode_progress_cb(unsigned long current_position, unsigned long duration, void *user_data);
53 static void __video_util_transcode_completed_cb(int error, void *user_data);
54 static bool __video_util_type_callback(int codec_type, void *user_data);
55 static int __video_util_foreach_supported_type(video_util_type_e type, video_util_supported_type_cb callback, void *user_data);
57 static int __video_util_create_transcode_handle(video_util_s *handle)
59 int ret = VIDEO_UTIL_ERROR_NONE;
60 MMHandleType transcode_h = 0;
62 ret = mm_transcode_create(&transcode_h);
63 if(ret != MM_ERROR_NONE)
65 if(ret == MM_ERROR_INVALID_ARGUMENT)
67 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
68 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
72 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
73 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
77 ret = mm_transcode_prepare(transcode_h, handle->input_path, handle->file_format, handle->video_codec, handle->audio_codec);
78 if(ret != MM_ERROR_NONE)
80 if(ret == MM_ERROR_INVALID_ARGUMENT)
82 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
83 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
87 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
88 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
92 handle->transcode_h = transcode_h;
97 //when should make new trandcode handle? input_filepath or file_format or video_codec or audio_codec is modified
98 static int __video_util_destroy_transcode_handle(video_util_s *handle)
100 int ret = VIDEO_UTIL_ERROR_NONE;
102 if(handle->transcode_h)
104 ret = mm_transcode_destroy(handle->transcode_h);
105 LOGI("mm_transcode_destroy [%d]\n", ret);
106 if(ret != MM_ERROR_NONE)
108 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
109 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
113 handle->transcode_h = 0;
118 int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy)
120 int ret = VIDEO_UTIL_ERROR_NONE;
122 if(handle->transcode_h)
124 ret = mm_transcode_is_busy(handle->transcode_h, is_busy);
125 if(ret != MM_ERROR_NONE)
127 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
128 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
139 static bool __video_util_check_video_codec(video_util_video_codec_e video_codec)
141 if((video_codec < 0) || (video_codec > VIDEO_UTIL_VIDEO_CODEC_NONE ))
143 LOGE("invalid video_codec [%d]", video_codec);
150 static bool __video_util_check_audio_codec(video_util_audio_codec_e audio_codec)
152 if((audio_codec < 0) || (audio_codec > VIDEO_UTIL_AUDIO_CODEC_NONE ))
154 LOGE("invalid audio_codec [%d]", audio_codec);
161 static bool __video_util_check_file_format(video_util_file_format_e file_format)
163 if((file_format < 0) || (file_format >= VIDEO_UTIL_FILE_FORMAT_MAX ))
165 LOGE("invalid file_format [%d]", file_format);
172 static bool __video_util_check_resolution(int width, int height)
174 if(((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0))
176 LOGE("invalid width [%d]", width);
180 if(((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0))
182 LOGE("invalid height [%d]", height);
189 static bool __video_util_check_duration(int duration)
191 if(((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0))
193 LOGE("invalid duration [%d]", duration);
200 static bool __video_util_check_fps(int fps)
202 if((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS))
204 LOGE("invalid fps [%d]", fps);
211 static video_util_error_e __video_util_error_convert(int error)
213 LOGI("error [%d]\n", error);
215 if(error == MM_ERROR_NONE)
217 return VIDEO_UTIL_ERROR_NONE;
219 else if(error == MM_ERROR_INVALID_ARGUMENT)
221 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
222 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
226 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
227 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
231 static void __video_util_transcode_progress_cb(unsigned long current_position, unsigned long duration, void *user_data)
233 int error_value = VIDEO_UTIL_ERROR_NONE;
234 video_util_cb_s *_util_cb = (video_util_cb_s *)user_data;
236 if((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL))
238 _util_cb->transcode_progress_cb(current_position, duration, _util_cb->user_data);
244 static void __video_util_transcode_completed_cb(int error, void *user_data)
246 int error_value = VIDEO_UTIL_ERROR_NONE;
247 video_util_cb_s *_util_cb = (video_util_cb_s *)user_data;
249 if((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL))
251 error_value = __video_util_error_convert(error);
252 _util_cb->transcode_completed_cb(error_value, _util_cb->user_data);
255 UTIL_SAFE_FREE(_util_cb);
260 static bool __video_util_type_callback(int codec_type, void *user_data)
262 video_util_type_cb_s *codec_cb = (video_util_type_cb_s *)user_data;
266 if (codec_cb->supported_type_cb) {
267 codec_cb->supported_type_cb(codec_type, codec_cb->user_data);
274 static int __video_util_foreach_supported_type(video_util_type_e type, video_util_supported_type_cb callback, void *user_data)
276 int ret = VIDEO_UTIL_ERROR_NONE;
278 video_util_type_cb_s *codec_cb = (video_util_type_cb_s*)calloc(1, sizeof(video_util_type_cb_s));
279 codec_cb->user_data = user_data;
280 codec_cb->supported_type_cb = (video_util_supported_type_cb)callback;
282 if(type == VIDEO_UTIL_TYPE_FORMAT)
284 ret = mm_transcode_get_supported_container_format((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
286 else if(type == VIDEO_UTIL_TYPE_VIDEO_ENC)
288 ret = mm_transcode_get_supported_video_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
290 else if(type == VIDEO_UTIL_TYPE_AUDIO_ENC)
292 ret = mm_transcode_get_supported_audio_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
296 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
297 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
300 UTIL_SAFE_FREE(codec_cb);
305 int video_util_create(video_util_h *handle)
307 int ret = VIDEO_UTIL_ERROR_NONE;
313 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
314 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
317 video_util_s *_handle = (video_util_s*)calloc(1,sizeof(video_util_s));
320 LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
321 return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
324 _handle->input_path = NULL;
325 _handle->accurate_mode = false;
326 _handle->video_codec = 0;
327 _handle->audio_codec = 0;
328 _handle->file_format = 0;
332 _handle->transcode_h = 0;
334 *handle = (video_util_h)_handle;
341 int video_util_destroy(video_util_h handle)
343 int ret = VIDEO_UTIL_ERROR_NONE;
344 video_util_s *_handle = (video_util_s*)handle;
350 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
351 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
354 ret = __video_util_destroy_transcode_handle(_handle);
356 UTIL_SAFE_FREE(_handle->input_path);
357 UTIL_SAFE_FREE(_handle);
364 int video_util_set_file_path(video_util_h handle, const char *file_path)
366 int ret = VIDEO_UTIL_ERROR_NONE;
367 video_util_s *_handle = (video_util_s*)handle;
368 bool is_busy = false;
370 if((_handle != NULL) && (UTIL_STRING_VALID(file_path)))
372 LOGI("file_path [%s]\n", file_path);
374 if(_handle->input_path != NULL)
376 ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
377 if(ret != VIDEO_UTIL_ERROR_NONE)
382 LOGE("BUSY!! Transcoding is already running.\n");
383 return VIDEO_UTIL_ERROR_BUSY;
387 ret = __video_util_destroy_transcode_handle(_handle);
388 if(ret != VIDEO_UTIL_ERROR_NONE)
391 UTIL_SAFE_FREE(_handle->input_path);
395 _handle->input_path = strdup(file_path);
396 if(_handle->input_path == NULL)
398 LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
399 return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
404 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
405 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
411 int video_util_get_file_path(video_util_h handle, char **file_path)
413 int ret = VIDEO_UTIL_ERROR_NONE;
414 video_util_s *_handle = (video_util_s*)handle;
416 if(_handle && file_path)
418 if(UTIL_STRING_VALID(_handle->input_path))
420 *file_path = strdup(_handle->input_path);
421 if(*file_path == NULL)
423 LOGE("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
424 return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
434 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
435 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
441 int video_util_set_accurate_mode(video_util_h handle, bool accurate_mode)
443 int ret = VIDEO_UTIL_ERROR_NONE;
444 video_util_s *_handle = (video_util_s*)handle;
446 LOGI("accurate_mode [%d]\n", accurate_mode);
450 _handle->accurate_mode= accurate_mode;
454 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
455 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
461 int video_util_get_accurate_mode(video_util_h handle, bool *accurate_mode)
463 int ret = VIDEO_UTIL_ERROR_NONE;
464 video_util_s *_handle = (video_util_s*)handle;
466 if(_handle && accurate_mode)
468 *accurate_mode = _handle->accurate_mode;
472 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
473 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
479 int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e codec)
481 int ret = VIDEO_UTIL_ERROR_NONE;
482 video_util_s *_handle = (video_util_s*)handle;
483 bool is_busy = false;
485 LOGI("video_codec [%d]\n", codec);
487 if((_handle != NULL) && (__video_util_check_video_codec(codec)))
489 ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
490 if(ret != VIDEO_UTIL_ERROR_NONE)
495 LOGE("BUSY!! Transcoding is already running.\n");
496 return VIDEO_UTIL_ERROR_BUSY;
500 ret = __video_util_destroy_transcode_handle(_handle);
501 if(ret != VIDEO_UTIL_ERROR_NONE)
505 _handle->video_codec= codec;
509 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
510 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
516 int video_util_get_video_codec(video_util_h handle, video_util_video_codec_e *codec)
518 int ret = VIDEO_UTIL_ERROR_NONE;
519 video_util_s *_handle = (video_util_s*)handle;
523 *codec = _handle->video_codec;
527 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
528 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
534 int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e codec)
536 int ret = VIDEO_UTIL_ERROR_NONE;
537 video_util_s *_handle = (video_util_s*)handle;
538 bool is_busy = false;
540 LOGI("audio_codec [%d]\n", codec);
542 if((_handle != NULL) && (__video_util_check_audio_codec(codec)))
544 ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
545 if(ret != VIDEO_UTIL_ERROR_NONE)
550 LOGE("BUSY!! Transcoding is already running.\n");
551 return VIDEO_UTIL_ERROR_BUSY;
555 ret = __video_util_destroy_transcode_handle(_handle);
556 if(ret != VIDEO_UTIL_ERROR_NONE)
560 _handle->audio_codec= codec;
564 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
565 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
571 int video_util_get_audio_codec(video_util_h handle, video_util_audio_codec_e *codec)
573 int ret = VIDEO_UTIL_ERROR_NONE;
574 video_util_s *_handle = (video_util_s*)handle;
578 *codec = _handle->audio_codec;
582 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
583 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
589 int video_util_set_file_format(video_util_h handle, video_util_file_format_e format)
591 int ret = VIDEO_UTIL_ERROR_NONE;
592 video_util_s *_handle = (video_util_s*)handle;
593 bool is_busy = false;
595 LOGI("file_format [%d]\n", format);
597 if((_handle != NULL) && (__video_util_check_file_format(format)))
599 ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
600 if(ret != VIDEO_UTIL_ERROR_NONE)
605 LOGE("BUSY!! Transcoding is already running.\n");
606 return VIDEO_UTIL_ERROR_BUSY;
610 ret = __video_util_destroy_transcode_handle(_handle);
611 if(ret != VIDEO_UTIL_ERROR_NONE)
615 _handle->file_format= format;
619 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
620 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
626 int video_util_get_file_format(video_util_h handle, video_util_file_format_e *format)
628 int ret = VIDEO_UTIL_ERROR_NONE;
629 video_util_s *_handle = (video_util_s*)handle;
631 if(_handle && format)
633 *format = _handle->file_format;
637 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
638 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
644 int video_util_set_resolution(video_util_h handle, int width, int height)
646 int ret = VIDEO_UTIL_ERROR_NONE;
647 video_util_s *_handle = (video_util_s*)handle;
649 LOGI("width [%d] height [%d]\n", width, height);
651 if((_handle != NULL) && (__video_util_check_resolution(width, height)))
653 _handle->width= width;
654 _handle->height= height;
658 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
659 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
665 int video_util_get_resolution(video_util_h handle, int *width, int *height)
667 int ret = VIDEO_UTIL_ERROR_NONE;
668 video_util_s *_handle = (video_util_s*)handle;
670 if(_handle && width && height)
672 *width = _handle->width;
673 *height = _handle->height;
677 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
678 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
684 int video_util_set_fps(video_util_h handle, int fps)
686 int ret = VIDEO_UTIL_ERROR_NONE;
687 video_util_s *_handle = (video_util_s*)handle;
689 if(_handle && __video_util_check_fps(fps))
695 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
696 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
702 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)
704 int ret = VIDEO_UTIL_ERROR_NONE;
705 video_util_s *_handle = (video_util_s*)handle;
706 mm_seek_mode_e accurate_mode = MM_SEEK_NUM;
707 bool is_busy = false;
709 LOGI("start [%d] duration [%d]\n", start, duration);
711 if(_handle && (__video_util_check_duration(duration)) && (UTIL_STRING_VALID(_handle->input_path)) && (UTIL_STRING_VALID(out_path)) && completed_cb)
713 if(!_handle->transcode_h)
715 ret = __video_util_create_transcode_handle(_handle);
716 if(ret != MM_ERROR_NONE)
721 if(!_handle->transcode_h)
723 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
724 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
729 ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
730 if(ret != VIDEO_UTIL_ERROR_NONE)
735 LOGE("BUSY!! Transcoding is already running.\n");
736 return VIDEO_UTIL_ERROR_BUSY;
740 LOGI("width [%d] height [%d] fps [%d]v_codec [%d] a_codec [%d] file_format [%d] accurate [%d]\n",
741 _handle->width, _handle->height, _handle->fps, _handle->video_codec, _handle->audio_codec, _handle->file_format, _handle->accurate_mode);
743 video_util_cb_s *_util_cb = (video_util_cb_s*)calloc(1, sizeof(video_util_cb_s));
744 _util_cb->user_data = user_data;
745 _util_cb->transcode_completed_cb = completed_cb;
746 _util_cb->transcode_progress_cb = progress_cb;
748 if(_handle->accurate_mode)
749 accurate_mode = MM_SEEK_ACCURATE;
751 accurate_mode = MM_SEEK_INACCURATE;
753 ret = mm_transcode(_handle->transcode_h, _handle->width, _handle->height, _handle->fps, start, duration, accurate_mode, out_path, (mm_transcode_progress_callback)__video_util_transcode_progress_cb, (mm_transcode_completed_callback)__video_util_transcode_completed_cb, (void *)_util_cb);
755 if(ret != MM_ERROR_NONE)
757 if(ret == MM_ERROR_INVALID_ARGUMENT)
759 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
760 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
764 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
765 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
771 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
772 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
778 int video_util_cancel_transcoding(video_util_h handle)
780 int ret = VIDEO_UTIL_ERROR_NONE;
781 video_util_s *_handle = (video_util_s*)handle;
783 if(_handle && (_handle->transcode_h))
785 ret = mm_transcode_cancel(_handle->transcode_h);
786 if(ret != MM_ERROR_NONE)
788 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
789 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
794 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
795 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
801 int video_util_get_progress_transcoding(video_util_h handle, unsigned long *current_position, unsigned long *duration)
803 int ret = VIDEO_UTIL_ERROR_NONE;
804 video_util_s *_handle = (video_util_s*)handle;
807 if(_handle && current_position && duration)
809 if(_handle->transcode_h)
811 ret = mm_transcode_get_attrs(_handle->transcode_h, (mm_containerformat_e *)&value, (mm_videoencoder_e *)&value, (mm_audioencoder_e *)&value,
812 current_position, duration, (unsigned int *)&value, (unsigned int *)&value);
813 if(ret != MM_ERROR_NONE)
815 LOGE("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
816 return VIDEO_UTIL_ERROR_INVALID_OPERATION;
821 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
822 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
827 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
828 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
834 int video_util_foreach_supported_file_format(video_util_h handle, video_util_supported_file_format_cb callback, void *user_data)
836 int ret = VIDEO_UTIL_ERROR_NONE;
837 video_util_s *_handle = (video_util_s*)handle;
839 if(_handle && callback)
841 ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_FORMAT, (video_util_supported_type_cb)callback, user_data);
845 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
846 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
852 int video_util_foreach_supported_video_codec(video_util_h handle, video_util_supported_video_encoder_cb callback, void *user_data)
854 int ret = VIDEO_UTIL_ERROR_NONE;
855 video_util_s *_handle = (video_util_s*)handle;
857 if(_handle && callback)
859 ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_VIDEO_ENC, (video_util_supported_type_cb)callback, user_data);
863 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
864 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
870 int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data)
872 int ret = VIDEO_UTIL_ERROR_NONE;
873 video_util_s *_handle = (video_util_s*)handle;
875 if(_handle && callback)
877 ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_AUDIO_ENC, (video_util_supported_type_cb)callback, user_data);
881 LOGE("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
882 return VIDEO_UTIL_ERROR_INVALID_PARAMETER;