diff options
-rwxr-xr-x | packaging/capi-media-video-util.spec | 4 | ||||
-rwxr-xr-x | src/video_util.c | 18 | ||||
-rw-r--r-- | test/video_util_test.c | 34 |
3 files changed, 40 insertions, 16 deletions
diff --git a/packaging/capi-media-video-util.spec b/packaging/capi-media-video-util.spec index 040565d..c895775 100755 --- a/packaging/capi-media-video-util.spec +++ b/packaging/capi-media-video-util.spec @@ -1,7 +1,7 @@ Name: capi-media-video-util Summary: A Video Utility library in Tizen Native API -Version: 0.1.7 -Release: 6 +Version: 0.1.8 +Release: 0 Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/video_util.c b/src/video_util.c index 2d7b30e..f433983 100755 --- a/src/video_util.c +++ b/src/video_util.c @@ -223,10 +223,11 @@ static video_util_error_e __video_util_error_convert(int error) static void __video_util_transcode_progress_cb(unsigned long current_position, unsigned long duration, void *user_data) { - video_util_cb_s *_util_cb = (video_util_cb_s *)user_data; + video_util_s *_handle = (video_util_s *)user_data; - if ((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL)) - _util_cb->transcode_progress_cb(current_position, duration, _util_cb->user_data); + if ((_handle != NULL) && (_handle->_util_cb != NULL) + && (_handle->_util_cb->transcode_progress_cb != NULL)) + _handle->_util_cb->transcode_progress_cb(current_position, duration, _handle->_util_cb->user_data); return; } @@ -234,14 +235,15 @@ static void __video_util_transcode_progress_cb(unsigned long current_position, u static void __video_util_transcode_completed_cb(int error, void *user_data) { int error_value = VIDEO_UTIL_ERROR_NONE; - video_util_cb_s *_util_cb = (video_util_cb_s *)user_data; + video_util_s *_handle = (video_util_s *)user_data; - if ((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL)) { + if ((_handle != NULL) && (_handle->_util_cb != NULL) + && (_handle->_util_cb->transcode_completed_cb != NULL)) { error_value = __video_util_error_convert(error); - _util_cb->transcode_completed_cb(error_value, _util_cb->user_data); + _handle->_util_cb->transcode_completed_cb(error_value, _handle->_util_cb->user_data); } - UTIL_SAFE_FREE(_util_cb); + UTIL_SAFE_FREE(_handle->_util_cb); return; } @@ -661,7 +663,7 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig else accurate_mode = MM_SEEK_INACCURATE; - 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 *)_handle->_util_cb); + 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 *)_handle); if (ret != MM_ERROR_NONE) { UTIL_SAFE_FREE(_handle->_util_cb); diff --git a/test/video_util_test.c b/test/video_util_test.c index ab6a877..fe170bb 100644 --- a/test/video_util_test.c +++ b/test/video_util_test.c @@ -68,6 +68,9 @@ typedef struct { unsigned long duration; } test_util_s; +test_util_s *_util_s; + + static void display_sub_basic(); void _video_util_start_transcoding(test_util_s *util_s); @@ -144,14 +147,16 @@ void _transcode_completed_cb(video_util_error_e error, void *user_data) test_util_s *_util_s = (test_util_s *)user_data; + if (!_util_s) { + LOGE("completed_cb user data is NULL"); + return; + } + LOGI("transcode_completed_cb============= [%2d / %2d][%d]\n", _util_s->idx, make_video_cnt, error); printf("transcode_completed_cb============= [%2d / %2d][%d]\n", _util_s->idx, make_video_cnt, error); if (_util_s->idx == (make_video_cnt - 1)) { LOGI("End trascoding"); - video_util_destroy(_util_s->video_h); - _util_s->video_h = NULL; - video_h = NULL; return; } @@ -314,10 +319,13 @@ void _interpret_main_menu(char *cmd) if (strncmp(cmd, "a", 1) == 0) { g_menu_state = CURRENT_STATUS_FILENAME; } else if (strncmp(cmd, "s", 1) == 0) { + if (!_util_s) { + _util_s = (test_util_s *)calloc(1, sizeof(test_util_s)); + LOGE("_util_s malloc"); + } - test_util_s *_util_s = (test_util_s *)calloc(1, sizeof(test_util_s)); if (!_util_s) { - g_print("test util calloc failed"); + LOGE("test util calloc failed"); return; } @@ -349,6 +357,19 @@ void _interpret_main_menu(char *cmd) g_menu_state = CURRENT_STATUS_SET_OUTFILENAME; } else if (strncmp(cmd, "q", 1) == 0) { _quit_program(); + } else if (strncmp(cmd, "d", 1) == 0) { + int ret = VIDEO_UTIL_ERROR_NONE; + if (!video_h) { + g_print("video_util handle is NULL, please set format after create"); + return;; + } + ret = video_util_destroy(video_h); + if (ret != VIDEO_UTIL_ERROR_NONE) { + g_print("video_util_cancel_transcoding is failed (%d)", ret); + return; + } + free(_util_s); + _util_s = NULL; } else { g_print("unknown menu \n"); } @@ -627,7 +648,8 @@ static void display_sub_basic() g_print("vf. Set video fps\n"); g_print(" t. Set start/duration time \t"); g_print(" o. Set output filename\t"); - g_print(" q. quite test suite\t"); + g_print(" q. quite test suite\t\n"); + g_print(" d. Destroy\t"); g_print("\n"); g_print("=========================================================================================\n"); } |