Apply Tizen coding rule and add doc 62/53862/3 accepted/tizen/mobile/20151213.231953 accepted/tizen/tv/20151213.232011 accepted/tizen/wearable/20151213.232032 submit/tizen/20151211.082143
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Dec 2015 01:38:14 +0000 (10:38 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Dec 2015 04:36:24 +0000 (13:36 +0900)
Change-Id: I78f82fbdef49e08780827d7cf04844ad376bc7d1
Signed-off-by: Gilbok Lee <gilbok.lee@samsung.com>
doc/video_util_doc.h [new file with mode: 0644]
include/video_util.h
include/video_util_private.h
include/video_util_type.h
packaging/capi-media-video-util.spec
src/video_util.c
test/video_util_test.c

diff --git a/doc/video_util_doc.h b/doc/video_util_doc.h
new file mode 100644 (file)
index 0000000..b45e1f4
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_MEDIA_VIDEO_UTIL_DOC_H__
+#define __TIZEN_MEDIA_VIDEO_UTIL_DOC_H__
+
+/**
+ * @file video_util_doc.h
+ * @brief This file contains high level documentation of the Multimedia Service.
+ */
+
+/**
+ * @defgroup CAPI_MEDIA_VIDEO_UTIL_MODULE Video Util
+ * @brief  The @ref CAPI_MEDIA_VIDEO_UTIL_MODULE  APIs provides functions that transcode a media file.
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+ *
+ * @section CAPI_MEDIA_VIDEO_UTIL_MODULE_HEADER Required Header
+ *   \#include <video_util.h>
+ *
+ * @section CAPI_MEDIA_VIDEO_UTIL_MODULE_OVERVIEW Overview
+ *
+ * Video Util API provides support for transcoding of a media file. Codec and the format that the API supported :
+ *- Video : mpge4/h.263/h.264
+ *- Audio : aac/amrnb
+ *- Format : 3gp/mp4/max
+ *
+ * @section CAPI_MEDIA_VIDEO_UTIL_FEATURE Related Features
+ * This API is related with the following features:\n
+ *  - http://tizen.org/feature/multimedia.transcoder\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ *
+ * @subsection CAPI_MEDIA_VIDEO_UTIL_FOREACH_OPERATIONS Foreach Operations
+ * <div><table class="doxtable" >
+ *     <tr>
+ *        <th><b>FOREACH</b></th>
+ *        <th><b>CALLBACK</b></th>
+ *        <th><b>DESCRIPTION</b></th>
+ *     </tr>
+ *     <tr>
+ *        <td>video_util_foreach_supported_file_format()</td>
+ *        <td>video_util_supported_file_format_cb()</td>
+ *        <td>Retrieves the list of supported media format</td>
+ *     </tr>
+ *     <tr>
+ *        <td>video_util_foreach_supported_video_codec()</td>
+ *        <td>video_util_supported_video_encoder_cb()</td>
+ *        <td>Retrieves the list of supported video codec</td>
+ *     </tr>
+ *     <tr>
+ *        <td>video_util_foreach_supported_audio_codec()</td>
+ *        <td>video_util_supported_audio_encoder_cb()</td>
+ *        <td>Retrieves the list of supported audio codec</td>
+ *     </tr>
+ *</table></div>
+ */
+
+#endif // __TIZEN_MEDIA_VIDEO_UTIL_DOC_H__
index 7190d81..64850d9 100755 (executable)
 * limitations under the License.
 */
 
-
 #ifndef __TIZEN_MEDIA_VIDEO_UTIL_H__
 #define __TIZEN_MEDIA_VIDEO_UTIL_H__
 
-
 #include <video_util_type.h>
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -441,7 +438,6 @@ int video_util_foreach_supported_video_codec(video_util_h handle, video_util_sup
  */
 int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_supported_audio_encoder_cb callback, void *user_data);
 
-
 /**
  * @}
  */
@@ -450,4 +446,4 @@ int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_sup
 }
 #endif /* __cplusplus */
 
-#endif /*__TIZEN_MEDIA_VIDEO_UTIL_H__ */
+#endif /* __TIZEN_MEDIA_VIDEO_UTIL_H__ */
index 34910a9..5645029 100755 (executable)
@@ -14,7 +14,6 @@
 * limitations under the License.
 */
 
-
 #ifndef __TIZEN_VIDEO_UTIL_PRIVATE_H__
 #define __TIZEN_VIDEO_UTIL_PRIVATE_H__
 
                        SECURE_LOGI(""fmt"", ##arg);     \
                } while (0)
 
-typedef bool (*video_util_supported_type_cb)(int type, void *user_data);
+typedef bool(*video_util_supported_type_cb)(int type, void *user_data);
 
-typedef struct
-{
+typedef struct {
        void *user_data;
        video_util_transcoding_progress_cb transcode_progress_cb;
        video_util_transcoding_completed_cb transcode_completed_cb;
-}video_util_cb_s;
+} video_util_cb_s;
 
-typedef struct
-{
+typedef struct {
        void *user_data;
        video_util_supported_type_cb supported_type_cb;
-}video_util_type_cb_s;
+} video_util_type_cb_s;
 
-typedef struct
-{
+typedef struct {
        char *input_path;
        bool accurate_mode;
        video_util_video_codec_e video_codec;
@@ -81,13 +77,12 @@ typedef struct
        unsigned long bps;
        MMHandleType transcode_h;
        video_util_cb_s *_util_cb;
-}video_util_s;
+} video_util_s;
 
-typedef enum
-{
-       VIDEO_UTIL_TYPE_FORMAT  = 0,
+typedef enum {
+       VIDEO_UTIL_TYPE_FORMAT = 0,
        VIDEO_UTIL_TYPE_VIDEO_ENC,
        VIDEO_UTIL_TYPE_AUDIO_ENC
-}video_util_type_e;
+} video_util_type_e;
 
 #endif /*__TIZEN_VIDEO_UTIL_PRIVATE_H__*/
index b9af21c..3ee1c8c 100755 (executable)
@@ -14,7 +14,6 @@
 * limitations under the License.
 */
 
-
 #ifndef __TIZEN_MEDIA_VIDEO_UTIL_TYPE_H__
 #define __TIZEN_MEDIA_VIDEO_UTIL_TYPE_H__
 
@@ -44,16 +43,15 @@ extern "C" {
  * @brief Enumeration for errors of a video util.
  * @since_tizen 2.3
  */
-typedef enum
-{
-       VIDEO_UTIL_ERROR_NONE                                   = TIZEN_ERROR_NONE,                             /**< Successful */
-       VIDEO_UTIL_ERROR_INVALID_PARAMETER              = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
-       VIDEO_UTIL_ERROR_OUT_OF_MEMORY                  = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
-       VIDEO_UTIL_ERROR_INVALID_OPERATION                      = TIZEN_ERROR_INVALID_OPERATION,        /**< Invalid operation */
-       VIDEO_UTIL_ERROR_BUSY                                           = TIZEN_ERROR_RESOURCE_BUSY,    /**< Device or resource busy */
-       VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT   = TIZEN_ERROR_VIDEO_UTIL | 0x01,        /**< Not supported format */
-       VIDEO_UTIL_ERROR_PERMISSION_DENIED                      = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied  */
-       VIDEO_UTIL_ERROR_NOT_SUPPORTED                  = TIZEN_ERROR_NOT_SUPPORTED     /**< Not supported */
+typedef enum {
+       VIDEO_UTIL_ERROR_NONE = TIZEN_ERROR_NONE,                                                       /**< Successful */
+       VIDEO_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,             /**< Invalid parameter */
+       VIDEO_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,                             /**< Out of memory */
+       VIDEO_UTIL_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION,                     /**< Invalid operation */
+       VIDEO_UTIL_ERROR_BUSY = TIZEN_ERROR_RESOURCE_BUSY,                                              /**< Device or resource busy */
+       VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT = TIZEN_ERROR_VIDEO_UTIL | 0x01,  /**< Not supported format */
+       VIDEO_UTIL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,                     /**< Permission denied  */
+       VIDEO_UTIL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED              /**< Not supported */
 } video_util_error_e;
 
 /**
@@ -61,39 +59,34 @@ typedef enum
  * @brief Enumeration for video codec.
  * @since_tizen 2.3
  */
-typedef enum
-{
-       VIDEO_UTIL_VIDEO_CODEC_MPEG4 = 0,               /**< MPEG4 */
-       VIDEO_UTIL_VIDEO_CODEC_H263,                    /**< H.263 */
-       VIDEO_UTIL_VIDEO_CODEC_H264,                    /**< H.264 */
-       VIDEO_UTIL_VIDEO_CODEC_NONE                     /**< No transcoding for video */
-
-}video_util_video_codec_e;
+typedef enum {
+       VIDEO_UTIL_VIDEO_CODEC_MPEG4 = 0,       /**< MPEG4 */
+       VIDEO_UTIL_VIDEO_CODEC_H263,            /**< H.263 */
+       VIDEO_UTIL_VIDEO_CODEC_H264,            /**< H.264 */
+       VIDEO_UTIL_VIDEO_CODEC_NONE             /**< No transcoding for video */
+} video_util_video_codec_e;
 
 /**
  * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE
  * @brief Enumeration for audio codec.
  * @since_tizen 2.3
  */
-typedef enum
-{
-       VIDEO_UTIL_AUDIO_CODEC_AAC      = 0,            /**< AAC */
-       VIDEO_UTIL_AUDIO_CODEC_AMRNB,           /**< AMRNB */
-       VIDEO_UTIL_AUDIO_CODEC_NONE                     /**< No transcoding for audio */
-}video_util_audio_codec_e;
-
+typedef enum {
+       VIDEO_UTIL_AUDIO_CODEC_AAC = 0,         /**< AAC */
+       VIDEO_UTIL_AUDIO_CODEC_AMRNB,   /**< AMRNB */
+       VIDEO_UTIL_AUDIO_CODEC_NONE             /**< No transcoding for audio */
+} video_util_audio_codec_e;
 
 /**
  * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE
  * @brief Enumeration for formats of a media.
  * @since_tizen 2.3
  */
-typedef enum
-{
-       VIDEO_UTIL_FILE_FORMAT_3GP      = 0,            /**< 3GP */
-       VIDEO_UTIL_FILE_FORMAT_MP4,                     /**< MP4 */
-       VIDEO_UTIL_FILE_FORMAT_MAX                      /**< MAX */
-}video_util_file_format_e;
+typedef enum {
+       VIDEO_UTIL_FILE_FORMAT_3GP = 0,         /**< 3GP */
+       VIDEO_UTIL_FILE_FORMAT_MP4,             /**< MP4 */
+       VIDEO_UTIL_FILE_FORMAT_MAX              /**< MAX */
+} video_util_file_format_e;
 
 /**
  * @ingroup CAPI_MEDIA_VIDEO_UTIL_MODULE
@@ -175,7 +168,6 @@ typedef bool (*video_util_supported_audio_encoder_cb)(video_util_audio_codec_e c
 
 __attribute__ ((deprecated)) typedef bool (*video_util_progress_transcoding_cb)(video_util_error_e error, unsigned long current_position, unsigned long duration, void *user_data);
 
-
 /**
  * @}
  */
@@ -183,6 +175,4 @@ __attribute__ ((deprecated)) typedef bool (*video_util_progress_transcoding_cb)(
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
-
-
 #endif /*__TIZEN_MEDIA_VIDEO_UTIL_TYPE_H__*/
index 86e2fac..d1e9635 100755 (executable)
@@ -1,11 +1,11 @@
 Name:       capi-media-video-util
 Summary:    A Video Utility library in Tizen Native API
 Version:    0.1.7
-Release:    5
+Release:    6
 Group:      System/Libraries
 License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
-Source1001:    capi-media-video-util.manifest
+Source1001: capi-media-video-util.manifest
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(mm-common)
 BuildRequires:  pkgconfig(mm-transcode)
index 81394d7..e8d453c 100755 (executable)
 
 #define LOG_TAG "CAPI_MEDIA_VIDEO_UTIL"
 
-#define UTIL_SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
-#define UTIL_STRING_VALID(str) \
+#define UTIL_SAFE_FREE(src)    \
+       do {                                    \
+               if (src) {                      \
+                       free(src);              \
+                       src = NULL;             \
+               }                                       \
+       } while (0)
+
+#define UTIL_STRING_VALID(str) \
        ((str != NULL && strlen(str) > 0) ? true : false)
 
 #define VIDEO_UTIL_MINIMUM_WIDTH                       128
 #define VIDEO_UTIL_MINIMUM_HEIGHT              96
-#define VIDEO_UTIL_MINIMUM_DURATION            1000    /*1 sec*/
+#define VIDEO_UTIL_MINIMUM_DURATION            1000    /* 1 sec */
 #define VIDEO_UTIL_MINIMUM_FPS                 5
 #define VIDEO_UTIL_MAXIMUM_FPS                 30
 #define VIDEO_UTIL_MAXIMUM_BPS                 4294967295UL
@@ -61,65 +68,49 @@ static int __video_util_create_transcode_handle(video_util_s *handle)
        MMHandleType transcode_h = 0;
 
        ret = mm_transcode_create(&transcode_h);
-       if(ret != MM_ERROR_NONE)
-       {
-               if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE)
-               {
+       if (ret != MM_ERROR_NONE) {
+               if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
                        video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                        return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
-               } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT)
-               {
+               } else if (ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) {
                        video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
                        return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-               }
-               else
-               {
+               } else {
                        video_util_error("INVALID_OPERATION(0x%08x)", ret);
                        return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                }
        }
 
        ret = mm_transcode_prepare(transcode_h, handle->input_path, handle->file_format, handle->video_codec, handle->audio_codec);
-       if(ret != MM_ERROR_NONE)
-       {
-               if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE)
-               {
+       if (ret != MM_ERROR_NONE) {
+               if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
                        video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                        ret = VIDEO_UTIL_ERROR_INVALID_PARAMETER;
-               } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT)
-               {
+               } else if (ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) {
                        video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
                        return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-               }
-               else
-               {
+               } else {
                        video_util_error("INVALID_OPERATION(0x%08x)", ret);
                        ret = VIDEO_UTIL_ERROR_INVALID_OPERATION;
                }
        }
 
-       if(ret == MM_ERROR_NONE)
-       {
+       if (ret == MM_ERROR_NONE)
                handle->transcode_h = transcode_h;
-       }
        else
-       {
                __video_util_destroy_transcode_handle(handle);
-       }
 
        return ret;
 }
 
-//when should make new trandcode handle? input_filepath or file_format or video_codec or audio_codec is modified
+/* when should make new trandcode handle? input_filepath or file_format or video_codec or audio_codec is modified */
 static int __video_util_destroy_transcode_handle(video_util_s *handle)
 {
        int ret = VIDEO_UTIL_ERROR_NONE;
 
-       if(handle->transcode_h)
-       {
+       if (handle->transcode_h) {
                ret = mm_transcode_destroy(handle->transcode_h);
-               if(ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        video_util_error("INVALID_OPERATION (0x%08x)", ret);
                        return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                }
@@ -130,21 +121,17 @@ static int __video_util_destroy_transcode_handle(video_util_s *handle)
        return ret;
 }
 
-int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy)
+int __video_util_check_transcode_is_busy(video_util_s *handle, bool *is_busy)
 {
        int ret = VIDEO_UTIL_ERROR_NONE;
 
-       if(handle->transcode_h)
-       {
+       if (handle->transcode_h) {
                ret = mm_transcode_is_busy(handle->transcode_h, is_busy);
-               if(ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        video_util_error("INVALID_OPERATION(0x%08x)", ret);
                        return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                }
-       }
-       else
-       {
+       } else {
                *is_busy = false;
        }
 
@@ -153,8 +140,7 @@ int __video_util_check_transcode_is_busy(video_util_s * handle, bool *is_busy)
 
 static bool __video_util_check_video_codec(video_util_video_codec_e video_codec)
 {
-       if((video_codec < 0) || (video_codec > VIDEO_UTIL_VIDEO_CODEC_NONE ))
-       {
+       if ((video_codec < 0) || (video_codec > VIDEO_UTIL_VIDEO_CODEC_NONE)) {
                video_util_error("invalid video_codec [%d]", video_codec);
                return false;
        }
@@ -164,8 +150,7 @@ static bool __video_util_check_video_codec(video_util_video_codec_e video_codec)
 
 static bool __video_util_check_audio_codec(video_util_audio_codec_e audio_codec)
 {
-       if((audio_codec < 0) || (audio_codec > VIDEO_UTIL_AUDIO_CODEC_NONE ))
-       {
+       if ((audio_codec < 0) || (audio_codec > VIDEO_UTIL_AUDIO_CODEC_NONE)) {
                video_util_error("invalid audio_codec [%d]", audio_codec);
                return false;
        }
@@ -175,8 +160,7 @@ static bool __video_util_check_audio_codec(video_util_audio_codec_e audio_codec)
 
 static bool __video_util_check_file_format(video_util_file_format_e file_format)
 {
-       if((file_format < 0) || (file_format >= VIDEO_UTIL_FILE_FORMAT_MAX ))
-       {
+       if ((file_format < 0) || (file_format >= VIDEO_UTIL_FILE_FORMAT_MAX)) {
                video_util_error("invalid file_format [%d]", file_format);
                return false;
        }
@@ -186,14 +170,12 @@ static bool __video_util_check_file_format(video_util_file_format_e file_format)
 
 static bool __video_util_check_resolution(int width, int height)
 {
-       if(((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0))
-       {
+       if (((width > 0) && (width < VIDEO_UTIL_MINIMUM_WIDTH)) || (width < 0)) {
                video_util_error("invalid width [%d]", width);
                return false;
        }
 
-       if(((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0))
-       {
+       if (((height > 0) && (height < VIDEO_UTIL_MINIMUM_HEIGHT)) || (height < 0)) {
                video_util_error("invalid height [%d]", height);
                return false;
        }
@@ -203,8 +185,7 @@ static bool __video_util_check_resolution(int width, int height)
 
 static bool __video_util_check_duration(int duration)
 {
-       if(((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0))
-       {
+       if (((duration > 0) && (duration < VIDEO_UTIL_MINIMUM_DURATION)) || (duration < 0)) {
                video_util_error("invalid duration [%d]", duration);
                return false;
        }
@@ -214,8 +195,7 @@ static bool __video_util_check_duration(int duration)
 
 static bool __video_util_check_fps(int fps)
 {
-       if((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS))
-       {
+       if ((fps < 0) || ((fps > 0) && (fps < VIDEO_UTIL_MINIMUM_FPS)) || (fps > VIDEO_UTIL_MAXIMUM_FPS)) {
                video_util_error("invalid fps [%d]", fps);
                return false;
        }
@@ -225,22 +205,16 @@ static bool __video_util_check_fps(int fps)
 
 static video_util_error_e __video_util_error_convert(int error)
 {
-       if(error == MM_ERROR_NONE)
-       {
+       if (error == MM_ERROR_NONE) {
                video_util_debug("Error None");
                return VIDEO_UTIL_ERROR_NONE;
-       }
-       else if(error == MM_ERROR_TRANSCODE_INVALID_VALUE)
-       {
+       } else if (error == MM_ERROR_TRANSCODE_INVALID_VALUE) {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
-       } else if(error == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT)
-       {
+       } else if (error == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) {
                video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
-                       return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-       }
-       else
-       {
+               return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
+       } else {
                video_util_error("INVALID_OPERATION(0x%08x)", error);
                return VIDEO_UTIL_ERROR_INVALID_OPERATION;
        }
@@ -250,10 +224,8 @@ static void __video_util_transcode_progress_cb(unsigned long current_position, u
 {
        video_util_cb_s *_util_cb = (video_util_cb_s *)user_data;
 
-       if((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL))
-       {
+       if ((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL))
                _util_cb->transcode_progress_cb(current_position, duration, _util_cb->user_data);
-       }
 
        return;
 }
@@ -263,8 +235,7 @@ 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;
 
-       if((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL))
-       {
+       if ((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL)) {
                error_value = __video_util_error_convert(error);
                _util_cb->transcode_completed_cb(error_value, _util_cb->user_data);
        }
@@ -278,11 +249,9 @@ static bool __video_util_type_callback(int codec_type, void *user_data)
 {
        video_util_type_cb_s *codec_cb = (video_util_type_cb_s *)user_data;
 
-       if(codec_cb != NULL)
-       {
-               if (codec_cb->supported_type_cb) {
+       if (codec_cb != NULL) {
+               if (codec_cb->supported_type_cb)
                        codec_cb->supported_type_cb(codec_type, codec_cb->user_data);
-               }
        }
 
        return true;
@@ -292,24 +261,17 @@ static int __video_util_foreach_supported_type(video_util_type_e type, video_uti
 {
        int ret = VIDEO_UTIL_ERROR_NONE;
 
-       video_util_type_cb_s *codec_cb = (video_util_type_cb_s*)calloc(1, sizeof(video_util_type_cb_s));
+       video_util_type_cb_s *codec_cb = (video_util_type_cb_s *)calloc(1, sizeof(video_util_type_cb_s));
        codec_cb->user_data = user_data;
        codec_cb->supported_type_cb = (video_util_supported_type_cb)callback;
 
-       if(type == VIDEO_UTIL_TYPE_FORMAT)
-       {
+       if (type == VIDEO_UTIL_TYPE_FORMAT)
                ret = mm_transcode_get_supported_container_format((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
-       }
-       else if(type == VIDEO_UTIL_TYPE_VIDEO_ENC)
-       {
+       else if (type == VIDEO_UTIL_TYPE_VIDEO_ENC)
                ret = mm_transcode_get_supported_video_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
-       }
-       else if(type == VIDEO_UTIL_TYPE_AUDIO_ENC)
-       {
+       else if (type == VIDEO_UTIL_TYPE_AUDIO_ENC)
                ret = mm_transcode_get_supported_audio_encoder((mm_transcode_support_type_callback)__video_util_type_callback, (void *)codec_cb);
-       }
-       else
-       {
+       else {
                video_util_error("Invalid type (%d)", type);
                ret = VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -334,15 +296,13 @@ int video_util_create(video_util_h *handle)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       if(handle == NULL)
-       {
+       if (handle == NULL) {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       video_util_s *_handle = (video_util_s*)calloc(1,sizeof(video_util_s));
-       if(_handle == NULL)
-       {
+       video_util_s *_handle = (video_util_s *)calloc(1, sizeof(video_util_s));
+       if (_handle == NULL) {
                video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY);
                return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
        }
@@ -378,9 +338,8 @@ int video_util_destroy(video_util_h handle)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle == NULL)
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle == NULL) {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -411,26 +370,21 @@ int video_util_set_file_path(video_util_h handle, const char *file_path)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if((_handle != NULL) && (UTIL_STRING_VALID(file_path)))
-       {
+       _handle = (video_util_s *)handle;
+       if ((_handle != NULL) && (UTIL_STRING_VALID(file_path))) {
                video_util_secure_info("file_path [%s]\n", file_path);
 
-               if(_handle->input_path != NULL)
-               {
+               if (_handle->input_path != NULL) {
                        ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
-                       if(ret != VIDEO_UTIL_ERROR_NONE)
+                       if (ret != VIDEO_UTIL_ERROR_NONE)
                                return ret;
 
-                       if(is_busy)
-                       {
+                       if (is_busy) {
                                video_util_error("BUSY!! Transcoding is already running.\n");
                                return VIDEO_UTIL_ERROR_BUSY;
-                       }
-                       else
-                       {
+                       } else {
                                ret = __video_util_destroy_transcode_handle(_handle);
-                               if(ret != VIDEO_UTIL_ERROR_NONE)
+                               if (ret != VIDEO_UTIL_ERROR_NONE)
                                        return ret;
 
                                UTIL_SAFE_FREE(_handle->input_path);
@@ -438,14 +392,11 @@ int video_util_set_file_path(video_util_h handle, const char *file_path)
                }
 
                _handle->input_path = strdup(file_path);
-               if(_handle->input_path == NULL)
-               {
+               if (_handle->input_path == NULL) {
                        video_util_error("OUT_OF_MEMORY(0x%08x)", VIDEO_UTIL_ERROR_OUT_OF_MEMORY);
                        return VIDEO_UTIL_ERROR_OUT_OF_MEMORY;
                }
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -468,13 +419,10 @@ int video_util_set_accurate_mode(video_util_h handle, bool accurate_mode)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle != NULL)
-       {
-               _handle->accurate_mode= accurate_mode;
-       }
-       else
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle != NULL) {
+               _handle->accurate_mode = accurate_mode;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -498,29 +446,23 @@ int video_util_set_video_codec(video_util_h handle, video_util_video_codec_e cod
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if((_handle != NULL) && (__video_util_check_video_codec(codec)))
-       {
+       _handle = (video_util_s *)handle;
+       if ((_handle != NULL) && (__video_util_check_video_codec(codec))) {
                ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
-               if(ret != VIDEO_UTIL_ERROR_NONE)
+               if (ret != VIDEO_UTIL_ERROR_NONE)
                        return ret;
 
-               if(is_busy)
-               {
+               if (is_busy) {
                        video_util_error("BUSY!! Transcoding is already running.\n");
                        return VIDEO_UTIL_ERROR_BUSY;
-               }
-               else
-               {
+               } else {
                        ret = __video_util_destroy_transcode_handle(_handle);
-                       if(ret != VIDEO_UTIL_ERROR_NONE)
+                       if (ret != VIDEO_UTIL_ERROR_NONE)
                                return ret;
                }
 
-               _handle->video_codec= codec;
-       }
-       else
-       {
+               _handle->video_codec = codec;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -544,29 +486,23 @@ int video_util_set_audio_codec(video_util_h handle, video_util_audio_codec_e cod
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if((_handle != NULL) && (__video_util_check_audio_codec(codec)))
-       {
+       _handle = (video_util_s *)handle;
+       if ((_handle != NULL) && (__video_util_check_audio_codec(codec))) {
                ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
-               if(ret != VIDEO_UTIL_ERROR_NONE)
+               if (ret != VIDEO_UTIL_ERROR_NONE)
                        return ret;
 
-               if(is_busy)
-               {
+               if (is_busy) {
                        video_util_error("BUSY!! Transcoding is already running.\n");
                        return VIDEO_UTIL_ERROR_BUSY;
-               }
-               else
-               {
+               } else {
                        ret = __video_util_destroy_transcode_handle(_handle);
-                       if(ret != VIDEO_UTIL_ERROR_NONE)
+                       if (ret != VIDEO_UTIL_ERROR_NONE)
                                return ret;
                }
 
-               _handle->audio_codec= codec;
-       }
-       else
-       {
+               _handle->audio_codec = codec;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -590,29 +526,23 @@ int video_util_set_file_format(video_util_h handle, video_util_file_format_e for
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if((_handle != NULL) && (__video_util_check_file_format(format)))
-       {
+       _handle = (video_util_s *)handle;
+       if ((_handle != NULL) && (__video_util_check_file_format(format))) {
                ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
-               if(ret != VIDEO_UTIL_ERROR_NONE)
+               if (ret != VIDEO_UTIL_ERROR_NONE)
                        return ret;
 
-               if(is_busy)
-               {
+               if (is_busy) {
                        video_util_error("BUSY!! Transcoding is already running.\n");
                        return VIDEO_UTIL_ERROR_BUSY;
-               }
-               else
-               {
+               } else {
                        ret = __video_util_destroy_transcode_handle(_handle);
-                       if(ret != VIDEO_UTIL_ERROR_NONE)
+                       if (ret != VIDEO_UTIL_ERROR_NONE)
                                return ret;
                }
 
-               _handle->file_format= format;
-       }
-       else
-       {
+               _handle->file_format = format;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -635,14 +565,11 @@ int video_util_set_resolution(video_util_h handle, int width, int height)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if((_handle != NULL) && (__video_util_check_resolution(width, height)))
-       {
-               _handle->width= width;
-               _handle->height= height;
-       }
-       else
-       {
+       _handle = (video_util_s *)handle;
+       if ((_handle != NULL) && (__video_util_check_resolution(width, height))) {
+               _handle->width = width;
+               _handle->height = height;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -665,13 +592,10 @@ int video_util_set_fps(video_util_h handle, int fps)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle && __video_util_check_fps(fps))
-       {
-               _handle->fps= fps;
-       }
-       else
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle && __video_util_check_fps(fps)) {
+               _handle->fps = fps;
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -679,7 +603,7 @@ int video_util_set_fps(video_util_h handle, int fps)
        return ret;
 }
 
-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)
+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)
 {
        int ret = VIDEO_UTIL_ERROR_NONE;
        video_util_s *_handle = NULL;
@@ -696,43 +620,34 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
+       _handle = (video_util_s *)handle;
        video_util_debug("start [%d] duration [%d]\n", start, duration);
 
-       if(_handle && (__video_util_check_duration(duration)) && (UTIL_STRING_VALID(_handle->input_path)) && (UTIL_STRING_VALID(out_path)) && completed_cb)
-       {
-               if(!_handle->transcode_h)
-               {
+       if (_handle && (__video_util_check_duration(duration)) && (UTIL_STRING_VALID(_handle->input_path)) && (UTIL_STRING_VALID(out_path)) && completed_cb) {
+               if (!_handle->transcode_h) {
                        ret = __video_util_create_transcode_handle(_handle);
-                       if(ret != MM_ERROR_NONE)
-                       {
+                       if (ret != MM_ERROR_NONE)
                                return ret;
-                       }
 
-                       if(!_handle->transcode_h)
-                       {
+                       if (!_handle->transcode_h) {
                                video_util_error("INVALID_OPERATION(0x%08x)", VIDEO_UTIL_ERROR_INVALID_OPERATION);
                                return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                        }
-               }
-               else
-               {
+               } else {
                        ret = __video_util_check_transcode_is_busy(_handle, &is_busy);
-                       if(ret != VIDEO_UTIL_ERROR_NONE)
+                       if (ret != VIDEO_UTIL_ERROR_NONE)
                                return ret;
 
-                       if(is_busy)
-                       {
+                       if (is_busy) {
                                video_util_error("BUSY!! Transcoding is already running.\n");
                                return VIDEO_UTIL_ERROR_BUSY;
                        }
                }
 
-               video_util_debug("width [%d] height [%d] fps [%d]v_codec [%d] a_codec [%d] file_format [%d] accurate [%d]\n",
-                       _handle->width, _handle->height, _handle->fps, _handle->video_codec, _handle->audio_codec, _handle->file_format, _handle->accurate_mode);
+               video_util_debug("width [%d] height [%d] fps [%d]v_codec [%d] a_codec [%d] file_format [%d] accurate [%d]\n", _handle->width, _handle->height, _handle->fps, _handle->video_codec, _handle->audio_codec, _handle->file_format, _handle->accurate_mode);
 
-               _handle->_util_cb = (video_util_cb_s*)calloc(1, sizeof(video_util_cb_s));
-               if(!_handle->_util_cb) {
+               _handle->_util_cb = (video_util_cb_s *)calloc(1, sizeof(video_util_cb_s));
+               if (!_handle->_util_cb) {
                        video_util_error("Error _util_cb");
                        return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
                }
@@ -740,35 +655,28 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig
                _handle->_util_cb->transcode_completed_cb = completed_cb;
                _handle->_util_cb->transcode_progress_cb = progress_cb;
 
-               if(_handle->accurate_mode)
+               if (_handle->accurate_mode)
                        accurate_mode = MM_SEEK_ACCURATE;
                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);
 
-               if(ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        UTIL_SAFE_FREE(_handle->_util_cb);
 
-                       if(ret == MM_ERROR_TRANSCODE_INVALID_VALUE)
-                       {
+                       if (ret == MM_ERROR_TRANSCODE_INVALID_VALUE) {
                                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
-                       } else if(ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT)
-                       {
+                       } else if (ret == MM_ERROR_TRANSCODE_NOT_SUPPORT_FORMAT) {
                                video_util_error("NOT_SUPPORTED_FORMAT(0x%08x)", VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT);
                                return VIDEO_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
-                       }
-                       else
-                       {
+                       } else {
                                video_util_error("INVALID_OPERATION(0x%08x)", ret);
                                return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                        }
                }
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -791,18 +699,14 @@ int video_util_cancel_transcoding(video_util_h handle)
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle && (_handle->transcode_h))
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle && (_handle->transcode_h)) {
                ret = mm_transcode_cancel(_handle->transcode_h);
-               if(ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        video_util_error("INVALID_OPERATION(0x%08x)", ret);
                        return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                }
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -829,27 +733,19 @@ int video_util_get_progress_transcoding(video_util_h handle, unsigned long *curr
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle && current_position && duration)
-       {
-               if(_handle->transcode_h)
-               {
-                       ret = mm_transcode_get_attrs(_handle->transcode_h, (mm_containerformat_e *)&value, (mm_videoencoder_e *)&value, (mm_audioencoder_e *)&value,
-                                                                               current_position, duration, (unsigned int *)&value, (unsigned int *)&value);
-                       if(ret != MM_ERROR_NONE)
-                       {
+       _handle = (video_util_s *)handle;
+       if (_handle && current_position && duration) {
+               if (_handle->transcode_h) {
+                       ret = mm_transcode_get_attrs(_handle->transcode_h, (mm_containerformat_e *)&value, (mm_videoencoder_e *)&value, (mm_audioencoder_e *)&value, current_position, duration, (unsigned int *)&value, (unsigned int *)&value);
+                       if (ret != MM_ERROR_NONE) {
                                video_util_error("INVALID_OPERATION(0x%08x)", ret);
                                return VIDEO_UTIL_ERROR_INVALID_OPERATION;
                        }
-               }
-               else
-               {
+               } else {
                        video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                        return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
                }
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -872,13 +768,10 @@ int video_util_foreach_supported_file_format(video_util_h handle, video_util_sup
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle && callback)
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle && callback) {
                ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_FORMAT, (video_util_supported_type_cb)callback, user_data);
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -897,13 +790,10 @@ int video_util_foreach_supported_video_codec(video_util_h handle, video_util_sup
                        return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
                }
        }
-       _handle = (video_util_s*)handle;
-       if(_handle && callback)
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle && callback) {
                ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_VIDEO_ENC, (video_util_supported_type_cb)callback, user_data);
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -926,13 +816,10 @@ int video_util_foreach_supported_audio_codec(video_util_h handle, video_util_sup
                return VIDEO_UTIL_ERROR_NOT_SUPPORTED;
        }
 
-       _handle = (video_util_s*)handle;
-       if(_handle && callback)
-       {
+       _handle = (video_util_s *)handle;
+       if (_handle && callback) {
                ret = __video_util_foreach_supported_type(VIDEO_UTIL_TYPE_AUDIO_ENC, (video_util_supported_type_cb)callback, user_data);
-       }
-       else
-       {
+       } else {
                video_util_error("INVALID_PARAMETER(0x%08x)", VIDEO_UTIL_ERROR_INVALID_PARAMETER);
                return VIDEO_UTIL_ERROR_INVALID_PARAMETER;
        }
index 921d0a3..0470058 100755 (executable)
 #include <glib.h>
 #include <video_util.h>
 
-//#define CANCEL_TEST
+/* #define CANCEL_TEST */
 
-typedef struct
-{
+typedef struct {
        video_util_h video_h;
        int     idx;
        int start_time;
        int duration;
-}test_util_s;
+} test_util_s;
 
 GMainLoop *g_loop = NULL;
 int g_make_video_cnt = 5;
@@ -43,11 +42,10 @@ void test_transcode_completed_cb(video_util_error_e error, void *user_data)
        int start_position = 0;
 
        test_util_s *_util_s = (test_util_s *)user_data;
-       printf("transcode_completed_cb============= [%2d][%d]\n", _util_s->idx, error);
+       g_print("transcode_completed_cb============= [%2d][%d]\n", _util_s->idx, error);
 
-       if(_util_s->idx == (g_make_video_cnt-1))
-       {
-               if(g_loop)
+       if (_util_s->idx == (g_make_video_cnt - 1)) {
+               if (g_loop)
                        g_main_loop_quit(g_loop);
                return;
        }
@@ -61,14 +59,12 @@ void test_transcode_completed_cb(video_util_error_e error, void *user_data)
 
 #ifdef CANCEL_TEST
        int ret = VIDEO_UTIL_ERROR_NONE;
-       if(_util_s->idx == 3)
-       {
-               printf("Try cancel============= [%2d]]\n", _util_s->idx);
+       if (_util_s->idx == 3) {
+               g_print("Try cancel============= [%2d]]\n", _util_s->idx);
                ret = video_util_cancel_transcoding(_util_s->video_h);
-               if(ret != VIDEO_UTIL_ERROR_NONE)
-               {
-                       printf("[%d]error video_util_cancel_transcoding [%d]\n", __LINE__, ret);
-                       if(g_loop)
+               if (ret != VIDEO_UTIL_ERROR_NONE) {
+                       g_print("[%d]error video_util_cancel_transcoding [%d]\n", __LINE__, ret);
+                       if (g_loop)
                                g_main_loop_quit(g_loop);
                        return;
                }
@@ -85,22 +81,23 @@ void test_transcode_progress_cb(unsigned long current_position,  unsigned long d
 {
        test_util_s *_util_s = (test_util_s *)user_data;
 
-       printf("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, current_position, duration);
+       g_print("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, current_position, duration);
 
 #if 0
        unsigned long pos = 0;
        unsigned long dur = 0;
        video_util_get_progress_transcoding(_util_s->video_h, &pos, &dur);
-       printf("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, pos, dur);
+       g_print("transcode_progress_cb-------------- [%2d][%ld][%ld]\n", _util_s->idx, pos, dur);
 #endif
        return;
 }
 
 bool test_transcode_spec_cb(int value, void *user_data)
 {
-       if(user_data != NULL)
-               printf("[%s]-----------", (char*)user_data);
-       printf("[%d] \n", value);
+       if (user_data != NULL)
+               g_print("[%s]-----------", (char*)user_data);
+
+       g_print("[%d] \n", value);
 
        return true;
 }
@@ -109,11 +106,11 @@ bool supported_spec_check(video_util_h handle)
 {
        int ret = 0;
        ret = video_util_foreach_supported_file_format(handle, (video_util_supported_file_format_cb)test_transcode_spec_cb, "format_check");
-       printf("video_util_foreach_supported_file_format [%d]\n", ret);
+       g_print("video_util_foreach_supported_file_format [%d]\n", ret);
        ret = video_util_foreach_supported_video_codec(handle, (video_util_supported_video_encoder_cb)test_transcode_spec_cb, "video_codec_check");
-       printf("video_util_foreach_supported_video_codec [%d]\n", ret);
+       g_print("video_util_foreach_supported_video_codec [%d]\n", ret);
        ret = video_util_foreach_supported_audio_codec(handle, (video_util_supported_audio_encoder_cb)test_transcode_spec_cb, "audio_codec_check");
-       printf("video_util_foreach_supported_audio_codec [%d]\n", ret);
+       g_print("video_util_foreach_supported_audio_codec [%d]\n", ret);
 
        return true;
 }
@@ -126,14 +123,14 @@ static int test_transcode_do(test_util_s *util_s)
        memset(test_output_file_path, 0x00, sizeof(test_output_file_path));
        snprintf(test_output_file_path, sizeof(test_output_file_path), "/opt/usr/media/Videos/transcode_test_%d.mp4", util_s->idx);
 
-       printf("g_start_time[%d] duration[%d] [%s]\n", util_s->start_time, util_s->duration, test_output_file_path);
+       g_print("g_start_time[%d] duration[%d] [%s]\n", util_s->start_time, util_s->duration, test_output_file_path);
 
        ret = video_util_start_transcoding(util_s->video_h, util_s->start_time, util_s->duration, test_output_file_path, test_transcode_progress_cb, test_transcode_completed_cb, util_s);
-       if(ret != VIDEO_UTIL_ERROR_NONE)
-       {
-               printf("[%d]error video_util_start_transcoding [%d]\n", __LINE__, ret);
-               if(g_loop)
+       if (ret != VIDEO_UTIL_ERROR_NONE) {
+               g_print("[%d]error video_util_start_transcoding [%d]\n", __LINE__, ret);
+               if (g_loop)
                        g_main_loop_quit(g_loop);
+
                return ret;
        }
 
@@ -147,17 +144,14 @@ int main(int argc, char *argv[])
        test_util_s *_util_s = NULL;
        int cnt = argc -1;
 
-       if(cnt < 1)
-       {
-               printf("type file path plz. [%d]\n", cnt);
+       if (cnt < 1) {
+               g_print("type file path plz. [%d]\n", cnt);
                return 0;
        }
 
        ret = video_util_create(&video_h);
-       if(ret != VIDEO_UTIL_ERROR_NONE)
-       {
-               printf("[%d]error video_util_create [%d]\n", __LINE__, ret);
-       }
+       if (ret != VIDEO_UTIL_ERROR_NONE)
+               g_print("[%d]error video_util_create [%d]\n", __LINE__, ret);
 
 #if 0
        supported_spec_check(video_h);
@@ -171,16 +165,14 @@ int main(int argc, char *argv[])
        ret = video_util_set_resolution(video_h, 176, 144);
        ret = video_util_set_fps(video_h, 10);
 
-       if(ret != VIDEO_UTIL_ERROR_NONE)
-       {
-               printf("[%d]error video_util_set condition [%d]\n", __LINE__, ret);
+       if (ret != VIDEO_UTIL_ERROR_NONE) {
+               g_print("[%d]error video_util_set condition [%d]\n", __LINE__, ret);
                return 0;
        }
 
-       _util_s = (test_util_s*)calloc(1,sizeof(test_util_s));
-       if(_util_s == NULL)
-       {
-               printf("[%d]error calloc\n", __LINE__);
+       _util_s = (test_util_s *)calloc(1, sizeof(test_util_s));
+       if (_util_s == NULL) {
+               g_print("[%d]error calloc\n", __LINE__);
                return 0;
        }
 
@@ -190,7 +182,7 @@ int main(int argc, char *argv[])
        _util_s->duration = g_duration;
 
        ret = test_transcode_do(_util_s);
-       if(ret != VIDEO_UTIL_ERROR_NONE)
+       if (ret != VIDEO_UTIL_ERROR_NONE)
                goto Exit;
 
        g_loop = g_main_loop_new(NULL, FALSE);
@@ -199,17 +191,14 @@ int main(int argc, char *argv[])
        g_main_loop_unref(g_loop);
 
 Exit:
-       ret = video_util_destroy(video_h);      //destory handle in cb
-       if(ret != VIDEO_UTIL_ERROR_NONE)
-       {
-               printf("[%d]error video_util_destroy [%d]\n", __LINE__, ret);
-       }
+       /* destory handle in cb */
+       ret = video_util_destroy(video_h);
+       if (ret != VIDEO_UTIL_ERROR_NONE)
+               g_print("[%d]error video_util_destroy [%d]\n", __LINE__, ret);
        else
-       {
-               printf("[%d]Success video_util_destroy [%d]\n", __LINE__, ret);
-       }
+               g_print("[%d]Success video_util_destroy [%d]\n", __LINE__, ret);
 
-       if(_util_s != NULL)
+       if (_util_s != NULL)
                free(_util_s);
 
        return 0;