Apply Tizen coding rule and add doc 79/53879/3 accepted/tizen/mobile/20151212.071204 accepted/tizen/tv/20151212.072654 accepted/tizen/wearable/20151212.073300 submit/tizen/20151211.082052
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Dec 2015 04:08:25 +0000 (13:08 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Dec 2015 04:30:52 +0000 (13:30 +0900)
Change-Id: I1312f777266dd8ad3e7ae8a88fb9b5083628227a
Signed-off-by: Gilbok Lee <gilbok.lee@samsung.com>
packaging/libmm-transcode.spec
transcode/mm_transcode.c
transcode/mm_transcode_codec.c
transcode/mm_transcode_pipeline.c
transcode/mm_transcode_seek.c
transcode/test/mm_transcode_testsuite.c

index 35ff3f5..f4afff0 100644 (file)
@@ -1,11 +1,11 @@
 Name:       libmm-transcode
 Summary:    Multimedia Framework Video Transcode Library
 Version:    0.10
-Release:    2
+Release:    4
 Group:      System/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
-Source1001:    libmm-transcode.manifest
+Source1001: libmm-transcode.manifest
 BuildRequires:  pkgconfig(mm-common)
 BuildRequires:  pkgconfig(mm-log)
 BuildRequires:  pkgconfig(mm-fileinfo)
index cbab70c..b979171 100755 (executable)
 #include "mm_transcode.h"
 #include "mm_transcode_internal.h"
 
-int
-mm_transcode_create(MMHandleType* MMHandle)
+int mm_transcode_create(MMHandleType *MMHandle)
 {
        int ret = MM_ERROR_NONE;
        handle_s *handle = NULL;
 
        /* Check argument here */
        if (MMHandle == NULL) {
-               debug_error ("Invalid arguments [tag null]\n");
+               debug_error("Invalid arguments [tag null]\n");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
        /* Init Transcode */
-       gst_init (NULL, NULL);
-       handle = g_new0 (handle_s, 1); /*handle = g_malloc(sizeof(handle_s));*/
+       gst_init(NULL, NULL);
+       /*handle = g_malloc(sizeof(handle_s)); */
+       handle = g_new0(handle_s, 1);
        if (!handle) {
                debug_error("[ERROR] - handle");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_vidp= g_new0 (handle_vidp_plugin_s, 1);
+       handle->decoder_vidp = g_new0(handle_vidp_plugin_s, 1);
        if (!handle->decoder_vidp) {
                debug_error("[ERROR] - handle decoder video process bin");
                goto ERROR5;
        }
 
-       handle->decoder_audp= g_new0 (handle_audp_plugin_s, 1);
+       handle->decoder_audp = g_new0(handle_audp_plugin_s, 1);
        if (!handle->decoder_audp) {
                debug_error("[ERROR] - handle decoder audio process bin");
                goto ERROR4;
        }
 
-       handle->encodebin= g_new0 (handle_encode_s, 1);
+       handle->encodebin = g_new0(handle_encode_s, 1);
        if (!handle->encodebin) {
                debug_error("[ERROR] - handle encodebin");
                goto ERROR3;
        }
 
-       handle->property = g_new0 (handle_property_s, 1);
+       handle->property = g_new0(handle_property_s, 1);
        if (!handle->property) {
                debug_error("[ERROR] - handle property");
                goto ERROR2;
        }
 
-       *MMHandle = (MMHandleType)handle;
+       *MMHandle = (MMHandleType) handle;
 
        if (MMHandle) {
                debug_log("MMHandle: 0x%2x", handle);
@@ -78,21 +78,19 @@ mm_transcode_create(MMHandleType* MMHandle)
        return ret;
 
 ERROR1:
-       TRANSCODE_FREE (handle->property);
+       TRANSCODE_FREE(handle->property);
 ERROR2:
-       TRANSCODE_FREE (handle->encodebin);
+       TRANSCODE_FREE(handle->encodebin);
 ERROR3:
-       TRANSCODE_FREE (handle->decoder_audp);
+       TRANSCODE_FREE(handle->decoder_audp);
 ERROR4:
-       TRANSCODE_FREE (handle->decoder_vidp);
+       TRANSCODE_FREE(handle->decoder_vidp);
 ERROR5:
-       TRANSCODE_FREE (handle);
+       TRANSCODE_FREE(handle);
        return MM_ERROR_TRANSCODE_INTERNAL;
 }
 
-int
-mm_transcode_prepare (MMHandleType MMHandle, const char *in_Filename, mm_containerformat_e containerformat, mm_videoencoder_e videoencoder,
-mm_audioencoder_e audioencoder)
+int mm_transcode_prepare(MMHandleType MMHandle, const char *in_Filename, mm_containerformat_e containerformat, mm_videoencoder_e videoencoder, mm_audioencoder_e audioencoder)
 {
        int ret = MM_ERROR_NONE;
 
@@ -108,7 +106,7 @@ mm_audioencoder_e audioencoder)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if ((in_Filename == NULL) || (strlen (in_Filename) == 0)) {
+       if ((in_Filename == NULL) || (strlen(in_Filename) == 0)) {
                debug_error("Invalid Input file");
                return MM_ERROR_INVALID_ARGUMENT;
        }
@@ -123,7 +121,7 @@ mm_audioencoder_e audioencoder)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       /* set element*/
+       /* set element */
        ret = _mm_transcode_set_handle_element(handle, in_Filename, containerformat, videoencoder, audioencoder);
        if (ret != MM_ERROR_NONE) {
                debug_error("ERROR -Set element");
@@ -131,12 +129,13 @@ mm_audioencoder_e audioencoder)
        }
 
        debug_log("%s == %s", handle->property->sourcefile, in_Filename);
-       if (0 == strlen(handle->property->sourcefile) || 0 == strcmp(handle->property->sourcefile, in_Filename)) { /* protect the case of changing input file during transcoding */
+       /* protect the case of changing input file during transcoding */
+       if (0 == strlen(handle->property->sourcefile) || 0 == strcmp(handle->property->sourcefile, in_Filename)) {
                /* setup */
                ret = _mm_setup_pipeline(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Setup Pipeline");
-               } else{
+               } else {
                        debug_error("ERROR - Setup Pipeline");
                        return ret;
                }
@@ -145,7 +144,7 @@ mm_audioencoder_e audioencoder)
                ret = _mm_transcode_get_stream_info(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Get stream info");
-               } else{
+               } else {
                        debug_error("ERROR - Get stream info");
                        return ret;
                }
@@ -154,7 +153,7 @@ mm_audioencoder_e audioencoder)
                ret = _mm_transcode_create(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Create Pipeline");
-               } else{
+               } else {
                        debug_error("ERROR -Create Pipeline");
                        return ret;
                }
@@ -163,7 +162,7 @@ mm_audioencoder_e audioencoder)
                ret = _mm_transcode_link(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Link pipeline");
-               } else{
+               } else {
                        debug_error("ERROR - Link pipeline");
                        return ret;
                }
@@ -172,7 +171,7 @@ mm_audioencoder_e audioencoder)
                ret = _mm_transcode_param_flush(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Init parameter");
-               } else{
+               } else {
                        debug_error("ERROR - Init parameter");
                        return ret;
                }
@@ -181,15 +180,15 @@ mm_audioencoder_e audioencoder)
                ret = _mm_transcode_thread(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Link pipeline");
-               } else{
+               } else {
                        debug_error("ERROR - Link pipeline");
                        return ret;
                }
 
-               /* Add_watcher Transcode Bus*/
-               GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (handle->pipeline));
-               handle->property->bus_watcher = gst_bus_add_watch (bus, (GstBusFunc)_mm_cb_transcode_bus, handle);
-               gst_object_unref (GST_OBJECT(bus));
+               /* Add_watcher Transcode Bus */
+               GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(handle->pipeline));
+               handle->property->bus_watcher = gst_bus_add_watch(bus, (GstBusFunc)_mm_cb_transcode_bus, handle);
+               gst_object_unref(GST_OBJECT(bus));
                debug_log("Success - gst_object_unref (bus)");
        }
 
@@ -198,12 +197,10 @@ mm_audioencoder_e audioencoder)
        return ret;
 }
 
-int
-mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int resolution_height, unsigned int fps_value, unsigned long start_position,
-       unsigned long duration, mm_seek_mode_e seek_mode, const char *out_Filename, mm_transcode_progress_callback progress_callback, mm_transcode_completed_callback completed_callback, void *user_param)
+int mm_transcode(MMHandleType MMHandle, unsigned int resolution_width, unsigned int resolution_height, unsigned int fps_value, unsigned long start_position, unsigned long duration, mm_seek_mode_e seek_mode, const char *out_Filename, mm_transcode_progress_callback progress_callback, mm_transcode_completed_callback completed_callback, void *user_param)
 {
        int ret = MM_ERROR_NONE;
-       handle_s *handle = (handle_s *) MMHandle;
+       handle_s *handle = (handle_s *)MMHandle;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -225,12 +222,12 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       if (duration < MIN_DURATION && duration !=0) {
+       if (duration < MIN_DURATION && duration != 0) {
                debug_error("The minimum seek duration is 1000 msec ");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       handle->property->progress_cb= progress_callback;
+       handle->property->progress_cb = progress_callback;
        handle->property->progress_cb_param = user_param;
        debug_log("[MMHandle] 0x%2x [progress_cb] 0x%2x [progress_cb_param] 0x%2x", MMHandle, handle->property->progress_cb, handle->property->progress_cb_param);
 
@@ -242,15 +239,15 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                debug_error("[ERROR] - handle property");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
-
-       if (handle->property->_MMHandle == 1) { /* check if prepare is called during transcoding */
-               handle_param_s *param = g_new0 (handle_param_s, 1);
+       /* check if prepare is called during transcoding */
+       if (handle->property->_MMHandle == 1) {
+               handle_param_s *param = g_new0(handle_param_s, 1);
                if (param) {
-                       /*g_value_init (param, G_TYPE_INT);*/
+                       /*g_value_init (param, G_TYPE_INT); */
                        debug_log("[param] 0x%2x", param);
                }
 
-               /* set parameter*/
+               /* set parameter */
                ret = _mm_transcode_set_handle_parameter(param, resolution_width, resolution_height, fps_value, start_position, duration, seek_mode, out_Filename);
                if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Set parameter");
@@ -260,7 +257,7 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                ret = _mm_transcode_preset_capsfilter(handle, resolution_width, resolution_height);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Preset Capsfilter");
-               } else{
+               } else {
                        debug_error("ERROR - Preset Capsfilter");
                        return ret;
                }
@@ -268,18 +265,17 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                handle->property->is_busy = TRUE;
 
                /*push data to handle */
-               g_async_queue_push (handle->property->queue, GINT_TO_POINTER(param));
+               g_async_queue_push(handle->property->queue, GINT_TO_POINTER(param));
        }
 
        return ret;
 }
 
-int
-mm_transcode_is_busy (MMHandleType MMHandle, bool *is_busy)
+int mm_transcode_is_busy(MMHandleType MMHandle, bool *is_busy)
 {
        int ret = MM_ERROR_NONE;
 
-       handle_s *handle = (handle_s *) MMHandle;
+       handle_s *handle = (handle_s *)MMHandle;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -302,11 +298,10 @@ mm_transcode_is_busy (MMHandleType MMHandle, bool *is_busy)
        return ret;
 }
 
-int
-mm_transcode_cancel (MMHandleType MMHandle)
+int mm_transcode_cancel(MMHandleType MMHandle)
 {
        int ret = MM_ERROR_NONE;
-       handle_s *handle = (handle_s *) MMHandle;
+       handle_s *handle = (handle_s *)MMHandle;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -333,10 +328,10 @@ mm_transcode_cancel (MMHandleType MMHandle)
                        debug_error("unlink error");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
-               g_mutex_lock (handle->property->thread_mutex);
+               g_mutex_lock(handle->property->thread_mutex);
                g_cond_signal(handle->property->thread_cond);
                debug_log("===> send completed signal <-cancel");
-               g_mutex_unlock (handle->property->thread_mutex);
+               g_mutex_unlock(handle->property->thread_mutex);
        }
 
        handle->property->is_busy = FALSE;
@@ -344,12 +339,11 @@ mm_transcode_cancel (MMHandleType MMHandle)
        return ret;
 }
 
-int
-mm_transcode_destroy (MMHandleType MMHandle)
+int mm_transcode_destroy(MMHandleType MMHandle)
 {
        int ret = MM_ERROR_NONE;
 
-       handle_s *handle = (handle_s*) MMHandle;
+       handle_s *handle = (handle_s *)MMHandle;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -367,7 +361,7 @@ mm_transcode_destroy (MMHandleType MMHandle)
                ret = mm_transcode_cancel(MMHandle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Cancel Transcode");
-               } else{
+               } else {
                        debug_error("ERROR - Cancel Transcode");
                        return FALSE;
                }
@@ -375,10 +369,10 @@ mm_transcode_destroy (MMHandleType MMHandle)
        /* handle->property->is_busy = FALSE; */
        g_mutex_unlock(handle->property->thread_exit_mutex);
 
-       handle_param_s *param = g_new0 (handle_param_s, 1);
+       handle_param_s *param = g_new0(handle_param_s, 1);
        if (param) {
                debug_log("[Try to Push Last Queue]");
-               g_async_queue_push (handle->property->queue, GINT_TO_POINTER(param));
+               g_async_queue_push(handle->property->queue, GINT_TO_POINTER(param));
        } else {
                debug_error("Fail to create Last Queue");
                return MM_ERROR_INVALID_ARGUMENT;
@@ -395,7 +389,7 @@ mm_transcode_destroy (MMHandleType MMHandle)
        if ((handle->param) && (!handle->param->completed)) {
                g_cond_signal(handle->property->thread_cond);
                debug_log("===> send completed signal <-destroy");
-               g_mutex_unlock (handle->property->thread_mutex);
+               g_mutex_unlock(handle->property->thread_mutex);
                debug_log("unlock destory");
                if (strlen(handle->param->outputfile) > 0) {
                        unlink(handle->param->outputfile);
@@ -406,23 +400,21 @@ mm_transcode_destroy (MMHandleType MMHandle)
        ret = _mm_cleanup_pipeline(handle);
        if (ret == MM_ERROR_NONE) {
                debug_log("Success - CleanUp Pipeline");
-       } else{
+       } else {
                debug_error("ERROR - CleanUp Pipeline");
                return ret;
        }
-       TRANSCODE_FREE (param);
+       TRANSCODE_FREE(param);
        debug_log("[param] free");
 
        return ret;
 }
 
-int
-mm_transcode_get_attrs(MMHandleType MMHandle, mm_containerformat_e *containerformat, mm_videoencoder_e *videoencoder,
-       mm_audioencoder_e *audioencoder, unsigned long *current_pos, unsigned long *duration, unsigned int *resolution_width, unsigned int *resolution_height)
+int mm_transcode_get_attrs(MMHandleType MMHandle, mm_containerformat_e * containerformat, mm_videoencoder_e * videoencoder, mm_audioencoder_e * audioencoder, unsigned long *current_pos, unsigned long *duration, unsigned int *resolution_width, unsigned int *resolution_height)
 {
 
        int ret = MM_ERROR_NONE;
-       handle_s *handle = (handle_s *) MMHandle;
+       handle_s *handle = (handle_s *)MMHandle;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -434,7 +426,7 @@ mm_transcode_get_attrs(MMHandleType MMHandle, mm_containerformat_e *containerfor
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if (!containerformat || !videoencoder ||!audioencoder || !current_pos || !duration || !resolution_width || !resolution_height) {
+       if (!containerformat || !videoencoder || !audioencoder || !current_pos || !duration || !resolution_width || !resolution_height) {
                debug_error("[ERROR] - Invalid argument pointer");
                return MM_ERROR_INVALID_ARGUMENT;
        }
@@ -448,29 +440,25 @@ mm_transcode_get_attrs(MMHandleType MMHandle, mm_containerformat_e *containerfor
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if (handle->property->current_pos > handle->param->duration) {
+       if (handle->property->current_pos > handle->param->duration)
                *current_pos = handle->param->duration;
-       } else {
+       else
                *current_pos = handle->property->current_pos;
-       }
        *duration = handle->property->real_duration;
        *resolution_width = handle->param->resolution_width;
        *resolution_height = handle->param->resolution_height;
 
-       debug_log("containerformat : %d, videoencoder : %d, audioencoder : %d, current_pos : %d, duration : %d, resolution_width : %d, resolution_height : %d",
-               *containerformat, *videoencoder, *audioencoder, *current_pos, *duration, *resolution_width, *resolution_height);
+       debug_log("containerformat : %d, videoencoder : %d, audioencoder : %d, current_pos : %d, duration : %d, resolution_width : %d, resolution_height : %d", *containerformat, *videoencoder, *audioencoder, *current_pos, *duration, *resolution_width, *resolution_height);
 
        return ret;
 }
 
-int
-mm_transcode_get_supported_container_format(mm_transcode_support_type_callback type_callback, void *user_param)
+int mm_transcode_get_supported_container_format(mm_transcode_support_type_callback type_callback, void *user_param)
 {
        int idx = 0;
 
        for (idx = 0; idx < MM_CONTAINER_NUM; idx++) {
-               if (type_callback(idx, user_param) == false)
-               {
+               if (type_callback(idx, user_param) == false) {
                        debug_error("error occured. idx[%d]", idx);
                        break;
                }
@@ -479,14 +467,12 @@ mm_transcode_get_supported_container_format(mm_transcode_support_type_callback t
        return MM_ERROR_NONE;
 }
 
-int
-mm_transcode_get_supported_video_encoder(mm_transcode_support_type_callback type_callback, void *user_param)
+int mm_transcode_get_supported_video_encoder(mm_transcode_support_type_callback type_callback, void *user_param)
 {
        int idx = 0;
 
        for (idx = 0; idx < MM_VIDEOENCODER_H264; idx++) {
-               if (type_callback(idx, user_param) == false)
-               {
+               if (type_callback(idx, user_param) == false) {
                        debug_error("error occured. idx[%d]", idx);
                        break;
                }
@@ -495,14 +481,12 @@ mm_transcode_get_supported_video_encoder(mm_transcode_support_type_callback type
        return MM_ERROR_NONE;
 }
 
-int
-mm_transcode_get_supported_audio_encoder(mm_transcode_support_type_callback type_callback, void *user_param)
+int mm_transcode_get_supported_audio_encoder(mm_transcode_support_type_callback type_callback, void *user_param)
 {
        int idx = 0;
 
        for (idx = 0; idx < MM_AUDIOENCODER_NO_USE; idx++) {
-               if (type_callback(idx, user_param) == false)
-               {
+               if (type_callback(idx, user_param) == false) {
                        debug_error("error occured. idx[%d]", idx);
                        break;
                }
index 4f0b4c2..0aae807 100755 (executable)
@@ -21,8 +21,7 @@
 #include "mm_transcode.h"
 #include "mm_transcode_internal.h"
 
-int
-_mm_encodebin_set_venc_aenc(handle_s *handle)
+int _mm_encodebin_set_venc_aenc(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -59,52 +58,51 @@ _mm_encodebin_set_venc_aenc(handle_s *handle)
        memset(handle->property->venc, 0, ENC_BUFFER_SIZE);
        memset(handle->property->aenc, 0, ENC_BUFFER_SIZE);
 
-       switch(handle->property->containerformat) {
-               case MM_CONTAINER_3GP :
-               case MM_CONTAINER_MP4 :
-                       if (handle->property->videoencoder == MM_VIDEOENCODER_NO_USE && handle->property->audioencoder == MM_AUDIOENCODER_AAC) {
-                               strncpy(handle->property->mux, MUXAAC, ENC_BUFFER_SIZE-1);
-                       } else {
-                               strncpy(handle->property->mux, MUX3GP, ENC_BUFFER_SIZE-1);
-                       }
-                       break;
-               default :
-                       debug_error("error container value");
-                       break;
+       switch (handle->property->containerformat) {
+       case MM_CONTAINER_3GP:
+       case MM_CONTAINER_MP4:
+               if (handle->property->videoencoder == MM_VIDEOENCODER_NO_USE && handle->property->audioencoder == MM_AUDIOENCODER_AAC)
+                       strncpy(handle->property->mux, MUXAAC, ENC_BUFFER_SIZE - 1);
+               else
+                       strncpy(handle->property->mux, MUX3GP, ENC_BUFFER_SIZE - 1);
+               break;
+       default:
+               debug_error("error container value");
+               break;
        }
 
-       switch(handle->property->videoencoder) {
-               case MM_VIDEOENCODER_MPEG4 :
-                       strncpy(handle->property->venc, AVENCMPEG4, ENC_BUFFER_SIZE-1);
-                       debug_log("[FFMPEG] %s", handle->property->venc);
-                       break;
-               case MM_VIDEOENCODER_H263 :
-                       strncpy(handle->property->venc, AVENCH263, ENC_BUFFER_SIZE-1);
-                       debug_log("[FFMPEG] %s", handle->property->venc);
-                       break;
-               case MM_VIDEOENCODER_NO_USE :
-                       debug_log("No VIDEO");
-                       break;
-               default :
-                       debug_error("error videoencoder value");
-                       break;
+       switch (handle->property->videoencoder) {
+       case MM_VIDEOENCODER_MPEG4:
+               strncpy(handle->property->venc, AVENCMPEG4, ENC_BUFFER_SIZE - 1);
+               debug_log("[FFMPEG] %s", handle->property->venc);
+               break;
+       case MM_VIDEOENCODER_H263:
+               strncpy(handle->property->venc, AVENCH263, ENC_BUFFER_SIZE - 1);
+               debug_log("[FFMPEG] %s", handle->property->venc);
+               break;
+       case MM_VIDEOENCODER_NO_USE:
+               debug_log("No VIDEO");
+               break;
+       default:
+               debug_error("error videoencoder value");
+               break;
        }
 
-       switch(handle->property->audioencoder) {
-               case MM_AUDIOENCODER_AAC :
-                       strncpy(handle->property->aenc, AACENC, ENC_BUFFER_SIZE-1);
-                       debug_log("[FFMPEG] %s", handle->property->aenc);
-                       break;
-               case MM_AUDIOENCODER_AMR :
-                       strncpy(handle->property->aenc, AMRENC, ENC_BUFFER_SIZE-1);
-                       debug_log("[FFMPEG] %s", handle->property->aenc);
-                       break;
-               case MM_AUDIOENCODER_NO_USE :
-                       debug_log("No AUDIO");
-                       break;
-               default :
-                       debug_error("error audioencoder value");
-                       break;
+       switch (handle->property->audioencoder) {
+       case MM_AUDIOENCODER_AAC:
+               strncpy(handle->property->aenc, AACENC, ENC_BUFFER_SIZE - 1);
+               debug_log("[FFMPEG] %s", handle->property->aenc);
+               break;
+       case MM_AUDIOENCODER_AMR:
+               strncpy(handle->property->aenc, AMRENC, ENC_BUFFER_SIZE - 1);
+               debug_log("[FFMPEG] %s", handle->property->aenc);
+               break;
+       case MM_AUDIOENCODER_NO_USE:
+               debug_log("No AUDIO");
+               break;
+       default:
+               debug_error("error audioencoder value");
+               break;
        }
        return ret;
 }
index ce2195d..fa2003e 100755 (executable)
@@ -32,18 +32,16 @@ static int _mm_encodebin_set_video_property(handle_s *handle);
 static int _mm_filesrc_pipeline_create(handle_s *handle);
 static int _mm_filesrc_decodebin_link(handle_s *handle);
 
-const gchar*
-_mm_check_media_type(GstCaps *caps)
+const gchar *_mm_check_media_type(GstCaps *caps)
 {
        /* check media type */
-       GstStructure *_str = gst_caps_get_structure (caps, 0);
-       const gchar*mime = gst_structure_get_name(_str);
+       GstStructure *_str = gst_caps_get_structure(caps, 0);
+       const gchar *mime = gst_structure_get_name(_str);
 
        return mime;
 }
 
-int
-_mm_cleanup_encodebin(handle_s *handle)
+int _mm_cleanup_encodebin(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -63,19 +61,19 @@ _mm_cleanup_encodebin(handle_s *handle)
        }
 
        if (handle->encodebin->encvideopad) {
-               gst_object_unref (GST_OBJECT(handle->encodebin->encvideopad));
+               gst_object_unref(GST_OBJECT(handle->encodebin->encvideopad));
                handle->encodebin->encvideopad = NULL;
                debug_log("Success - gst_object_unref (encvideopad)");
        }
 
        if (handle->encodebin->encaudiopad) {
-               gst_object_unref (GST_OBJECT(handle->encodebin->encaudiopad));
+               gst_object_unref(GST_OBJECT(handle->encodebin->encaudiopad));
                handle->encodebin->encaudiopad = NULL;
                debug_log("Success - gst_object_unref (encaudiopad)");
        }
 
        if (handle->property->caps) {
-               gst_caps_unref (handle->property->caps);
+               gst_caps_unref(handle->property->caps);
                handle->property->caps = NULL;
                debug_log("gst_caps_unref");
        }
@@ -83,8 +81,7 @@ _mm_cleanup_encodebin(handle_s *handle)
        return ret;
 }
 
-int
-_mm_cleanup_pipeline(handle_s *handle)
+int _mm_cleanup_pipeline(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -113,7 +110,7 @@ _mm_cleanup_pipeline(handle_s *handle)
        }
 
        /* disconnecting bus watch */
-       if ( handle->property->bus_watcher ) {
+       if (handle->property->bus_watcher) {
                g_source_remove(handle->property->bus_watcher);
                debug_log("g_source_remove");
                handle->property->bus_watcher = 0;
@@ -126,19 +123,19 @@ _mm_cleanup_pipeline(handle_s *handle)
        }
 
        if (handle->property->thread_mutex) {
-               g_mutex_free (handle->property->thread_mutex);
+               g_mutex_free(handle->property->thread_mutex);
                handle->property->thread_mutex = NULL;
                debug_log("Success - free (thread_mutex)");
        }
 
        if (handle->property->thread_cond) {
-               g_cond_free (handle->property->thread_cond);
+               g_cond_free(handle->property->thread_cond);
                handle->property->thread_cond = NULL;
                debug_log("Success - free (thread_cond)");
        }
 
        if (handle->property->thread_exit_mutex) {
-               g_mutex_free (handle->property->thread_exit_mutex);
+               g_mutex_free(handle->property->thread_exit_mutex);
                handle->property->thread_exit_mutex = NULL;
                debug_log("Success - free (thread_exit_mutex)");
        }
@@ -157,38 +154,38 @@ _mm_cleanup_pipeline(handle_s *handle)
        }
 
        if (handle->decoder_vidp->srcdecvideopad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_vidp->srcdecvideopad));
+               gst_object_unref(GST_OBJECT(handle->decoder_vidp->srcdecvideopad));
                handle->decoder_vidp->srcdecvideopad = NULL;
                debug_log("Success - gst_object_unref (srcdecvideopad)");
        }
 
        if (handle->decoder_vidp->sinkdecvideopad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_vidp->sinkdecvideopad));
+               gst_object_unref(GST_OBJECT(handle->decoder_vidp->sinkdecvideopad));
                handle->decoder_vidp->sinkdecvideopad = NULL;
                debug_log("Success - gst_object_unref (sinkdecvideopad)");
        }
 
        /* release audiopad */
        if (handle->decoder_audp->decaudiosinkpad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_audp->decaudiosinkpad));
+               gst_object_unref(GST_OBJECT(handle->decoder_audp->decaudiosinkpad));
                handle->decoder_audp->decaudiosinkpad = NULL;
                debug_log("Success - gst_object_unref (decaudiosinkpad)");
        }
 
        if (handle->decoder_audp->decaudiosrcpad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_audp->decaudiosrcpad));
-               handle->decoder_audp->decaudiosrcpad=NULL;
+               gst_object_unref(GST_OBJECT(handle->decoder_audp->decaudiosrcpad));
+               handle->decoder_audp->decaudiosrcpad = NULL;
                debug_log("Success - gst_object_unref (decaudiosrcpad)");
        }
 
        if (handle->decoder_audp->srcdecaudiopad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_audp->srcdecaudiopad));
+               gst_object_unref(GST_OBJECT(handle->decoder_audp->srcdecaudiopad));
                handle->decoder_audp->srcdecaudiopad = NULL;
                debug_log("Success - gst_object_unref (srcdecaudiopad)");
        }
 
        if (handle->decoder_audp->sinkdecaudiopad) {
-               gst_object_unref (GST_OBJECT(handle->decoder_audp->sinkdecaudiopad));
+               gst_object_unref(GST_OBJECT(handle->decoder_audp->sinkdecaudiopad));
                handle->decoder_audp->sinkdecaudiopad = NULL;
                debug_log("Success - gst_object_unref (sinkdecaudiopad)");
        }
@@ -201,60 +198,60 @@ _mm_cleanup_pipeline(handle_s *handle)
        }
 
        if (handle->property->sink_elements) {
-               g_list_free (handle->property->sink_elements);
+               g_list_free(handle->property->sink_elements);
                handle->property->sink_elements = NULL;
                debug_log("Success - g_list_free (sink_elements)");
        }
 
        if (handle->pipeline) {
-               gst_object_unref (handle->pipeline);
+               gst_object_unref(handle->pipeline);
                handle->pipeline = NULL;
                debug_log("Success - gst_object_unref (pipeline)");
        }
 
        if (handle->property->audio_cb_probe_id) {
-               g_source_remove (handle->property->audio_cb_probe_id);
+               g_source_remove(handle->property->audio_cb_probe_id);
                handle->property->audio_cb_probe_id = 0;
                debug_log("g_source_remove (audio_cb_probe_id)");
        }
 
        if (handle->property->video_cb_probe_id) {
-               g_source_remove (handle->property->video_cb_probe_id);
+               g_source_remove(handle->property->video_cb_probe_id);
                handle->property->video_cb_probe_id = 0;
                debug_log("g_source_remove (video_cb_probe_id)");
        }
 
        if (handle->property->progrss_event_id) {
-               g_source_remove (handle->property->progrss_event_id);
+               g_source_remove(handle->property->progrss_event_id);
                handle->property->progrss_event_id = 0;
                debug_log("g_source_remove (progrss_event_id)");
        }
 
-       if(handle->encodebin->audio_event_probe_id) {
-               g_source_remove (handle->encodebin->audio_event_probe_id);
+       if (handle->encodebin->audio_event_probe_id) {
+               g_source_remove(handle->encodebin->audio_event_probe_id);
                handle->encodebin->audio_event_probe_id = 0;
                debug_log("g_source_remove (audio_event_probe_id)");
        }
 
-       if(handle->encodebin->video_event_probe_id) {
-               g_source_remove (handle->encodebin->video_event_probe_id);
+       if (handle->encodebin->video_event_probe_id) {
+               g_source_remove(handle->encodebin->video_event_probe_id);
                handle->property->video_cb_probe_id = 0;
                debug_log("g_source_remove (video_event_probe_id)");
        }
 
-       TRANSCODE_FREE (handle->property->mux);
-       TRANSCODE_FREE (handle->property->venc);
-       TRANSCODE_FREE (handle->property->aenc);
-       TRANSCODE_FREE (handle->decoder_vidp);
-       TRANSCODE_FREE (handle->decoder_audp);
-       TRANSCODE_FREE (handle->encodebin);
-       TRANSCODE_FREE (handle->property);
-       TRANSCODE_FREE (handle);
+       TRANSCODE_FREE(handle->property->mux);
+       TRANSCODE_FREE(handle->property->venc);
+       TRANSCODE_FREE(handle->property->aenc);
+       TRANSCODE_FREE(handle->decoder_vidp);
+       TRANSCODE_FREE(handle->decoder_audp);
+       TRANSCODE_FREE(handle->encodebin);
+       TRANSCODE_FREE(handle->property);
+       TRANSCODE_FREE(handle);
 
        return ret;
 }
-static void
-_mm_decode_add_sink(handle_s *handle , GstElement* sink_elements)
+
+static void _mm_decode_add_sink(handle_s *handle, GstElement *sink_elements)
 {
 
        if (!handle) {
@@ -267,16 +264,14 @@ _mm_decode_add_sink(handle_s *handle , GstElement* sink_elements)
                return;
        }
 
-       if(sink_elements) {
+       if (sink_elements) {
                handle->property->sink_elements = g_list_append(handle->property->sink_elements, sink_elements);
                debug_log("g_list_append");
        }
 
 }
 
-
-static int
-_mm_decode_audio_output_create(handle_s *handle)
+static int _mm_decode_audio_output_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -295,13 +290,13 @@ _mm_decode_audio_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_audp->decaudiobin = gst_bin_new ("audiobin");
+       handle->decoder_audp->decaudiobin = gst_bin_new("audiobin");
        if (!handle->decoder_audp->decaudiobin) {
                debug_error("decaudiobin could not be created");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_audp->decsinkaudioqueue = gst_element_factory_make("queue","decsinkaudioqueue");
+       handle->decoder_audp->decsinkaudioqueue = gst_element_factory_make("queue", "decsinkaudioqueue");
        if (!handle->decoder_audp->decsinkaudioqueue) {
                debug_error("decsinkaudioqueue could not be created");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -309,7 +304,7 @@ _mm_decode_audio_output_create(handle_s *handle)
 
        _mm_decode_add_sink(handle, handle->decoder_audp->decsinkaudioqueue);
 
-       handle->decoder_audp->decaudiosinkpad = gst_element_get_static_pad (handle->decoder_audp->decsinkaudioqueue, "sink");
+       handle->decoder_audp->decaudiosinkpad = gst_element_get_static_pad(handle->decoder_audp->decsinkaudioqueue, "sink");
        if (!handle->decoder_audp->decaudiosinkpad) {
                debug_error("decaudiosinkpad could not be created");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -318,39 +313,39 @@ _mm_decode_audio_output_create(handle_s *handle)
        if (handle->property->audioencoder == MM_AUDIOENCODER_NO_USE) {
                debug_log("[MM_AUDIOENCODER_NO_USE] fakesink create");
 
-               handle->decoder_audp->audiofakesink = gst_element_factory_make ("fakesink", "audiofakesink");
+               handle->decoder_audp->audiofakesink = gst_element_factory_make("fakesink", "audiofakesink");
                if (!handle->decoder_audp->audiofakesink) {
                        debug_error("fakesink element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
        } else {
-               handle->decoder_audp->aconv = gst_element_factory_make ("audioconvert", "aconv");
+               handle->decoder_audp->aconv = gst_element_factory_make("audioconvert", "aconv");
                if (!handle->decoder_audp->aconv) {
                        debug_error("decaudiobin element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               handle->decoder_audp->valve = gst_element_factory_make ("valve", "valve");
+               handle->decoder_audp->valve = gst_element_factory_make("valve", "valve");
                if (!handle->decoder_audp->valve) {
                        debug_error("decaudiobin element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               g_object_set(handle->decoder_audp->valve,"drop", FALSE, NULL);
+               g_object_set(handle->decoder_audp->valve, "drop", FALSE, NULL);
 
-               handle->decoder_audp->resample = gst_element_factory_make ("audioresample", "audioresample");
+               handle->decoder_audp->resample = gst_element_factory_make("audioresample", "audioresample");
                if (!handle->decoder_audp->resample) {
                        debug_error("decaudiobin element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               handle->decoder_audp->audflt = gst_element_factory_make ("capsfilter", "afilter");
+               handle->decoder_audp->audflt = gst_element_factory_make("capsfilter", "afilter");
                if (!handle->decoder_audp->audflt) {
                        debug_error("audflt element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               handle->decoder_audp->decaudiosrcpad = gst_element_get_static_pad (handle->decoder_audp->audflt, "src");
+               handle->decoder_audp->decaudiosrcpad = gst_element_get_static_pad(handle->decoder_audp->audflt, "src");
                if (!handle->decoder_audp->decaudiosrcpad) {
                        debug_error("decaudiosrcpad element could not be created");
                        return MM_ERROR_TRANSCODE_INTERNAL;
@@ -360,8 +355,7 @@ _mm_decode_audio_output_create(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_decode_audio_output_link(handle_s *handle)
+static int _mm_decode_audio_output_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -383,37 +377,40 @@ _mm_decode_audio_output_link(handle_s *handle)
        if (handle->property->audioencoder == MM_AUDIOENCODER_NO_USE) {
                debug_log("[MM_AUDIOENCODER_NO_USE] fakesink pad create");
 
-               gst_bin_add_many (GST_BIN (handle->decoder_audp->decaudiobin), handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->audiofakesink, NULL);
+               gst_bin_add_many(GST_BIN(handle->decoder_audp->decaudiobin), handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->audiofakesink, NULL);
                if (!gst_element_link_many(handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->audiofakesink, NULL)) {
                        debug_error("[Audio Output Bin] gst_element_link_many failed");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               gst_element_add_pad (handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosink", handle->decoder_audp->decaudiosinkpad));
-               handle->decoder_audp->sinkdecaudiopad = gst_element_get_static_pad (handle->decoder_audp->decaudiobin, "decbin_audiosink"); /* get sink audiopad of decodebin */
+               gst_element_add_pad(handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosink", handle->decoder_audp->decaudiosinkpad));
+               /* get sink audiopad of decodebin */
+               handle->decoder_audp->sinkdecaudiopad = gst_element_get_static_pad(handle->decoder_audp->decaudiobin, "decbin_audiosink");
        } else {
-               gst_bin_add_many (GST_BIN (handle->decoder_audp->decaudiobin), handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->valve, handle->decoder_audp->aconv, handle->decoder_audp->resample, handle->decoder_audp->audflt, NULL);
+               gst_bin_add_many(GST_BIN(handle->decoder_audp->decaudiobin), handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->valve, handle->decoder_audp->aconv, handle->decoder_audp->resample, handle->decoder_audp->audflt, NULL);
                if (!gst_element_link_many(handle->decoder_audp->decsinkaudioqueue, handle->decoder_audp->valve, handle->decoder_audp->aconv, handle->decoder_audp->resample, handle->decoder_audp->audflt, NULL)) {
                        debug_error("[Audio Output Bin] gst_element_link_many failed");
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               gst_element_add_pad (handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosink", handle->decoder_audp->decaudiosinkpad));
-               gst_element_add_pad (handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosrc", handle->decoder_audp->decaudiosrcpad));
+               gst_element_add_pad(handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosink", handle->decoder_audp->decaudiosinkpad));
+               gst_element_add_pad(handle->decoder_audp->decaudiobin, gst_ghost_pad_new("decbin_audiosrc", handle->decoder_audp->decaudiosrcpad));
 
-               handle->decoder_audp->sinkdecaudiopad = gst_element_get_static_pad (handle->decoder_audp->decaudiobin, "decbin_audiosink"); /* get sink audiopad of decodebin */
-               handle->decoder_audp->srcdecaudiopad = gst_element_get_static_pad (handle->decoder_audp->decaudiobin, "decbin_audiosrc"); /* get src audiopad of decodebin */
+               /* get sink audiopad of decodebin */
+               handle->decoder_audp->sinkdecaudiopad = gst_element_get_static_pad(handle->decoder_audp->decaudiobin, "decbin_audiosink");
+               /* get src audiopad of decodebin */
+               handle->decoder_audp->srcdecaudiopad = gst_element_get_static_pad(handle->decoder_audp->decaudiobin, "decbin_audiosrc");
 
-               handle->property->audio_cb_probe_id = gst_pad_add_probe (handle->decoder_audp->sinkdecaudiopad, GST_PAD_PROBE_TYPE_BUFFER, _mm_cb_audio_output_stream_probe, handle, NULL);
-               debug_log("audio_cb_probe_id: %d", handle->property->audio_cb_probe_id); /* must use sinkpad (sinkpad => srcpad) for normal resized video buffer*/
+               handle->property->audio_cb_probe_id = gst_pad_add_probe(handle->decoder_audp->sinkdecaudiopad, GST_PAD_PROBE_TYPE_BUFFER, _mm_cb_audio_output_stream_probe, handle, NULL);
+               /* must use sinkpad (sinkpad => srcpad) for normal resized video buffer */
+               debug_log("audio_cb_probe_id: %d", handle->property->audio_cb_probe_id);
        }
 
-       gst_bin_add (GST_BIN (handle->pipeline), handle->decoder_audp->decaudiobin);
+       gst_bin_add(GST_BIN(handle->pipeline), handle->decoder_audp->decaudiobin);
        return ret;
 }
 
-static int
-_mm_decode_video_output_create(handle_s *handle)
+static int _mm_decode_video_output_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -432,13 +429,13 @@ _mm_decode_video_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_vidp->decvideobin= gst_bin_new("videobin");
+       handle->decoder_vidp->decvideobin = gst_bin_new("videobin");
        if (!handle->decoder_vidp->decvideobin) {
                debug_error("decvideobin could not be created. Exiting");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_vidp->decsinkvideoqueue = gst_element_factory_make("queue","decsinkvideoqueue");
+       handle->decoder_vidp->decsinkvideoqueue = gst_element_factory_make("queue", "decsinkvideoqueue");
        if (!handle->decoder_vidp->decsinkvideoqueue) {
                debug_error("decsinkvideoqueue element could not be created. Exiting");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -446,7 +443,7 @@ _mm_decode_video_output_create(handle_s *handle)
 
        _mm_decode_add_sink(handle, handle->decoder_vidp->decsinkvideoqueue);
 
-       handle->decoder_vidp->decvideosinkpad = gst_element_get_static_pad(handle->decoder_vidp->decsinkvideoqueue,"sink");
+       handle->decoder_vidp->decvideosinkpad = gst_element_get_static_pad(handle->decoder_vidp->decsinkvideoqueue, "sink");
        if (!handle->decoder_vidp->decvideosinkpad) {
                debug_error("decvideosinkpad element could not be created. Exiting");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -458,8 +455,8 @@ _mm_decode_video_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       g_object_set (handle->decoder_vidp->videorate, "average-period", GST_SECOND/2, NULL);
-       g_object_set (handle->decoder_vidp->videorate, "max-rate", 30, NULL);
+       g_object_set(handle->decoder_vidp->videorate, "average-period", GST_SECOND / 2, NULL);
+       g_object_set(handle->decoder_vidp->videorate, "max-rate", 30, NULL);
 
        handle->decoder_vidp->videoscale = gst_element_factory_make("videoscale", "scaler");
        if (!handle->decoder_vidp->videoscale) {
@@ -467,7 +464,7 @@ _mm_decode_video_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
        /* Configure videoscale to use 4-tap scaling for higher quality */
-       g_object_set (handle->decoder_vidp->videoscale, "method", 2, NULL);
+       g_object_set(handle->decoder_vidp->videoscale, "method", 2, NULL);
 
        handle->decoder_vidp->vidflt = gst_element_factory_make("capsfilter", "vfilter");
        if (!handle->decoder_vidp->vidflt) {
@@ -475,7 +472,7 @@ _mm_decode_video_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->decoder_vidp->decvideosrcpad = gst_element_get_static_pad(handle->decoder_vidp->vidflt,"src");
+       handle->decoder_vidp->decvideosrcpad = gst_element_get_static_pad(handle->decoder_vidp->vidflt, "src");
        if (!handle->decoder_vidp->decvideosrcpad) {
                debug_error("decvideosrcpad element could not be created. Exiting");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -484,8 +481,7 @@ _mm_decode_video_output_create(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_decode_video_output_link(handle_s *handle)
+static int _mm_decode_video_output_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -499,7 +495,7 @@ _mm_decode_video_output_link(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       gst_bin_add_many(GST_BIN(handle->decoder_vidp->decvideobin), handle->decoder_vidp->decsinkvideoqueue, handle->decoder_vidp->videoscale,  handle->decoder_vidp->videorate, handle->decoder_vidp->vidflt, NULL);
+       gst_bin_add_many(GST_BIN(handle->decoder_vidp->decvideobin), handle->decoder_vidp->decsinkvideoqueue, handle->decoder_vidp->videoscale, handle->decoder_vidp->videorate, handle->decoder_vidp->vidflt, NULL);
        if (!gst_element_link_many(handle->decoder_vidp->decsinkvideoqueue, handle->decoder_vidp->videoscale, handle->decoder_vidp->videorate, handle->decoder_vidp->vidflt, NULL)) {
                debug_error("[Video Output Bin] gst_element_link_many failed");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -508,37 +504,37 @@ _mm_decode_video_output_link(handle_s *handle)
        gst_element_add_pad(handle->decoder_vidp->decvideobin, gst_ghost_pad_new("decbin_videosink", handle->decoder_vidp->decvideosinkpad));
        gst_element_add_pad(handle->decoder_vidp->decvideobin, gst_ghost_pad_new("decbin_videosrc", handle->decoder_vidp->decvideosrcpad));
 
-       handle->decoder_vidp->sinkdecvideopad = gst_element_get_static_pad(handle->decoder_vidp->decvideobin,"decbin_videosink");
-       handle->decoder_vidp->srcdecvideopad = gst_element_get_static_pad(handle->decoder_vidp->decvideobin,"decbin_videosrc");
+       handle->decoder_vidp->sinkdecvideopad = gst_element_get_static_pad(handle->decoder_vidp->decvideobin, "decbin_videosink");
+       handle->decoder_vidp->srcdecvideopad = gst_element_get_static_pad(handle->decoder_vidp->decvideobin, "decbin_videosrc");
 
-       handle->property->video_cb_probe_id = gst_pad_add_probe (handle->decoder_vidp->sinkdecvideopad, GST_PAD_PROBE_TYPE_BUFFER, _mm_cb_video_output_stream_probe, handle, NULL);
-       debug_log("video_cb_probe_sink_id: %d", handle->property->video_cb_probe_id); /* must use sinkpad (sinkpad => srcpad) */
+       handle->property->video_cb_probe_id = gst_pad_add_probe(handle->decoder_vidp->sinkdecvideopad, GST_PAD_PROBE_TYPE_BUFFER, _mm_cb_video_output_stream_probe, handle, NULL);
+       /* must use sinkpad (sinkpad => srcpad) */
+       debug_log("video_cb_probe_sink_id: %d", handle->property->video_cb_probe_id);
 
        gst_bin_add(GST_BIN(handle->pipeline), handle->decoder_vidp->decvideobin);
 
        return ret;
 }
 
-static int
-_mm_decodebin_pipeline_create(handle_s *handle)
+static int _mm_decodebin_pipeline_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
-       handle->decodebin = gst_element_factory_make ("decodebin", "decoder"); /* autoplug-select is not worked when decodebin */
+       /* autoplug-select is not worked when decodebin */
+       handle->decodebin = gst_element_factory_make("decodebin", "decoder");
 
        if (!handle->decodebin) {
                debug_error("decbin element could not be created. Exiting");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       g_signal_connect (handle->decodebin, "pad-added",G_CALLBACK(_mm_cb_decoder_newpad_encoder), handle);
-       g_signal_connect (handle->decodebin, "autoplug-select", G_CALLBACK(_mm_cb_decode_bin_autoplug_select), handle);
+       g_signal_connect(handle->decodebin, "pad-added", G_CALLBACK(_mm_cb_decoder_newpad_encoder), handle);
+       g_signal_connect(handle->decodebin, "autoplug-select", G_CALLBACK(_mm_cb_decode_bin_autoplug_select), handle);
 
        return ret;
 }
 
-int
-_mm_decodesrcbin_create(handle_s *handle)
+int _mm_decodesrcbin_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -565,7 +561,7 @@ _mm_decodesrcbin_create(handle_s *handle)
        ret = _mm_filesrc_pipeline_create(handle);
        if (ret == MM_ERROR_NONE) {
                debug_log("Success - Create filesrc pipeline");
-       } else{
+       } else {
                debug_error("ERROR -Create filesrc pipeline");
                return ret;
        }
@@ -573,8 +569,8 @@ _mm_decodesrcbin_create(handle_s *handle)
        if (handle->property->has_audio_stream) {
                ret = _mm_decode_audio_output_create(handle);
                if (ret == MM_ERROR_NONE) {
-                       debug_log("Success - Create audiobin pipeline: 0x%2x",handle->decoder_audp->decaudiobin);
-               } else{
+                       debug_log("Success - Create audiobin pipeline: 0x%2x", handle->decoder_audp->decaudiobin);
+               } else {
                        debug_error("ERROR - Create audiobin pipeline");
                        return ret;
                }
@@ -583,8 +579,8 @@ _mm_decodesrcbin_create(handle_s *handle)
        if (handle->property->has_video_stream) {
                ret = _mm_decode_video_output_create(handle);
                if (ret == MM_ERROR_NONE) {
-                       debug_log("Success - Create videobin pipeline: 0x%2x",handle->decoder_vidp->decvideobin);
-               } else{
+                       debug_log("Success - Create videobin pipeline: 0x%2x", handle->decoder_vidp->decvideobin);
+               } else {
                        debug_error("ERROR -Create videobin pipeline");
                        return ret;
                }
@@ -593,7 +589,7 @@ _mm_decodesrcbin_create(handle_s *handle)
        ret = _mm_decodebin_pipeline_create(handle);
        if (ret == MM_ERROR_NONE) {
                debug_log("Success - Create decodebin pipeline");
-       } else{
+       } else {
                debug_error("ERROR - Create decodebin pipeline");
                return ret;
        }
@@ -601,8 +597,7 @@ _mm_decodesrcbin_create(handle_s *handle)
        return ret;
 }
 
-int
-_mm_decodesrcbin_link(handle_s *handle)
+int _mm_decodesrcbin_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -616,10 +611,10 @@ _mm_decodesrcbin_link(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       ret=_mm_filesrc_decodebin_link(handle);
+       ret = _mm_filesrc_decodebin_link(handle);
        if (ret == MM_ERROR_NONE) {
                debug_log("Success - _mm_filesrc_decodebin_link");
-       } else{
+       } else {
                debug_error("ERROR - _mm_filesrc_decodebin_link");
                return ret;
        }
@@ -628,17 +623,17 @@ _mm_decodesrcbin_link(handle_s *handle)
                ret = _mm_decode_audio_output_link(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - _mm_decode_audio_output_link");
-               } else{
+               } else {
                        debug_error("ERROR - _mm_decode_audio_output_link");
                        return ret;
                }
        }
 
        if (handle->property->has_video_stream) {
-               ret=_mm_decode_video_output_link(handle);
+               ret = _mm_decode_video_output_link(handle);
                if (ret == MM_ERROR_NONE) {
                        debug_log("Success - _mm_decode_video_output_link");
-               } else{
+               } else {
                        debug_error("ERROR - _mm_decode_video_output_link");
                        return ret;
                }
@@ -647,8 +642,7 @@ _mm_decodesrcbin_link(handle_s *handle)
        return ret;
 }
 
-int
-_mm_encodebin_create(handle_s *handle)
+int _mm_encodebin_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -667,9 +661,9 @@ _mm_encodebin_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       handle->encodebin->encbin = gst_element_factory_make ("encodebin", "encodebin");
+       handle->encodebin->encbin = gst_element_factory_make("encodebin", "encodebin");
 
-       if (!handle->encodebin->encbin ) {
+       if (!handle->encodebin->encbin) {
                debug_error("encbin element could not be created");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
@@ -712,8 +706,7 @@ _mm_encodebin_create(handle_s *handle)
        return ret;
 }
 
-int
-_mm_encodebin_link(handle_s *handle)
+int _mm_encodebin_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -741,10 +734,7 @@ _mm_encodebin_link(handle_s *handle)
                        if (handle->encodebin->encvideopad) {
                                debug_log("encvideopad: 0x%2x", handle->encodebin->encvideopad);
                                gst_pad_link(handle->decoder_vidp->srcdecvideopad, handle->encodebin->encvideopad);
-                               handle->encodebin->audio_event_probe_id =
-                                       gst_pad_add_probe (handle->encodebin->encvideopad,
-                                       GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
-                                       _mm_cb_encodebin_sinkpad_event_probe, handle, NULL);
+                               handle->encodebin->audio_event_probe_id = gst_pad_add_probe(handle->encodebin->encvideopad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, _mm_cb_encodebin_sinkpad_event_probe, handle, NULL);
                        } else {
                                debug_error("error encvideopad");
                                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -758,10 +748,7 @@ _mm_encodebin_link(handle_s *handle)
                        if (handle->encodebin->encaudiopad) {
                                debug_log("encaudiopad: 0x%2x", handle->encodebin->encaudiopad);
                                gst_pad_link(handle->decoder_audp->srcdecaudiopad, handle->encodebin->encaudiopad);
-                               handle->encodebin->audio_event_probe_id =
-                                       gst_pad_add_probe (handle->encodebin->encaudiopad,
-                                       GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
-                                       _mm_cb_encodebin_sinkpad_event_probe, handle, NULL);
+                               handle->encodebin->audio_event_probe_id = gst_pad_add_probe(handle->encodebin->encaudiopad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, _mm_cb_encodebin_sinkpad_event_probe, handle, NULL);
                        } else {
                                debug_error("error encaudiopad");
                                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -772,8 +759,7 @@ _mm_encodebin_link(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_encodebin_set_audio_property(handle_s* handle)
+static int _mm_encodebin_set_audio_property(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -812,15 +798,14 @@ _mm_encodebin_set_audio_property(handle_s* handle)
 
                if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), AENC)) {
                        g_object_set(G_OBJECT(handle->encodebin->encbin), AENC, handle->property->aenc, NULL);
-                       debug_log("[AUDIOENCODER] encbin set [%s: %s]",AENC, handle->property->aenc);
+                       debug_log("[AUDIOENCODER] encbin set [%s: %s]", AENC, handle->property->aenc);
                } else {
-                       debug_error("error [AUDIOENCODER] encbin set [%s: %s]",AENC, handle->property->aenc);
+                       debug_error("error [AUDIOENCODER] encbin set [%s: %s]", AENC, handle->property->aenc);
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               if (g_strcmp0(handle->property->aenc, AACENC) == 0) {
+               if (g_strcmp0(handle->property->aenc, AACENC) == 0)
                        g_object_set(G_OBJECT(gst_bin_get_by_name(GST_BIN(handle->encodebin->encbin), "audio_encode")), AACCOMPLIANCE, AACCOMPLIANCELEVEL, NULL);
-               }
 
                g_object_get(G_OBJECT(handle->encodebin->encbin), "use-aenc-queue", &(handle->encodebin->aencqueue), NULL);
                debug_log("aencqueue : %s", GST_ELEMENT_NAME(handle->encodebin->aencqueue));
@@ -829,8 +814,7 @@ _mm_encodebin_set_audio_property(handle_s* handle)
        return ret;
 }
 
-static int
-_mm_encodebin_set_property(handle_s *handle)
+static int _mm_encodebin_set_property(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -868,8 +852,7 @@ _mm_encodebin_set_property(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_encodebin_set_video_property(handle_s *handle)
+static int _mm_encodebin_set_video_property(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -913,8 +896,7 @@ _mm_encodebin_set_video_property(handle_s *handle)
        return ret;
 }
 
-int
-_mm_filesink_create(handle_s *handle)
+int _mm_filesink_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -923,7 +905,7 @@ _mm_filesink_create(handle_s *handle)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       handle->filesink = gst_element_factory_make ("filesink", "filesink");
+       handle->filesink = gst_element_factory_make("filesink", "filesink");
 
        if (!handle->filesink) {
                debug_error("filesink element could not be created");
@@ -931,14 +913,13 @@ _mm_filesink_create(handle_s *handle)
        }
 
        debug_log("[sync]");
-       g_object_set (G_OBJECT (handle->filesink), "sync", TRUE, NULL);
-       g_object_set (G_OBJECT (handle->filesink), "async", FALSE, NULL);
+       g_object_set(G_OBJECT(handle->filesink), "sync", TRUE, NULL);
+       g_object_set(G_OBJECT(handle->filesink), "async", FALSE, NULL);
 
        return ret;
 }
 
-int
-_mm_filesink_link(handle_s *handle)
+int _mm_filesink_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -966,12 +947,11 @@ _mm_filesink_link(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_filesrc_pipeline_create(handle_s *handle)
+static int _mm_filesrc_pipeline_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
-       handle->filesrc = gst_element_factory_make ("filesrc", "source");
+       handle->filesrc = gst_element_factory_make("filesrc", "source");
 
        if (!handle->filesrc) {
                debug_error("filesrc element could not be created. Exiting");
@@ -984,13 +964,12 @@ _mm_filesrc_pipeline_create(handle_s *handle)
        }
 
        debug_log("sourcefile: %s", handle->property->sourcefile);
-       g_object_set (G_OBJECT (handle->filesrc), "location", handle->property->sourcefile, NULL);
+       g_object_set(G_OBJECT(handle->filesrc), "location", handle->property->sourcefile, NULL);
 
        return ret;
 }
 
-static int
-_mm_filesrc_decodebin_link(handle_s *handle)
+static int _mm_filesrc_decodebin_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -999,7 +978,7 @@ _mm_filesrc_decodebin_link(handle_s *handle)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       /* Add element(filesrc, decodebin)*/
+       /* Add element(filesrc, decodebin) */
        gst_bin_add_many(GST_BIN(handle->pipeline), handle->filesrc, handle->decodebin, NULL);
 
        if (!gst_element_link_many(handle->filesrc, handle->decodebin, NULL)) {
@@ -1010,8 +989,7 @@ _mm_filesrc_decodebin_link(handle_s *handle)
        return ret;
 }
 
-int
-_mm_transcode_preset_capsfilter(handle_s *handle, unsigned int resolution_width, unsigned int resolution_height)
+int _mm_transcode_preset_capsfilter(handle_s *handle, unsigned int resolution_width, unsigned int resolution_height)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1033,26 +1011,16 @@ _mm_transcode_preset_capsfilter(handle_s *handle, unsigned int resolution_width,
        if (handle->decoder_vidp->vidflt) {
                debug_log("[Resolution] Output Width: [%d], Output Height: [%d]", resolution_width, resolution_height);
 
-               if (resolution_width == 0 || resolution_height == 0) {
-                       g_object_set (G_OBJECT (handle->decoder_vidp->vidflt), "caps",
-                               gst_caps_new_simple("video/x-raw",
-                                                                       "format", G_TYPE_STRING, "I420",
-                                                                       NULL), NULL);
-               } else {
-                       g_object_set (G_OBJECT (handle->decoder_vidp->vidflt), "caps",
-                               gst_caps_new_simple("video/x-raw",
-                                                                       "format", G_TYPE_STRING, "I420",
-                                                                       "width", G_TYPE_INT, resolution_width,
-                                                                       "height", G_TYPE_INT, resolution_height,
-                                                                       NULL), NULL);
-               }
+               if (resolution_width == 0 || resolution_height == 0)
+                       g_object_set(G_OBJECT(handle->decoder_vidp->vidflt), "caps", gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "I420", NULL), NULL);
+               else
+                       g_object_set(G_OBJECT(handle->decoder_vidp->vidflt), "caps", gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "I420", "width", G_TYPE_INT, resolution_width, "height", G_TYPE_INT, resolution_height, NULL), NULL);
        };
 
        return ret;
 }
 
-int
-_mm_setup_pipeline(handle_s *handle)
+int _mm_setup_pipeline(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1061,7 +1029,7 @@ _mm_setup_pipeline(handle_s *handle)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       handle->pipeline= gst_pipeline_new ("TransCode");
+       handle->pipeline = gst_pipeline_new("TransCode");
        debug_log("Success - pipeline");
 
        if (!handle->pipeline) {
index f84d1e5..eb675bb 100755 (executable)
@@ -26,14 +26,13 @@ static void _mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle);
 static void _mm_transcode_video_capsfilter_call(handle_s *handle);
 static void _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle);
 static int _mm_transcode_exec(handle_s *handle, handle_param_s *param);
-static int _mm_transcode_play (handle_s *handle);
-static int _mm_transcode_seek (handle_s *handle);
+static int _mm_transcode_play(handle_s *handle);
+static int _mm_transcode_seek(handle_s *handle);
 static gpointer _mm_transcode_thread_repeate(gpointer data);
 
-GstPadProbeReturn
-_mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
+GstPadProbeReturn _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
 {
-       handle_s *handle = (handle_s*) user_data;
+       handle_s *handle = (handle_s *)user_data;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -47,11 +46,11 @@ _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
 
        gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000);
 
-       if (GST_BUFFER_PTS_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
+       if (GST_BUFFER_PTS_IS_VALID(GST_PAD_PROBE_INFO_BUFFER(info))) {
                if (0 == handle->property->AUDFLAG++) {
-                       GstCaps *current_caps = gst_pad_get_current_caps (pad);
-                       /* Need to audio caps converting when amrnbenc*/
-                       /* Not drop buffer with 'return FALSE'*/
+                       GstCaps *current_caps = gst_pad_get_current_caps(pad);
+                       /* Need to audio caps converting when amrnbenc */
+                       /* Not drop buffer with 'return FALSE' */
                        _mm_transcode_audio_capsfilter(current_caps, handle);
 
                        if (current_caps)
@@ -60,8 +59,8 @@ _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
 
                if (handle->param->seeking) {
                        /* Shifting the decoded out buffer time as the start time */
-                       if (GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) >= start_pos_ts) {
-                               GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) -= start_pos_ts;
+                       if (GST_BUFFER_PTS(GST_PAD_PROBE_INFO_BUFFER(info)) >= start_pos_ts) {
+                               GST_BUFFER_PTS(GST_PAD_PROBE_INFO_BUFFER(info)) -= start_pos_ts;
                        } else {
                                /* If input buffer time is less than start position,
                                 * input buffer will be dropped.
@@ -74,10 +73,9 @@ _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
        return GST_PAD_PROBE_OK;
 }
 
-GstPadProbeReturn
-_mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
+GstPadProbeReturn _mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
 {
-       handle_s *handle = (handle_s*) user_data;
+       handle_s *handle = (handle_s *)user_data;
 
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -91,20 +89,20 @@ _mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
 
        gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000);
 
-       if (GST_BUFFER_PTS_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
+       if (GST_BUFFER_PTS_IS_VALID(GST_PAD_PROBE_INFO_BUFFER(info))) {
                if (0 == handle->property->VIDFLAG++) {
-                       GstCaps *current_caps = gst_pad_get_current_caps (pad);
-                       /* Not drop buffer with 'return FALSE'*/
+                       GstCaps *current_caps = gst_pad_get_current_caps(pad);
+                       /* Not drop buffer with 'return FALSE' */
                        _mm_transcode_video_capsfilter(current_caps, handle);
 
                        if (current_caps)
                                gst_caps_unref(current_caps);
                }
 
-               if(handle->param->seeking) {
+               if (handle->param->seeking) {
                        /* Shifting the decoded out buffer time as the start time */
-                       if (GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) >= start_pos_ts) {
-                               GST_BUFFER_PTS (GST_PAD_PROBE_INFO_BUFFER(info)) -= start_pos_ts;
+                       if (GST_BUFFER_PTS(GST_PAD_PROBE_INFO_BUFFER(info)) >= start_pos_ts) {
+                               GST_BUFFER_PTS(GST_PAD_PROBE_INFO_BUFFER(info)) -= start_pos_ts;
                        } else {
                                /* If input buffer time is less than start position,
                                 * input buffer will be dropped.
@@ -117,10 +115,9 @@ _mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
        return GST_PAD_PROBE_OK;
 }
 
-GstPadProbeReturn
-_mm_cb_encodebin_sinkpad_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
+GstPadProbeReturn _mm_cb_encodebin_sinkpad_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
 {
-       handle_s *handle = (handle_s*) user_data;
+       handle_s *handle = (handle_s *)user_data;
        GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
 
        if (!handle) {
@@ -140,32 +137,32 @@ _mm_cb_encodebin_sinkpad_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointe
 
        switch (GST_EVENT_TYPE(event)) {
        case GST_EVENT_SEGMENT:
-       {
-               if (!handle->param->seeking)
-                       break;
+               {
+                       if (!handle->param->seeking)
+                               break;
 
-               const GstSegment *segment = NULL;
-               GstSegment *new_segment = NULL;
-               gst_event_parse_segment (event, &segment);
-               if (segment->format != GST_FORMAT_TIME)
-                       break;
+                       const GstSegment *segment = NULL;
+                       GstSegment *new_segment = NULL;
+                       gst_event_parse_segment(event, &segment);
+                       if (segment->format != GST_FORMAT_TIME)
+                               break;
 
-               new_segment = gst_segment_copy(segment);
-               gst_event_unref (event);
+                       new_segment = gst_segment_copy(segment);
+                       gst_event_unref(event);
 
-               if (!new_segment) {
-                       debug_error ("[ERROR] segment copy error");
-                       return GST_PAD_PROBE_REMOVE;
-               }
+                       if (!new_segment) {
+                               debug_error("[ERROR] segment copy error");
+                               return GST_PAD_PROBE_REMOVE;
+                       }
 
-               new_segment->start = 0;
-               new_segment->stop = handle->param->duration * G_GINT64_CONSTANT(1000000);
+                       new_segment->start = 0;
+                       new_segment->stop = handle->param->duration * G_GINT64_CONSTANT(1000000);
 
-               /* replace the new segment (change start/stop position) */
-               GstEvent *new_event = gst_event_new_segment(new_segment);
+                       /* replace the new segment (change start/stop position) */
+                       GstEvent *new_event = gst_event_new_segment(new_segment);
 
-               GST_PAD_PROBE_INFO_DATA(info) = new_event;
-       }
+                       GST_PAD_PROBE_INFO_DATA(info) = new_event;
+               }
 
                break;
        default:
@@ -175,12 +172,9 @@ _mm_cb_encodebin_sinkpad_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointe
        return GST_PAD_PROBE_OK;
 }
 
-
-
-GstAutoplugSelectResult
-_mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps * caps, GstElementFactory * factory, handle_s *handle)
+GstAutoplugSelectResult _mm_cb_decode_bin_autoplug_select(GstElement *element, GstPad *pad, GstCaps *caps, GstElementFactory *factory, handle_s *handle)
 {
-       const gchar *feature_name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
+       const gchar *feature_name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory));
        const gchar *caps_str = NULL;
 
        if (!handle) {
@@ -195,14 +189,14 @@ _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps *
 
        caps_str = _mm_check_media_type(caps);
        if (g_strrstr(caps_str, "audio")) {
-               handle->property->audiodecodename = (char*)malloc(sizeof(char) * ENC_BUFFER_SIZE);
+               handle->property->audiodecodename = (char *)malloc(sizeof(char) * ENC_BUFFER_SIZE);
                if (handle->property->audiodecodename == NULL) {
                        debug_error("audiodecodename is NULL");
                        return GST_AUTOPLUG_SELECT_TRY;
                }
                memset(handle->property->audiodecodename, 0, ENC_BUFFER_SIZE);
                strncpy(handle->property->audiodecodename, feature_name, strlen(feature_name));
-               debug_log ("[audio decode name %s : %s]", caps_str, handle->property->audiodecodename);
+               debug_log("[audio decode name %s : %s]", caps_str, handle->property->audiodecodename);
        }
 
        if (g_strrstr(caps_str, "video")) {
@@ -211,22 +205,21 @@ _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps *
                        debug_log("SKIP HW Codec");
                        return GST_AUTOPLUG_SELECT_SKIP;
                }
-               handle->property->videodecodename = (char*)malloc(sizeof(char) * ENC_BUFFER_SIZE);
+               handle->property->videodecodename = (char *)malloc(sizeof(char) * ENC_BUFFER_SIZE);
                if (handle->property->videodecodename == NULL) {
                        debug_error("videodecodename is NULL");
                        return GST_AUTOPLUG_SELECT_TRY;
                }
                memset(handle->property->videodecodename, 0, ENC_BUFFER_SIZE);
                strncpy(handle->property->videodecodename, feature_name, strlen(feature_name));
-               debug_log ("[video decode name %s : %s]", caps_str, handle->property->videodecodename);
+               debug_log("[video decode name %s : %s]", caps_str, handle->property->videodecodename);
        }
 
        /* Try factory. */
        return GST_AUTOPLUG_SELECT_TRY;
 }
 
-void
-_mm_cb_decoder_newpad_encoder(GstElement *decodebin, GstPad *pad, handle_s *handle)
+void _mm_cb_decoder_newpad_encoder(GstElement *decodebin, GstPad *pad, handle_s *handle)
 {
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -254,7 +247,7 @@ _mm_cb_decoder_newpad_encoder(GstElement *decodebin, GstPad *pad, handle_s *hand
        }
 
        debug_log("[============ new-decoded-pad ============]");
-       handle->property->caps = gst_pad_query_caps (pad, NULL);
+       handle->property->caps = gst_pad_query_caps(pad, NULL);
        const gchar *mime = _mm_check_media_type(handle->property->caps);
 
        if (!mime) {
@@ -262,32 +255,30 @@ _mm_cb_decoder_newpad_encoder(GstElement *decodebin, GstPad *pad, handle_s *hand
                return;
        }
 
-       if (g_strrstr(mime,"video")) {
+       if (g_strrstr(mime, "video")) {
                handle->property->linked_vidoutbin = TRUE;
 
                /* link videopad */
                if (gst_pad_is_linked(pad)) {
                        debug_log("pad liked");
                } else {
-                       if (gst_pad_link(pad, (GstPad *)handle->decoder_vidp->sinkdecvideopad) != GST_PAD_LINK_OK) {
+                       if (gst_pad_link(pad, (GstPad *) handle->decoder_vidp->sinkdecvideopad) != GST_PAD_LINK_OK)
                                debug_error("Error [pad - sinkdecvideopad]");
-                       } else {
+                       else
                                debug_log("Success [pad - sinkdecvideopad]");
-                       }
                }
 
-       } else if (g_strrstr(mime,"audio")) {
+       } else if (g_strrstr(mime, "audio")) {
                handle->property->linked_audoutbin = TRUE;
 
                /* link audiopad */
                if (gst_pad_is_linked(pad)) {
                        debug_log("pad liked");
                } else {
-                       if (gst_pad_link(pad, (GstPad *)handle->decoder_audp->sinkdecaudiopad) != GST_PAD_LINK_OK) {
+                       if (gst_pad_link(pad, (GstPad *) handle->decoder_audp->sinkdecaudiopad) != GST_PAD_LINK_OK)
                                debug_error("Error [pad - sinkdecaudiopad]");
-                       } else {
+                       else
                                debug_log("Success [pad - sinkdecaudiopad]");
-                       }
                }
 
        } else {
@@ -295,8 +286,7 @@ _mm_cb_decoder_newpad_encoder(GstElement *decodebin, GstPad *pad, handle_s *hand
        }
 }
 
-gboolean
-_mm_cb_print_position(handle_s *handle)
+gboolean _mm_cb_print_position(handle_s *handle)
 {
        GstFormat fmt = GST_FORMAT_TIME;
        gint64 pos;
@@ -311,33 +301,35 @@ _mm_cb_print_position(handle_s *handle)
                return FALSE;
        }
 
-       if (!handle->property->repeat_thread_exit) { /* To avoid gst_element_query_position bs */
-               if (gst_element_query_position (handle->pipeline, fmt, &pos)) {
-                       unsigned long current_pos =(unsigned long)(GST_TIME_AS_MSECONDS(pos));
+       /* To avoid gst_element_query_position bs */
+       if (!handle->property->repeat_thread_exit) {
+               if (gst_element_query_position(handle->pipeline, fmt, &pos)) {
+                       unsigned long current_pos = (unsigned long)(GST_TIME_AS_MSECONDS(pos));
                        if (handle->param->seeking == FALSE) {
                                handle->property->current_pos = current_pos;
-                               handle->property->real_duration= handle->property->total_length;
+                               handle->property->real_duration = handle->property->total_length;
                        } else if (handle->param->seeking == TRUE) {
                                handle->property->current_pos = current_pos - handle->param->start_pos;
                                if (handle->param->duration != 0) {
-                                       if (handle->param->start_pos + handle->param->duration > handle->property->total_length) {
+                                       if (handle->param->start_pos + handle->param->duration > handle->property->total_length)
                                                handle->property->real_duration = handle->property->total_length - handle->param->start_pos;
-                                       } else {
+                                       else
                                                handle->property->real_duration = handle->param->duration;
-                                       }
-                               } else if (handle->param->duration == 0) { /* seek to origin file length */
+                               /* seek to origin file length */
+                               } else if (handle->param->duration == 0) {
                                        handle->property->real_duration = handle->property->total_length - handle->param->start_pos;
                                }
                        }
 
                        if (handle->property->current_pos <= handle->property->real_duration) {
-                               if (handle->property->current_pos == 0 && handle->param->printed > 2) { /* 2 = 1000 / 500 minimum printed cnt for last buffer */
+                               /* 2 = 1000 / 500 minimum printed cnt for last buffer */
+                               if (handle->property->current_pos == 0 && handle->param->printed > 2)
                                        handle->property->current_pos = handle->property->real_duration;
-                               }
+
                                if (handle->property->progress_cb) {
-                                       if (0 == handle->param->printed) {/* for first buffer */
+                                       /* for first buffer */
+                                       if (0 == handle->param->printed)
                                                handle->property->current_pos = 0;
-                                       }
                                        handle->property->progress_cb(handle->property->current_pos, handle->property->real_duration, handle->property->progress_cb_param);
                                        handle->param->printed++;
                                }
@@ -348,10 +340,9 @@ _mm_cb_print_position(handle_s *handle)
        return TRUE;
 }
 
-gboolean
-_mm_cb_transcode_bus(GstBus * bus, GstMessage * message, gpointer userdata)
+gboolean _mm_cb_transcode_bus(GstBus *bus, GstMessage *message, gpointer userdata)
 {
-       handle_s* handle = (handle_s*) userdata;
+       handle_s *handle = (handle_s *)userdata;
        int ret = MM_ERROR_NONE;
 
        if (!handle) {
@@ -366,170 +357,167 @@ _mm_cb_transcode_bus(GstBus * bus, GstMessage * message, gpointer userdata)
 
        gint64 total_length;
        GstFormat fmt = GST_FORMAT_TIME;
-       MMHandleType MMHandle = (MMHandleType) handle;
+       MMHandleType MMHandle = (MMHandleType)handle;
 
-       switch (GST_MESSAGE_TYPE (message)) {
-       case GST_MESSAGE_ERROR: {
-               GError *err;
-               gchar *debug;
-               gst_message_parse_error (message, &err, &debug);
+       switch (GST_MESSAGE_TYPE(message)) {
+       case GST_MESSAGE_ERROR:
+               {
+                       GError *err;
+                       gchar *debug;
+                       gst_message_parse_error(message, &err, &debug);
 
-               if (!err) {
-                       debug_warning("Fail to parse error message");
-                       break;
-               }
-
-               debug_error("[Source: %s] Error: %s",
-                       GST_OBJECT_NAME(GST_OBJECT_CAST(GST_ELEMENT(GST_MESSAGE_SRC (message)))),
-                       err->message);
+                       if (!err) {
+                               debug_warning("Fail to parse error message");
+                               break;
+                       }
 
-               ret = mm_transcode_cancel(MMHandle);
-               if (ret == MM_ERROR_NONE) {
-                       debug_log("Success - Cancel Transcode");
-               } else {
-                       debug_error("ERROR - Cancel Transcode");
-                       return FALSE;
-               }
+                       debug_error("[Source: %s] Error: %s", GST_OBJECT_NAME(GST_OBJECT_CAST(GST_ELEMENT(GST_MESSAGE_SRC(message)))), err->message);
 
-               g_error_free (err);
-               err = NULL;
+                       ret = mm_transcode_cancel(MMHandle);
+                       if (ret == MM_ERROR_NONE) {
+                               debug_log("Success - Cancel Transcode");
+                       } else {
+                               debug_error("ERROR - Cancel Transcode");
+                               return FALSE;
+                       }
 
-               TRANSCODE_FREE(debug);
-               TRANSCODE_FREE(handle->param);
-               /* g_main_loop_quit (handle->loop); */
-               break;
-       }
+                       g_error_free(err);
+                       err = NULL;
 
-       case GST_MESSAGE_STATE_CHANGED: {
-               if (GST_ELEMENT (GST_MESSAGE_SRC (message)) != handle->pipeline) {
+                       TRANSCODE_FREE(debug);
+                       TRANSCODE_FREE(handle->param);
+                       /* g_main_loop_quit (handle->loop); */
                        break;
                }
-               GstState State_Old, State_New, State_Pending;
-               gst_message_parse_state_changed (message, &State_Old, &State_New, &State_Pending);
 
-               debug_log("[Source: %s] [State: %d -> %d]",
-                       GST_OBJECT_NAME(GST_OBJECT_CAST(GST_ELEMENT(GST_MESSAGE_SRC (message)))),
-                       State_Old, State_New);
+       case GST_MESSAGE_STATE_CHANGED:
+               {
+                       if (GST_ELEMENT(GST_MESSAGE_SRC(message)) != handle->pipeline)
+                               break;
 
-               if (State_Old == GST_STATE_NULL && State_New == GST_STATE_READY) {
-                       debug_log("[Set State: Pause]");
-                       /* Pause Transcode */
-                       ret = _mm_transcode_state_change(handle, GST_STATE_PAUSED);
-                       if (ret == MM_ERROR_NONE) {
-                               debug_log("Success - Pause pipeline");
-                       } else {
-                               debug_error("ERROR - Pause pipeline");
-                               return FALSE;
-                       }
-               }
+                       GstState State_Old, State_New, State_Pending;
+                       gst_message_parse_state_changed(message, &State_Old, &State_New, &State_Pending);
 
-               if (State_Old == GST_STATE_READY && State_New == GST_STATE_PAUSED) {
-                       /* Seek */
-                       debug_log("[%s] Start New Segment pipeline", handle->param->outputfile);
-                       ret = _mm_transcode_seek(handle);
+                       debug_log("[Source: %s] [State: %d -> %d]", GST_OBJECT_NAME(GST_OBJECT_CAST(GST_ELEMENT(GST_MESSAGE_SRC(message)))), State_Old, State_New);
 
-                       if (ret == MM_ERROR_NONE) {
-                               debug_log("Success - Set New Segment pipeline");
-                       } else {
-                               debug_log("[Null Trancode]");
-                               if (_mm_transcode_state_change(handle, GST_STATE_NULL) != MM_ERROR_NONE) {
-                                       debug_error("ERROR -Null Pipeline");
+                       if (State_Old == GST_STATE_NULL && State_New == GST_STATE_READY) {
+                               debug_log("[Set State: Pause]");
+                               /* Pause Transcode */
+                               ret = _mm_transcode_state_change(handle, GST_STATE_PAUSED);
+                               if (ret == MM_ERROR_NONE) {
+                                       debug_log("Success - Pause pipeline");
+                               } else {
+                                       debug_error("ERROR - Pause pipeline");
                                        return FALSE;
                                }
-                               g_mutex_lock (handle->property->thread_mutex);
-                               debug_log("[g_mutex_lock]");
-                               TRANSCODE_FREE(handle->param);
-                               debug_log("g_free(param)");
-                               g_cond_signal(handle->property->thread_cond);
-                               debug_log("[g_cond_signal]");
-                               g_mutex_unlock (handle->property->thread_mutex);
-                               debug_log("[g_mutex_unlock]");
                        }
-               }
 
-               break;
-       }
+                       if (State_Old == GST_STATE_READY && State_New == GST_STATE_PAUSED) {
+                               /* Seek */
+                               debug_log("[%s] Start New Segment pipeline", handle->param->outputfile);
+                               ret = _mm_transcode_seek(handle);
+
+                               if (ret == MM_ERROR_NONE) {
+                                       debug_log("Success - Set New Segment pipeline");
+                               } else {
+                                       debug_log("[Null Trancode]");
+                                       if (_mm_transcode_state_change(handle, GST_STATE_NULL) != MM_ERROR_NONE) {
+                                               debug_error("ERROR -Null Pipeline");
+                                               return FALSE;
+                                       }
+                                       g_mutex_lock(handle->property->thread_mutex);
+                                       debug_log("[g_mutex_lock]");
+                                       TRANSCODE_FREE(handle->param);
+                                       debug_log("g_free(param)");
+                                       g_cond_signal(handle->property->thread_cond);
+                                       debug_log("[g_cond_signal]");
+                                       g_mutex_unlock(handle->property->thread_mutex);
+                                       debug_log("[g_mutex_unlock]");
+                               }
+                       }
 
-       case GST_MESSAGE_ASYNC_DONE: {
-               if (GST_ELEMENT (GST_MESSAGE_SRC (message)) != handle->pipeline) {
                        break;
                }
 
-               if (gst_element_query_duration (handle->pipeline, fmt, &total_length) && handle->property->total_length == 0) {
-                       debug_log("[GST_MESSAGE_ASYNC_DONE] Total Duration: %" G_GUINT64_FORMAT " ", total_length);
-                       handle->property->total_length = (unsigned long)(GST_TIME_AS_MSECONDS(total_length));
-               }
+       case GST_MESSAGE_ASYNC_DONE:
+               {
+                       if (GST_ELEMENT(GST_MESSAGE_SRC(message)) != handle->pipeline)
+                               break;
 
-               handle->param->async_done = TRUE;
-               debug_log("GST_MESSAGE_ASYNC_DONE");
+                       if (gst_element_query_duration(handle->pipeline, fmt, &total_length) && handle->property->total_length == 0) {
+                               debug_log("[GST_MESSAGE_ASYNC_DONE] Total Duration: %" G_GUINT64_FORMAT " ", total_length);
+                               handle->property->total_length = (unsigned long)(GST_TIME_AS_MSECONDS(total_length));
+                       }
+
+                       handle->param->async_done = TRUE;
+                       debug_log("GST_MESSAGE_ASYNC_DONE");
 
-               /* Play Transcode */
-               debug_log("[Play Trancode] [%d ~ %d]", handle->param->start_pos, handle->property->end_pos);
+                       /* Play Transcode */
+                       debug_log("[Play Trancode] [%d ~ %d]", handle->param->start_pos, handle->property->end_pos);
 
-               if (_mm_transcode_play (handle) != MM_ERROR_NONE) {
-                       debug_error("ERROR - Play Pipeline");
-                       return FALSE;
+                       if (_mm_transcode_play(handle) != MM_ERROR_NONE) {
+                               debug_error("ERROR - Play Pipeline");
+                               return FALSE;
+                       }
+                       break;
                }
-               break;
-       }
 
-       case GST_MESSAGE_SEGMENT_DONE: {
-               if (GST_ELEMENT (GST_MESSAGE_SRC (message)) != handle->pipeline) {
+       case GST_MESSAGE_SEGMENT_DONE:
+               {
+                       if (GST_ELEMENT(GST_MESSAGE_SRC(message)) != handle->pipeline)
+                               break;
+
+                       handle->param->segment_done = TRUE;
+                       debug_log("GST_MESSAGE_SEGMENT_DONE");
                        break;
                }
-               handle->param->segment_done = TRUE;
-               debug_log("GST_MESSAGE_SEGMENT_DONE");
-               break;
-       }
 
-       case GST_MESSAGE_EOS: {
-               /* end-of-stream */
-               debug_log("[GST_MESSAGE_EOS] end-of-stream");
+       case GST_MESSAGE_EOS:
+               {
+                       /* end-of-stream */
+                       debug_log("[GST_MESSAGE_EOS] end-of-stream");
 
-               debug_log("[completed] %s (Transcode ID: %d)", handle->param->outputfile, handle->property->seek_idx++);
-               handle->property->AUDFLAG = 0;
-               handle->property->VIDFLAG = 0;
+                       debug_log("[completed] %s (Transcode ID: %d)", handle->param->outputfile, handle->property->seek_idx++);
+                       handle->property->AUDFLAG = 0;
+                       handle->property->VIDFLAG = 0;
 
-               /* Null Transcode */ /* Need to fresh filesink's property*/
-               debug_log("[Null Trancode]");
-               if (_mm_transcode_state_change(handle, GST_STATE_NULL) != MM_ERROR_NONE) {
-                       debug_error("ERROR -Null Pipeline");
-                       return FALSE;
-               }
+                       /* Null Transcode *//* Need to fresh filesink's property */
+                       debug_log("[Null Trancode]");
+                       if (_mm_transcode_state_change(handle, GST_STATE_NULL) != MM_ERROR_NONE) {
+                               debug_error("ERROR -Null Pipeline");
+                               return FALSE;
+                       }
+                       /* checkpoint once more here (eos) and not unlink when Audio only */
+                       if ((handle->param->start_pos > handle->property->total_length && handle->property->total_length != 0) && (handle->property->videoencoder != MM_VIDEOENCODER_NO_USE)) {
+                               unlink(handle->param->outputfile);
+                               debug_log("[unlink] %s %d > %d", handle->param->outputfile, handle->param->start_pos, handle->property->total_length);
+                       }
+                       g_mutex_lock(handle->property->thread_mutex);
+                       handle->param->completed = TRUE;
+                       handle->property->is_busy = FALSE;
+                       g_cond_signal(handle->property->thread_cond);
+                       debug_log("===> send completed signal");
+                       g_mutex_unlock(handle->property->thread_mutex);
 
-               if ((handle->param->start_pos > handle->property->total_length && handle->property->total_length != 0 /* checkpoint once more here (eos)*/) && (handle->property->videoencoder != MM_VIDEOENCODER_NO_USE) /* Not unlink when Audio only */) {
-                       unlink(handle->param->outputfile);
-                       debug_log("[unlink] %s %d > %d", handle->param->outputfile, handle->param->start_pos, handle->property->total_length);
-               }
-               g_mutex_lock (handle->property->thread_mutex);
-               handle->param->completed = TRUE;
-               handle->property->is_busy = FALSE;
-               g_cond_signal(handle->property->thread_cond);
-               debug_log("===> send completed signal");
-               g_mutex_unlock (handle->property->thread_mutex);
+                       debug_log("[MMHandle] 0x%2x [msg_cb] 0x%2x [msg_cb_param] 0x%2x", MMHandle, handle->property->completed_cb, handle->property->completed_cb_param);
 
-               debug_log("[MMHandle] 0x%2x [msg_cb] 0x%2x [msg_cb_param] 0x%2x", MMHandle,handle->property->completed_cb, handle->property->completed_cb_param);
+                       if (handle->property->progress_cb)
+                               handle->property->progress_cb(handle->property->real_duration, handle->property->real_duration, handle->property->progress_cb_param);
 
-               if (handle->property->progress_cb) {
-                       handle->property->progress_cb(handle->property->real_duration, handle->property->real_duration, handle->property->progress_cb_param);
-               }
+                       if (handle->property->completed_cb)
+                               handle->property->completed_cb(MM_ERROR_NONE, handle->property->completed_cb_param);
 
-               if (handle->property->completed_cb) {
-                       handle->property->completed_cb(MM_ERROR_NONE, handle->property->completed_cb_param);
+                       break;
                }
-
-               break;
-       }
        default:
                /* unhandle meage */
-               /*debug_log("unhandle message");*/
+               /*debug_log("unhandle message"); */
                break;
        }
        return TRUE;
 }
 
-static void
-_mm_transcode_audio_capsfilter(GstCaps *caps, handle_s *handle)
+static void _mm_transcode_audio_capsfilter(GstCaps *caps, handle_s *handle)
 {
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -551,23 +539,17 @@ _mm_transcode_audio_capsfilter(GstCaps *caps, handle_s *handle)
                return;
        }
 
-       if (!strcmp(handle->property->aenc, AMRENC)) {
-               caps = gst_caps_new_simple("audio/x-raw",
-                               "rate", G_TYPE_INT, 8000,
-                               "channels", G_TYPE_INT, 1, NULL);
-       } else if (!strcmp(handle->property->aenc, AACENC)) {
-               caps = gst_caps_new_simple("audio/x-raw",
-                               "rate", G_TYPE_INT, 44100,
-                               "channels", G_TYPE_INT, 1, NULL);
-       }
+       if (!strcmp(handle->property->aenc, AMRENC))
+               caps = gst_caps_new_simple("audio/x-raw", "rate", G_TYPE_INT, 8000, "channels", G_TYPE_INT, 1, NULL);
+       else if (!strcmp(handle->property->aenc, AACENC))
+               caps = gst_caps_new_simple("audio/x-raw", "rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 1, NULL);
 
        TRANSCODE_FREE(handle->property->audiodecodename);
        g_object_set(G_OBJECT(handle->decoder_audp->audflt), "caps", caps, NULL);
        debug_log("%s audiocaps: %s", "audio decoder capsfilter", gst_caps_to_string(caps));
 }
 
-int
-_mm_transcode_create(handle_s *handle)
+int _mm_transcode_create(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -612,8 +594,7 @@ _mm_transcode_create(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_transcode_exec(handle_s *handle, handle_param_s *param)
+static int _mm_transcode_exec(handle_s *handle, handle_param_s *param)
 {
        int ret = MM_ERROR_NONE;
 
@@ -640,7 +621,7 @@ _mm_transcode_exec(handle_s *handle, handle_param_s *param)
        } else {
                debug_log("start_pos: %d, duration: %d, seek_mode: %d output file name: %s\n", param->start_pos, param->duration, param->seek_mode, param->outputfile);
                handle->param = g_new0(handle_param_s, 1);
-               /*g_value_init (handle->param, G_TYPE_INT);*/
+               /*g_value_init (handle->param, G_TYPE_INT); */
 
                if (!handle->param) {
                        debug_error("[ERROR] - handle param");
@@ -667,20 +648,18 @@ _mm_transcode_exec(handle_s *handle, handle_param_s *param)
                handle->param->segment_done = FALSE;
                handle->param->completed = FALSE;
                handle->param->printed = 0;
-               debug_log("[SEEK: %d] width: %d height: %d fps_value: %d start_pos: %d duration: %d seek_mode: %d outputfile: %s", handle->param->seeking, handle->param->resolution_width,
-               handle->param->resolution_height, handle->param->fps_value, handle->param->start_pos, handle->param->duration, handle->param->seek_mode, handle->param->outputfile);
+               debug_log("[SEEK: %d] width: %d height: %d fps_value: %d start_pos: %d duration: %d seek_mode: %d outputfile: %s", handle->param->seeking, handle->param->resolution_width, handle->param->resolution_height, handle->param->fps_value, handle->param->start_pos, handle->param->duration, handle->param->seek_mode, handle->param->outputfile);
 
                if (handle->property->total_length != 0 && handle->param->start_pos > handle->property->total_length) {
                        debug_log("[SKIP] [%s] because out of duration [%d < %d ~ %d] ", handle->param->outputfile, handle->property->total_length, handle->param->start_pos, handle->param->duration);
                        g_mutex_unlock(handle->property->thread_mutex);
                        debug_log("[thread_mutex unlock]");
                } else {
-                       g_object_set (G_OBJECT (handle->filesink), "location", handle->param->outputfile, NULL);
+                       g_object_set(G_OBJECT(handle->filesink), "location", handle->param->outputfile, NULL);
                        debug_log("[%s] set filesink location", handle->param->outputfile);
 
-
                        /* Ready Transcode */
-                       if (strlen(handle->param->outputfile) !=0) {
+                       if (strlen(handle->param->outputfile) != 0) {
                                debug_log("[Set State: Ready]");
                                ret = _mm_transcode_state_change(handle, GST_STATE_READY);
                                if (ret == MM_ERROR_NONE) {
@@ -694,13 +673,13 @@ _mm_transcode_exec(handle_s *handle, handle_param_s *param)
 
                        if (0 == handle->property->seek_idx) {
                                debug_log("Link Filesink");
-                               /*link filesink */
+                               /* link filesink */
                                ret = _mm_filesink_link(handle);
                                if (ret == MM_ERROR_NONE) {
                                        debug_log("Success - Link Filesink");
                                } else {
                                        debug_error("ERROR - Link Filesink");
-                                       g_mutex_unlock (handle->property->thread_mutex);
+                                       g_mutex_unlock(handle->property->thread_mutex);
                                        return ret;
                                }
                        }
@@ -714,8 +693,7 @@ _mm_transcode_exec(handle_s *handle, handle_param_s *param)
        return ret;
 }
 
-int
-_mm_transcode_get_stream_info(handle_s *handle)
+int _mm_transcode_get_stream_info(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -729,8 +707,8 @@ _mm_transcode_get_stream_info(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(strlen (handle->property->sourcefile) == 0) {
-               debug_error ("Invalid arguments [sourcefile size 0]\n");
+       if (strlen(handle->property->sourcefile) == 0) {
+               debug_error("Invalid arguments [sourcefile size 0]\n");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
@@ -745,21 +723,21 @@ _mm_transcode_get_stream_info(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if (audio_track_num) {
+       if (audio_track_num)
                handle->property->has_audio_stream = TRUE;
-       } else {
+       else
                handle->property->has_audio_stream = FALSE;
-       }
+
        debug_log("has_audio_stream: %d", handle->property->has_audio_stream);
 
-       if(video_track_num) {
+       if (video_track_num)
                handle->property->has_video_stream = TRUE;
-       } else{
+       else
                handle->property->has_video_stream = FALSE;
-       }
+
        debug_log("has_video_stream: %d", handle->property->has_video_stream);
 
-       if((handle->property->videoencoder != MM_VIDEOENCODER_NO_USE && !handle->property->has_video_stream) || (handle->property->audioencoder != MM_AUDIOENCODER_NO_USE && !handle->property->has_audio_stream)) {
+       if ((handle->property->videoencoder != MM_VIDEOENCODER_NO_USE && !handle->property->has_video_stream) || (handle->property->audioencoder != MM_AUDIOENCODER_NO_USE && !handle->property->has_audio_stream)) {
                debug_error("No video || audio stream");
                return MM_ERROR_INVALID_ARGUMENT;
        }
@@ -767,8 +745,7 @@ _mm_transcode_get_stream_info(handle_s *handle)
        return ret;
 }
 
-int
-_mm_transcode_link(handle_s *handle)
+int _mm_transcode_link(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -777,7 +754,7 @@ _mm_transcode_link(handle_s *handle)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret=_mm_decodesrcbin_link(handle);
+       ret = _mm_decodesrcbin_link(handle);
        if (ret == MM_ERROR_NONE) {
                debug_log("Success - decodesrcbin link");
        } else {
@@ -796,8 +773,7 @@ _mm_transcode_link(handle_s *handle)
        return ret;
 }
 
-static void
-_mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle)
+static void _mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle)
 {
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -818,12 +794,12 @@ _mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle)
        debug_log("[First Video Buffer] Set CapsFilter Parameter");
        _mm_transcode_video_capsfilter_set_parameter(caps, handle);
 
-       /* Not support enlarge video resolution*/
+       /* Not support enlarge video resolution */
        debug_log("Execute Resize");
-       #if 0
-       /* Not irrelevant to the ratio*/
-       handle->param->resolution_height= handle->param->resolution_width * handle->in_height / handle->in_width;
-       #endif
+#if 0
+       /* Not irrelevant to the ratio */
+       handle->param->resolution_height = handle->param->resolution_width * handle->in_height / handle->in_width;
+#endif
 
        debug_log("[Resize] resolution_width: %d, resolution_height: %d", handle->param->resolution_width, handle->param->resolution_height);
        if (0 == handle->param->resolution_width || 0 == handle->param->resolution_height) {
@@ -849,8 +825,7 @@ _mm_transcode_video_capsfilter(GstCaps *caps, handle_s *handle)
        TRANSCODE_FREE(handle->property->videodecodename);
 }
 
-static void
-_mm_transcode_video_capsfilter_call(handle_s *handle)
+static void _mm_transcode_video_capsfilter_call(handle_s *handle)
 {
        if (!handle) {
                debug_error("[ERROR] - handle");
@@ -870,17 +845,10 @@ _mm_transcode_video_capsfilter_call(handle_s *handle)
        /* Configure videoscale to use 4-tap scaling for higher quality */
        debug_log("Input Width: [%d] Input Hieght: [%d] Output Width: [%d], Output Height: [%d]", handle->property->in_width, handle->property->in_height, handle->param->resolution_width, handle->param->resolution_height);
 
-       g_object_set (G_OBJECT (handle->decoder_vidp->vidflt), "caps", gst_caps_new_simple(handle->property->mime,
-                                                                               "format", G_TYPE_STRING, handle->property->format,
-                                                                               "width", G_TYPE_INT, handle->param->resolution_width,
-                                                                               "height", G_TYPE_INT, handle->param->resolution_height,
-                                                                               "framerate", GST_TYPE_FRACTION, handle->property->fps_n, handle->property->fps_d,
-                                                                               "pixel-aspect-ratio", GST_TYPE_FRACTION, handle->property->aspect_x, handle->property->aspect_y,
-                                                                               NULL), NULL);
+       g_object_set(G_OBJECT(handle->decoder_vidp->vidflt), "caps", gst_caps_new_simple(handle->property->mime, "format", G_TYPE_STRING, handle->property->format, "width", G_TYPE_INT, handle->param->resolution_width, "height", G_TYPE_INT, handle->param->resolution_height, "framerate", GST_TYPE_FRACTION, handle->property->fps_n, handle->property->fps_d, "pixel-aspect-ratio", GST_TYPE_FRACTION, handle->property->aspect_x, handle->property->aspect_y, NULL), NULL);
 }
 
-static void
-_mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
+static void _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
 {
        const GValue *par, *fps;
 
@@ -899,13 +867,13 @@ _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
                return;
        }
 
-       GstStructure *_str = gst_caps_get_structure (caps, 0);
+       GstStructure *_str = gst_caps_get_structure(caps, 0);
        handle->property->mime = _mm_check_media_type(caps);
        debug_log("mime: %s", handle->property->mime);
 
-       const gcharformat = gst_structure_get_string(_str, "format");
+       const gchar *format = gst_structure_get_string(_str, "format");
        strncpy(handle->property->format, format, sizeof(handle->property->format));
-       handle->property->format[sizeof(handle->property->format)-1] = '\0';
+       handle->property->format[sizeof(handle->property->format) - 1] = '\0';
 
        switch (gst_video_format_from_string(handle->property->format)) {
        case GST_VIDEO_FORMAT_I420:
@@ -915,39 +883,38 @@ _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
                break;
 
        case GST_VIDEO_FORMAT_UNKNOWN:
-               if (strcmp(handle->property->format, "SN12") == 0 || strcmp(handle->property->format, "ST12") == 0) {
+               if (strcmp(handle->property->format, "SN12") == 0 || strcmp(handle->property->format, "ST12") == 0)
                        debug_log("format: %s", handle->property->format);
-               }
+
                break;
 
        default:
                break;
        }
 
-       if (!gst_structure_get_int(_str, "width", &handle->property->in_width) || !gst_structure_get_int(_str, "height", &handle->property->in_height)) {
+       if (!gst_structure_get_int(_str, "width", &handle->property->in_width) || !gst_structure_get_int(_str, "height", &handle->property->in_height))
                debug_error("error gst_structure_get_int [width] [height]");
-       } else {
+       else
                debug_log("Origin File's Width: [%u] Origin File's Hieght: [%u]", handle->property->in_width, handle->property->in_height);
-       }
 
-       fps = gst_structure_get_value (_str, "framerate");
+       fps = gst_structure_get_value(_str, "framerate");
 
        if (fps) {
-               handle->property->fps_n = gst_value_get_fraction_numerator (fps);
-               handle->property->fps_d = gst_value_get_fraction_denominator (fps);
+               handle->property->fps_n = gst_value_get_fraction_numerator(fps);
+               handle->property->fps_d = gst_value_get_fraction_denominator(fps);
                debug_log("[Origin framerate] gst_value_get_fraction_numerator: %d, gst_value_get_fraction_denominator: %d", handle->property->fps_n, handle->property->fps_d);
        }
 
-       if (handle->param->fps_value>= 5 && handle->param->fps_value <= 30 && handle->param->fps_value <= handle->property->fps_n) {
+       if (handle->param->fps_value >= 5 && handle->param->fps_value <= 30 && handle->param->fps_value <= handle->property->fps_n) {
                handle->property->fps_n = (gint) handle->param->fps_value;
                handle->property->fps_d = 1;
        }
        debug_log("[framerate] gst_value_get_fraction_numerator: %d, gst_value_get_fraction_denominator: %d", handle->property->fps_n, handle->property->fps_d);
 
-       par = gst_structure_get_value (_str, "pixel-aspect-ratio");
+       par = gst_structure_get_value(_str, "pixel-aspect-ratio");
        if (par) {
-               handle->property->aspect_x= gst_value_get_fraction_numerator (par);
-               handle->property->aspect_y = gst_value_get_fraction_denominator (par);
+               handle->property->aspect_x = gst_value_get_fraction_numerator(par);
+               handle->property->aspect_y = gst_value_get_fraction_denominator(par);
        } else {
                handle->property->aspect_x = handle->property->aspect_y = 1;
        }
@@ -955,9 +922,7 @@ _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
 
 }
 
-int
-_mm_transcode_set_handle_element(handle_s *handle, const char * in_Filename, mm_containerformat_e containerformat,
-       mm_videoencoder_e videoencoder, mm_audioencoder_e audioencoder)
+int _mm_transcode_set_handle_element(handle_s *handle, const char *in_Filename, mm_containerformat_e containerformat, mm_videoencoder_e videoencoder, mm_audioencoder_e audioencoder)
 {
        int ret = MM_ERROR_NONE;
 
@@ -972,12 +937,12 @@ _mm_transcode_set_handle_element(handle_s *handle, const char * in_Filename, mm_
        }
 
        if (in_Filename == NULL) {
-               debug_error ("Invalid arguments [filename null]\n");
+               debug_error("Invalid arguments [filename null]\n");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
        if (strlen(in_Filename) == 0 || strlen(in_Filename) > BUFFER_SIZE) {
-               debug_error ("Invalid arguments [filename size: %d]\n", strlen(in_Filename));
+               debug_error("Invalid arguments [filename size: %d]\n", strlen(in_Filename));
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1000,9 +965,7 @@ _mm_transcode_set_handle_element(handle_s *handle, const char * in_Filename, mm_
        return ret;
 }
 
-int
-_mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolution_width, unsigned int resolution_height, unsigned int fps_value, unsigned long start_pos,
-       unsigned long duration, mm_seek_mode_e seek_mode, const char *out_Filename)
+int _mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolution_width, unsigned int resolution_height, unsigned int fps_value, unsigned long start_pos, unsigned long duration, mm_seek_mode_e seek_mode, const char *out_Filename)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1020,11 +983,10 @@ _mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolutio
        param->seek_mode = seek_mode;
        debug_log("resolution_width: %d, resolution_height: %d, fps_value: %d, start_pos: %d, duration: %d, seek_mode: %d \n", param->resolution_width, param->resolution_height, fps_value, param->start_pos, param->duration, param->seek_mode);
 
-       if (start_pos == 0 && duration == 0) {
+       if (start_pos == 0 && duration == 0)
                param->seeking = FALSE;
-       } else {
+       else
                param->seeking = TRUE;
-       }
 
        if (out_Filename) {
                param->outputfile = malloc(sizeof(gchar) * BUFFER_SIZE);
@@ -1043,74 +1005,70 @@ _mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolutio
        return ret;
 }
 
-int
-_mm_transcode_state_change(handle_s *handle, GstState gst_state)
+int _mm_transcode_state_change(handle_s *handle, GstState gst_state)
 {
        int ret = MM_ERROR_NONE;
        GstStateChangeReturn ret_state;
 
-       if (gst_state == GST_STATE_NULL) {
+       if (gst_state == GST_STATE_NULL)
                debug_log("Before - GST_STATE_NULL");
-       } else if (gst_state == GST_STATE_READY) {
+       else if (gst_state == GST_STATE_READY)
                debug_log("Before - GST_STATE_READY");
-       } else if (gst_state == GST_STATE_PAUSED) {
+       else if (gst_state == GST_STATE_PAUSED)
                debug_log("Before - GST_STATE_PAUSED");
-       } else if (gst_state == GST_STATE_PLAYING) {
+       else if (gst_state == GST_STATE_PLAYING)
                debug_log("Before - GST_STATE_PLAYING");
-       }
-       ret_state = gst_element_set_state (handle->pipeline,gst_state /* GST_STATE_READY GST_STATE_PAUSED GST_STATE_NULL*/);
+
+       ret_state = gst_element_set_state(handle->pipeline, gst_state);
        if (ret_state == GST_STATE_CHANGE_FAILURE) {
-               if (gst_state == GST_STATE_NULL) {
+               if (gst_state == GST_STATE_NULL)
                        debug_error("ERROR - SET GST_STATE_NULL");
-               } else if (gst_state == GST_STATE_READY) {
+               else if (gst_state == GST_STATE_READY)
                        debug_error("ERROR - SET GST_STATE_READY");
-               } else if( gst_state == GST_STATE_PAUSED) {
+               else if (gst_state == GST_STATE_PAUSED)
                        debug_error("ERROR - SET GST_STATE_PAUSED");
-               } else if (gst_state == GST_STATE_PLAYING) {
+               else if (gst_state == GST_STATE_PLAYING)
                        debug_error("ERROR - SET GST_STATE_PLAYING");
-               }
+
                return MM_ERROR_TRANSCODE_INTERNAL;
        } else {
-               if (gst_state == GST_STATE_NULL) {
+               if (gst_state == GST_STATE_NULL)
                        debug_log("Success - SET GST_STATE_NULL");
-               } else if (gst_state == GST_STATE_READY) {
+               else if (gst_state == GST_STATE_READY)
                        debug_log("Success - SET GST_STATE_READY");
-               } else if (gst_state == GST_STATE_PAUSED) {
+               else if (gst_state == GST_STATE_PAUSED)
                        debug_log("Success - SET GST_STATE_PAUSED");
-               } else if (gst_state == GST_STATE_PLAYING) {
+               else if (gst_state == GST_STATE_PLAYING)
                        debug_log("Success - SET GST_STATE_PLAYING");
-               }
        }
 
-       ret_state = gst_element_get_state (handle->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+       ret_state = gst_element_get_state(handle->pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
        if (ret_state == GST_STATE_CHANGE_FAILURE) {
-               if (gst_state == GST_STATE_NULL) {
+               if (gst_state == GST_STATE_NULL)
                        debug_error("ERROR - GET GST_STATE_NULL");
-               } else if (gst_state == GST_STATE_READY) {
+               else if (gst_state == GST_STATE_READY)
                        debug_error("ERROR - GET GST_STATE_READY");
-               } else if (gst_state == GST_STATE_PAUSED) {
+               else if (gst_state == GST_STATE_PAUSED)
                        debug_error("ERROR - GET GST_STATE_PAUSED");
-               } else if (gst_state == GST_STATE_PLAYING) {
+               else if (gst_state == GST_STATE_PLAYING)
                        debug_error("ERROR - GET GST_STATE_PLAYING");
-               }
+
                return MM_ERROR_TRANSCODE_INTERNAL;
        } else {
-               if (gst_state == GST_STATE_NULL) {
+               if (gst_state == GST_STATE_NULL)
                        debug_log("Success - GET GST_STATE_NULL");
-               } else if (gst_state == GST_STATE_READY) {
+               else if (gst_state == GST_STATE_READY)
                        debug_log("Success - GET GST_STATE_READY");
-               } else if (gst_state == GST_STATE_PAUSED) {
+               else if (gst_state == GST_STATE_PAUSED)
                        debug_log("Success - GET GST_STATE_PAUSED");
-               } else if (gst_state == GST_STATE_PLAYING) {
+               else if (gst_state == GST_STATE_PLAYING)
                        debug_log("Success - GET GST_STATE_PLAYING");
-               }
        }
 
        return ret;
 }
 
-int
-_mm_transcode_param_flush(handle_s *handle)
+int _mm_transcode_param_flush(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1140,16 +1098,15 @@ _mm_transcode_param_flush(handle_s *handle)
        handle->property->total_length = 0;
        handle->property->repeat_thread_exit = FALSE;
        handle->property->is_busy = FALSE;
-       handle->property->audio_cb_probe_id= 0;
-       handle->property->video_cb_probe_id= 0;
-       handle->property->progrss_event_id= 0;
+       handle->property->audio_cb_probe_id = 0;
+       handle->property->video_cb_probe_id = 0;
+       handle->property->progrss_event_id = 0;
        handle->property->seek_idx = 0;
 
        return ret;
 }
 
-static int
-_mm_transcode_play(handle_s *handle)
+static int _mm_transcode_play(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1169,8 +1126,7 @@ _mm_transcode_play(handle_s *handle)
                return ret;
        }
 
-       debug_log("[SEEK: %d] width: %d height: %d start_pos: %d duration: %d (%d) seek_mode: %d outputfile: %s",handle->param->seeking, handle->param->resolution_width,
-               handle->param->resolution_height, handle->param->start_pos, handle->param->duration, handle->property->end_pos, handle->param->seek_mode, handle->param->outputfile);
+       debug_log("[SEEK: %d] width: %d height: %d start_pos: %d duration: %d (%d) seek_mode: %d outputfile: %s", handle->param->seeking, handle->param->resolution_width, handle->param->resolution_height, handle->param->start_pos, handle->param->duration, handle->property->end_pos, handle->param->seek_mode, handle->param->outputfile);
 
        handle->property->progrss_event_id = g_timeout_add(LAZY_PAUSE_TIMEOUT_MSEC, (GSourceFunc) _mm_cb_print_position, handle);
        debug_log("Timer (id=[%d], timeout=[%d ms])\n", handle->property->progrss_event_id, LAZY_PAUSE_TIMEOUT_MSEC);
@@ -1178,8 +1134,7 @@ _mm_transcode_play(handle_s *handle)
        return ret;
 }
 
-static int
-_mm_transcode_seek(handle_s *handle)
+static int _mm_transcode_seek(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1207,42 +1162,40 @@ _mm_transcode_seek(handle_s *handle)
        } else {
                if (handle->param->duration != 0) {
                        end_pos = start_pos + handle->param->duration * G_GINT64_CONSTANT(1000000);
-               } else if (handle->param->duration == 0) { /* seek to origin file length */
+               } else if (handle->param->duration == 0) {
+                       /* seek to origin file length */
                        end_pos = handle->property->total_length * G_GINT64_CONSTANT(1000000);
                }
 
                debug_log("seek time : [ (%d msec) : (%d msec) ]\n", handle->param->start_pos, handle->property->end_pos);
 
                while (walk_element) {
-                       GstElement *seekable_element = GST_ELEMENT (walk_element->data);
+                       GstElement *seekable_element = GST_ELEMENT(walk_element->data);
 
                        if (!seekable_element) {
                                debug_error("ERROR - seekable");
                                return MM_ERROR_TRANSCODE_INTERNAL;
                        }
 
-                       if (handle->param->seek_mode == MM_SEEK_ACCURATE) {
+                       if (handle->param->seek_mode == MM_SEEK_ACCURATE)
                                _Flags = GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH;
-                       } else if (handle->param->seek_mode == MM_SEEK_INACCURATE) {
+                       else if (handle->param->seek_mode == MM_SEEK_INACCURATE)
                                _Flags = GST_SEEK_FLAG_KEY_UNIT | GST_SEEK_FLAG_FLUSH;
-                       }
 
                        if (!gst_element_seek(seekable_element, rate, GST_FORMAT_TIME, _Flags, GST_SEEK_TYPE_SET, start_pos, GST_SEEK_TYPE_SET, end_pos)) {
                                debug_error("ERROR - gst_element_seek (on) event : %s", GST_OBJECT_NAME(GST_OBJECT_CAST(seekable_element)));
                                return MM_ERROR_TRANSCODE_SEEK_FAILED;
                        }
 
-                       if (walk_element) {
-                               walk_element = g_list_next (walk_element);
-                       }
+                       if (walk_element)
+                               walk_element = g_list_next(walk_element);
                }
        }
 
        return ret;
 }
 
-int
-_mm_transcode_thread(handle_s *handle)
+int _mm_transcode_thread(handle_s *handle)
 {
        int ret = MM_ERROR_NONE;
 
@@ -1256,7 +1209,7 @@ _mm_transcode_thread(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(!handle->property->thread_mutex) {
+       if (!handle->property->thread_mutex) {
                handle->property->thread_mutex = g_mutex_new();
                debug_log("create thread_mutex: 0x%2x", handle->property->thread_mutex);
        } else {
@@ -1287,7 +1240,7 @@ _mm_transcode_thread(handle_s *handle)
 
        /* create threads */
        debug_log("create thread");
-       handle->property->thread = g_thread_create ((GThreadFunc)_mm_transcode_thread_repeate, (gpointer)handle, TRUE, NULL);
+       handle->property->thread = g_thread_create((GThreadFunc)_mm_transcode_thread_repeate, (gpointer)handle, TRUE, NULL);
        if (!handle->property->thread) {
                debug_error("ERROR - create thread");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -1298,10 +1251,9 @@ _mm_transcode_thread(handle_s *handle)
        return ret;
 }
 
-static gpointer
-_mm_transcode_thread_repeate(gpointer data)
+static gpointer _mm_transcode_thread_repeate(gpointer data)
 {
-       handle_s* handle = (handle_s*) data;
+       handle_s *handle = (handle_s *) data;
        int ret = MM_ERROR_NONE;
 
        if (!handle) {
@@ -1314,7 +1266,8 @@ _mm_transcode_thread_repeate(gpointer data)
                return NULL;
        }
 
-       while (1) { /* thread while */
+       /* thread while */
+       while (1) {
                int length = g_async_queue_length(handle->property->queue);
                if (length) {
                        debug_log("[QUEUE #] %d", length);
@@ -1328,10 +1281,10 @@ _mm_transcode_thread_repeate(gpointer data)
                        debug_log("[Destroy]");
                        break;
                } else {
-                       debug_log("[pop queue] resolution_width: %d, resolution_height: %d, start_pos: %d, duration: %d, seek_mode: %d outputfile: %s\n",
-                       pop_data->resolution_width, pop_data->resolution_height, pop_data->start_pos, pop_data->duration, pop_data->seek_mode, pop_data->outputfile);
+                       debug_log("[pop queue] resolution_width: %d, resolution_height: %d, start_pos: %d, duration: %d, seek_mode: %d outputfile: %s\n", pop_data->resolution_width, pop_data->resolution_height, pop_data->start_pos, pop_data->duration, pop_data->seek_mode, pop_data->outputfile);
 
-                       ret = _mm_transcode_exec(handle, pop_data); /* Need to block */
+                       /* Need to block */
+                       ret = _mm_transcode_exec(handle, pop_data);
                        if (ret == MM_ERROR_NONE) {
                                debug_log("Success - transcode_exec");
                        } else {
index 44d1158..7ceb89e 100755 (executable)
@@ -35,39 +35,35 @@ GstBus *bus;
 static int seek_call_cnt = 0;
 static int seek_cnt = 0;
 
-bool
-transcode_completed_cb(int error, void *user_param)
+bool transcode_completed_cb(int error, void *user_param)
 {
        debug_log("MMHandle: 0x%2x", MMHandle);
 
-       if(error == MM_ERROR_NONE) {
+       if (error == MM_ERROR_NONE) {
                debug_log("completed");
-               #if _one_by_one
-               g_main_loop_quit (loop);
-               #endif
+#if _one_by_one
+               g_main_loop_quit(loop);
+#endif
        }
        return TRUE;
 }
 
-bool
-transcode_progress_cb(unsigned long  current_position, unsigned long  real_duration, void *user_parm)
+bool transcode_progress_cb(unsigned long current_position, unsigned long real_duration, void *user_parm)
 {
        debug_log("(%d msec) / (%d msec)", current_position, real_duration);
 
        return TRUE;
 }
 
-void
-trap(int sig)
+void trap(int sig)
 {
        debug_log("quit thread");
        signal(SIGINT, SIG_DFL);
-       #if _cancel
-       if(mm_transcode_cancel (MMHandle) == MM_ERROR_NONE) {
+#if _cancel
+       if (mm_transcode_cancel(MMHandle) == MM_ERROR_NONE)
                debug_log("[Success Cancel]");
-       }
-       mm_transcode (MMHandle, 176, 144, 0, 0, 5000, 1, "/opt/usr/media/Videos/aftercancel.3gp", transcode_progress_cb, transcode_completed_cb, NULL);
-       #endif
+       mm_transcode(MMHandle, 176, 144, 0, 0, 5000, 1, "/opt/usr/media/Videos/aftercancel.3gp", transcode_progress_cb, transcode_completed_cb, NULL);
+#endif
 }
 
 int main(int argc, char *argv[])
@@ -77,7 +73,7 @@ int main(int argc, char *argv[])
        bool is_busy = FALSE;
 
        mm_containerformat_e containerformat = 0;
-       mm_videoencoder_e videoencoder = 0 ;
+       mm_videoencoder_e videoencoder = 0;
        mm_audioencoder_e audioencoder = 0;
        unsigned int resolution_width = 0;
        unsigned int resolution_height = 0;
@@ -87,14 +83,14 @@ int main(int argc, char *argv[])
        unsigned int fps_value = 0;
 
        debug_log("Success - Loop Init");
-       loop = g_main_loop_new (NULL, FALSE);
+       loop = g_main_loop_new(NULL, FALSE);
 
        /* Create Transcode */
-       ret = mm_transcode_create (&MMHandle);
-       if(ret == MM_ERROR_NONE) {
+       ret = mm_transcode_create(&MMHandle);
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - Create Transcode Handle");
                debug_log("MMHandle: 0x%2x", MMHandle);
-       } else{
+       } else {
                debug_log("ERROR - Create Transcode Handle");
                return ret;
        }
@@ -106,57 +102,54 @@ int main(int argc, char *argv[])
        audioencoder = atoi(argv[5]);
 
        /* Transcode */
-       ret = mm_transcode_prepare (MMHandle, argv[1], containerformat, videoencoder, audioencoder);
-       if(ret == MM_ERROR_NONE) {
+       ret = mm_transcode_prepare(MMHandle, argv[1], containerformat, videoencoder, audioencoder);
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - Transcode pipeline");
-       } else{
+       } else {
                debug_error("ERROR - Transcode pipeline");
                return ret;
        }
 
        seek_call_cnt = atoi(argv[2]);
-       for(seek_cnt=0; seek_cnt<seek_call_cnt; seek_cnt++) {
-               resolution_width = atoi(argv[6+(seek_cnt* 7)]);
-               resolution_height = atoi(argv[7+(seek_cnt* 7)]);
-               fps_value = atoi(argv[8+(seek_cnt* 7)]);
-               start_pos = atoi(argv[9+(seek_cnt* 7)]);
-               duration = atoi(argv[10+(seek_cnt* 7)]);
-               seek_mode = atoi(argv[11+(seek_cnt* 7)]);
+       for (seek_cnt = 0; seek_cnt < seek_call_cnt; seek_cnt++) {
+               resolution_width = atoi(argv[6 + (seek_cnt * 7)]);
+               resolution_height = atoi(argv[7 + (seek_cnt * 7)]);
+               fps_value = atoi(argv[8 + (seek_cnt * 7)]);
+               start_pos = atoi(argv[9 + (seek_cnt * 7)]);
+               duration = atoi(argv[10 + (seek_cnt * 7)]);
+               seek_mode = atoi(argv[11 + (seek_cnt * 7)]);
 
                debug_log("mm_transcode_testsuite [Input Filename] [Seek Count] [Container Format] [VENC] [AENC] [Resolution Width] [Resolution Height] [fps] [Start_position] [Duration] [Seek Accurate Mode T/F] [Output Filename]\n");
-               debug_log("container format: %d videoencoder: %d  audioencoder: %d resolution_height: %d, resolution_height: %d, start_pos: %d, duration: %d, seek_mode: %d\n",
-               containerformat, videoencoder, audioencoder, resolution_width, resolution_height, start_pos, duration, seek_mode);
+               debug_log("container format: %d videoencoder: %d  audioencoder: %d resolution_height: %d, resolution_height: %d, start_pos: %d, duration: %d, seek_mode: %d\n", containerformat, videoencoder, audioencoder, resolution_width, resolution_height, start_pos, duration, seek_mode);
 
                /* Transcode */
-               if(mm_transcode_is_busy(MMHandle, &is_busy) == MM_ERROR_NONE) {
-                       if(is_busy == FALSE) {
-                               ret = mm_transcode (MMHandle, resolution_width, resolution_height, fps_value, start_pos, duration, seek_mode, argv[12+(seek_cnt* 7)], transcode_progress_cb, transcode_completed_cb, user_param);
-                       } else {
+               if (mm_transcode_is_busy(MMHandle, &is_busy) == MM_ERROR_NONE) {
+                       if (is_busy == FALSE)
+                               ret = mm_transcode(MMHandle, resolution_width, resolution_height, fps_value, start_pos, duration, seek_mode, argv[12 + (seek_cnt * 7)], transcode_progress_cb, transcode_completed_cb, user_param);
+                       else
                                debug_log("BUSY");
-                       }
                }
-               #if _one_by_one
-               g_main_loop_run (loop);
+#if _one_by_one
+               g_main_loop_run(loop);
        }
-               #else
+#else
        }
-       g_main_loop_run (loop);
-       #endif
+       g_main_loop_run(loop);
+#endif
 
-       if(ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE) {
                /* cleanup */
-               mm_transcode_destroy (MMHandle);
-               if(ret == MM_ERROR_NONE) {
+               mm_transcode_destroy(MMHandle);
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Transcode attribute");
-               }else{
+               } else {
                        debug_error("ERROR - Transcode attribute");
                        return ret;
                }
-       } else{
+       } else {
                debug_error("ERROR - Transcode pipeline");
                return ret;
        }
 
        return ret;
 }
-