Support new pixel format - VP8, VP9
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_videorec.c
index 1413b08..64b0c99 100644 (file)
 /*=======================================================================================
 |  INCLUDE FILES                                                                                                                                               |
 =======================================================================================*/
+#include <gst/allocators/gsttizenmemory.h>
 #include <gst/video/cameracontrol.h>
 #include <gst/app/gstappsrc.h>
 #include "mm_camcorder_internal.h"
 #include "mm_camcorder_videorec.h"
 
 /*---------------------------------------------------------------------------------------
-|    GLOBAL VARIABLE DEFINITIONS for internal                                                                                  |
----------------------------------------------------------------------------------------*/
-#define _MMCAMCORDER_LOCATION_INFO             /* for add gps information */
-#define MAX_ERROR_MESSAGE_LEN                  128
-
-/*---------------------------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS for internal                                                                                   |
 ---------------------------------------------------------------------------------------*/
-#define _MMCAMCORDER_MINIMUM_FRAME             5
-#define _MMCAMCORDER_RETRIAL_COUNT             15
-#define _MMCAMCORDER_FRAME_WAIT_TIME   200000      /* us */
-#define _OFFSET_COMPOSITION_MATRIX             40L
-#define _GOP_GEN_INTERVAL                              1000000000  /* ns */
-#define _MMCAMCORDER_VIDEO_MINIMUM_SPACE       (_MMCAMCORDER_MINIMUM_SPACE << 1)      /* byte */
+#define _MMCAMCORDER_MINIMUM_FRAME          5
+#define _MMCAMCORDER_RETRIAL_COUNT          15
+#define _MMCAMCORDER_FRAME_WAIT_TIME        200000 /* us */
+#define _MMCAMCORDER_FRAME_PASS_MIN_FPS     30
+#define _MMCAMCORDER_MIN_TIME_TO_PASS_FRAME 30000000 /* ns */
+#define _MMCAMCORDER_VIDEO_MINIMUM_SPACE    (_MMCAMCORDER_MINIMUM_SPACE << 1) /* byte */
+#define OFFSET_COMPOSITION_MATRIX           40L
+#define MAX_ERROR_MESSAGE_LEN               128
 
 /*---------------------------------------------------------------------------------------
 |    LOCAL FUNCTION PROTOTYPES:                                                                                                                        |
 ---------------------------------------------------------------------------------------*/
 /* STATIC INTERNAL FUNCTION */
-static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
+static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
 static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
+static GstPadProbeReturn __mmcamcorder_video_dataprobe_encoded(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
 static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
 static GstPadProbeReturn __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
 static GstPadProbeReturn __mmcamcorder_audio_dataprobe_audio_mute(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
@@ -62,71 +59,144 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle);
 /*---------------------------------------------------------------------------------------
 |    GLOBAL FUNCTION DEFINITIONS:                                                      |
 ---------------------------------------------------------------------------------------*/
-static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
+gboolean _mmcamcorder_video_push_buffer(void *handle, GstSample *sample)
 {
-       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
+       _MMCamcorderImageInfo *info_image = NULL;
+       _MMCamcorderVideoInfo *info_video = NULL;
+       _MMCamcorderGstElement *element = NULL;
+       GstClockTime current_ts = 0; /* nsec */
+       GstBuffer *buffer = NULL;
+
+       mmf_return_val_if_fail(hcamcorder, FALSE);
+       mmf_return_val_if_fail(MMF_CAMCORDER_SUBCONTEXT(hcamcorder), FALSE);
+
+       buffer = gst_sample_get_buffer(sample);
 
-       GstBuffer *buffer = gst_sample_get_buffer(sample);
        mmf_return_val_if_fail(buffer, FALSE);
        mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
-       mmf_return_val_if_fail(hcamcorder, FALSE);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
-       mmf_return_val_if_fail(sc, FALSE);
 
-       /*
-       _mmcam_dbg_log("ENTER - push_encoding_buffer %d, buffer %p, MALLOCDATA %p, size %d",
-               sc->info_video->push_encoding_buffer, buffer, GST_BUFFER_MALLOCDATA(buffer), GST_BUFFER_SIZE(buffer));
-       */
-
-       /* push buffer in appsrc to encode */
-       if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_RUN &&
-           sc->info_video->record_dual_stream &&
-           sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst) {
-               GstFlowReturn ret = 0;
-               GstClock *pipe_clock = NULL;
-
-               if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
-                       if (sc->info_video->is_firstframe) {
-                               sc->info_video->is_firstframe = FALSE;
-                               pipe_clock = GST_ELEMENT_CLOCK(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
-                               if (pipe_clock) {
-                                       gst_object_ref(pipe_clock);
-                                       sc->info_video->base_video_ts = GST_BUFFER_PTS(buffer) - (gst_clock_get_time(pipe_clock) - GST_ELEMENT(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst)->base_time);
-                                       gst_object_unref(pipe_clock);
+       mmf_return_val_if_fail(sc->info_image, FALSE);
+       mmf_return_val_if_fail(sc->info_video, FALSE);
+       mmf_return_val_if_fail(sc->encode_element, FALSE);
+
+       info_image = sc->info_image;
+       info_video = sc->info_video;
+       element = sc->encode_element;
+
+       if (info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_RUN &&
+               element[_MMCAMCORDER_ENCSINK_SRC].gst) {
+               int ret = 0;
+               GstClock *clock = NULL;
+
+               MMCAM_LOG_VERBOSE("GST_BUFFER_FLAG_DELTA_UNIT is set : %d",
+                       GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT));
+
+               current_ts = GST_BUFFER_PTS(buffer);
+
+               if (info_video->is_first_frame) {
+                       /* check first I frame for H.264 stream */
+                       if (_mmcamcorder_is_encoded_preview_pixel_format(info_image->preview_format)) {
+                               if (GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
+                                       MMCAM_LOG_WARNING("NOT key frame.. skip this buffer");
+                                       return TRUE;
+                               } else {
+                                       MMCAM_LOG_WARNING("first key frame");
+                               }
+                       }
+
+                       /* set base timestamp */
+                       if (element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
+                               clock = GST_ELEMENT_CLOCK(element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
+                               if (clock) {
+                                       gst_object_ref(clock);
+                                       info_video->base_video_ts = current_ts - (gst_clock_get_time(clock) - \
+                                               GST_ELEMENT(element[_MMCAMCORDER_ENCSINK_SRC].gst)->base_time);
+                                       gst_object_unref(clock);
+                               }
+                       } else {
+                               /* for image capture with encodebin and v4l2src */
+                               if (sc->bencbin_capture && info_image->capturing) {
+                                       g_mutex_lock(&hcamcorder->task_thread_lock);
+                                       MMCAM_LOG_INFO("send signal for sound play");
+                                       hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START;
+                                       g_cond_signal(&hcamcorder->task_thread_cond);
+                                       g_mutex_unlock(&hcamcorder->task_thread_lock);
                                }
+                               info_video->base_video_ts = current_ts;
                        }
                } else {
-                       if (sc->info_video->is_firstframe) {
-                               sc->info_video->is_firstframe = FALSE;
-                               sc->info_video->base_video_ts = GST_BUFFER_PTS(buffer);
+                       if (_mmcamcorder_invoke_video_stream_cb(handle, sample, FALSE, -1) == FALSE) {
+                               /* increase base video timestamp by frame duration,
+                                  it will remove delay of dropped buffer when play recorded file. */
+                               info_video->base_video_ts += current_ts - info_video->last_video_ts;
+                               MMCAM_LOG_DEBUG("do not push buffer to encode by app's return value");
+                               goto _VIDEO_PUSH_BUFFER_DONE;
                        }
                }
 
-               GST_BUFFER_PTS(buffer) = GST_BUFFER_PTS(buffer) - sc->info_video->base_video_ts;
-               GST_BUFFER_DTS(buffer) = GST_BUFFER_PTS(buffer);
+               GST_BUFFER_DTS(buffer) = GST_BUFFER_PTS(buffer) = current_ts - info_video->base_video_ts;
+
+               MMCAM_LOG_DEBUG("buffer %p, timestamp %"GST_TIME_FORMAT,
+                       buffer, GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));
 
-               ret = gst_app_src_push_buffer((GstAppSrc *)sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, buffer);
-               if (ret != GST_FLOW_OK && ret != GST_FLOW_FLUSHING) {
-                       _mmcam_dbg_err("gst_app_src_push_buffer failed [0x%x]", ret);
-                       gst_buffer_unref(buffer);
-                       buffer = NULL;
+               if (info_video->record_dual_stream) {
+                       /* It will NOT INCREASE reference count of buffer */
+                       ret = gst_app_src_push_buffer((GstAppSrc *)element[_MMCAMCORDER_ENCSINK_SRC].gst, buffer);
+               } else {
+                       /* It will INCREASE reference count of buffer */
+                       g_signal_emit_by_name(element[_MMCAMCORDER_ENCSINK_SRC].gst, "push-buffer", buffer, &ret);
                }
 
-               /*_mmcam_dbg_log("push buffer result : 0x%x", ret);*/
-       } else {
-               _mmcam_dbg_warn("unref video buffer immediately - push encoding buffer %d",
-                       sc->info_video->push_encoding_buffer);
+               MMCAM_LOG_VERBOSE("push buffer result : 0x%x", ret);
+
+_VIDEO_PUSH_BUFFER_DONE:
+               info_video->last_video_ts = current_ts;
+
+               if (info_video->is_first_frame) {
+                       info_video->is_first_frame = FALSE;
+
+                       /* drop buffer if it's from tizen allocator */
+                       if (gst_is_tizen_memory(gst_buffer_peek_memory(buffer, 0))) {
+                               MMCAM_LOG_WARNING("drop first buffer from tizen allocator to avoid copy in basesrc");
+                               return FALSE;
+                       }
+               }
+       }
+
+       /* skip display if too fast FPS */
+       if (info_video->record_dual_stream == FALSE &&
+               info_video->fps > _MMCAMCORDER_FRAME_PASS_MIN_FPS) {
+               if (info_video->prev_preview_ts != 0) {
+                       if (GST_BUFFER_PTS(buffer) - info_video->prev_preview_ts < _MMCAMCORDER_MIN_TIME_TO_PASS_FRAME) {
+                               MMCAM_LOG_VERBOSE("it's too fast. drop frame...");
+                               return FALSE;
+                       }
+               }
 
-               gst_buffer_unref(buffer);
-               buffer = NULL;
+               MMCAM_LOG_VERBOSE("display buffer [%p]", buffer);
+
+               info_video->prev_preview_ts = GST_BUFFER_PTS(buffer);
        }
 
        return TRUE;
 }
 
 
+static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
+{
+       mmf_return_if_fail(sample);
+
+       /* no need to check return value here */
+       _mmcamcorder_video_push_buffer(u_data, sample);
+
+       gst_sample_unref(sample);
+}
+
+
 int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
 {
        int i = 0;
@@ -148,7 +218,7 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
        mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       _mmcam_dbg_warn("start");
+       MMCAM_LOG_WARNING("start");
 
        err = _mmcamcorder_check_videocodec_fileformat_compatibility(handle);
        if (err != MM_ERROR_NONE)
@@ -156,7 +226,7 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
 
        /* Main pipeline */
        if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst) {
-               _mmcam_dbg_log("pipeline is exist so need to remove pipeline _MMCAMCORDER_ENCODE_MAIN_PIPE = %p",
+               MMCAM_LOG_INFO("pipeline is exist so need to remove pipeline _MMCAMCORDER_ENCODE_MAIN_PIPE = %p",
                        sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst);
                _mmcamcorder_remove_recorder_pipeline((MMHandleType)hcamcorder);
        }
@@ -168,10 +238,11 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                MMCAM_AUDIO_DISABLE, &sc->audio_disable,
                NULL);
 
-       _mmcam_dbg_log("MMCAM_AUDIO_DISABLE %d, is_modified_rate %d",
-               sc->audio_disable, sc->is_modified_rate);
+       MMCAM_LOG_INFO("MMCAM_AUDIO_DISABLE %d, is_modified_rate %d, ved_cb %p",
+               sc->audio_disable, sc->is_modified_rate, hcamcorder->vedecision_cb);
 
-       sc->audio_disable |= sc->is_modified_rate;
+       if (sc->is_modified_rate || hcamcorder->vedecision_cb)
+               sc->audio_disable = TRUE;
 
        if (sc->audio_disable == FALSE) {
                /* create audiosrc bin */
@@ -189,12 +260,22 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
                        sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst);
        }
 
-       /* add element and encodesink bin to encode main pipeline */
-       gst_bin_add_many(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst),
-               sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
-               sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst,
-               sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst,
-               NULL);
+       /* add elements and encodesink bin to encode main pipeline */
+       if (sc->info_video->use_videoscale) {
+               gst_bin_add_many(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst),
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE_FILT].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst,
+                       NULL);
+       } else {
+               gst_bin_add_many(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst),
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst,
+                       sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst,
+                       NULL);
+       }
 
        /* Link each element : appsrc - capsfilter - encodesink bin */
        srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "src");
@@ -202,6 +283,16 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
 
        srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "src");
+       if (sc->info_video->use_videoscale) {
+               sinkpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE].gst, "sink");
+               _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
+
+               srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE].gst, "src");
+               sinkpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE_FILT].gst, "sink");
+               _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
+
+               srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE_FILT].gst, "src");
+       }
        sinkpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, "video_sink0");
        _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
 
@@ -218,7 +309,7 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        _mmcamcorder_conf_get_value_element_name(RecordsinkElement, &gst_element_rsink_name);
 
        if (!gst_element_rsink_name) {
-               _mmcam_dbg_err("failed to get recordsink name");
+               MMCAM_LOG_ERROR("failed to get recordsink name");
                err = MM_ERROR_CAMCORDER_INTERNAL;
                goto pipeline_creation_error;
        }
@@ -270,7 +361,7 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
        if (!strcmp(gst_element_rsink_name, "filesink")) {
                srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, "src");
                MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_VIDEOREC,
-                       __mmcamcorder_video_dataprobe_record, hcamcorder);
+                       __mmcamcorder_video_dataprobe_encoded, hcamcorder);
                gst_object_unref(srcpad);
                srcpad = NULL;
 
@@ -291,9 +382,6 @@ int _mmcamcorder_create_recorder_pipeline(MMHandleType handle)
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
 
-       /* register pipeline message callback */
-       hcamcorder->encode_pipeline_cb_event_id = gst_bus_add_watch(bus, (GstBusFunc)_mmcamcorder_pipeline_cb_message, hcamcorder);
-
        /* set sync handler */
        gst_bus_set_sync_handler(bus, _mmcamcorder_encode_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
@@ -324,7 +412,7 @@ int _mmcamcorder_remove_audio_pipeline(MMHandleType handle)
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
        mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       _mmcam_dbg_log("");
+       MMCAM_LOG_INFO("");
 
        if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst != NULL) {
                srcpad = gst_element_get_static_pad(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst, "src");
@@ -345,7 +433,7 @@ int _mmcamcorder_remove_audio_pipeline(MMHandleType handle)
                */
                _mmcamcorder_remove_element_handle(handle, (void *)sc->encode_element, _MMCAMCORDER_AUDIOSRC_BIN, _MMCAMCORDER_AUDIOSRC_VOL);
 
-               _mmcam_dbg_log("Audio pipeline removed");
+               MMCAM_LOG_INFO("Audio pipeline removed");
        }
 
        return MM_ERROR_NONE;
@@ -367,7 +455,7 @@ int _mmcamcorder_remove_encode_pipeline(MMHandleType handle)
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
        mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       _mmcam_dbg_log("");
+       MMCAM_LOG_INFO("");
 
        if (sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst != NULL) {
                /* release request pad */
@@ -399,12 +487,12 @@ int _mmcamcorder_remove_encode_pipeline(MMHandleType handle)
                /* _mmcamcorder_remove_element_handle(handle, (void *)sc->encode_element,
                        _MMCAMCORDER_ENCODE_MAIN_PIPE, _MMCAMCORDER_ENCSINK_SINK); */
 
-               _mmcam_dbg_warn("Encoder pipeline removed");
+               MMCAM_LOG_WARNING("Encoder pipeline removed");
 
 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
                _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
 
-               _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
+               MMCAM_LOG_WARNING("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
 
                if (hcamcorder->is_release_cb_calling == FALSE) {
                        /* release resource */
@@ -413,16 +501,16 @@ int _mmcamcorder_remove_encode_pipeline(MMHandleType handle)
                        if (ret == MM_RESOURCE_MANAGER_ERROR_NONE)
                                hcamcorder->video_encoder_resource = NULL;
 
-                       _mmcam_dbg_warn("mark resource for release 0x%x", ret);
+                       MMCAM_LOG_WARNING("mark resource for release 0x%x", ret);
 
                        ret = mm_resource_manager_commit(hcamcorder->resource_manager);
 
-                       _mmcam_dbg_warn("commit resource release 0x%x", ret);
+                       MMCAM_LOG_WARNING("commit resource release 0x%x", ret);
                }
 
                _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
 
-               _mmcam_dbg_warn("unlock resource");
+               MMCAM_LOG_WARNING("unlock resource");
 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
        }
 
@@ -442,10 +530,10 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       _mmcam_dbg_log("start");
+       MMCAM_LOG_INFO("start");
 
        if (!sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst) {
-               _mmcam_dbg_warn("pipeline is not existed.");
+               MMCAM_LOG_WARNING("pipeline is not existed.");
                return MM_ERROR_NONE;
        }
 
@@ -453,7 +541,7 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
 
        ret = _mmcamcorder_gst_set_state(handle, sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst, GST_STATE_NULL);
        if (ret != MM_ERROR_NONE) {
-               _mmcam_dbg_err("Faile to change encode main pipeline [0x%x]", ret);
+               MMCAM_LOG_ERROR("Failed to change encode main pipeline [0x%x]", ret);
                return ret;
        }
 
@@ -462,22 +550,16 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
        /* remove audio pipeline first */
        ret = _mmcamcorder_remove_audio_pipeline(handle);
        if (ret != MM_ERROR_NONE) {
-               _mmcam_dbg_err("Fail to remove audio pipeline");
+               MMCAM_LOG_ERROR("Fail to remove audio pipeline");
                return ret;
        }
 
        ret = _mmcamcorder_remove_encode_pipeline(handle);
        if (ret != MM_ERROR_NONE) {
-               _mmcam_dbg_err("Fail to remove encoder pipeline");
+               MMCAM_LOG_ERROR("Fail to remove encoder pipeline");
                return ret;
        }
 
-       /* Remove pipeline message callback */
-       if (hcamcorder->encode_pipeline_cb_event_id != 0) {
-               g_source_remove(hcamcorder->encode_pipeline_cb_event_id);
-               hcamcorder->encode_pipeline_cb_event_id = 0;
-       }
-
        /* Remove remained message */
        if (bus) {
                GstMessage *gst_msg = NULL;
@@ -490,7 +572,7 @@ int _mmcamcorder_remove_recorder_pipeline(MMHandleType handle)
                bus = NULL;
        }
 
-       _mmcam_dbg_log("done");
+       MMCAM_LOG_INFO("done");
 
        return ret;
 }
@@ -524,7 +606,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
        info = sc->info_video;
 
-       _mmcam_dbg_log("Command(%d)", command);
+       MMCAM_LOG_INFO("Command(%d)", command);
 
        pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
 
@@ -541,7 +623,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        int root_directory_length = 0;
 
                        /* Recording */
-                       _mmcam_dbg_log("Record Start - dual stream %d", info->support_dual_stream);
+                       MMCAM_LOG_INFO("Record Start - dual stream %d", info->support_dual_stream);
 
 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
                        _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
@@ -553,19 +635,19 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                                MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
                                                &hcamcorder->video_encoder_resource);
                                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                                       _mmcam_dbg_err("could not prepare for encoder resource");
+                                       MMCAM_LOG_ERROR("could not prepare for encoder resource");
                                        ret = MM_ERROR_RESOURCE_INTERNAL;
                                        _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
                                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
                                }
                        } else {
-                               _mmcam_dbg_log("encoder already acquired");
+                               MMCAM_LOG_INFO("encoder already acquired");
                        }
 
                        /* acquire resources */
                        ret = mm_resource_manager_commit(hcamcorder->resource_manager);
                        if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               _mmcam_dbg_err("could not acquire resources");
+                               MMCAM_LOG_ERROR("could not acquire resources");
                                ret = MM_ERROR_RESOURCE_INTERNAL;
                                _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
@@ -592,13 +674,13 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                MMCAM_ROOT_DIRECTORY, &hcamcorder->root_directory, &root_directory_length,
                                NULL);
                        if (ret != MM_ERROR_NONE) {
-                               _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, ret);
+                               MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, ret);
                                SAFE_FREE(err_name);
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
                        }
 
                        if (!target_filename && !hcamcorder->mstream_cb) {
-                               _mmcam_dbg_err("filename is not set and muxed stream cb is NULL");
+                               MMCAM_LOG_ERROR("filename is not set and muxed stream cb is NULL");
                                ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
                        }
@@ -618,7 +700,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        ret = _mmcamcorder_get_storage_validity(hcamcorder, target_filename,
                                _MMCAMCORDER_VIDEO_MINIMUM_SPACE, &storage_validity);
                        if (ret != MM_ERROR_NONE) {
-                               _mmcam_dbg_err("storage validation failed[0x%x]:%d", ret, storage_validity);
+                               MMCAM_LOG_ERROR("storage validation failed[0x%x]:%d", ret, storage_validity);
                                return ret;
                        }
 
@@ -632,17 +714,17 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        }
                        g_mutex_unlock(&hcamcorder->task_thread_lock);
 
-                       _mmcam_dbg_warn("video size [%dx%d]", info->video_width, info->video_height);
+                       MMCAM_LOG_WARNING("video size [%dx%d]", info->video_width, info->video_height);
 
                        if (info->video_width == 0 || info->video_height == 0) {
-                               _mmcam_dbg_warn("video size is invalid [%dx%d] use preview size [%dx%d]",
+                               MMCAM_LOG_WARNING("video size is invalid [%dx%d] use preview size [%dx%d]",
                                        info->video_width, info->video_height, info->preview_width, info->preview_height);
                                info->video_width = info->preview_width;
                                info->video_height = info->preview_height;
                        }
 
                        if (info->support_dual_stream) {
-                               _mmcam_dbg_warn("DUAL STREAM MODE");
+                               MMCAM_LOG_WARNING("DUAL STREAM MODE");
 
                                info->record_dual_stream = TRUE;
 
@@ -651,16 +733,20 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-width", info->video_width);
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-height", info->video_height);
-                       } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
+                       } else if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format) &&
                                info->preview_width == info->video_width &&
                                info->preview_height == info->video_height) {
-                               _mmcam_dbg_log("H264 preview mode and same resolution");
-
+                               MMCAM_LOG_INFO("Encoded[%d] preview mode and same resolution", sc->info_image->preview_format);
                                /* No need to restart preview */
                                info->restart_preview = FALSE;
+                       } else if (info->use_videoscale &&
+                               info->preview_width >= info->video_width &&
+                               info->preview_height >= info->video_height) {
+                               info->restart_preview = FALSE;
                        } else {
-                               /* always need to restart preview  */
                                info->restart_preview = TRUE;
+                               /* reset use_videoscale */
+                               info->use_videoscale = FALSE;
                        }
 
                        /* set recording hint */
@@ -668,7 +754,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                        if (info->restart_preview) {
                                /* stop preview and set new size */
-                               _mmcam_dbg_log("restart preview");
+                               MMCAM_LOG_INFO("restart preview");
 
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
@@ -678,7 +764,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                                /* check decoder recreation */
                                if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
-                                       _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+                                       MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
                                        ret = MM_ERROR_CAMCORDER_INTERNAL;
                                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
                                }
@@ -701,11 +787,11 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
 
                                if (motion_rate < 1.0) {
-                                       _mmcam_dbg_warn("wait for stabilization of frame");
+                                       MMCAM_LOG_WARNING("wait for stabilization of frame");
                                        usleep(300000);
                                }
                        } else {
-                               _mmcam_dbg_log("no need to restart preview");
+                               MMCAM_LOG_INFO("no need to restart preview");
                        }
 
                        _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
@@ -718,7 +804,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                "PassFirstVideoFrame",
                                &(sc->pass_first_vframe));
 
-                       _mmcam_dbg_log("Drop video frame count[%d], Pass fisrt video frame count[%d]",
+                       MMCAM_LOG_INFO("Drop video frame count[%d], Pass fisrt video frame count[%d]",
                                sc->drop_vframe, sc->pass_first_vframe);
 
                        info->record_drop_count = (guint)motion_rate;
@@ -728,15 +814,14 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        else
                                info->record_timestamp_ratio = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
 
-                       _mmcam_dbg_warn("recording fps %d, motion rate %f, timestamp_ratio %f",
+                       MMCAM_LOG_WARNING("recording fps %d, motion rate %f, timestamp_ratio %f",
                                fps, info->record_motion_rate, info->record_timestamp_ratio);
 
                        /* set push buffer flag */
                        info->push_encoding_buffer = PUSH_ENCODING_BUFFER_INIT;
                        info->base_video_ts = 0;
 
-                       /* connect video stream cb signal */
-                       /*130826 Connect video stream cb for handling fast record frame cb*/
+                       /* connect video stream cb signal if it supports dual stream. */
                        if (info->record_dual_stream) {
                                if (_mmcamcorder_connect_video_stream_cb_signal((MMHandleType)hcamcorder) != MM_ERROR_NONE)
                                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
@@ -748,12 +833,12 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                if (CameraControl) {
                                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
 
-                                       _mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_START");
+                                       MMCAM_LOG_INFO("GST_CAMERA_CONTROL_RECORD_COMMAND_START");
                                        gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_START);
 
                                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
                                } else {
-                                       _mmcam_dbg_err("could not get camera control");
+                                       MMCAM_LOG_ERROR("could not get camera control");
                                }
                        }
 
@@ -785,7 +870,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        */
 
                        info->video_frame_count = 0;
-                       info->is_firstframe = TRUE;
+                       info->is_first_frame = TRUE;
                        info->audio_frame_count = 0;
                        info->filesize = 0;
                        sc->ferror_send = FALSE;
@@ -802,19 +887,19 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                        if (CameraControl) {
                                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
 
-                                               _mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
+                                               MMCAM_LOG_INFO("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
                                                gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
 
                                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
                                        } else {
-                                               _mmcam_dbg_err("failed to get camera control");
+                                               MMCAM_LOG_ERROR("failed to get camera control");
                                        }
                                }
 
                                /* Remove recorder pipeline and recording file which size maybe zero */
                                _mmcamcorder_remove_recorder_pipeline((MMHandleType)hcamcorder);
                                if (info->filename) {
-                                       _mmcam_dbg_log("file delete(%s)", info->filename);
+                                       MMCAM_LOG_INFO("file delete(%s)", info->filename);
                                        unlink(info->filename);
                                }
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
@@ -826,7 +911,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                        MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval, NULL) == MM_ERROR_NONE)
                                        _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
                                else
-                                       _mmcam_dbg_err("get gop interval failed");
+                                       MMCAM_LOG_ERROR("get gop interval failed");
                        }
                } else {
                        /* Resume case */
@@ -835,19 +920,19 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                        MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval, NULL) == MM_ERROR_NONE)
                                        _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
                                else
-                                       _mmcam_dbg_err("get gop interval failed");
+                                       MMCAM_LOG_ERROR("get gop interval failed");
                        }
 
                        MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "runtime-pause", FALSE);
 
-                       _mmcam_dbg_log("Object property settings done");
+                       MMCAM_LOG_INFO("Object property settings done");
                }
        }
                break;
        case _MMCamcorder_CMD_PAUSE:
        {
-               if (info->b_commiting) {
-                       _mmcam_dbg_warn("now on commiting previous file!!(command : %d)", command);
+               if (info->b_committing) {
+                       MMCAM_LOG_WARNING("now on committing previous file!!(command : %d)", command);
                        return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
                }
 
@@ -857,10 +942,10 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
                                        break;
                                } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
-                                       _mmcam_dbg_err("Pause fail, frame count %"G_GUINT64_FORMAT, info->video_frame_count);
+                                       MMCAM_LOG_ERROR("Pause fail, frame count %"G_GUINT64_FORMAT, info->video_frame_count);
                                        return MM_ERROR_CAMCORDER_INVALID_CONDITION;
                                } else {
-                                       _mmcam_dbg_warn("Waiting for enough video frame, retrial[%d], frame %"G_GUINT64_FORMAT, count, info->video_frame_count);
+                                       MMCAM_LOG_WARNING("Waiting for enough video frame, retrial[%d], frame %"G_GUINT64_FORMAT, count, info->video_frame_count);
                                }
 
                                usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
@@ -869,11 +954,11 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
                                        break;
                                } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
-                                       _mmcam_dbg_err("Pause fail, frame count VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"]",
+                                       MMCAM_LOG_ERROR("Pause fail, frame count VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"]",
                                                info->video_frame_count, info->audio_frame_count);
                                        return MM_ERROR_CAMCORDER_INVALID_CONDITION;
                                } else {
-                                       _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"]",
+                                       MMCAM_LOG_WARNING("Waiting for enough frames, retrial [%d], VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"]",
                                                count, info->video_frame_count, info->audio_frame_count);
                                }
 
@@ -887,8 +972,8 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
        }
        case _MMCamcorder_CMD_CANCEL:
        {
-               if (info->b_commiting) {
-                       _mmcam_dbg_warn("now on commiting previous file!!(command : %d)", command);
+               if (info->b_committing) {
+                       MMCAM_LOG_WARNING("now on committing previous file!!(command : %d)", command);
                        return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
                }
 
@@ -897,11 +982,11 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        if (hcamcorder->capture_in_recording == FALSE) {
                                break;
                        } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
-                               _mmcam_dbg_err("Failed to Wait capture data");
+                               MMCAM_LOG_ERROR("Failed to Wait capture data");
                                hcamcorder->capture_in_recording = FALSE;
                                break;
                        } else {
-                               _mmcam_dbg_warn("Waiting for capture data - retrial [%d]", count);
+                               MMCAM_LOG_WARNING("Waiting for capture data - retrial [%d]", count);
                        }
 
                        usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
@@ -923,12 +1008,12 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        if (CameraControl) {
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
 
-                               _mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
+                               MMCAM_LOG_INFO("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
                                gst_camera_control_set_record_command(CameraControl, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
 
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
                        } else {
-                               _mmcam_dbg_err("failed to get camera control");
+                               MMCAM_LOG_ERROR("failed to get camera control");
                        }
                }
 
@@ -942,7 +1027,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                        /* check decoder recreation */
                        if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
-                               _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+                               MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
                                ret = MM_ERROR_CAMCORDER_INTERNAL;
                        }
 
@@ -968,7 +1053,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                /* remove target file */
                if (info->filename) {
-                       _mmcam_dbg_log("file delete(%s)", info->filename);
+                       MMCAM_LOG_INFO("file delete(%s)", info->filename);
                        unlink(info->filename);
                }
 
@@ -987,12 +1072,12 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
        {
                guint64 free_space;
 
-               if (info->b_commiting) {
-                       _mmcam_dbg_err("now on commiting previous file!!(command : %d)", command);
+               if (info->b_committing) {
+                       MMCAM_LOG_ERROR("now on committing previous file!!(command : %d)", command);
                        return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
                } else {
-                       _mmcam_dbg_log("_MMCamcorder_CMD_COMMIT : start");
-                       info->b_commiting = TRUE;
+                       MMCAM_LOG_INFO("_MMCamcorder_CMD_COMMIT : start");
+                       info->b_committing = TRUE;
                        sc->bget_eos = FALSE;
                }
 
@@ -1003,17 +1088,17 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                    hcamcorder->capture_in_recording == FALSE) {
                                        break;
                                } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
-                                       _mmcam_dbg_err("Commit fail, frame count is %"G_GUINT64_FORMAT", capturing %d",
+                                       MMCAM_LOG_ERROR("Commit fail, frame count is %"G_GUINT64_FORMAT", capturing %d",
                                                info->video_frame_count, hcamcorder->capture_in_recording);
 
                                        if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME) {
-                                               _mmcam_dbg_warn("video frames are enough. keep going...");
+                                               MMCAM_LOG_WARNING("video frames are enough. keep going...");
                                        } else {
-                                               info->b_commiting = FALSE;
+                                               info->b_committing = FALSE;
                                                return MM_ERROR_CAMCORDER_INVALID_CONDITION;
                                        }
                                } else {
-                                       _mmcam_dbg_warn("Waiting for enough video frame, retrial [%d], frame %"G_GUINT64_FORMAT", capturing %d",
+                                       MMCAM_LOG_WARNING("Waiting for enough video frame, retrial [%d], frame %"G_GUINT64_FORMAT", capturing %d",
                                                count, info->video_frame_count, hcamcorder->capture_in_recording);
                                }
                        } else {
@@ -1023,19 +1108,19 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                    hcamcorder->capture_in_recording == FALSE) {
                                        break;
                                } else if (count == _MMCAMCORDER_RETRIAL_COUNT) {
-                                       _mmcam_dbg_err("Commit fail, VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"], capturing %d",
+                                       MMCAM_LOG_ERROR("Commit fail, VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"], capturing %d",
                                                info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
 
                                        if (info->video_frame_count >= _MMCAMCORDER_MINIMUM_FRAME && info->audio_frame_count) {
-                                               _mmcam_dbg_warn("video/audio frames are enough. keep going...");
+                                               MMCAM_LOG_WARNING("video/audio frames are enough. keep going...");
                                        } else {
-                                               info->b_commiting = FALSE;
+                                               info->b_committing = FALSE;
                                                return MM_ERROR_CAMCORDER_INVALID_CONDITION;
                                        }
 
                                        return MM_ERROR_CAMCORDER_INVALID_CONDITION;
                                } else {
-                                       _mmcam_dbg_warn("Waiting for enough frames, retrial [%d], VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"], capturing %d",
+                                       MMCAM_LOG_WARNING("Waiting for enough frames, retrial [%d], VIDEO[%"G_GUINT64_FORMAT"], AUDIO [%"G_GUINT64_FORMAT"], capturing %d",
                                                count, info->video_frame_count, info->audio_frame_count, hcamcorder->capture_in_recording);
                                }
                        }
@@ -1043,7 +1128,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        if (hcamcorder->capture_in_recording) {
                                gint64 end_time = g_get_monotonic_time() + (200 * G_TIME_SPAN_MILLISECOND);
                                if (!_MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time))
-                                       _mmcam_dbg_warn("timeout");
+                                       MMCAM_LOG_WARNING("timeout");
                        } else {
                                usleep(_MMCAMCORDER_FRAME_WAIT_TIME);
                        }
@@ -1051,42 +1136,42 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                /* block push buffer */
                info->push_encoding_buffer = PUSH_ENCODING_BUFFER_STOP;
-               _mmcam_dbg_log("block push buffer to appsrc");
+               MMCAM_LOG_INFO("block push buffer to appsrc");
 
                _mmcamcorder_get_freespace(hcamcorder->storage_info.type, &free_space);
                if (free_space < _MMCAMCORDER_MINIMUM_SPACE) {
-                       _mmcam_dbg_warn("_MMCamcorder_CMD_COMMIT out of storage [%" G_GUINT64_FORMAT "]", free_space);
+                       MMCAM_LOG_WARNING("_MMCamcorder_CMD_COMMIT out of storage [%" G_GUINT64_FORMAT "]", free_space);
                        ret = MM_ERROR_OUT_OF_STORAGE;
                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
                }
 
                if (sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst != NULL) {
                        if (gst_element_send_event(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, gst_event_new_eos())) {
-                               _mmcam_dbg_warn("VIDEO: send eos to appsrc done");
+                               MMCAM_LOG_WARNING("VIDEO: send eos to appsrc done");
                        } else {
-                               _mmcam_dbg_err("VIDEO: send EOS failed");
-                               info->b_commiting = FALSE;
+                               MMCAM_LOG_ERROR("VIDEO: send EOS failed");
+                               info->b_committing = FALSE;
                                ret = MM_ERROR_CAMCORDER_INTERNAL;
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
                        }
                } else {
-                       _mmcam_dbg_err("No video stream source");
-                       info->b_commiting = FALSE;
+                       MMCAM_LOG_ERROR("No video stream source");
+                       info->b_committing = FALSE;
                        ret = MM_ERROR_CAMCORDER_INTERNAL;
                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
                }
 
                if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst != NULL) {
                        if (gst_element_send_event(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, gst_event_new_eos())) {
-                               _mmcam_dbg_warn("AUDIO: send eos to audiosrc done");
+                               MMCAM_LOG_WARNING("AUDIO: send eos to audiosrc done");
                        } else {
-                               _mmcam_dbg_err("AUDIO: send EOS failed");
-                               info->b_commiting = FALSE;
+                               MMCAM_LOG_ERROR("AUDIO: send EOS failed");
+                               info->b_committing = FALSE;
                                ret = MM_ERROR_CAMCORDER_INTERNAL;
                                goto _ERR_CAMCORDER_VIDEO_COMMAND;
                        }
                } else {
-                       _mmcam_dbg_log("No audio stream");
+                       MMCAM_LOG_INFO("No audio stream");
                }
 
                /* sc */
@@ -1094,10 +1179,10 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                sc->previous_slot_time = 0;
 
                /* Wait EOS */
-               _mmcam_dbg_log("Start to wait EOS");
+               MMCAM_LOG_INFO("Start to wait EOS");
                ret = _mmcamcorder_get_eos_message(handle);
                if (ret != MM_ERROR_NONE) {
-                       info->b_commiting = FALSE;
+                       info->b_committing = FALSE;
                        goto _ERR_CAMCORDER_VIDEO_COMMAND;
                }
 
@@ -1140,7 +1225,7 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
 
        info = sc->info_video;
 
-       _mmcam_dbg_err("");
+       MMCAM_LOG_ERROR("");
 
        /* Play record stop sound */
        _mmcamcorder_sound_solo_play(handle, _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_STOP, FALSE);
@@ -1154,7 +1239,7 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
 
        ret = _mmcamcorder_remove_recorder_pipeline((MMHandleType)hcamcorder);
        if (ret != MM_ERROR_NONE)
-               _mmcam_dbg_warn("_MMCamcorder_CMD_COMMIT:__mmcamcorder_remove_recorder_pipeline failed. error[%x]", ret);
+               MMCAM_LOG_WARNING("_MMCamcorder_CMD_COMMIT:__mmcamcorder_remove_recorder_pipeline failed. error[%x]", ret);
 
        /* set recording hint */
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "recording-hint", FALSE);
@@ -1165,29 +1250,29 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
                if (control) {
                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", TRUE);
 
-                       _mmcam_dbg_log("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
+                       MMCAM_LOG_INFO("GST_CAMERA_CONTROL_RECORD_COMMAND_STOP");
                        gst_camera_control_set_record_command(control, GST_CAMERA_CONTROL_RECORD_COMMAND_STOP);
 
                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "stop-video", FALSE);
                } else {
-                       _mmcam_dbg_err("failed to get camera control");
+                       MMCAM_LOG_ERROR("failed to get camera control");
                }
        }
 
        if (enabletag && !(sc->ferror_send)) {
                ret = __mmcamcorder_add_metadata((MMHandleType)hcamcorder, info->fileformat);
-               _mmcam_dbg_log("Writing location information [%s] !!", ret ? "SUCCEEDED" : "FAILED");
+               MMCAM_LOG_INFO("Writing location information [%s] !!", ret ? "SUCCEEDED" : "FAILED");
        }
 
        /* Check file size */
        if (info->max_size > 0) {
                _mmcamcorder_get_file_size(info->filename, &file_size);
-               _mmcam_dbg_log("MAX size %"G_GUINT64_FORMAT" byte - created filesize %"G_GUINT64_FORMAT" byte",
+               MMCAM_LOG_INFO("MAX size %"G_GUINT64_FORMAT" byte - created filesize %"G_GUINT64_FORMAT" byte",
                                           info->max_size, file_size);
 
                if (file_size > info->max_size) {
                        _MMCamcorderMsgItem message;
-                       _mmcam_dbg_err("File size is greater than max size !!");
+                       MMCAM_LOG_ERROR("File size is greater than max size !!");
                        message.id = MM_MESSAGE_CAMCORDER_ERROR;
                        message.param.code = MM_ERROR_CAMCORDER_FILE_SIZE_OVER;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &message);
@@ -1200,12 +1285,12 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "keep-camera-preview", TRUE);
 
-               _mmcam_dbg_log("Set state of pipeline as READY");
+               MMCAM_LOG_INFO("Set state of pipeline as READY");
                ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
 
                /* check decoder recreation */
                if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
-                       _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
+                       MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
                        ret = MM_ERROR_CAMCORDER_INTERNAL;
                }
 
@@ -1218,7 +1303,7 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
                        msg.id = MM_MESSAGE_CAMCORDER_ERROR;
                        msg.param.code = ret;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-                       _mmcam_dbg_err("Failed to set state READY[%x]", ret);
+                       MMCAM_LOG_ERROR("Failed to set state READY[%x]", ret);
                }
 
                /* reset restart_preview for inset window layout */
@@ -1229,7 +1314,7 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
                        msg.id = MM_MESSAGE_CAMCORDER_ERROR;
                        msg.param.code = MM_ERROR_CAMCORDER_INTERNAL;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-                       _mmcam_dbg_err("Failed to set camera resolution %dx%d",
+                       MMCAM_LOG_ERROR("Failed to set camera resolution %dx%d",
                                info->preview_width, info->preview_height);
                }
 
@@ -1240,23 +1325,19 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
                        msg.id = MM_MESSAGE_CAMCORDER_ERROR;
                        msg.param.code = ret;
                        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-                       _mmcam_dbg_err("Failed to set state PLAYING[%x]", ret);
+                       MMCAM_LOG_ERROR("Failed to set state PLAYING[%x]", ret);
                }
        } else {
-               _mmcam_dbg_log("No need to restart preview");
+               MMCAM_LOG_INFO("No need to restart preview");
        }
 
        /* Send recording report to application */
        msg.id = MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED;
        report = (MMCamRecordingReport *)g_malloc(sizeof(MMCamRecordingReport));
-       if (!report) {
-               _mmcam_dbg_err("Recording report fail(%s). Out of memory.", info->filename);
-       } else {
-               report->recording_filename = g_strdup(info->filename);
-               msg.param.data = report;
-               msg.param.code = 1;
-               _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-       }
+       report->recording_filename = g_strdup(info->filename);
+       msg.param.data = report;
+       msg.param.code = 1;
+       _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
 
        /* Finishing */
        sc->pipeline_time = 0;
@@ -1268,12 +1349,12 @@ int _mmcamcorder_video_handle_eos(MMHandleType handle)
        info->video_frame_count = 0;
        info->audio_frame_count = 0;
        info->filesize = 0;
-       info->b_commiting = FALSE;
+       info->b_committing = FALSE;
 
        /* check recording stop sound */
        _mmcamcorder_sound_solo_play_wait(handle);
 
-       _mmcam_dbg_err("_MMCamcorder_CMD_COMMIT : end");
+       MMCAM_LOG_ERROR("_MMCamcorder_CMD_COMMIT : end");
 
        return TRUE;
 }
@@ -1300,15 +1381,13 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPad
 
        /* get buffer size */
        if (!gst_buffer_map(buffer, &mapinfo, GST_MAP_READ)) {
-               _mmcam_dbg_warn("map failed : buffer %p", buffer);
+               MMCAM_LOG_WARNING("map failed : buffer %p", buffer);
                return GST_PAD_PROBE_OK;
        }
 
        buffer_size = mapinfo.size;
        gst_buffer_unmap(buffer, &mapinfo);
 
-       /*_mmcam_dbg_err("[%" GST_TIME_FORMAT "]", GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));*/
-
        g_mutex_lock(&videoinfo->size_check_lock);
 
        if (videoinfo->audio_frame_count == 0) {
@@ -1319,7 +1398,7 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPad
        }
 
        if (sc->ferror_send || sc->isMaxsizePausing) {
-               _mmcam_dbg_warn("Recording is paused, drop frames");
+               MMCAM_LOG_WARNING("Recording is paused, drop frames");
                g_mutex_unlock(&videoinfo->size_check_lock);
                return GST_PAD_PROBE_DROP;
        }
@@ -1335,9 +1414,9 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPad
        if (videoinfo->max_size > 0 && videoinfo->max_size < max_size) {
                GstState pipeline_state = GST_STATE_VOID_PENDING;
                GstElement *pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
-               _mmcam_dbg_warn("Max size!!! Recording is paused.");
-               _mmcam_dbg_warn("Max size : [%" G_GUINT64_FORMAT "], current file size : [%" G_GUINT64_FORMAT "]," \
-                       " buffer size : [%" G_GUINT64_FORMAT "], trailer size : [%" G_GUINT64_FORMAT "]",
+
+               MMCAM_LOG_WARNING("Max size[%"G_GUINT64_FORMAT"], current size[%"G_GUINT64_FORMAT"],"\
+                       " buffer size[%"G_GUINT64_FORMAT"], trailer size[%"G_GUINT64_FORMAT"]",
                        videoinfo->max_size, videoinfo->filesize, buffer_size, trailer_size);
 
                if (!sc->isMaxsizePausing) {
@@ -1358,13 +1437,16 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPad
        videoinfo->filesize += buffer_size;
        videoinfo->audio_frame_count++;
 
+       MMCAM_LOG_DEBUG("video rec[%"GST_TIME_FORMAT"], size[%"G_GUINT64_FORMAT"(trailer:%"G_GUINT64_FORMAT")]",
+               GST_TIME_ARGS(GST_BUFFER_PTS(buffer)), videoinfo->filesize + trailer_size, trailer_size);
+
        g_mutex_unlock(&videoinfo->size_check_lock);
 
        return GST_PAD_PROBE_OK;
 }
 
 
-static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+static GstPadProbeReturn __mmcamcorder_video_dataprobe_encoded(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
        gint ret = 0;
        guint vq_size = 0;
@@ -1390,9 +1472,8 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
        mmf_return_val_if_fail(sc && sc->info_video, GST_PAD_PROBE_OK);
        videoinfo = sc->info_video;
 
-       /*_mmcam_dbg_log("[%" GST_TIME_FORMAT "]", GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));*/
        if (sc->ferror_send) {
-               _mmcam_dbg_warn("file write error, drop frames");
+               MMCAM_LOG_WARNING("file write error, drop frames");
                return GST_PAD_PROBE_DROP;
        }
 
@@ -1402,8 +1483,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
 
        videoinfo->video_frame_count++;
        if (videoinfo->video_frame_count <= (guint64)_MMCAMCORDER_MINIMUM_FRAME) {
-               /* _mmcam_dbg_log("Pass minimum frame: info->video_frame_count: %" G_GUINT64_FORMAT " ",
-                       info->video_frame_count); */
+               MMCAM_LOG_DEBUG("Pass minimum frame[%"G_GUINT64_FORMAT"]", videoinfo->video_frame_count);
                g_mutex_lock(&videoinfo->size_check_lock);
                videoinfo->filesize += buffer_size;
                g_mutex_unlock(&videoinfo->size_check_lock);
@@ -1419,7 +1499,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
        /* check free space */
        ret = _mmcamcorder_get_freespace(hcamcorder->storage_info.type, &free_space);
        if (ret != 0) {
-               _mmcam_dbg_err("Error occured. [%d]", ret);
+               MMCAM_LOG_ERROR("Error occurred. [%d]", ret);
                if (sc->ferror_count == 2 && sc->ferror_send == FALSE) {
                        sc->ferror_send = TRUE;
 
@@ -1438,16 +1518,16 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
                /* check storage state */
                storage_get_state(hcamcorder->storage_info.id, &storage_state);
 
-               _mmcam_dbg_warn("storage state %d", storage_state);
+               MMCAM_LOG_WARNING("storage state %d", storage_state);
 
                if (storage_state == STORAGE_STATE_REMOVED ||
                        storage_state == STORAGE_STATE_UNMOUNTABLE) {
-                       _mmcam_dbg_err("storage was removed!");
+                       MMCAM_LOG_ERROR("storage was removed!");
 
                        _MMCAMCORDER_LOCK(hcamcorder);
 
                        if (sc->ferror_send == FALSE) {
-                               _mmcam_dbg_err("OUT_OF_STORAGE error");
+                               MMCAM_LOG_ERROR("OUT_OF_STORAGE error");
 
                                sc->ferror_send = TRUE;
 
@@ -1459,7 +1539,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
                                _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
                        } else {
                                _MMCAMCORDER_UNLOCK(hcamcorder);
-                               _mmcam_dbg_warn("error was already sent");
+                               MMCAM_LOG_WARNING("error was already sent");
                        }
 
                        return GST_PAD_PROBE_DROP;
@@ -1476,8 +1556,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
        queued_buffer = aq_size + vq_size;
 
        if (free_space < (_MMCAMCORDER_MINIMUM_SPACE + buffer_size + trailer_size + queued_buffer)) {
-               _mmcam_dbg_warn("No more space for recording!!! Recording is paused.");
-               _mmcam_dbg_warn("Free Space : [%" G_GUINT64_FORMAT "], trailer size : [%" G_GUINT64_FORMAT "]," \
+               MMCAM_LOG_WARNING("Free Space : [%" G_GUINT64_FORMAT "], trailer size : [%" G_GUINT64_FORMAT "]," \
                        " buffer size : [%" G_GUINT64_FORMAT "], queued buffer size : [%" G_GUINT64_FORMAT "]", \
                        free_space, trailer_size, buffer_size, queued_buffer);
 
@@ -1499,8 +1578,8 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
        if (videoinfo->max_size > 0 && videoinfo->max_size < max_size) {
                GstState pipeline_state = GST_STATE_VOID_PENDING;
                GstElement *pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
-               _mmcam_dbg_warn("Max size!!! Recording is paused.");
-               _mmcam_dbg_warn("Max size : [%" G_GUINT64_FORMAT "], current file size : [%" G_GUINT64_FORMAT "]," \
+
+               MMCAM_LOG_WARNING("Max size : [%" G_GUINT64_FORMAT "], current file size : [%" G_GUINT64_FORMAT "]," \
                        " buffer size : [%" G_GUINT64_FORMAT "], trailer size : [%" G_GUINT64_FORMAT "]",
                        videoinfo->max_size, videoinfo->filesize, buffer_size, trailer_size);
 
@@ -1521,9 +1600,8 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPa
 
        videoinfo->filesize += (guint64)buffer_size;
 
-       /*
-       _mmcam_dbg_log("filesize %lld Byte, ", videoinfo->filesize);
-       */
+       MMCAM_LOG_DEBUG("video rec[%"GST_TIME_FORMAT"], size[%"G_GUINT64_FORMAT"(trailer:%"G_GUINT64_FORMAT")]",
+               GST_TIME_ARGS(GST_BUFFER_PTS(buffer)), videoinfo->filesize + trailer_size, trailer_size);
 
        g_mutex_unlock(&videoinfo->size_check_lock);
 
@@ -1566,7 +1644,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad
 
        /* check max time */
        if (videoinfo->max_time > 0 && rec_pipe_time > videoinfo->max_time) {
-               _mmcam_dbg_warn("Time current [%" G_GUINT64_FORMAT "], Max [%" G_GUINT64_FORMAT "], motion rate [%lf]", \
+               MMCAM_LOG_WARNING("Time current [%" G_GUINT64_FORMAT "], Max [%" G_GUINT64_FORMAT "], motion rate [%lf]", \
                        rec_pipe_time, videoinfo->max_time, videoinfo->record_motion_rate);
 
                if (!sc->isMaxtimePausing) {
@@ -1603,32 +1681,21 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad
        msg.param.recording_status.remained_time = remained_time;
        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
 
-       /*
-       _mmcam_dbg_log("time [%" GST_TIME_FORMAT "], size [%d]",
-               GST_TIME_ARGS(rec_pipe_time), msg.param.recording_status.filesize);
-       */
-
        if (videoinfo->record_timestamp_ratio != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) {
                guint record_motion_rate = (guint)videoinfo->record_motion_rate;
 
-               /*
-               _mmcam_dbg_log("record_motion_rate %d, videoinfo->record_drop_count %d",
+               MMCAM_LOG_VERBOSE("record_motion_rate[%u], videoinfo->record_drop_count[%u]",
                        record_motion_rate, videoinfo->record_drop_count);
-               */
 
                /* drop some frame if fast motion */
                if (videoinfo->record_motion_rate > _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) {
                        if (record_motion_rate != (videoinfo->record_drop_count++)) {
-                               /*
-                               _mmcam_dbg_warn("drop frame");
-                               */
+                               MMCAM_LOG_VERBOSE("drop frame");
                                return GST_PAD_PROBE_DROP;
                        }
 
                        videoinfo->record_drop_count = 1;
-                       /*
-                       _mmcam_dbg_warn("pass frame");
-                       */
+                       MMCAM_LOG_VERBOSE("pass frame");
                }
 
                GST_BUFFER_PTS(buffer) = b_time * (videoinfo->record_timestamp_ratio);
@@ -1661,7 +1728,7 @@ static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadPro
        videoinfo = sc->info_video;
 
        if (!GST_CLOCK_TIME_IS_VALID(GST_BUFFER_PTS(buffer))) {
-               _mmcam_dbg_err("Buffer timestamp is invalid, check it");
+               MMCAM_LOG_ERROR("Buffer timestamp is invalid, check it");
                return GST_PAD_PROBE_OK;
        }
 
@@ -1683,7 +1750,7 @@ static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadPro
        }
 
        if (videoinfo->max_time > 0 && rec_pipe_time > videoinfo->max_time) {
-               _mmcam_dbg_warn("Time current [%" G_GUINT64_FORMAT "], Max [%" G_GUINT64_FORMAT "], motion rate [%lf]", \
+               MMCAM_LOG_WARNING("Time current [%" G_GUINT64_FORMAT "], Max [%" G_GUINT64_FORMAT "], motion rate [%lf]", \
                        rec_pipe_time, videoinfo->max_time, videoinfo->record_motion_rate);
 
                if (!sc->isMaxtimePausing) {
@@ -1710,10 +1777,8 @@ static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadPro
        msg.param.recording_status.remained_time = remained_time;
        _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
 
-       /*
-       _mmcam_dbg_log("audio data probe :: time [%" GST_TIME_FORMAT "], size [%lld KB]",
-               GST_TIME_ARGS(rec_pipe_time), msg.param.recording_status.filesize);
-       */
+       MMCAM_LOG_DEBUG("audio data probe[%" GST_TIME_FORMAT "], size[%"G_GUINT64_FORMAT"]",
+               GST_TIME_ARGS(GST_BUFFER_PTS(buffer)), videoinfo->filesize + trailer_size);
 
        return GST_PAD_PROBE_OK;
 }
@@ -1733,14 +1798,13 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_audio_mute(GstPad *pad, G
        mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
        mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_DROP);
 
-       /*_mmcam_dbg_log("AUDIO SRC time stamp : [%" GST_TIME_FORMAT "] \n", GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));*/
        err = mm_camcorder_get_attributes((MMHandleType)hcamcorder, &err_name,
                MMCAM_AUDIO_VOLUME, &volume,
                MMCAM_AUDIO_FORMAT, &format,
                MMCAM_AUDIO_CHANNEL, &channel,
                NULL);
        if (err != MM_ERROR_NONE) {
-               _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
+               MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, err);
                SAFE_FREE(err_name);
                return err;
        }
@@ -1753,24 +1817,24 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_audio_mute(GstPad *pad, G
        if (volume == 0.0)
                memset(mapinfo.data, 0, mapinfo.size);
 
+       MMCAM_LOG_DEBUG("audio stream[%"GST_TIME_FORMAT"] - cb[%p], fmt[%d], ch[%d], size[%"G_GSIZE_FORMAT"]",
+               GST_TIME_ARGS(GST_BUFFER_PTS(buffer)), hcamcorder->astream_cb, format, channel, mapinfo.size);
+
        /* CALL audio stream callback */
        if (hcamcorder->astream_cb && buffer && mapinfo.data && mapinfo.size > 0) {
                MMCamcorderAudioStreamDataType stream;
 
                if (_mmcamcorder_get_state((MMHandleType)hcamcorder) < MM_CAMCORDER_STATE_PREPARE) {
-                       _mmcam_dbg_warn("Not ready for stream callback");
+                       MMCAM_LOG_WARNING("Not ready for stream callback");
                        gst_buffer_unmap(buffer, &mapinfo);
                        return GST_PAD_PROBE_OK;
                }
 
-               /*_mmcam_dbg_log("Call video steramCb, data[%p], Width[%d],Height[%d], Format[%d]",
-                       GST_BUFFER_DATA(buffer), width, height, format);*/
-
                stream.data = (void *)mapinfo.data;
                stream.format = format;
                stream.channel = channel;
                stream.length = mapinfo.size;
-               stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer)/1000000); /* nano -> milli second */
+               stream.timestamp = (unsigned int)(GST_TIME_AS_MSECONDS(GST_BUFFER_PTS(buffer)));
 
                _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(hcamcorder);
 
@@ -1781,6 +1845,7 @@ static GstPadProbeReturn __mmcamcorder_audio_dataprobe_audio_mute(GstPad *pad, G
        }
 
        gst_buffer_unmap(buffer, &mapinfo);
+
        return GST_PAD_PROBE_OK;
 }
 
@@ -1795,7 +1860,7 @@ static gboolean __mmcamcorder_add_metadata(MMHandleType handle, int fileformat)
                bret = __mmcamcorder_add_metadata_mp4(handle);
                break;
        default:
-               _mmcam_dbg_warn("Unsupported fileformat to insert location info (%d)", fileformat);
+               MMCAM_LOG_WARNING("Unsupported fileformat to insert location info (%d)", fileformat);
                break;
        }
 
@@ -1832,14 +1897,14 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
        mmf_return_val_if_fail(sc->info_video, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       _mmcam_dbg_log("");
+       MMCAM_LOG_INFO("");
 
        info = sc->info_video;
 
        f = fopen64(info->filename, "rb+");
        if (f == NULL) {
                strerror_r(errno, err_msg, MAX_ERROR_MESSAGE_LEN);
-               _mmcam_dbg_err("file open failed [%s]", err_msg);
+               MMCAM_LOG_ERROR("file open failed [%s]", err_msg);
                return FALSE;
        }
 
@@ -1851,7 +1916,7 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
                MMCAM_TAG_GPS_ENABLE, &gps_enable,
                NULL);
        if (err_name) {
-               _mmcam_dbg_warn("Get tag attrs fail. (%s:%x)", err_name, err);
+               MMCAM_LOG_WARNING("Get tag attrs fail. (%s:%x)", err_name, err);
                SAFE_FREE(err_name);
        }
 
@@ -1867,7 +1932,7 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
        if (_mmcamcorder_find_fourcc(f, MMCAM_FOURCC('u', 'd', 't', 'a'), TRUE)) {
                size_t nread = 0;
 
-               _mmcam_dbg_log("find udta container");
+               MMCAM_LOG_INFO("find udta container");
 
                /* read size */
                if (fseek(f, -8L, SEEK_CUR) != 0)
@@ -1879,7 +1944,7 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
 
                nread = fread(&buf, sizeof(char), sizeof(buf), f);
 
-               _mmcam_dbg_log("recorded file fread %zu", nread);
+               MMCAM_LOG_INFO("recorded file fread %zu", nread);
 
                udta_size = _mmcamcorder_get_container_size(buf);
 
@@ -1889,12 +1954,12 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
 
                if (gps_enable) {
                        if (!_mmcamcorder_write_loci(f, location_info)) {
-                               _mmcam_dbg_err("failed to write loci");
+                               MMCAM_LOG_ERROR("failed to write loci");
                                goto fail;
                        }
 
                        if (!_mmcamcorder_write_geodata(f, geo_info)) {
-                               _mmcam_dbg_err("failed to write geodata");
+                               MMCAM_LOG_ERROR("failed to write geodata");
                                goto fail;
                        }
                }
@@ -1906,12 +1971,12 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
                if (!_mmcamcorder_update_size(f, udta_pos, current_pos))
                        goto fail;
        } else {
-               _mmcam_dbg_log("No udta container");
+               MMCAM_LOG_INFO("No udta container");
                if (fseek(f, 0, SEEK_END) != 0)
                        goto fail;
 
                if (!_mmcamcorder_write_udta(f, gps_enable, location_info, geo_info)) {
-                       _mmcam_dbg_err("failed to write udta");
+                       MMCAM_LOG_ERROR("failed to write udta");
                        goto fail;
                }
        }
@@ -1924,7 +1989,7 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
        if (_mmcamcorder_find_tag(f, MMCAM_FOURCC('m', 'o', 'o', 'v'), TRUE)) {
                gint64 internal_pos = ftello(f);
 
-               _mmcam_dbg_log("found moov container");
+               MMCAM_LOG_INFO("found moov container");
                if (fseek(f, -8L, SEEK_CUR) != 0)
                        goto fail;
 
@@ -1937,32 +2002,32 @@ static gboolean __mmcamcorder_add_metadata_mp4(MMHandleType handle)
 
                /* add orientation info */
                if (fseeko(f, internal_pos, SEEK_SET) < 0) {
-                       _mmcam_dbg_err("fseeko failed : errno %d", errno);
+                       MMCAM_LOG_ERROR("fseeko failed : errno %d", errno);
                        goto fail;
                }
 
                if (!_mmcamcorder_find_tag(f, MMCAM_FOURCC('t', 'r', 'a', 'k'), FALSE)) {
-                       _mmcam_dbg_err("failed to find [trak] tag");
+                       MMCAM_LOG_ERROR("failed to find [trak] tag");
                        goto fail;
                }
 
                if (!_mmcamcorder_find_tag(f, MMCAM_FOURCC('t', 'k', 'h', 'd'), FALSE)) {
-                       _mmcam_dbg_err("failed to find [tkhd] tag");
+                       MMCAM_LOG_ERROR("failed to find [tkhd] tag");
                        goto fail;
                }
 
-               _mmcam_dbg_log("found [tkhd] tag");
+               MMCAM_LOG_INFO("found [tkhd] tag");
 
                /* seek to start position of composition matrix */
-               if (fseek(f, _OFFSET_COMPOSITION_MATRIX, SEEK_CUR) == 0) {
+               if (fseek(f, OFFSET_COMPOSITION_MATRIX, SEEK_CUR) == 0) {
                        /* update composition matrix for orientation */
                        _mmcamcorder_update_composition_matrix(f, orientation);
                } else {
-                       _mmcam_dbg_err("fseek failed : errno %d", errno);
+                       MMCAM_LOG_ERROR("fseek failed : errno %d", errno);
                        goto fail;
                }
        } else {
-               _mmcam_dbg_err("No 'moov' container");
+               MMCAM_LOG_ERROR("No 'moov' container");
                goto fail;
        }
 
@@ -1974,7 +2039,7 @@ fail:
        return FALSE;
 
 ftell_fail:
-       _mmcam_dbg_err("ftell() returns negative value.");
+       MMCAM_LOG_ERROR("ftell() returns negative value.");
        fclose(f);
        return FALSE;
 }
@@ -1992,14 +2057,14 @@ int _mmcamcorder_connect_video_stream_cb_signal(MMHandleType handle)
 
        /* check video source element */
        if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
-               _mmcam_dbg_warn("connect video stream cb signal to _MMCAMCORDER_VIDEOSRC_SRC");
+               MMCAM_LOG_WARNING("connect video stream cb signal to _MMCAMCORDER_VIDEOSRC_SRC");
                MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
                        _MMCAMCORDER_HANDLER_VIDEOREC, "video-stream-cb",
                        G_CALLBACK(__mmcamcorder_video_stream_cb),
                        hcamcorder);
                return MM_ERROR_NONE;
        } else {
-               _mmcam_dbg_err("videosrc element is not created yet");
+               MMCAM_LOG_ERROR("videosrc element is not created yet");
                return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
 }
@@ -2023,7 +2088,7 @@ int _mmcamcorder_video_prepare_record(MMHandleType handle)
 
        info = sc->info_video;
 
-       _mmcam_dbg_warn("start");
+       MMCAM_LOG_WARNING("start");
 
        /* create encoding pipeline */
        ret = _mmcamcorder_create_recorder_pipeline((MMHandleType)hcamcorder);
@@ -2038,14 +2103,14 @@ int _mmcamcorder_video_prepare_record(MMHandleType handle)
        if (temp_filename) {
                info->filename = g_strdup(temp_filename);
                if (!info->filename) {
-                       _mmcam_dbg_err("strdup[src:%p] was failed", temp_filename);
+                       MMCAM_LOG_ERROR("strdup[src:%p] was failed", temp_filename);
                        goto _ERR_PREPARE_RECORD;
                }
 
-               _mmcam_dbg_log("Record file name [%s]", info->filename);
+               MMCAM_LOG_INFO("Record file name [%s]", info->filename);
                MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", info->filename);
        } else {
-               _mmcam_dbg_log("Recorded data will be written in [%s]", _MMCamcorder_FILENAME_NULL);
+               MMCAM_LOG_INFO("Recorded data will be written in [%s]", _MMCamcorder_FILENAME_NULL);
                MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", _MMCamcorder_FILENAME_NULL);
        }
 
@@ -2059,7 +2124,7 @@ int _mmcamcorder_video_prepare_record(MMHandleType handle)
        if (ret != MM_ERROR_NONE)
                goto _ERR_PREPARE_RECORD;
 
-       _mmcam_dbg_warn("done");
+       MMCAM_LOG_WARNING("done");
 
        return ret;
 
@@ -2067,7 +2132,7 @@ _ERR_PREPARE_RECORD:
        /* Remove recorder pipeline and recording file which size maybe zero */
        _mmcamcorder_remove_recorder_pipeline((MMHandleType)hcamcorder);
        if (info && info->filename) {
-               _mmcam_dbg_log("file delete(%s)", info->filename);
+               MMCAM_LOG_INFO("file delete(%s)", info->filename);
                unlink(info->filename);
        }