Fixed prevent issues and update code alignment 07/45907/2
authorGilbok Lee <gilbok.lee@samsung.com>
Wed, 12 Aug 2015 09:00:13 +0000 (18:00 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 12 Aug 2015 10:07:52 +0000 (19:07 +0900)
Change-Id: I7ce2a19ef62a2d67ce0fbf73bc8d1214a898b90b
Signed-off-by: Gilbok Lee <gilbok.lee@samsung.com>
packaging/libmm-transcode.spec
transcode/Makefile.am
transcode/mm_transcode.c
transcode/mm_transcode_codec.c
transcode/mm_transcode_pipeline.c
transcode/mm_transcode_seek.c

index 89f7b61..8c956f3 100644 (file)
@@ -1,7 +1,7 @@
 Name:       libmm-transcode
 Summary:    Multimedia Framework Video Transcode Library
 Version:    0.9
-Release:    3
+Release:    4
 Group:      System/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 5aade34..4a0b6c2 100755 (executable)
@@ -12,26 +12,27 @@ libmm_transcode_la_SOURCES = mm_transcode.c \
                              mm_transcode_codec.c
 
 libmm_transcode_la_CFLAGS = -I$(srcdir)/include \
-                            $(MMCOMMON_CFLAGS) \
-                            $(MMFILEINFO_CFLAGS) \
-                            $(GLIB_CFLAGS) \
-                            $(GST_CFLAGS) \
-                            $(GSTAPP_CFLAGS)  \
-                             $(GST_PLUGIN_BASE_CFLAGS) \
-                            $(GST_INTERFACE_CFLAGS) \
-                             $(GSTPBUTILS_CFLAGS) \
-                             $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x300000 -DMMF_DEBUG_PREFIX=\"MMF-VIDEOEDIT\"
+                                                       $(MMCOMMON_CFLAGS) \
+                                                       $(MMFILEINFO_CFLAGS) \
+                                                       $(GLIB_CFLAGS) \
+                                                       $(GST_CFLAGS) \
+                                                       $(GSTAPP_CFLAGS)  \
+                                                       $(GST_PLUGIN_BASE_CFLAGS) \
+                                                       $(GST_INTERFACE_CFLAGS) \
+                                                       $(GSTPBUTILS_CFLAGS) \
+                                                       $(GST_VIDEO_LIBS) \
+                                                       $(MMLOG_CFLAGS) -DMMF_LOG_OWNER=0x300000 -DMMF_DEBUG_PREFIX=\"MMF-VIDEOEDIT\"
 
 libmm_transcode_la_LIBADD = $(MMCOMMON_LIBS) \
-                           $(MMFILEINFO_LIBS) \
-                           $(GLIB_LIBS) \
-                           $(GST_LIBS) \
-                           $(GSTAPP_LIBS) \
-                $(GST_VIDEO_LIBS) \
-                            $(GST_PLUGIN_BASE_LIBS) \
-                           $(GST_INTERFACE_LIBS) \
-                            $(GSTPBUTILS_LIBS) \
-                           $(MMLOG_LIBS)
+                                                       $(MMFILEINFO_LIBS) \
+                                                       $(GLIB_LIBS) \
+                                                       $(GST_LIBS) \
+                                                       $(GSTAPP_LIBS) \
+                                                       $(GST_VIDEO_LIBS) \
+                                                       $(GST_PLUGIN_BASE_LIBS) \
+                                                       $(GST_INTERFACE_LIBS) \
+                                                       $(GSTPBUTILS_LIBS) \
+                                                       $(MMLOG_LIBS)
 
 pcfiles = mm-transcode.pc
 pkgconfigdir = $(libdir)/pkgconfig
index bf3f917..8c96256 100755 (executable)
@@ -28,7 +28,7 @@ mm_transcode_create(MMHandleType* MMHandle)
        handle_s *handle = NULL;
 
        /* Check argument here */
-       if(MMHandle == NULL) {
+       if (MMHandle == NULL) {
                debug_error ("Invalid arguments [tag null]\n");
                return MM_ERROR_INVALID_ARGUMENT;
        }
@@ -67,7 +67,7 @@ mm_transcode_create(MMHandleType* MMHandle)
 
        *MMHandle = (MMHandleType)handle;
 
-       if(MMHandle) {
+       if (MMHandle) {
                debug_log("MMHandle: 0x%2x", handle);
                handle->property->_MMHandle = 0;
        } else {
@@ -96,33 +96,33 @@ 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;
        }
 
-       if(videoencoder == MM_VIDEOENCODER_NO_USE && audioencoder == MM_AUDIOENCODER_NO_USE) {
+       if (videoencoder == MM_VIDEOENCODER_NO_USE && audioencoder == MM_AUDIOENCODER_NO_USE) {
                debug_error("No encoder resource");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       if(videoencoder == MM_VIDEOENCODER_H264) {
+       if (videoencoder == MM_VIDEOENCODER_H264) {
                debug_error("Can't support encoding to H264");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
        /* set element*/
        ret = _mm_transcode_set_handle_element(handle, in_Filename, containerformat, videoencoder, audioencoder);
-       if(ret != MM_ERROR_NONE) {
+       if (ret != MM_ERROR_NONE) {
                debug_error("ERROR -Set element");
                return ret;
        }
 
        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 */
+       if (0 == strlen(handle->property->sourcefile) || 0 == strcmp(handle->property->sourcefile, in_Filename)) { /* protect the case of changing input file during transcoding */
                /* setup */
                ret = _mm_setup_pipeline(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Setup Pipeline");
                } else{
                        debug_error("ERROR - Setup Pipeline");
@@ -131,7 +131,7 @@ mm_audioencoder_e audioencoder)
 
                /* video / auido stream */
                ret = _mm_transcode_get_stream_info(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Get stream info");
                } else{
                        debug_error("ERROR - Get stream info");
@@ -140,7 +140,7 @@ mm_audioencoder_e audioencoder)
 
                /* create pipeline */
                ret = _mm_transcode_create(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Create Pipeline");
                } else{
                        debug_error("ERROR -Create Pipeline");
@@ -149,7 +149,7 @@ mm_audioencoder_e audioencoder)
 
                /*link pipeline */
                ret = _mm_transcode_link(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Link pipeline");
                } else{
                        debug_error("ERROR - Link pipeline");
@@ -158,7 +158,7 @@ mm_audioencoder_e audioencoder)
 
                /* flush param */
                ret = _mm_transcode_param_flush(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Init parameter");
                } else{
                        debug_error("ERROR - Init parameter");
@@ -167,7 +167,7 @@ mm_audioencoder_e audioencoder)
 
                /* create thread */
                ret = _mm_transcode_thread(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Link pipeline");
                } else{
                        debug_error("ERROR - Link pipeline");
@@ -203,17 +203,17 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(!completed_callback) {
+       if (!completed_callback) {
                debug_error("[ERROR] - completed_callback");
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       if(!out_Filename) {
+       if (!out_Filename) {
                debug_error("[ERROR] - out_Filename");
                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;
        }
@@ -231,22 +231,22 @@ mm_transcode (MMHandleType MMHandle, unsigned int resolution_width, unsigned int
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->_MMHandle == 1) { /* check if prepare is called during transcoding */
+       if (handle->property->_MMHandle == 1) { /* check if prepare is called during transcoding */
                handle_param_s *param = g_new0 (handle_param_s, 1);
-               if(param) {
+               if (param) {
                        /*g_value_init (param, G_TYPE_INT);*/
                        debug_log("[param] 0x%2x", param);
                }
 
                /* 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) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Set parameter");
                        return ret;
                }
 
                ret = _mm_transcode_preset_capsfilter(handle, resolution_width, resolution_height);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Preset Capsfilter");
                } else{
                        debug_error("ERROR - Preset Capsfilter");
@@ -306,15 +306,15 @@ mm_transcode_cancel (MMHandleType MMHandle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->is_busy) {
+       if (handle->property->is_busy) {
                debug_log("Cancel - [IS BUSY]");
                ret = _mm_transcode_state_change(handle, GST_STATE_NULL);
-               if(ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR - Null Pipeline");
                        return ret;
                }
 
-               if((handle->param) && (strlen(handle->param->outputfile) > 0)) {
+               if ((handle->param) && (strlen(handle->param->outputfile) > 0)) {
                        unlink(handle->param->outputfile);
                        debug_log("[Cancel] unlink %s", handle->param->outputfile);
                } else {
@@ -351,9 +351,9 @@ mm_transcode_destroy (MMHandleType MMHandle)
 
        g_mutex_lock(handle->property->thread_exit_mutex);
        handle->property->repeat_thread_exit = TRUE;
-       if(handle->property->is_busy) {
+       if (handle->property->is_busy) {
                ret = mm_transcode_cancel(MMHandle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Cancel Transcode");
                } else{
                        debug_error("ERROR - Cancel Transcode");
@@ -364,7 +364,7 @@ mm_transcode_destroy (MMHandleType MMHandle)
        g_mutex_unlock(handle->property->thread_exit_mutex);
 
        handle_param_s *param = g_new0 (handle_param_s, 1);
-       if(param) {
+       if (param) {
                debug_log("[Try to Push Last Queue]");
                g_async_queue_push (handle->property->queue, GINT_TO_POINTER(param));
        } else {
@@ -373,26 +373,26 @@ mm_transcode_destroy (MMHandleType MMHandle)
        }
 
        ret = _mm_transcode_state_change(handle, GST_STATE_NULL);
-       if(ret != MM_ERROR_NONE) {
+       if (ret != MM_ERROR_NONE) {
                debug_error("ERROR - Null Pipeline");
                return ret;
        } else {
                debug_log("SUCCESS - Null Pipeline");
        }
 
-       if((handle->param) && (!handle->param->completed)) {
+       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);
                debug_log("unlock destory");
-               if(strlen(handle->param->outputfile) > 0) {
+               if (strlen(handle->param->outputfile) > 0) {
                        unlink(handle->param->outputfile);
                        debug_log("[Cancel] unlink %s", handle->param->outputfile);
                }
        }
 
        ret = _mm_cleanup_pipeline(handle);
-       if(ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - CleanUp Pipeline");
        } else{
                debug_error("ERROR - CleanUp Pipeline");
@@ -422,7 +422,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;
        }
@@ -436,7 +436,7 @@ 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 {
                *current_pos = handle->property->current_pos;
@@ -456,8 +456,8 @@ mm_transcode_get_supported_container_format(mm_transcode_support_type_callback t
 {
        int idx = 0;
 
-       for(idx = 0; idx < MM_CONTAINER_NUM; idx++) {
-               if(type_callback(idx, user_param) == false)
+       for (idx = 0; idx < MM_CONTAINER_NUM; idx++) {
+               if (type_callback(idx, user_param) == false)
                {
                        debug_error("error occured. idx[%d]", idx);
                        break;
@@ -472,8 +472,8 @@ mm_transcode_get_supported_video_encoder(mm_transcode_support_type_callback type
 {
        int idx = 0;
 
-       for(idx = 0; idx < MM_VIDEOENCODER_H264; idx++) {
-               if(type_callback(idx, user_param) == false)
+       for (idx = 0; idx < MM_VIDEOENCODER_H264; idx++) {
+               if (type_callback(idx, user_param) == false)
                {
                        debug_error("error occured. idx[%d]", idx);
                        break;
@@ -488,8 +488,8 @@ mm_transcode_get_supported_audio_encoder(mm_transcode_support_type_callback type
 {
        int idx = 0;
 
-       for(idx = 0; idx < MM_AUDIOENCODER_NO_USE; idx++) {
-               if(type_callback(idx, user_param) == false)
+       for (idx = 0; idx < MM_AUDIOENCODER_NO_USE; idx++) {
+               if (type_callback(idx, user_param) == false)
                {
                        debug_error("error occured. idx[%d]", idx);
                        break;
index 796849a..4f0b4c2 100755 (executable)
@@ -37,18 +37,18 @@ _mm_encodebin_set_venc_aenc(handle_s *handle)
        }
 
        handle->property->mux = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
-       if(handle->property->mux == NULL) {
+       if (handle->property->mux == NULL) {
                debug_error("[NULL] mux");
                return MM_ERROR_INVALID_ARGUMENT;
        }
        handle->property->venc = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
-       if(handle->property->venc == NULL) {
+       if (handle->property->venc == NULL) {
                debug_error("[NULL] venc");
                TRANSCODE_FREE(handle->property->mux);
                return MM_ERROR_INVALID_ARGUMENT;
        }
        handle->property->aenc = malloc(sizeof(gchar) * ENC_BUFFER_SIZE);
-       if(handle->property->aenc == NULL) {
+       if (handle->property->aenc == NULL) {
                debug_error("[NULL] aenc");
                TRANSCODE_FREE(handle->property->mux);
                TRANSCODE_FREE(handle->property->venc);
@@ -62,7 +62,7 @@ _mm_encodebin_set_venc_aenc(handle_s *handle)
        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) {
+                       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);
index 57144dc..8806768 100755 (executable)
@@ -62,19 +62,19 @@ _mm_cleanup_encodebin(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->encodebin->encvideopad) {
+       if (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) {
+       if (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) {
+       if (handle->property->caps) {
                gst_caps_unref (handle->property->caps);
                handle->property->caps = NULL;
                debug_log("gst_caps_unref");
@@ -107,7 +107,7 @@ _mm_cleanup_pipeline(handle_s *handle)
 
        /* g_thread_exit(handle->thread); */
        debug_log("g_thread_exit");
-       if(handle->property->thread) {
+       if (handle->property->thread) {
                g_thread_join(handle->property->thread);
                debug_log("Success - join (thread)");
        }
@@ -119,112 +119,112 @@ _mm_cleanup_pipeline(handle_s *handle)
                handle->property->bus_watcher = 0;
        }
 
-       if(handle->property->queue) {
+       if (handle->property->queue) {
                g_async_queue_unref(handle->property->queue);
                handle->property->queue = NULL;
                debug_log("Success - g_async_queue_unref(queue)");
        }
 
-       if(handle->property->thread_mutex) {
+       if (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) {
+       if (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) {
+       if (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)");
        }
 
        /* release videopad */
-       if(handle->decoder_vidp->decvideosinkpad) {
+       if (handle->decoder_vidp->decvideosinkpad) {
                gst_object_unref(GST_OBJECT(handle->decoder_vidp->decvideosinkpad));
                handle->decoder_vidp->decvideosinkpad = NULL;
                debug_log("Success - gt_object_unref (decvideosinkpad)");
        }
 
-       if(handle->decoder_vidp->decvideosrcpad) {
+       if (handle->decoder_vidp->decvideosrcpad) {
                gst_object_unref(GST_OBJECT(handle->decoder_vidp->decvideosrcpad));
                handle->decoder_vidp->decvideosrcpad = NULL;
                debug_log("Success - gst_object_unref (decvideosrcpad)");
        }
 
-       if(handle->decoder_vidp->srcdecvideopad) {
+       if (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) {
+       if (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) {
+       if (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) {
+       if (handle->decoder_audp->decaudiosrcpad) {
                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) {
+       if (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) {
+       if (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)");
        }
 
-       if(_mm_cleanup_encodebin(handle) != MM_ERROR_NONE) {
+       if (_mm_cleanup_encodebin(handle) != MM_ERROR_NONE) {
                debug_error("ERROR -Play Pipeline");
                return FALSE;
        } else {
                debug_log("Success -clean encodebin");
        }
 
-       if(handle->property->sink_elements) {
+       if (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) {
+       if (handle->pipeline) {
                gst_object_unref (handle->pipeline);
                handle->pipeline = NULL;
                debug_log("Success - gst_object_unref (pipeline)");
        }
 
-       if(handle->property->audio_cb_probe_id) {
+       if (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) {
+       if (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) {
+       if (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)");
@@ -280,7 +280,7 @@ _mm_decode_audio_output_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->audioencoder == MM_AUDIOENCODER_NO_USE) {
+       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");
@@ -345,11 +345,11 @@ _mm_decode_audio_output_link(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->audioencoder == MM_AUDIOENCODER_NO_USE) {
+       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);
-               if(!gst_element_link_many(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;
                }
@@ -358,7 +358,7 @@ _mm_decode_audio_output_link(handle_s *handle)
                handle->decoder_audp->sinkdecaudiopad = gst_element_get_static_pad (handle->decoder_audp->decaudiobin, "decbin_audiosink"); /* get sink audiopad of decodebin */
        } 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);
-               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)) {
+               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;
                }
@@ -369,7 +369,7 @@ _mm_decode_audio_output_link(handle_s *handle)
                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 */
 
-        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);
+               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*/
        }
 
@@ -463,7 +463,7 @@ _mm_decode_video_output_link(handle_s *handle)
        }
 
        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)) {
+       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;
        }
@@ -526,16 +526,16 @@ _mm_decodesrcbin_create(handle_s *handle)
        }
 
        ret = _mm_filesrc_pipeline_create(handle);
-       if(ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - Create filesrc pipeline");
        } else{
                debug_error("ERROR -Create filesrc pipeline");
                return ret;
        }
 
-       if(handle->property->has_audio_stream) {
+       if (handle->property->has_audio_stream) {
                ret = _mm_decode_audio_output_create(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Create audiobin pipeline: 0x%2x",handle->decoder_audp->decaudiobin);
                } else{
                        debug_error("ERROR - Create audiobin pipeline");
@@ -543,9 +543,9 @@ _mm_decodesrcbin_create(handle_s *handle)
                }
        }
 
-       if(handle->property->has_video_stream) {
+       if (handle->property->has_video_stream) {
                ret = _mm_decode_video_output_create(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - Create videobin pipeline: 0x%2x",handle->decoder_vidp->decvideobin);
                } else{
                        debug_error("ERROR -Create videobin pipeline");
@@ -554,7 +554,7 @@ _mm_decodesrcbin_create(handle_s *handle)
        }
 
        ret = _mm_decodebin_pipeline_create(handle);
-       if(ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - Create decodebin pipeline");
        } else{
                debug_error("ERROR - Create decodebin pipeline");
@@ -580,16 +580,16 @@ _mm_decodesrcbin_link(handle_s *handle)
        }
 
        ret=_mm_filesrc_decodebin_link(handle);
-       if(ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE) {
                debug_log("Success - _mm_filesrc_decodebin_link");
        } else{
                debug_error("ERROR - _mm_filesrc_decodebin_link");
                return ret;
        }
 
-       if(handle->property->has_audio_stream) {
+       if (handle->property->has_audio_stream) {
                ret = _mm_decode_audio_output_link(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - _mm_decode_audio_output_link");
                } else{
                        debug_error("ERROR - _mm_decode_audio_output_link");
@@ -597,9 +597,9 @@ _mm_decodesrcbin_link(handle_s *handle)
                }
        }
 
-       if(handle->property->has_video_stream) {
+       if (handle->property->has_video_stream) {
                ret=_mm_decode_video_output_link(handle);
-               if(ret == MM_ERROR_NONE) {
+               if (ret == MM_ERROR_NONE) {
                        debug_log("Success - _mm_decode_video_output_link");
                } else{
                        debug_error("ERROR - _mm_decode_video_output_link");
@@ -637,29 +637,29 @@ _mm_encodebin_create(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->videoencoder != MM_VIDEOENCODER_NO_USE && handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
+       if (handle->property->videoencoder != MM_VIDEOENCODER_NO_USE && handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
                ret = _mm_encodebin_set_video_property(handle);
-               if(ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Setup encodebin video property");
                        return ret;
                }
 
                ret = _mm_encodebin_set_audio_property(handle);
-               if(ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Setup encodebin audio property");
                        return ret;
                }
-       } else if(handle->property->videoencoder != MM_VIDEOENCODER_NO_USE) {
+       } else if (handle->property->videoencoder != MM_VIDEOENCODER_NO_USE) {
                ret = _mm_encodebin_set_video_property(handle);
-               if(ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Setup encodebin video property");
                        return ret;
                }
-       } else if(handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
+       } else if (handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
                handle->encodebin->encodebin_profile = 1;
                debug_log("[AUDIO ONLY ENCODE]");
                ret = _mm_encodebin_set_audio_property(handle);
-               if(ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE) {
                        debug_error("ERROR -Setup encodebin video property");
                        return ret;
                }
@@ -667,7 +667,7 @@ _mm_encodebin_create(handle_s *handle)
 
        debug_log("[Encodebin Profile: %d]", handle->encodebin->encodebin_profile);
        ret = _mm_encodebin_set_property(handle);
-       if(ret != MM_ERROR_NONE) {
+       if (ret != MM_ERROR_NONE) {
                debug_error("ERROR -Setup encodebin property");
                return ret;
        }
@@ -698,10 +698,10 @@ _mm_encodebin_link(handle_s *handle)
        /* Add encodebin to pipeline */
        gst_bin_add(GST_BIN(handle->pipeline), handle->encodebin->encbin);
 
-       if(handle->property->has_video_stream) {
-               if(handle->property->videoencoder != MM_VIDEOENCODER_NO_USE) {
+       if (handle->property->has_video_stream) {
+               if (handle->property->videoencoder != MM_VIDEOENCODER_NO_USE) {
                        handle->encodebin->encvideopad = gst_element_get_request_pad(handle->encodebin->encbin, "video");
-                       if(handle->encodebin->encvideopad) {
+                       if (handle->encodebin->encvideopad) {
                                debug_log("encvideopad: 0x%2x", handle->encodebin->encvideopad);
                                gst_pad_link(handle->decoder_vidp->srcdecvideopad, handle->encodebin->encvideopad);
                        } else {
@@ -711,12 +711,12 @@ _mm_encodebin_link(handle_s *handle)
                }
        }
 
-       if(handle->property->has_audio_stream) {
-               if(handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
+       if (handle->property->has_audio_stream) {
+               if (handle->property->audioencoder != MM_AUDIOENCODER_NO_USE) {
                        handle->encodebin->encaudiopad = gst_element_get_request_pad(handle->encodebin->encbin, "audio");
-                       if(handle->encodebin->encaudiopad) {
+                       if (handle->encodebin->encaudiopad) {
                                debug_log("encaudiopad: 0x%2x", handle->encodebin->encaudiopad);
-                               gst_pad_link(handle->decoder_audp->srcdecaudiopad, handle->encodebin->encaudiopad);
+                               gst_pad_link(handle->decoder_audp->srcdecaudiopad, handle->encodebin->encaudiopad);
                        } else {
                                debug_error("error encaudiopad");
                                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -747,9 +747,9 @@ _mm_encodebin_set_audio_property(handle_s* handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->has_audio_stream) {
+       if (handle->property->has_audio_stream) {
                /* Audio */
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ARS)) {
+               if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ARS)) {
                        g_object_set(G_OBJECT(handle->encodebin->encbin), ARS, 0, NULL);
                        debug_log("[AUDIO RESAMPLE] encbin set auto-audio-resample");
                } else {
@@ -757,7 +757,7 @@ _mm_encodebin_set_audio_property(handle_s* handle)
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ACON)) {
+               if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ACON)) {
                        g_object_set(G_OBJECT(handle->encodebin->encbin), ACON, 1, NULL);
                        debug_log("encbin set auto-audio-convert");
                } else {
@@ -765,7 +765,7 @@ _mm_encodebin_set_audio_property(handle_s* handle)
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), AENC)) {
+               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);
                } else {
@@ -773,7 +773,7 @@ _mm_encodebin_set_audio_property(handle_s* handle)
                        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);
                }
 
@@ -804,7 +804,7 @@ _mm_encodebin_set_property(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), PROFILE)) {
+       if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), PROFILE)) {
                g_object_set(G_OBJECT(handle->encodebin->encbin), PROFILE, handle->encodebin->encodebin_profile, NULL);
                debug_log("encbin set profile");
        } else {
@@ -812,7 +812,7 @@ _mm_encodebin_set_property(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), MUX)) {
+       if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), MUX)) {
                g_object_set(G_OBJECT(handle->encodebin->encbin), MUX, handle->property->mux, NULL);
                debug_log("[MUX] encbin set [%s: %s]", MUX, handle->property->mux);
        } else {
@@ -843,9 +843,9 @@ _mm_encodebin_set_video_property(handle_s *handle)
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
-       if(handle->property->has_video_stream) {
+       if (handle->property->has_video_stream) {
                /* Video */
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ACS)) {
+               if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), ACS)) {
                        g_object_set(G_OBJECT(handle->encodebin->encbin), ACS, 0, NULL);
                        debug_log("[AUTO COLORSPACE] encbin set auto-colorspace");
                } else {
@@ -853,7 +853,7 @@ _mm_encodebin_set_video_property(handle_s *handle)
                        return MM_ERROR_TRANSCODE_INTERNAL;
                }
 
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), VENC)) {
+               if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(handle->encodebin->encbin)), VENC)) {
                        g_object_set(G_OBJECT(handle->encodebin->encbin), VENC, handle->property->venc, NULL);
                        debug_log("[VIDEOENCODER] encbin set [%s: %s]", VENC, handle->property->venc);
                } else {
@@ -879,15 +879,16 @@ _mm_filesink_create(handle_s *handle)
        }
 
        handle->filesink = gst_element_factory_make ("filesink", "filesink");
-       debug_log("[sync]");
-       g_object_set (G_OBJECT (handle->filesink), "sync", TRUE, NULL);
-       g_object_set (G_OBJECT (handle->filesink), "async", FALSE, NULL);
 
        if (!handle->filesink) {
                debug_error("filesink element could not be created");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
 
+       debug_log("[sync]");
+       g_object_set (G_OBJECT (handle->filesink), "sync", TRUE, NULL);
+       g_object_set (G_OBJECT (handle->filesink), "async", FALSE, NULL);
+
        return ret;
 }
 
@@ -910,7 +911,7 @@ _mm_filesink_link(handle_s *handle)
        gst_bin_add(GST_BIN(handle->pipeline), handle->filesink);
 
        /* link encodebin and filesink */
-       if(!gst_element_link(handle->encodebin->encbin, handle->filesink)) {
+       if (!gst_element_link(handle->encodebin->encbin, handle->filesink)) {
                debug_error("gst_element_link [encbin ! filesink] failed");
                return MM_ERROR_TRANSCODE_INTERNAL;
        } else {
@@ -956,7 +957,7 @@ _mm_filesrc_decodebin_link(handle_s *handle)
        /* 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)) {
+       if (!gst_element_link_many(handle->filesrc, handle->decodebin, NULL)) {
                debug_error("gst_element_link_many src ! decbin failed");
                return MM_ERROR_TRANSCODE_INTERNAL;
        }
index 5f92bd8..8a8b883 100755 (executable)
@@ -38,27 +38,27 @@ _mm_cb_audio_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
 
        if (!handle) {
                debug_error("[ERROR] - handle");
-        return GST_PAD_PROBE_REMOVE;
+               return GST_PAD_PROBE_REMOVE;
        }
 
        if (!handle->property) {
                debug_error("[ERROR] - handle property");
-        return GST_PAD_PROBE_REMOVE;
+               return GST_PAD_PROBE_REMOVE;
        }
 
        gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000);
 
-       if(GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
-               if(0 == handle->property->AUDFLAG++) {
+       if (GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
+               if (0 == handle->property->AUDFLAG++) {
                        _mm_transcode_audio_capsfilter(gst_pad_get_current_caps (pad), handle); /* Need to audio caps converting when amrnbenc*/ /* Not drop buffer with 'return FALSE'*/
 
-                       if(handle->param->seeking) {
+                       if (handle->param->seeking) {
                                debug_log("[AUDIO BUFFER TIMESTAMP] ([%"G_GUINT64_FORMAT"])", start_pos_ts);
                                GST_BUFFER_TIMESTAMP (GST_PAD_PROBE_INFO_BUFFER(info)) = start_pos_ts;
                        }
                }
        }
-    return GST_PAD_PROBE_OK;
+       return GST_PAD_PROBE_OK;
 }
 
 GstAutoplugSelectResult
@@ -90,6 +90,11 @@ _mm_cb_decode_bin_autoplug_select(GstElement * element, GstPad * pad, GstCaps *
        }
 
        if(g_strrstr(caps_str, "video")) {
+               if(g_strrstr(feature_name, "omx")) {
+                       /* emit autoplug-select to see what we should do with it. */
+                       debug_log("SKIP HW Codec");
+                       return GST_AUTOPLUG_SELECT_SKIP;
+               }
                handle->property->videodecodename = (char*)malloc(sizeof(char) * ENC_BUFFER_SIZE);
                if(handle->property->videodecodename == NULL) {
                        debug_error("videodecodename is NULL");
@@ -190,31 +195,31 @@ _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)) {
+       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));
-                       if(handle->param->seeking == FALSE) {
+                       if (handle->param->seeking == FALSE) {
                                handle->property->current_pos = current_pos;
                                handle->property->real_duration= handle->property->total_length;
-                       } else if(handle->param->seeking == TRUE) {
+                       } 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->duration != 0) {
+                                       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 {
                                                handle->property->real_duration = handle->param->duration;
                                        }
-                               } else if(handle->param->duration == 0) { /* seek to origin file length */
+                               } else if (handle->param->duration == 0) { /* seek to origin file length */
                                        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 */
+                       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 */
                                        handle->property->current_pos = handle->property->real_duration;
                                }
-                               if(handle->property->progress_cb) {
-                                       if(0 == handle->param->printed) {/* for first buffer */
+                               if( handle->property->progress_cb) {
+                                       if (0 == handle->param->printed) {/* for first buffer */
                                                handle->property->current_pos = 0;
                                        }
                                        handle->property->progress_cb(handle->property->current_pos, handle->property->real_duration, handle->property->progress_cb_param);
@@ -234,18 +239,18 @@ _mm_cb_video_output_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer us
 
        if (!handle) {
                debug_error("[ERROR] - handle");
-        return GST_PAD_PROBE_REMOVE;
+               return GST_PAD_PROBE_REMOVE;
        }
 
        if (!handle->property) {
                debug_error("[ERROR] - handle property");
-        return GST_PAD_PROBE_REMOVE;
+               return GST_PAD_PROBE_REMOVE;
        }
 
        gint64 start_pos_ts = handle->param->start_pos * G_GINT64_CONSTANT(1000000);
 
-       if(GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
-               if(0 == handle->property->VIDFLAG++) {
+       if (GST_BUFFER_TIMESTAMP_IS_VALID (GST_PAD_PROBE_INFO_BUFFER(info))) {
+               if (0 == handle->property->VIDFLAG++) {
                        _mm_transcode_video_capsfilter(gst_pad_get_current_caps (pad), handle); /* Not drop buffer with 'return FALSE'*/
 
                        if(handle->param->seeking) {
@@ -356,7 +361,7 @@ _mm_cb_transcode_bus(GstBus * bus, GstMessage * message, gpointer userdata)
                        break;
                }
 
-        if(gst_element_query_duration (handle->pipeline, fmt, &total_length) && handle->property->total_length == 0) {
+               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));
                }
@@ -588,7 +593,7 @@ _mm_transcode_exec(handle_s *handle, handle_param_s *param)
                }
 
                memset(handle->param->outputfile, 0, BUFFER_SIZE);
-               strncpy(handle->param->outputfile, param->outputfile, strlen(param->outputfile) - 1);
+               strncpy(handle->param->outputfile, param->outputfile, strlen(param->outputfile));
 
                handle->param->seeking = param->seeking;
                handle->param->async_done = FALSE;
@@ -799,7 +804,7 @@ _mm_transcode_video_capsfilter_call(handle_s *handle)
        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,
+                                                                               "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,
@@ -833,21 +838,23 @@ _mm_transcode_video_capsfilter_set_parameter(GstCaps *caps, handle_s *handle)
 
        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';
+
        switch (gst_video_format_from_string(handle->property->format)) {
-           case GST_VIDEO_FORMAT_I420:
-           case GST_VIDEO_FORMAT_RGB:
-           case GST_VIDEO_FORMAT_NV12:
-               debug_log("format: %s", handle->property->format);
-               break;
+       case GST_VIDEO_FORMAT_I420:
+       case GST_VIDEO_FORMAT_RGB:
+       case GST_VIDEO_FORMAT_NV12:
+               debug_log("format: %s", handle->property->format);
+               break;
 
-           case GST_VIDEO_FORMAT_UNKNOWN:
-               if (strcmp(handle->property->format, "SN12") == 0 || strcmp(handle->property->format, "ST12") == 0) {
-                   debug_log("format: %s", handle->property->format);
-               }
-               break;
+       case GST_VIDEO_FORMAT_UNKNOWN:
+               if (strcmp(handle->property->format, "SN12") == 0 || strcmp(handle->property->format, "ST12") == 0) {
+                       debug_log("format: %s", handle->property->format);
+               }
+               break;
 
-           default:
-               break;
+       default:
+               break;
        }
 
        if(!gst_structure_get_int(_str, "width", &handle->property->in_width) || !gst_structure_get_int(_str, "height", &handle->property->in_height)) {
@@ -910,7 +917,8 @@ _mm_transcode_set_handle_element(handle_s *handle, const char * in_Filename, mm_
        handle->property->sourcefile = malloc(sizeof(char) * BUFFER_SIZE);
        if(handle->property->sourcefile) {
                memset(handle->property->sourcefile, 0, BUFFER_SIZE);
-               strncpy(handle->property->sourcefile, in_Filename, strlen (in_Filename) - 1);
+               strncpy(handle->property->sourcefile, in_Filename, strlen (in_Filename));
+               debug_log("%s", handle->property->sourcefile);
        } else {
                debug_error("[ERROR] malloc fail of sourcefile");
                return MM_ERROR_TRANSCODE_INTERNAL;
@@ -958,7 +966,7 @@ _mm_transcode_set_handle_parameter(handle_param_s *param, unsigned int resolutio
                        return MM_ERROR_TRANSCODE_NO_FREE_SPACE;
                }
                memset(param->outputfile, 0, BUFFER_SIZE);
-               strncpy(param->outputfile, out_Filename, strlen (out_Filename) - 1);
+               strncpy(param->outputfile, out_Filename, strlen (out_Filename));
                debug_log("%s(%d)", param->outputfile, strlen (out_Filename));
                debug_log("output file name: %s", param->outputfile);
        } else {