Always set internal buffer
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_gstcommon.c
index 8e1af22..306f0db 100644 (file)
@@ -25,7 +25,6 @@
 #include <gst/allocators/gsttizenmemory.h>
 #include <gst/audio/audio-format.h>
 #include <gst/video/videooverlay.h>
-#include <gst/video/cameracontrol.h>
 
 #include <sys/time.h>
 #include <unistd.h>
@@ -40,7 +39,7 @@
 |    GLOBAL VARIABLE DEFINITIONS for internal                           |
 -----------------------------------------------------------------------*/
 /* Table for compatibility between audio codec and file format */
-gboolean       audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+static gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
                   /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
 /*AMR*/       { 1,  0,  0,       0,  0,  0,  0, 0,   0,  1,  0,  0,   0, 0,  0,  0,  0,   0,  0,  0,      0,  0,  0,  0,   0,   0},
 /*G723.1*/    { 0,  0,  0,       0,  0,  0,  0, 0,   0,  0,  0,  0,   0, 0,  0,  0,  0,   0,  0,  0,      0,  0,  0,  0,   0,   0},
@@ -89,7 +88,7 @@ gboolean      audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_F
 };
 
 /* Table for compatibility between video codec and file format */
-gboolean       videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+static gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
                          /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
 /*NONE*/         { 0,  0,  0,       0,  0,  0,  0, 0,   0,  0,  0,  0,   0, 0,  0,  0,  0,   0,  0,  0,      0,  0,  0,  0,   0,   0},
 /*H263*/         { 1,  0,  1,       0,  0,  0,  0, 0,   0,  0,  0,  0,   0, 0,  0,  0,  0,   0,  0,  0,      0,  0,  0,  0,   0,   0},
@@ -157,23 +156,34 @@ static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_n
 static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
 #endif /* _MMCAMCORDER_PRODUCT_TV */
 
-static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info);
-static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
+static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
 
 /*=======================================================================================
 |  FUNCTION DEFINITIONS                                                                 |
 =======================================================================================*/
-static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info)
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory)
 {
+       gboolean ret = TRUE;
+       GstMapInfo map_info;
+
        mmf_return_val_if_fail(buffer, FALSE);
-       mmf_return_val_if_fail(map_info, FALSE);
        mmf_return_val_if_fail(stream, FALSE);
 
+       memset(&map_info, 0x0, sizeof(GstMapInfo));
+
+       if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE)) {
+               MMCAM_LOG_ERROR("map failed for memory[%p]", memory);
+               return FALSE;
+       }
+
+       stream->length_total = gst_memory_get_sizes(memory, NULL, NULL);
+
        switch (stream->format) {
        case MM_PIXEL_FORMAT_NV12: /* fall through */
        case MM_PIXEL_FORMAT_NV21:
                stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
-               stream->data.yuv420sp.y = map_info->data;
+               stream->data.yuv420sp.y = map_info.data;
                stream->data.yuv420sp.length_y = stream->width * stream->height;
                stream->data.yuv420sp.uv = stream->data.yuv420sp.y + stream->data.yuv420sp.length_y;
                stream->data.yuv420sp.length_uv = stream->data.yuv420sp.length_y >> 1;
@@ -186,7 +196,7 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
 
        case MM_PIXEL_FORMAT_I420:
                stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
-               stream->data.yuv420p.y = map_info->data;
+               stream->data.yuv420p.y = map_info.data;
                stream->data.yuv420p.length_y = stream->width * stream->height;
                stream->data.yuv420p.u = stream->data.yuv420p.y + stream->data.yuv420p.length_y;
                stream->data.yuv420p.length_u = stream->data.yuv420p.length_y >> 2;
@@ -201,7 +211,7 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
 
        case MM_PIXEL_FORMAT_422P:
                stream->data_type = MM_CAM_STREAM_DATA_YUV422P;
-               stream->data.yuv422p.y = map_info->data;
+               stream->data.yuv422p.y = map_info.data;
                stream->data.yuv422p.length_y = stream->width * stream->height;
                stream->data.yuv422p.u = stream->data.yuv422p.y + stream->data.yuv422p.length_y;
                stream->data.yuv422p.length_u = stream->data.yuv422p.length_y >> 1;
@@ -218,17 +228,19 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
        case MM_PIXEL_FORMAT_UYVY: /* fall through */
        case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
                stream->data_type = MM_CAM_STREAM_DATA_YUV422;
-               stream->data.yuv422.yuv = map_info->data;
+               stream->data.yuv422.yuv = map_info.data;
                stream->data.yuv422.length_yuv = stream->length_total;
                stream->stride[0] = stream->width << 1;
                stream->elevation[0] = stream->height;
                stream->num_planes = 1;
                break;
 
-       case MM_PIXEL_FORMAT_ENCODED_H264: /* fall through */
-       case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+       case MM_PIXEL_FORMAT_ENCODED_H264:  /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_MJPEG: /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_VP8:   /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_VP9:   /* fall through */
                stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
-               stream->data.encoded.data = map_info->data;
+               stream->data.encoded.data = map_info.data;
                stream->data.encoded.length_data = stream->length_total;
                stream->data.encoded.is_delta_frame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
                stream->num_planes = 1;
@@ -236,7 +248,7 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
 
        case MM_PIXEL_FORMAT_INVZ:
                stream->data_type = MM_CAM_STREAM_DATA_DEPTH;
-               stream->data.depth.data = map_info->data;
+               stream->data.depth.data = map_info.data;
                stream->data.depth.length_data = stream->length_total;
                stream->stride[0] = stream->width << 1;
                stream->elevation[0] = stream->height;
@@ -246,7 +258,7 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
        case MM_PIXEL_FORMAT_RGBA: /* fall through */
        case MM_PIXEL_FORMAT_ARGB:
                stream->data_type = MM_CAM_STREAM_DATA_RGB;
-               stream->data.rgb.data = map_info->data;
+               stream->data.rgb.data = map_info.data;
                stream->data.rgb.length_data = stream->length_total;
                stream->stride[0] = stream->width << 2;
                stream->elevation[0] = stream->height;
@@ -254,43 +266,106 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
                break;
 
        default:
-               _mmcam_dbg_err("unsupported format[%d]", stream->format);
-               return FALSE;
+               MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
+               ret = FALSE;
+               break;
        }
 
-       return TRUE;
+       gst_memory_unmap(memory, &map_info);
+
+       return ret;
 }
 
 
-static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info)
+static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory)
 {
-       mmf_return_val_if_fail(ts_info, FALSE);
+       int i = 0;
+       int num_bos = 0;
+       int tbm_ret = TBM_SURFACE_ERROR_NONE;
+       tbm_bo_handle bo_handle = {NULL, };
+       tbm_surface_info_s ts_info;
+
        mmf_return_val_if_fail(stream, FALSE);
+       mmf_return_val_if_fail(buffer, FALSE);
+       mmf_return_val_if_fail(memory, FALSE);
+
+       if (_mmcamcorder_is_encoded_preview_pixel_format(stream->format)) {
+               stream->bo[0] = gst_tizen_memory_get_bos(memory, 0);
+
+               bo_handle = tbm_bo_get_handle(stream->bo[0], TBM_DEVICE_CPU);
+               if (!bo_handle.ptr) {
+                       MMCAM_LOG_ERROR("tbm_bo_get_handle failed[bo:%p,memory:%p]", stream->bo[0], memory);
+                       return FALSE;
+               }
+
+               stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
+               stream->num_planes = 1;
+               stream->stride[0] = stream->width;
+               stream->elevation[0] = stream->height;
+               stream->data.encoded.data = bo_handle.ptr;
+               stream->length_total = gst_memory_get_sizes(memory, NULL, NULL);
+               stream->data.encoded.length_data = stream->length_total;
+               stream->data.encoded.is_delta_frame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+
+               MMCAM_LOG_VERBOSE("[ENCODED] length[%u], is_delta[%d]",
+                       stream->data.encoded.length_data, stream->data.encoded.is_delta_frame);
+
+               return TRUE;
+       }
+
+       memset(&ts_info, 0x0, sizeof(tbm_surface_info_s));
+
+       tbm_ret = tbm_surface_get_info((tbm_surface_h)gst_tizen_memory_get_surface(memory), &ts_info);
+       if (tbm_ret != TBM_SURFACE_ERROR_NONE) {
+               MMCAM_LOG_ERROR("get tbm surface info failed[0x%x]", tbm_ret);
+               return FALSE;
+       }
+
+       stream->length_total = ts_info.size;
+       for (i = 0 ; i < ts_info.num_planes ; i++) {
+               stream->stride[i] = ts_info.planes[i].stride;
+               stream->elevation[i] = ts_info.planes[i].size / ts_info.planes[i].stride;
+               MMCAM_LOG_VERBOSE("    plane[%d] %dx%d", i, stream->stride[i], stream->elevation[i]);
+       }
+
+       num_bos = gst_tizen_memory_get_num_bos(memory);
+       for (i = 0 ; i < num_bos ; i++)
+               stream->bo[i] = gst_tizen_memory_get_bos(memory, i);
+
 
        switch (stream->format) {
        case MM_PIXEL_FORMAT_NV12: /* fall through */
        case MM_PIXEL_FORMAT_NV21:
                stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
                stream->num_planes = 2;
-               stream->data.yuv420sp.y = ts_info->planes[0].ptr;
-               stream->data.yuv420sp.length_y = ts_info->planes[0].size;
-               stream->data.yuv420sp.uv = ts_info->planes[1].ptr;
-               stream->data.yuv420sp.length_uv = ts_info->planes[1].size;
+               stream->data.yuv420sp.y = ts_info.planes[0].ptr;
+               stream->data.yuv420sp.length_y = ts_info.planes[0].size;
+               stream->data.yuv420sp.uv = ts_info.planes[1].ptr;
+               stream->data.yuv420sp.length_uv = ts_info.planes[1].size;
+
+               MMCAM_LOG_VERBOSE("[420SP] 0[%p,%u], 1[%p,%u]",
+                       stream->data.yuv420sp.y, stream->data.yuv420sp.length_y,
+                       stream->data.yuv420sp.uv, stream->data.yuv420sp.length_uv);
                break;
 
        case MM_PIXEL_FORMAT_I420:
                stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
                stream->num_planes = 3;
-               stream->data.yuv420p.y = ts_info->planes[0].ptr;
-               stream->data.yuv420p.length_y = ts_info->planes[0].size;
-               stream->data.yuv420p.u = ts_info->planes[1].ptr;
-               stream->data.yuv420p.length_u = ts_info->planes[1].size;
-               stream->data.yuv420p.v = ts_info->planes[2].ptr;
-               stream->data.yuv420p.length_v = ts_info->planes[2].size;
+               stream->data.yuv420p.y = ts_info.planes[0].ptr;
+               stream->data.yuv420p.length_y = ts_info.planes[0].size;
+               stream->data.yuv420p.u = ts_info.planes[1].ptr;
+               stream->data.yuv420p.length_u = ts_info.planes[1].size;
+               stream->data.yuv420p.v = ts_info.planes[2].ptr;
+               stream->data.yuv420p.length_v = ts_info.planes[2].size;
+
+               MMCAM_LOG_VERBOSE("[420P] 0[%p,%u], 1[%p,%u], 2[%p,%u]",
+                       stream->data.yuv420p.y, stream->data.yuv420p.length_y,
+                       stream->data.yuv420p.u, stream->data.yuv420p.length_u,
+                       stream->data.yuv420p.v, stream->data.yuv420p.length_v);
                break;
 
        default:
-               _mmcam_dbg_err("unsupported format[%d]", stream->format);
+               MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
                return FALSE;
        }
 
@@ -298,118 +373,75 @@ static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType
 }
 
 
-gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstBuffer *buffer, gboolean is_preview)
+gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstSample *sample, gboolean is_preview, int stream_id)
 {
        int i = 0;
-       int num_bos = 0;
        gboolean ret_cb = TRUE;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
        MMCamcorderVideoStreamDataType stream;
 
-       tbm_surface_h t_surface = NULL;
-       tbm_surface_info_s ts_info;
-
+       GstBuffer *buffer = NULL;
        GstMemory *memory = NULL;
-       GstMapInfo map_info;
        GstCaps *caps = NULL;
-       GstPad *pad = NULL;
        GstStructure *structure = NULL;
 
        mmf_return_val_if_fail(hcamcorder, FALSE);
+
+       buffer = gst_sample_get_buffer(sample);
        mmf_return_val_if_fail(buffer, FALSE);
        mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
        mmf_return_val_if_fail(sc, FALSE);
 
-       /* clear data structure */
-       memset(&map_info, 0x0, sizeof(GstMapInfo));
        memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
 
-       stream.format = sc->info_image->preview_format;
-       if (is_preview) {
-               /* preview buffer - get resolution from caps */
-               pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src");
-               mmf_return_val_if_fail(pad, FALSE);
-
-               caps = gst_pad_get_allowed_caps(pad);
-               if (!caps) {
-                       _mmcam_dbg_err("failed to get caps from pad %p", pad);
-                       gst_object_unref(pad);
-                       return FALSE;
-               }
-
-               structure = gst_caps_get_structure(caps, 0);
-               if (!structure) {
-                       _mmcam_dbg_err("failed to get structure from caps %p", caps);
-                       gst_caps_unref(caps);
-                       gst_object_unref(pad);
-                       return FALSE;
-               }
-
-               gst_structure_get_int(structure, "width", &stream.width);
-               gst_structure_get_int(structure, "height", &stream.height);
+       caps = gst_sample_get_caps(sample);
+       mmf_return_val_if_fail(caps, FALSE);
 
-               gst_caps_unref(caps);
-               caps = NULL;
-               gst_object_unref(pad);
-               pad = NULL;
-       } else {
-               /* video recording buffer */
-               stream.width = sc->info_video->video_width;
-               stream.height = sc->info_video->video_height;
-       }
+       structure = gst_caps_get_structure(caps, 0);
+       mmf_return_val_if_fail(structure, FALSE);
 
-       /*
-       _mmcam_dbg_log("VideoStreamData : resolution[%dx%d], format[%d]",
-               stream.width, stream.height, stream.format);
-       */
+       stream.format = _mmcamcorder_get_pixel_format(caps, TRUE);
+       gst_structure_get(structure,
+               "width", G_TYPE_INT, &stream.width,
+               "height", G_TYPE_INT, &stream.height,
+               NULL);
 
-       /* set size and timestamp */
-       if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
-               memory = gst_buffer_get_all_memory(buffer);
-       else
-               memory = gst_buffer_peek_memory(buffer, 0);
+       memory = gst_buffer_peek_memory(buffer, 0);
        if (!memory) {
-               _mmcam_dbg_err("GstMemory get failed from buffer %p", buffer);
+               MMCAM_LOG_ERROR("GstMemory get failed from buffer %p", buffer);
                return FALSE;
        }
 
-       /* set zero-copy related information */
-       if (hcamcorder->use_zero_copy_format) {
-               t_surface = (tbm_surface_h)gst_tizen_memory_get_surface(memory);
-
-               if (tbm_surface_get_info(t_surface, &ts_info) != TBM_SURFACE_ERROR_NONE) {
-                       _mmcam_dbg_err("failed to get tbm surface[%p] info", t_surface);
-                       goto _INVOKE_VIDEO_STREAM_CB_DONE;
-               }
-
-               /* set bo, stride and elevation */
-               num_bos = gst_tizen_memory_get_num_bos(memory);
-               for (i = 0 ; i < num_bos ; i++)
-                       stream.bo[i] = gst_tizen_memory_get_bos(memory, i);
-
-               for (i = 0 ; i < ts_info.num_planes ; i++) {
-                       stream.stride[i] = ts_info.planes[i].stride;
-                       stream.elevation[i] = ts_info.planes[i].size / ts_info.planes[i].stride;
-                       /*_mmcam_dbg_log("[%d] %dx%d", i, stream.stride[i], stream.elevation[i]);*/
-               }
+       structure = gst_mini_object_get_qdata(GST_MINI_OBJECT_CAST(buffer), hcamcorder->buffer_quark);
+       if (structure) {
+               gst_structure_get(structure,
+                       "focus-state", G_TYPE_INT, &stream.focus_state,
+                       "facing-direction", G_TYPE_INT, &stream.facing_direction,
+                       "flip", G_TYPE_INT, &stream.flip,
+                       "rotation", G_TYPE_INT, &stream.rotation,
+                       NULL);
 
-               stream.length_total = ts_info.size;
-               stream.internal_buffer = buffer;
+               MMCAM_LOG_VERBOSE("structure[%p], [fs:%d,fd:%d,f:%d,r:%d]", structure,
+                       stream.focus_state, stream.facing_direction, stream.flip, stream.rotation);
+       }
 
-               if (!__mmcamcorder_set_stream_data_tbm(&stream, &ts_info))
+       if (gst_is_tizen_memory(memory)) {
+               if (!__mmcamcorder_set_stream_data_zero_copy(&stream, buffer, memory))
                        goto _INVOKE_VIDEO_STREAM_CB_DONE;
        } else {
-               stream.length_total = gst_memory_get_sizes(memory, NULL, NULL);
-
-               if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE) ||
-                       !__mmcamcorder_set_stream_data_normal(&stream, buffer, &map_info))
+               if (!__mmcamcorder_set_stream_data(&stream, buffer, memory))
                        goto _INVOKE_VIDEO_STREAM_CB_DONE;
        }
 
+       MMCAM_LOG_DEBUG("VideoStreamData : format[%d], resolution[%dx%d], stream_id[%d]",
+               stream.format, stream.width, stream.height, stream_id);
+
        stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer) / 1000000); /* nano sec -> milli sec */
+       stream.extra_stream_id = stream_id;
+       stream.internal_buffer = buffer;
 
        /* invoke application callback */
        if (is_preview) {
@@ -430,12 +462,6 @@ _INVOKE_VIDEO_STREAM_CB_DONE:
                tbm_bo_unmap(stream.bo[i]);
        }
 
-       if (map_info.data)
-               gst_memory_unmap(memory, &map_info);
-
-       if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
-               gst_memory_unref(memory);
-
        return ret_cb;
 }
 
@@ -457,18 +483,21 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
        const char *videosrc_name = NULL;
        const char *videosink_name = NULL;
        const char *videoconvert_name = NULL;
+       const char *videodecoder_name = NULL;
+       const char *decoder_conf_name = NULL;
+       char videodecoder_name_final[32] = {'\0',};
        char *err_name = NULL;
        char *socket_path = NULL;
        int socket_path_len;
 #ifdef _MMCAMCORDER_RM_SUPPORT
        int decoder_index = 0;
-       char decoder_name[20] = {'\0',};
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        GstElement *sink_element = NULL;
        GstCameraControl *control = NULL;
        int sink_element_size = 0;
        int *fds = NULL;
        int fd_number = 0;
+       int extra_preview_enable = 0;
 
        GList *element_list = NULL;
 
@@ -483,7 +512,7 @@ int _mmcamcorder_create_preview_elements(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("");
 
        /* Check existence */
        for (i = _MMCAMCORDER_VIDEOSRC_SRC ; i <= _MMCAMCORDER_VIDEOSINK_SINK ; i++) {
@@ -491,7 +520,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        if (((GObject *)sc->element[i].gst)->ref_count > 0)
                                gst_object_unref(sc->element[i].gst);
 
-                       _mmcam_dbg_log("element[index:%d] is Already existed.", i);
+                       MMCAM_LOG_INFO("element[index:%d] is Already existed.", i);
                }
        }
 
@@ -501,7 +530,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                                                                                  "InputIndex",
                                                                                  &input_index);
        if (input_index == NULL) {
-               _mmcam_dbg_err("Failed to get input_index");
+               MMCAM_LOG_ERROR("Failed to get input_index");
                return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
        }
 
@@ -519,9 +548,10 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality,
                MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
                MMCAM_DISPLAY_SURFACE, &display_surface_type,
+               MMCAM_EXTRA_PREVIEW_ENABLE, &extra_preview_enable,
                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;
        }
@@ -531,13 +561,13 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        MMCAM_USER_BUFFER_FD, &fds, &fd_number,
                        NULL);
                if (err != MM_ERROR_NONE || fd_number < 1) {
-                       _mmcam_dbg_err("get user buffer fd failed 0x%x, number %d", err, fd_number);
+                       MMCAM_LOG_ERROR("get user buffer fd failed 0x%x, number %d", err, fd_number);
                        return err;
                }
 
                /*
                for (i = 0 ; i < fd_number ; i++)
-                       _mmcam_dbg_log("fds[%d] %d", i, fds[i]);
+                       MMCAM_LOG_INFO("fds[%d] %d", i, fds[i]);
                */
        }
 
@@ -558,14 +588,21 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_FILT, "capsfilter", "videosrc_filter", element_list, err);
 
-       /* init high-speed-fps */
-       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0);
+       /**
+        * This is for "tizencamerasrc" element only.
+        * The camera HAL library will be loaded when "hal-name" property is set.
+        * The default HAL library (libtizen-camera.so) will be loaded if 'hal-name' property is set to NULL.
+        */
+       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hal-name", hcamcorder->network_hal_name);
 
-       /* set capture size, quality and flip setting which were set before mm_camcorder_realize */
+       /* camera properties */
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", capture_jpg_quality);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", sc->info_image->hdr_capture_mode);
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", extra_preview_enable);
+       MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "buffer-quark", &hcamcorder->buffer_quark);
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_QUE, "queue", "videosrc_queue", element_list, err);
 
@@ -585,17 +622,21 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
        _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, VideosrcElement);
 
        /* Set video device index */
+       if (hcamcorder->is_network) {
+               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", hcamcorder->device_type);
+       } else {
 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
-       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "device-name", hcamcorder->conf_device_info.node);
+               MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "device-name", hcamcorder->conf_device_info.node);
 #else
-       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
+               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
 #endif
+       }
 
        /* set user buffer fd to videosrc element */
        if (hcamcorder->support_user_buffer) {
                control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
                if (!gst_camera_control_set_user_buffer_fd(control, fds, fd_number)) {
-                       _mmcam_dbg_err("set user buffer fd failed");
+                       MMCAM_LOG_ERROR("set user buffer fd failed");
                        goto pipeline_creation_error;
                }
        }
@@ -608,98 +649,76 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        &hcamcorder->recreate_decoder);
        }
 
-       if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-               int preview_bitrate = 0;
-               int gop_interval = 0;
-               mm_camcorder_get_attributes(handle, NULL,
-                       MMCAM_ENCODED_PREVIEW_BITRATE, &preview_bitrate,
-                       MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
-                       NULL);
+       if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
+               _mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
+               switch (sc->info_image->preview_format) {
+               case MM_PIXEL_FORMAT_ENCODED_H264:
+                       decoder_conf_name = "VideodecoderElementH264";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+                       decoder_conf_name = "VideodecoderElementMJPEG";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_VP8:
+                       decoder_conf_name = "VideodecoderElementVP8";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_VP9:
+                       decoder_conf_name = "VideodecoderElementVP9";
+                       break;
+               default:
+                       MMCAM_LOG_ERROR("invalid format[%d]", sc->info_image->preview_format);
+                       goto pipeline_creation_error;
+               }
 
-               /* set encoded preview bitrate */
-               if (!_mmcamcorder_set_encoded_preview_bitrate(handle, preview_bitrate))
-                       _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_bitrate failed");
+               /* get video decoder element and name */
+               _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
+                       CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+                       decoder_conf_name,
+                       &sc->VideodecoderElement);
 
-               /* set encoded preview iframe interval */
-               if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
-                       _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_gop_interval failed");
-       }
+               _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElement,
+                       &videodecoder_name);
+
+               if (!videodecoder_name) {
+                       MMCAM_LOG_ERROR("failed to get video decoder[%d,%s]", sc->info_image->preview_format, decoder_conf_name);
+                       goto pipeline_creation_error;
+               }
 
-       if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
-               const char *videodecoder_name = NULL;
-               /* case of decoder element */
-               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                       /* get video decoder element and name for H.264 format */
-                       _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
-                               CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
-                               "VideodecoderElementH264",
-                               &sc->VideodecoderElementH264);
-                       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264,
-                               &videodecoder_name);
-                       if (videodecoder_name) {
 #ifdef _MMCAMCORDER_RM_SUPPORT
-                               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                                       decoder_index = 1;
-
-                               snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
-                               _mmcam_dbg_log("encoded preview decoder_name [%s], video decoder element [%s]",
-                                       decoder_name, videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
-#else /* _MMCAMCORDER_RM_SUPPORT */
-                               _mmcam_dbg_log("video decoder element [%s]", videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, videodecoder_name, "videosrc_decode", element_list, err);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-                               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
-                       } else {
-                               _mmcam_dbg_err("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
-                               goto pipeline_creation_error;
-                       }
+               MMCAM_LOG_INFO("decoder name from config[%s]", videodecoder_name);
+               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                       if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+                               decoder_index = 1;
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s%d", videodecoder_name, decoder_index);
                } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
-#ifdef _MMCAMCORDER_RM_SUPPORT
-                       /* get video decoder element and name for MJPEG format */
-                       _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
-                               CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
-                               "VideodecoderElementH264",
-                               &sc->VideodecoderElementH264);
-                       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264,
-                               &videodecoder_name);
-                       if (videodecoder_name) {
-                               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
-                                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_uhd_mjpegdec");
-                               else
-                                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_mjpegdec");
-                               _mmcam_dbg_log("encoded preview decoder_name [%s], video decoder element [%s]",
-                                       decoder_name, videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
-                               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
-                       } else {
-                               _mmcam_dbg_err("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
-                               goto pipeline_creation_error;
-                       }
-#else /* _MMCAMCORDER_RM_SUPPORT */
-                       _mmcam_dbg_log("video decoder element [jpegdec]");
-                       /* create decoder element */
-                       _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, "jpegdec", "videosrc_decode", element_list, err);
+                       if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
+                               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_uhd_mjpegdec");
+                       else
+                               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_mjpegdec");
+               } else {
 #endif /* _MMCAMCORDER_RM_SUPPORT */
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", videodecoder_name);
+#ifdef _MMCAMCORDER_RM_SUPPORT
                }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
+               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, videodecoder_name_final, "videosrc_decode", element_list, err);
+
+               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElement);
        }
 
-       _mmcam_dbg_log("Current mode[%d]", hcamcorder->type);
+       MMCAM_LOG_INFO("Current mode[%d]", hcamcorder->type);
 
        /* Get videosink name */
        _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
 
        if (!videosink_name) {
-               _mmcam_dbg_err("failed to get videosink name");
+               MMCAM_LOG_ERROR("failed to get videosink name");
                goto pipeline_creation_error;
        }
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_QUE, "queue", "videosink_queue", element_list, err);
 
-       _mmcam_dbg_log("videosink_name: %s", videosink_name);
+       MMCAM_LOG_INFO("videosink_name: %s", videosink_name);
 
        if (display_surface_type == MM_DISPLAY_SURFACE_REMOTE) {
                _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "ipc_sink", element_list, err);
@@ -710,7 +729,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
                        NULL);
                if (err != MM_ERROR_NONE) {
-                       _mmcam_dbg_warn("Get socket path failed 0x%x", err);
+                       MMCAM_LOG_WARNING("Get socket path failed 0x%x", err);
                        SAFE_FREE(err_name);
                        goto pipeline_creation_error;
                }
@@ -722,10 +741,10 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        _mmcamcorder_conf_get_value_element_name(sc->VideoconvertElement, &videoconvert_name);
 
                        if (videoconvert_name) {
-                               _mmcam_dbg_log("videoconvert element name : %s", videoconvert_name);
+                               MMCAM_LOG_INFO("videoconvert element name : %s", videoconvert_name);
                                _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_CLS, videoconvert_name, "videosink_cls", element_list, err);
                        } else
-                               _mmcam_dbg_err("failed to get videoconvert element name");
+                               MMCAM_LOG_ERROR("failed to get videoconvert element name");
                }
 
                /* check sink element in attribute */
@@ -737,7 +756,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        int attr_index = 0;
                        MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
 
-                       _mmcam_dbg_log("reuse sink element %p in attribute", sink_element);
+                       MMCAM_LOG_INFO("reuse sink element %p in attribute", sink_element);
 
                        _MMCAMCORDER_ELEMENT_ADD(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, sink_element, element_list, err);
 
@@ -747,7 +766,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                                mm_attrs_set_data(attrs, attr_index, NULL, 0);
                                mm_attrs_commit(attrs, attr_index);
                        } else {
-                               _mmcam_dbg_warn("attribute is NULL");
+                               MMCAM_LOG_WARNING("attribute is NULL");
                                err = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
                                goto pipeline_creation_error;
                        }
@@ -758,7 +777,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                }
 
                if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
-                       _mmcam_dbg_err("_mmcamcorder_videosink_window_set error");
+                       MMCAM_LOG_ERROR("_mmcamcorder_videosink_window_set error");
                        err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
                        goto pipeline_creation_error;
                }
@@ -769,14 +788,14 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
 
        /* add elements to main pipeline */
        if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst), element_list)) {
-               _mmcam_dbg_err("element_list add error.");
+               MMCAM_LOG_ERROR("element_list add error.");
                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                goto pipeline_creation_error;
        }
 
        /* link elements */
        if (!_mmcamcorder_link_elements(element_list)) {
-               _mmcam_dbg_err("element link error.");
+               MMCAM_LOG_ERROR("element link error.");
                err = MM_ERROR_CAMCORDER_GST_LINK;
                goto pipeline_creation_error;
        }
@@ -844,7 +863,7 @@ int _mmcamcorder_create_audiosrc_bin(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("");
 
        err = _mmcamcorder_check_audiocodec_fileformat_compatibility(handle);
        if (err != MM_ERROR_NONE)
@@ -864,7 +883,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                MMCAM_SOUND_STREAM_INDEX, &stream_index,
                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;
        }
@@ -874,7 +893,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                if (((GObject *)sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0)
                        gst_object_unref(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst);
 
-               _mmcam_dbg_log("_MMCAMCORDER_AUDIOSRC_BIN is Already existed. Unref once...");
+               MMCAM_LOG_INFO("_MMCAMCORDER_AUDIOSRC_BIN is Already existed. Unref once...");
        }
 
        /* Create bin element */
@@ -888,7 +907,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        }
 
        if (cat_name == NULL) {
-               _mmcam_dbg_err("strdup failed.");
+               MMCAM_LOG_ERROR("strdup failed.");
                err = MM_ERROR_CAMCORDER_LOW_MEMORY;
                goto pipeline_creation_error;
        }
@@ -902,7 +921,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        free(cat_name);
        cat_name = NULL;
 
-       _mmcam_dbg_log("Audio src name : %s", audiosrc_name);
+       MMCAM_LOG_INFO("Audio src name : %s", audiosrc_name);
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_SRC, audiosrc_name, "audiosrc_src", element_list, err);
 
@@ -919,7 +938,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                &buffer_interval);
 
        if (_mmcamcorder_get_audiosrc_blocksize(rate, format, channel, buffer_interval, &blocksize)) {
-               _mmcam_dbg_log("set audiosrc block size %d", blocksize);
+               MMCAM_LOG_INFO("set audiosrc block size %d", blocksize);
                MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, "blocksize", blocksize);
        }
 
@@ -958,7 +977,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                        "channels", G_TYPE_INT, channel,
                        "format", G_TYPE_STRING, format_name,
                        NULL);
-               _mmcam_dbg_log("caps [x-raw, rate:%d, channel:%d, depth:%d], volume %lf",
+               MMCAM_LOG_INFO("caps [x-raw, rate:%d, channel:%d, depth:%d], volume %lf",
                        rate, channel, depth, volume);
        } else {
                /* what are the audio encoder which should get audio/x-raw-float? */
@@ -967,12 +986,12 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                        "channels", G_TYPE_INT, channel,
                        "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
                        NULL);
-               _mmcam_dbg_log("caps [x-raw (F32), rate:%d, channel:%d, endianness:%d, width:32]",
+               MMCAM_LOG_INFO("caps [x-raw (F32), rate:%d, channel:%d, endianness:%d, width:32]",
                        rate, channel, BYTE_ORDER);
        }
 
        /* Replay Gain */
-       _mmcam_dbg_log("Replay gain - enable : %d, reference level : %lf",
+       MMCAM_LOG_INFO("Replay gain - enable : %d, reference level : %lf",
                replay_gain_enable, replay_gain_ref_level);
 
        if (replay_gain_enable) {
@@ -987,19 +1006,19 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
                gst_caps_unref(caps);
                caps = NULL;
        } else {
-               _mmcam_dbg_err("create caps error");
+               MMCAM_LOG_ERROR("create caps error");
                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                goto pipeline_creation_error;
        }
 
        if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst), element_list)) {
-               _mmcam_dbg_err("element add error.");
+               MMCAM_LOG_ERROR("element add error.");
                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                goto pipeline_creation_error;
        }
 
        if (!_mmcamcorder_link_elements(element_list)) {
-               _mmcam_dbg_err("element link error.");
+               MMCAM_LOG_ERROR("element link error.");
                err = MM_ERROR_CAMCORDER_GST_LINK;
                goto pipeline_creation_error;
        }
@@ -1009,7 +1028,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst, gst_ghost_pad_new("src", pad))) {
                gst_object_unref(pad);
                pad = NULL;
-               _mmcam_dbg_err("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
+               MMCAM_LOG_ERROR("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
                err = MM_ERROR_CAMCORDER_GST_LINK;
                goto pipeline_creation_error;
        }
@@ -1045,12 +1064,12 @@ void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, in
        int set_value = 0;
 
        if (!element) {
-               _mmcam_dbg_warn("NULL element, will be applied later - type %d, bitrate %d", type, bitrate);
+               MMCAM_LOG_WARNING("NULL element, will be applied later - type %d, bitrate %d", type, bitrate);
                return;
        }
 
        if (bitrate <= 0) {
-               _mmcam_dbg_warn("[type %d, codec %d] too small bitrate[%d], use default",
+               MMCAM_LOG_WARNING("[type %d, codec %d] too small bitrate[%d], use default",
                        type, codec, bitrate);
                return;
        }
@@ -1060,25 +1079,25 @@ void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, in
                switch (codec) {
                case MM_AUDIO_CODEC_AMR:
                        set_value = __mmcamcorder_get_amrnb_bitrate_mode(bitrate);
-                       _mmcam_dbg_log("Set AMR encoder mode [%d]", set_value);
+                       MMCAM_LOG_INFO("Set AMR encoder mode [%d]", set_value);
                        MMCAMCORDER_G_OBJECT_SET(element, "band-mode", set_value);
                        break;
                case MM_AUDIO_CODEC_MP3:
                        set_value = bitrate / 1000;
-                       _mmcam_dbg_log("Set MP3 encoder bitrate [%d] kbps", set_value);
+                       MMCAM_LOG_INFO("Set MP3 encoder bitrate [%d] kbps", set_value);
                        MMCAMCORDER_G_OBJECT_SET(element, "bitrate", set_value);
                        break;
                case MM_AUDIO_CODEC_AAC:
-                       _mmcam_dbg_log("Set AAC encoder bitrate [%d] bps", bitrate);
+                       MMCAM_LOG_INFO("Set AAC encoder bitrate [%d] bps", bitrate);
                        MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
                        break;
                default:
-                       _mmcam_dbg_warn("Not AMR, MP3 and AAC codec, need to add code for audio bitrate");
+                       MMCAM_LOG_WARNING("Not AMR, MP3 and AAC codec, need to add code for audio bitrate");
                        break;
                }
        } else {
                /* video encoder bitrate setting */
-               _mmcam_dbg_log("Set video encoder bitrate %d", bitrate);
+               MMCAM_LOG_INFO("Set video encoder bitrate %d", bitrate);
                MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
        }
 
@@ -1131,14 +1150,14 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
        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("start - profile : %d", profile);
+       MMCAM_LOG_INFO("start - profile : %d", profile);
 
        /* Check existence */
        if (sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst) {
                if (((GObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0)
                        gst_object_unref(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst);
 
-               _mmcam_dbg_log("_MMCAMCORDER_ENCSINK_BIN is Already existed.");
+               MMCAM_LOG_INFO("_MMCAMCORDER_ENCSINK_BIN is Already existed.");
        }
 
        /* Create bin element */
@@ -1162,14 +1181,14 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                /* set capsfilter */
                if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
                        if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
-                               _mmcam_dbg_log("get pad from videosrc_filter");
+                               MMCAM_LOG_INFO("get pad from videosrc_filter");
                                pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src");
                        } else {
-                               _mmcam_dbg_log("get pad from videosrc_que");
+                               MMCAM_LOG_INFO("get pad from videosrc_que");
                                pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
                        }
                        if (!pad) {
-                               _mmcam_dbg_err("get videosrc_que src pad failed");
+                               MMCAM_LOG_ERROR("get videosrc_que src pad failed");
                                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                                goto pipeline_creation_error;
                        }
@@ -1189,7 +1208,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                }
 
                if (!video_caps) {
-                       _mmcam_dbg_err("create recording pipeline caps failed");
+                       MMCAM_LOG_ERROR("create recording pipeline caps failed");
                        err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                        goto pipeline_creation_error;
                }
@@ -1211,7 +1230,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
 
                caps_str = gst_caps_to_string(video_caps);
 
-               _mmcam_dbg_log("encodebin caps [%s]", caps_str);
+               MMCAM_LOG_INFO("encodebin caps [%s]", caps_str);
 
                g_free(caps_str);
                caps_str = NULL;
@@ -1225,7 +1244,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO &&
                        sc->info_video->use_videoscale) {
                        if (!videoscale_caps) {
-                               _mmcam_dbg_err("no videoscale caps");
+                               MMCAM_LOG_ERROR("no videoscale caps");
                                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                                goto pipeline_creation_error;
                        }
@@ -1241,14 +1260,14 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                                &VideoscaleElement);
 
                        if (!_mmcamcorder_conf_get_value_element_name(VideoscaleElement, &gst_element_vscale_name)) {
-                               _mmcam_dbg_err("failed to get videoscale element name");
+                               MMCAM_LOG_ERROR("failed to get videoscale element name");
                                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                                goto pipeline_creation_error;
                        }
 
                        caps_str = gst_caps_to_string(videoscale_caps);
 
-                       _mmcam_dbg_log("encodebin videocale [%s][%s]", gst_element_vscale_name, caps_str);
+                       MMCAM_LOG_INFO("encodebin videocale [%s][%s]", gst_element_vscale_name, caps_str);
 
                        g_free(caps_str);
                        caps_str = NULL;
@@ -1276,7 +1295,8 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        hcamcorder);
        }
 
-       _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", "encodesink_encbin", element_list, err);
+       _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN,
+               "tizenencodebin", "encodesink_encbin", element_list, err);
 
        /* check element availability */
        if (profile == MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
@@ -1294,16 +1314,16 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
 
        if (err != MM_ERROR_NONE) {
                if (err_name) {
-                       _mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
+                       MMCAM_LOG_ERROR("failed to get attributes [%s][0x%x]", err_name, err);
                        SAFE_FREE(err_name);
                } else {
-                       _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+                       MMCAM_LOG_ERROR("failed to get attributes [0x%x]", err);
                }
 
                goto pipeline_creation_error;
        }
 
-       _mmcam_dbg_log("Profile[%d]", profile);
+       MMCAM_LOG_INFO("Profile[%d]", profile);
 
        /* Set information */
        if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
@@ -1328,7 +1348,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
        _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_aar, &auto_audio_resample);
        _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_acs, &auto_color_space);
 
-       _mmcam_dbg_log("Profile:%d, AutoAudioConvert:%d, AutoAudioResample:%d, AutoColorSpace:%d",
+       MMCAM_LOG_INFO("Profile:%d, AutoAudioConvert:%d, AutoAudioResample:%d, AutoColorSpace:%d",
                encodebin_profile, auto_audio_convert, auto_audio_resample, auto_color_space);
 
        MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "profile", encodebin_profile);
@@ -1347,7 +1367,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                VideoencElement = _mmcamcorder_get_type_element(handle, MM_CAM_VIDEO_ENCODER);
 
                if (!VideoencElement) {
-                       _mmcam_dbg_err("Fail to get type element");
+                       MMCAM_LOG_ERROR("Fail to get type element");
                        err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                        goto pipeline_creation_error;
                }
@@ -1360,19 +1380,19 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                }
 
                if (gst_element_venc_name) {
-                       _mmcam_dbg_log("video encoder name [%s]", gst_element_venc_name);
+                       MMCAM_LOG_INFO("video encoder name [%s]", gst_element_venc_name);
 
                        MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "venc-name", gst_element_venc_name);
                        _MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VENC, "video-encode", err);
                } else {
-                       _mmcam_dbg_err("Fail to get video encoder name");
+                       MMCAM_LOG_ERROR("Fail to get video encoder name");
                        err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                        goto pipeline_creation_error;
                }
 
                /* set color space converting element */
                if (auto_color_space) {
-                       _mmcam_dbg_log("set video convert element [%s]", videoconvert_name);
+                       MMCAM_LOG_INFO("set video convert element [%s]", videoconvert_name);
 
                        MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vconv-name", videoconvert_name);
                        _MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VCONV, "video-convert", err);
@@ -1392,10 +1412,10 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                                                gst_caps_unref(video_caps);
                                                video_caps = NULL;
                                        } else {
-                                               _mmcam_dbg_warn("failed to create caps");
+                                               MMCAM_LOG_WARNING("failed to create caps");
                                        }
                                } else {
-                                       _mmcam_dbg_log("current video codec is not openmax but [%s]", gst_element_venc_name);
+                                       MMCAM_LOG_INFO("current video codec is not openmax but [%s]", gst_element_venc_name);
                                }
                        }
                }
@@ -1414,7 +1434,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
 
                AudioencElement = _mmcamcorder_get_type_element(handle, MM_CAM_AUDIO_ENCODER);
                if (!AudioencElement) {
-                       _mmcam_dbg_err("Fail to get type element");
+                       MMCAM_LOG_ERROR("Fail to get type element");
                        err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                        goto pipeline_creation_error;
                }
@@ -1440,7 +1460,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
                        gst_caps_unref(audio_caps);
                        audio_caps = NULL;
-                       _mmcam_dbg_log("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
+                       MMCAM_LOG_INFO("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
                }
 
                _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
@@ -1458,7 +1478,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                if (cap_format == MM_PIXEL_FORMAT_ENCODED) {
                        ImageencElement = _mmcamcorder_get_type_element(handle, MM_CAM_IMAGE_ENCODER);
                        if (!ImageencElement) {
-                               _mmcam_dbg_err("Fail to get type element");
+                               MMCAM_LOG_ERROR("Fail to get type element");
                                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                                goto pipeline_creation_error;
                        }
@@ -1477,7 +1497,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
        if (profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
                MuxElement = _mmcamcorder_get_type_element(handle, MM_CAM_FILE_FORMAT);
                if (!MuxElement) {
-                       _mmcam_dbg_err("Fail to get type element");
+                       MMCAM_LOG_ERROR("Fail to get type element");
                        err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                        goto pipeline_creation_error;
                }
@@ -1526,23 +1546,23 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        a_bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
        }
 
-       _mmcam_dbg_log("Element creation complete");
+       MMCAM_LOG_INFO("Element creation complete");
 
        /* Add element to bin */
        if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst), element_list)) {
-               _mmcam_dbg_err("element add error.");
+               MMCAM_LOG_ERROR("element add error.");
                err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
                goto pipeline_creation_error;
        }
 
-       _mmcam_dbg_log("Element add complete");
+       MMCAM_LOG_INFO("Element add complete");
 
        if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
-               pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
+               pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("video_sink0", pad))) {
                        gst_object_unref(pad);
                        pad = NULL;
-                       _mmcam_dbg_err("failed to create ghost video_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+                       MMCAM_LOG_ERROR("failed to create ghost video_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
@@ -1550,11 +1570,11 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                pad = NULL;
 
                if (sc->audio_disable == FALSE) {
-                       pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+                       pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
                        if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
                                gst_object_unref(pad);
                                pad = NULL;
-                               _mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+                               MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                                err = MM_ERROR_CAMCORDER_GST_LINK;
                                goto pipeline_creation_error;
                        }
@@ -1562,11 +1582,11 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                        pad = NULL;
                }
        } else if (profile == MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
-               pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+               pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
                        gst_object_unref(pad);
                        pad = NULL;
-                       _mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+                       MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
@@ -1574,11 +1594,11 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                pad = NULL;
        } else {
                /* for stillshot */
-               pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
+               pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
                if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("image_sink0", pad))) {
                        gst_object_unref(pad);
                        pad = NULL;
-                       _mmcam_dbg_err("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+                       MMCAM_LOG_ERROR("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
                        err = MM_ERROR_CAMCORDER_GST_LINK;
                        goto pipeline_creation_error;
                }
@@ -1586,11 +1606,11 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                pad = NULL;
        }
 
-       _mmcam_dbg_log("Get pad complete");
+       MMCAM_LOG_INFO("Get pad complete");
 
        /* Link internal element */
        if (!_mmcamcorder_link_elements(element_list)) {
-               _mmcam_dbg_err("element link error.");
+               MMCAM_LOG_ERROR("element link error.");
                err = MM_ERROR_CAMCORDER_GST_LINK;
                goto pipeline_creation_error;
        }
@@ -1598,7 +1618,7 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
        if (element_list)
                g_list_free(element_list);
 
-       _mmcam_dbg_log("done");
+       MMCAM_LOG_INFO("done");
 
        return MM_ERROR_NONE;
 
@@ -1620,9 +1640,6 @@ pipeline_creation_error:
        if (element_list)
                g_list_free(element_list);
 
-       if (video_caps)
-               gst_caps_unref(video_caps);
-
        if (videoscale_caps)
                gst_caps_unref(videoscale_caps);
 
@@ -1646,7 +1663,7 @@ int _mmcamcorder_create_preview_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("");
 
        /** Create gstreamer element **/
        /* Main pipeline */
@@ -1659,10 +1676,10 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
 
        /* Set data probe function */
        if (sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst) {
-               _mmcam_dbg_log("add video dataprobe to videosrc queue");
+               MMCAM_LOG_INFO("add video dataprobe to videosrc queue");
                srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
        } else {
-               _mmcam_dbg_err("there is no queue plugin");
+               MMCAM_LOG_ERROR("there is no queue plugin");
                goto pipeline_creation_error;
        }
 
@@ -1673,7 +1690,7 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
                gst_object_unref(srcpad);
                srcpad = NULL;
        } else {
-               _mmcam_dbg_err("failed to get srcpad");
+               MMCAM_LOG_ERROR("failed to get srcpad");
                goto pipeline_creation_error;
        }
 
@@ -1692,9 +1709,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
 
        bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
 
-       /* Register pipeline message callback */
-       hcamcorder->pipeline_cb_event_id = gst_bus_add_watch(bus, _mmcamcorder_pipeline_cb_message, (gpointer)hcamcorder);
-
        /* set sync handler */
        gst_bus_set_sync_handler(bus, _mmcamcorder_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
 
@@ -1714,7 +1728,7 @@ void _mmcamcorder_ready_to_encode_callback(GstElement *element, guint size, gpoi
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
 
-       /*_mmcam_dbg_log("start");*/
+       /*MMCAM_LOG_INFO("start");*/
 
        mmf_return_if_fail(hcamcorder);
        mmf_return_if_fail(hcamcorder->sub_context);
@@ -1723,7 +1737,7 @@ void _mmcamcorder_ready_to_encode_callback(GstElement *element, guint size, gpoi
        /* set flag */
        if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_INIT) {
                sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_RUN;
-               _mmcam_dbg_warn("set push_encoding_buffer RUN");
+               MMCAM_LOG_WARNING("set push_encoding_buffer RUN");
        }
 }
 
@@ -1745,9 +1759,6 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        int zoom_attr = 0;
        int zoom_level = 0;
        int do_scaling = FALSE;
-#ifdef _MMCAMCORDER_RM_SUPPORT
-       int display_scaler = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
        int *dp_handle = NULL;
        MMCamWindowInfo *window_info = NULL;
        gulong xid;
@@ -1759,7 +1770,7 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
 
-       _mmcam_dbg_log("");
+       MMCAM_LOG_INFO("");
 
        mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
@@ -1787,10 +1798,10 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                NULL);
        if (err != MM_ERROR_NONE) {
                if (err_name) {
-                       _mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
+                       MMCAM_LOG_ERROR("failed to get attributes [%s][0x%x]", err_name, err);
                        SAFE_FREE(err_name);
                } else {
-                       _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+                       MMCAM_LOG_ERROR("failed to get attributes [0x%x]", err);
                }
 
                return err;
@@ -1799,50 +1810,49 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
        _mmcamcorder_conf_get_value_element_name(VideosinkElement, &videosink_name);
 
        if (!videosink_name) {
-               _mmcam_dbg_err("failed to get videosink name");
+               MMCAM_LOG_ERROR("failed to get videosink name");
                return MM_ERROR_CAMCORDER_INTERNAL;
        }
 
-       _mmcam_dbg_log("(dp_handle=%p, size=%d)", dp_handle, size);
+       MMCAM_LOG_INFO("(dp_handle=%p, size=%d)", dp_handle, size);
 
        /* Set display handle */
        if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
                if (dp_handle) {
                        xid = *dp_handle;
-                       _mmcam_dbg_log("xid = %lu )", xid);
+                       MMCAM_LOG_INFO("xid = %lu )", xid);
                        gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), xid);
                } else {
-                       _mmcam_dbg_warn("Handle is NULL. Set xid as 0.. but, it's not recommended.");
+                       MMCAM_LOG_WARNING("Handle is NULL. Set xid as 0.. but, it's not recommended.");
                        gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 0);
                }
-#ifdef _MMCAMCORDER_RM_SUPPORT
-               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                       display_scaler = 1;
-
-               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
        } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
-               _mmcam_dbg_log("videosink : %s, handle : %p", videosink_name, dp_handle);
+               MMCAM_LOG_INFO("videosink : %s, handle : %p", videosink_name, dp_handle);
 
                if (dp_handle) {
                        MMCAMCORDER_G_OBJECT_SET_POINTER(vsink, "evas-object", dp_handle);
                        MMCAMCORDER_G_OBJECT_SET(vsink, "origin-size", !do_scaling);
                } else {
-                       _mmcam_dbg_err("display handle(eavs object) is NULL");
+                       MMCAM_LOG_ERROR("display handle(eavs object) is NULL");
                        return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
                }
        } else if (!strcmp(videosink_name, "tizenwlsink")) {
                if (dp_handle) {
                        window_info = (MMCamWindowInfo *)dp_handle;
-                       _mmcam_dbg_log("wayland global surface id : %d", window_info->surface_id);
+                       MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
                        gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(vsink), window_info->surface_id);
                } else {
-                       _mmcam_dbg_warn("Handle is NULL. skip setting.");
+                       MMCAM_LOG_WARNING("Handle is NULL. skip setting.");
                }
        } else if (!strcmp(videosink_name, "directvideosink")) {
+#ifdef _MMCAMCORDER_RM_SUPPORT
+               /* set the videosink using the virtual device id instead of the real id (main=0, sub=1) */
+               MMCAM_LOG_INFO("device-scaler : %d", hcamcorder->returned_devices.device_id[1]);
+               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", hcamcorder->returned_devices.device_id[1]);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
                if (dp_handle) {
                        window_info = (MMCamWindowInfo *)dp_handle;
-                       _mmcam_dbg_log("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
+                       MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
                                window_info->surface_id,
                                window_info->rect.x,
                                window_info->rect.y,
@@ -1855,18 +1865,13 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                                window_info->rect.width,
                                window_info->rect.height);
                } else {
-                       _mmcam_dbg_warn("dp_handle is null");
+                       MMCAM_LOG_WARNING("dp_handle is null");
                }
-#ifdef _MMCAMCORDER_RM_SUPPORT
-               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                       display_scaler = 1;
-               MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
        } else {
-               _mmcam_dbg_warn("Who are you?? (Videosink: %s)", videosink_name);
+               MMCAM_LOG_WARNING("Who are you?? (Videosink: %s)", videosink_name);
        }
 
-       _mmcam_dbg_log("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[%d],flip[%d]",
+       MMCAM_LOG_INFO("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[%d],flip[%d]",
                videosink_name, display_geometry_method, origin_size, visible, rotation, flip);
 
        /* Set attribute */
@@ -1889,7 +1894,7 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
                        zoom_level = 3;
                        break;
                default:
-                       _mmcam_dbg_warn("Unsupported zoom value. set as default.");
+                       MMCAM_LOG_WARNING("Unsupported zoom value. set as default.");
                        zoom_level = 1;
                        break;
                }
@@ -1938,14 +1943,14 @@ int _mmcamcorder_video_frame_stabilize(MMHandleType handle, int cmd)
                category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
                break;
        default:
-               _mmcam_dbg_warn("unknown command : %d", cmd);
+               MMCAM_LOG_WARNING("unknown command : %d", cmd);
                return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
        }
 
        _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_ctrl,
                category, "FrameStabilityCount", &sc->frame_stability_count);
 
-       _mmcam_dbg_log("[cmd %d] frame stability count : %d",
+       MMCAM_LOG_INFO("[cmd %d] frame stability count : %d",
                cmd, sc->frame_stability_count);
 
        return MM_ERROR_NONE;
@@ -1978,7 +1983,7 @@ gboolean _mmcamcorder_get_device_info(MMHandleType handle)
                                if (exif_info.focal_len_denominator != 0)
                                        focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
                        } else {
-                               _mmcam_dbg_err("Fail to get camera control interface!");
+                               MMCAM_LOG_ERROR("Fail to get camera control interface!");
                                focal_len = 0.0;
                        }
                }
@@ -1988,12 +1993,12 @@ gboolean _mmcamcorder_get_device_info(MMHandleType handle)
                        MMCAM_CAMERA_FOCAL_LENGTH, focal_len,
                        NULL);
                if (err != MM_ERROR_NONE) {
-                       _mmcam_dbg_err("Set attributes error(%s:%x)!", err_name, err);
+                       MMCAM_LOG_ERROR("Set attributes error(%s:%x)!", err_name, err);
                        SAFE_FREE(err_name);
                        return FALSE;
                }
        } else {
-               _mmcam_dbg_warn("Sub context isn't exist.");
+               MMCAM_LOG_WARNING("Sub context isn't exist.");
                return FALSE;
        }
 
@@ -2007,10 +2012,12 @@ static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_n
 
 static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
+       gboolean ret = TRUE;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
        _MMCamcorderSubContext *sc = NULL;
-       _MMCamcorderKPIMeasure *kpi = NULL;
        GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+       GstSample *sample = NULL;
+       GstCaps *caps = NULL;
 
        mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
        mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_DROP);
@@ -2022,62 +2029,41 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
        if (sc->drop_vframe > 0) {
                if (sc->pass_first_vframe > 0) {
                        sc->pass_first_vframe--;
-                       _mmcam_dbg_log("Pass video frame by pass_first_vframe");
+                       MMCAM_LOG_INFO("Pass video frame by pass_first_vframe");
                } else {
                        sc->drop_vframe--;
-                       _mmcam_dbg_log("Drop video frame by drop_vframe");
+                       MMCAM_LOG_INFO("Drop video frame by drop_vframe");
                        return GST_PAD_PROBE_DROP;
                }
        } else if (sc->frame_stability_count > 0) {
                sc->frame_stability_count--;
-               _mmcam_dbg_log("Drop video frame by frame_stability_count");
+               MMCAM_LOG_INFO("Drop video frame by frame_stability_count");
                return GST_PAD_PROBE_DROP;
        }
 
-       if (hcamcorder->state >= MM_CAMCORDER_STATE_PREPARE) {
-               int diff_sec;
-               int frame_count = 0;
-               struct timeval current_video_time;
-
-               kpi = &(sc->kpi);
-               if (kpi->init_video_time.tv_sec == kpi->last_video_time.tv_sec &&
-                   kpi->init_video_time.tv_usec == kpi->last_video_time.tv_usec &&
-                   kpi->init_video_time.tv_usec  == 0) {
-                       /*
-                       _mmcam_dbg_log("START to measure FPS");
-                       */
-                       gettimeofday(&(kpi->init_video_time), NULL);
-               }
-
-               frame_count = ++(kpi->video_framecount);
-
-               gettimeofday(&current_video_time, NULL);
-               diff_sec = current_video_time.tv_sec - kpi->last_video_time.tv_sec;
-               if (diff_sec != 0) {
-                       kpi->current_fps = (frame_count - kpi->last_framecount) / diff_sec;
-                       if ((current_video_time.tv_sec - kpi->init_video_time.tv_sec) != 0) {
-                               int framecount = kpi->video_framecount;
-                               int elased_sec = current_video_time.tv_sec - kpi->init_video_time.tv_sec;
-                               kpi->average_fps = framecount / elased_sec;
-                       }
-
-                       kpi->last_framecount = frame_count;
-                       kpi->last_video_time.tv_sec = current_video_time.tv_sec;
-                       kpi->last_video_time.tv_usec = current_video_time.tv_usec;
-                       /*
-                       _mmcam_dbg_log("current fps(%d), average(%d)", kpi->current_fps, kpi->average_fps);
-                       */
-               }
-       }
+       if (hcamcorder->measure_preview_fps && hcamcorder->state >= MM_CAMCORDER_STATE_PREPARE)
+               _mmcamcorder_measure_fps(&sc->kpi);
 
        /* The first H.264 frame should not be skipped for vstream cb. */
        if (hcamcorder->state < MM_CAMCORDER_STATE_PREPARE &&
-               sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
-               _mmcam_dbg_warn("Not ready for stream callback");
+               !_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
+               MMCAM_LOG_WARNING("Not ready for stream callback");
                return GST_PAD_PROBE_OK;
        }
 
-       if (_mmcamcorder_invoke_video_stream_cb((MMHandleType)hcamcorder, buffer, TRUE))
+       /* make sample with buffer and caps */
+       caps = gst_pad_get_allowed_caps(pad);
+       mmf_return_val_if_fail(caps, GST_PAD_PROBE_OK);
+
+       sample = gst_sample_new(buffer, caps, NULL, NULL);
+       gst_caps_unref(caps);
+       mmf_return_val_if_fail(sample, GST_PAD_PROBE_OK);
+
+       ret = _mmcamcorder_invoke_video_stream_cb((MMHandleType)hcamcorder, sample, TRUE, -1);
+
+       gst_sample_unref(sample);
+
+       if (ret)
                return GST_PAD_PROBE_OK;
        else
                return GST_PAD_PROBE_DROP;
@@ -2086,10 +2072,22 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
 
 static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
 {
-       if (_mmcamcorder_video_push_buffer(u_data, GST_PAD_PROBE_INFO_BUFFER(info)))
-               return GST_PAD_PROBE_OK;
+       gboolean ret = TRUE;
+       GstSample *sample = NULL;
+       GstCaps *caps = NULL;
+
+       caps = gst_pad_get_allowed_caps(pad);
+       mmf_return_val_if_fail(caps, GST_PAD_PROBE_OK);
+
+       sample = gst_sample_new(GST_PAD_PROBE_INFO_BUFFER(info), caps, NULL, NULL);
+       gst_caps_unref(caps);
+       mmf_return_val_if_fail(sample, GST_PAD_PROBE_OK);
+
+       ret = _mmcamcorder_video_push_buffer(u_data, sample);
 
-       return GST_PAD_PROBE_DROP;
+       gst_sample_unref(sample);
+
+       return (ret ? GST_PAD_PROBE_OK : GST_PAD_PROBE_DROP);
 }
 
 
@@ -2109,7 +2107,7 @@ GstPadProbeReturn __mmcamcorder_muxed_dataprobe(GstPad *pad, GstPadProbeInfo *in
        mmf_return_val_if_fail(sc, GST_PAD_PROBE_OK);
 
        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;
        }
 
@@ -2150,18 +2148,18 @@ GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo
        case GST_EVENT_LATENCY:
        /* downstream serialized events */
        case GST_EVENT_BUFFERSIZE:
-               _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+               MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
                break;
        case GST_EVENT_TAG:
                {
                        GstTagList *tag_list = NULL;
                        _MMCamcorderReplayGain *replay_gain = NULL;
 
-                       _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+                       MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
 
                        hcamcorder = MMF_CAMCORDER(u_data);
                        if (!hcamcorder || !hcamcorder->sub_context) {
-                               _mmcam_dbg_warn("NULL handle");
+                               MMCAM_LOG_WARNING("NULL handle");
                                break;
                        }
 
@@ -2169,58 +2167,58 @@ GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo
 
                        gst_event_parse_tag(event, &tag_list);
                        if (!tag_list) {
-                               _mmcam_dbg_warn("failed to get tag list");
+                               MMCAM_LOG_WARNING("failed to get tag list");
                                break;
                        }
 
                        if (!gst_tag_list_get_double(tag_list, GST_TAG_TRACK_PEAK, &replay_gain->track_peak)) {
-                               _mmcam_dbg_warn("failed to get GST_TAG_TRACK_PEAK");
+                               MMCAM_LOG_WARNING("failed to get GST_TAG_TRACK_PEAK");
                                break;
                        }
 
                        if (!gst_tag_list_get_double(tag_list, GST_TAG_TRACK_GAIN, &replay_gain->track_gain)) {
-                               _mmcam_dbg_warn("failed to get GST_TAG_TRACK_GAIN");
+                               MMCAM_LOG_WARNING("failed to get GST_TAG_TRACK_GAIN");
                                break;
                        }
 
                        if (!gst_tag_list_get_double(tag_list, GST_TAG_ALBUM_PEAK, &replay_gain->album_peak)) {
-                               _mmcam_dbg_warn("failed to get GST_TAG_ALBUM_PEAK");
+                               MMCAM_LOG_WARNING("failed to get GST_TAG_ALBUM_PEAK");
                                break;
                        }
 
                        if (!gst_tag_list_get_double(tag_list, GST_TAG_ALBUM_GAIN, &replay_gain->album_gain)) {
-                               _mmcam_dbg_warn("failed to get GST_TAG_ALBUM_PEAK");
+                               MMCAM_LOG_WARNING("failed to get GST_TAG_ALBUM_PEAK");
                                break;
                        }
 
-                       _mmcam_dbg_log("Track [peak %lf, gain %lf], Album [peak %lf, gain %lf]",
+                       MMCAM_LOG_INFO("Track [peak %lf, gain %lf], Album [peak %lf, gain %lf]",
                                replay_gain->track_peak, replay_gain->track_gain,
                                replay_gain->album_peak, replay_gain->album_gain);
                }
                break;
        case GST_EVENT_SEGMENT:
-               _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+               MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
 
                hcamcorder = MMF_CAMCORDER(u_data);
                if (!hcamcorder) {
-                       _mmcam_dbg_warn("NULL handle");
+                       MMCAM_LOG_WARNING("NULL handle");
                        break;
                }
 
                sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
                if (!sc) {
-                       _mmcam_dbg_warn("NULL sub context");
+                       MMCAM_LOG_WARNING("NULL sub context");
                        break;
                }
 
                if (!sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
-                       _mmcam_dbg_warn("no encoder sink");
+                       MMCAM_LOG_WARNING("no encoder sink");
                        break;
                }
 
                parent = gst_pad_get_parent(pad);
                if (!parent) {
-                       _mmcam_dbg_warn("get parent failed");
+                       MMCAM_LOG_WARNING("get parent failed");
                        break;
                }
 
@@ -2228,7 +2226,7 @@ GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo
                        const GstSegment *segment;
                        gst_event_parse_segment(event, &segment);
                        if (segment->format == GST_FORMAT_BYTES) {
-                               _mmcam_dbg_log("change current offset %llu -> %"G_GUINT64_FORMAT,
+                               MMCAM_LOG_INFO("change current offset %llu -> %"G_GUINT64_FORMAT,
                                        sc->muxed_stream_offset, segment->start);
 
                                sc->muxed_stream_offset = (unsigned long long)segment->start;
@@ -2239,15 +2237,15 @@ GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo
                parent = NULL;
                break;
        case GST_EVENT_EOS:
-               _mmcam_dbg_warn("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+               MMCAM_LOG_WARNING("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
                break;
        /* bidirectional events */
        case GST_EVENT_FLUSH_START:
        case GST_EVENT_FLUSH_STOP:
-               _mmcam_dbg_err("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+               MMCAM_LOG_ERROR("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
                break;
        default:
-               _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+               MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
                break;
        }
 
@@ -2292,22 +2290,22 @@ int _mmcamcorder_get_eos_message(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");
 
        _MMCAMCORDER_LOCK(handle);
 
        if (sc->bget_eos == FALSE) {
                end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
                if (_MMCAMCORDER_WAIT_UNTIL(handle, end_time)) {
-                       _mmcam_dbg_log("EOS signal received");
+                       MMCAM_LOG_INFO("EOS signal received");
                } else {
-                       _mmcam_dbg_err("EOS wait time out");
+                       MMCAM_LOG_ERROR("EOS wait time out");
 
                        if (hcamcorder->error_code == MM_ERROR_NONE)
                                hcamcorder->error_code = MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
                }
        } else {
-               _mmcam_dbg_log("already got EOS");
+               MMCAM_LOG_INFO("already got EOS");
        }
 
        _MMCAMCORDER_UNLOCK(handle);
@@ -2324,10 +2322,10 @@ int _mmcamcorder_get_eos_message(MMHandleType handle)
                }
        } else {
                ret = hcamcorder->error_code;
-               _mmcam_dbg_err("error 0x%x", ret);
+               MMCAM_LOG_ERROR("error 0x%x", ret);
        }
 
-       _mmcam_dbg_log("END");
+       MMCAM_LOG_INFO("END");
 
        return ret;
 }
@@ -2341,7 +2339,7 @@ void _mmcamcorder_remove_element_handle(MMHandleType handle, void *element, int
        mmf_return_if_fail(handle && remove_element);
        mmf_return_if_fail((first_elem >= 0) && (last_elem > 0) && (last_elem > first_elem));
 
-       _mmcam_dbg_log("");
+       MMCAM_LOG_INFO("");
 
        for (i = first_elem ; i <= last_elem ; i++) {
                remove_element[i].gst = NULL;
@@ -2361,26 +2359,26 @@ int _mmcamcorder_check_codec_fileformat_compatibility(const char *codec_type, in
                if (codec > MM_AUDIO_CODEC_INVALID && codec < MM_AUDIO_CODEC_NUM &&
                        file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
                        if (audiocodec_fileformat_compatibility_table[codec][file_format] == 0) {
-                               _mmcam_dbg_err("Audio codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+                               MMCAM_LOG_ERROR("Audio codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
                                return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
                        }
 
-                       _mmcam_dbg_log("Audio codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+                       MMCAM_LOG_INFO("Audio codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
                } else {
-                       _mmcam_dbg_err("Audio codec[%d] or file format[%d] is INVALID.", codec, file_format);
+                       MMCAM_LOG_ERROR("Audio codec[%d] or file format[%d] is INVALID.", codec, file_format);
                        return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
                }
        } else if (!strcmp(codec_type, MMCAM_VIDEO_ENCODER)) {
                if (codec > MM_VIDEO_CODEC_INVALID && codec < MM_VIDEO_CODEC_NUM &&
                        file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
                        if (videocodec_fileformat_compatibility_table[codec][file_format] == 0) {
-                               _mmcam_dbg_err("Video codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+                               MMCAM_LOG_ERROR("Video codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
                                return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
                        }
 
-                       _mmcam_dbg_log("Video codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+                       MMCAM_LOG_INFO("Video codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
                } else {
-                       _mmcam_dbg_err("Video codec[%d] or file format[%d] is INVALID.", codec, file_format);
+                       MMCAM_LOG_ERROR("Video codec[%d] or file format[%d] is INVALID.", codec, file_format);
                        return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
                }
        }
@@ -2402,7 +2400,7 @@ int _mmcamcorder_check_audiocodec_fileformat_compatibility(MMHandleType handle)
                MMCAM_FILE_FORMAT, &file_format,
                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;
        }
@@ -2427,7 +2425,7 @@ int _mmcamcorder_check_videocodec_fileformat_compatibility(MMHandleType handle)
                MMCAM_FILE_FORMAT, &file_format,
                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;
        }
@@ -2457,7 +2455,7 @@ bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate,
                /* Get videosink name */
                _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
                if (videosink_name == NULL) {
-                       _mmcam_dbg_err("Please check videosink element in configuration file");
+                       MMCAM_LOG_ERROR("Please check videosink element in configuration file");
                        return FALSE;
                }
 
@@ -2465,14 +2463,14 @@ bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate,
                        !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
                        !strcmp(videosink_name, "directvideosink")) {
                        MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "rotate", display_rotate);
-                       _mmcam_dbg_log("Set display-rotate [%d] done.", display_rotate);
+                       MMCAM_LOG_INFO("Set display-rotate [%d] done.", display_rotate);
                } else {
-                       _mmcam_dbg_warn("[%s] does not support DISPLAY_ROTATION, but no error", videosink_name);
+                       MMCAM_LOG_WARNING("[%s] does not support DISPLAY_ROTATION, but no error", videosink_name);
                }
 
                return TRUE;
        } else {
-               _mmcam_dbg_err("Videosink element is null");
+               MMCAM_LOG_ERROR("Videosink element is null");
                return FALSE;
        }
 }
@@ -2496,7 +2494,7 @@ bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip, int vi
                /* Get videosink name */
                _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
                if (videosink_name == NULL) {
-                       _mmcam_dbg_err("Please check videosink element in configuration file");
+                       MMCAM_LOG_ERROR("Please check videosink element in configuration file");
                        return FALSE;
                }
 
@@ -2504,14 +2502,14 @@ bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip, int vi
                        !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
                        !strcmp(videosink_name, "directvideosink")) {
                        MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "flip", display_flip);
-                       _mmcam_dbg_log("Set display flip [%d] done.", display_flip);
+                       MMCAM_LOG_INFO("Set display flip [%d] done.", display_flip);
                } else {
-                       _mmcam_dbg_warn("[%s] does not support DISPLAY_FLIP, but no error", videosink_name);
+                       MMCAM_LOG_WARNING("[%s] does not support DISPLAY_FLIP, but no error", videosink_name);
                }
 
                return TRUE;
        } else {
-               _mmcam_dbg_err("Videosink element is null");
+               MMCAM_LOG_ERROR("Videosink element is null");
                return FALSE;
        }
 }
@@ -2529,7 +2527,7 @@ bool _mmcamcorder_set_videosrc_rotation(MMHandleType handle, int videosrc_rotate
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        if (!sc) {
-               _mmcam_dbg_log("sub context is not initialized");
+               MMCAM_LOG_INFO("sub context is not initialized");
                return TRUE;
        }
 
@@ -2539,7 +2537,7 @@ bool _mmcamcorder_set_videosrc_rotation(MMHandleType handle, int videosrc_rotate
                MMCAM_CAMERA_FPS, &fps,
                NULL);
 
-       _mmcam_dbg_log("set rotate %d", videosrc_rotate);
+       MMCAM_LOG_INFO("set rotate %d", videosrc_rotate);
 
        return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc,
                sc->info_video->preview_width, sc->info_video->preview_height,
@@ -2555,6 +2553,13 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
        int fps_auto = 0;
        unsigned int caps_fourcc = 0;
        gboolean do_set_caps = FALSE;
+       char fourcc_string[sizeof(fourcc) + 1];
+       gchar *caps_str = NULL;
+#ifdef _MMCAMCORDER_PRODUCT_TV
+       gint maxwidth = 0;
+       gint maxheight = 0;
+       int display_surface_type = MM_DISPLAY_SURFACE_NULL;
+#endif /* _MMCAMCORDER_PRODUCT_TV */
 
        GstCaps *caps = NULL;
 
@@ -2567,17 +2572,17 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
 
        if (!sc || !(sc->element)) {
-               _mmcam_dbg_log("sub context is not initialized");
+               MMCAM_LOG_INFO("sub context is not initialized");
                return TRUE;
        }
 
        if (!sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
-               _mmcam_dbg_err("Video src is NULL!");
+               MMCAM_LOG_ERROR("Video src is NULL!");
                return FALSE;
        }
 
        if (!sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst) {
-               _mmcam_dbg_err("Video filter is NULL!");
+               MMCAM_LOG_ERROR("Video filter is NULL!");
                return FALSE;
        }
 
@@ -2594,7 +2599,7 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                        MMCAM_VIDEO_WIDTH, &sc->info_video->video_width,
                        MMCAM_VIDEO_HEIGHT, &sc->info_video->video_height,
                        NULL);
-               _mmcam_dbg_log("motion rate %f, capture size %dx%d, fps auto %d, video size %dx%d",
+               MMCAM_LOG_INFO("motion rate %f, capture size %dx%d, fps auto %d, video size %dx%d",
                        motion_rate, capture_width, capture_height, fps_auto,
                        sc->info_video->video_width, sc->info_video->video_height);
 
@@ -2640,7 +2645,7 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                set_width = width;
                set_height = height;
 
-               _mmcam_dbg_warn("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]", rotate);
+               MMCAM_LOG_WARNING("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]", rotate);
        }
 
        MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &caps);
@@ -2659,18 +2664,20 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                        if (format_string)
                                caps_fourcc = _mmcamcorder_convert_fourcc_string_to_value(format_string);
 
-                       gst_structure_get_int(structure, "width", &caps_width);
-                       gst_structure_get_int(structure, "height", &caps_height);
-                       gst_structure_get_int(structure, "fps", &caps_fps);
-                       gst_structure_get_int(structure, "rotate", &caps_rotate);
+                       gst_structure_get(structure,
+                               "width", G_TYPE_INT, &caps_width,
+                               "height", G_TYPE_INT, &caps_height,
+                               "fps", G_TYPE_INT, &caps_fps,
+                               "rotate", G_TYPE_INT, &caps_rotate,
+                               NULL);
 
 #ifdef _MMCAMCORDER_PRODUCT_TV
                        if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
                                if (set_width == caps_width && set_height == caps_height &&
                                        set_rotate == caps_rotate && fps == caps_fps) {
-                                       _mmcam_dbg_log("No need to replace caps.");
+                                       MMCAM_LOG_INFO("No need to replace caps.");
                                } else {
-                                       _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+                                       MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
                                                caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
                                                caps_width, caps_height, caps_fps, caps_rotate,
                                                fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
@@ -2680,9 +2687,9 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                        } else {
                                if (set_width == caps_width && set_height == caps_height &&
                                    fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
-                                       _mmcam_dbg_log("No need to replace caps.");
+                                       MMCAM_LOG_INFO("No need to replace caps.");
                                } else {
-                                       _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+                                       MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
                                                caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
                                                caps_width, caps_height, caps_fps, caps_rotate,
                                                fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
@@ -2693,9 +2700,9 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
 #else /*_MMCAMCORDER_PRODUCT_TV */
                        if (set_width == caps_width && set_height == caps_height &&
                            fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
-                               _mmcam_dbg_log("No need to replace caps.");
+                               MMCAM_LOG_INFO("No need to replace caps.");
                        } else {
-                               _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+                               MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
                                        caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
                                        caps_width, caps_height, caps_fps, caps_rotate,
                                        fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
@@ -2704,11 +2711,11 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                        }
 #endif /*_MMCAMCORDER_PRODUCT_TV */
                } else {
-                       _mmcam_dbg_log("can not get structure of caps. set new one...");
+                       MMCAM_LOG_INFO("can not get structure of caps. set new one...");
                        do_set_caps = TRUE;
                }
        } else {
-               _mmcam_dbg_log("No caps. set new one...");
+               MMCAM_LOG_INFO("No caps. set new one...");
                do_set_caps = TRUE;
        }
 
@@ -2717,83 +2724,92 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                caps = NULL;
        }
 
-       if (do_set_caps) {
-               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-#ifdef _MMCAMCORDER_PRODUCT_TV
-                       gint maxwidth = 0;
-                       gint maxheight = 0;
-                       int display_surface_type = MM_DISPLAY_SURFACE_NULL;
-                       mm_camcorder_get_attributes(handle, NULL,
-                                       MMCAM_DISPLAY_SURFACE, &display_surface_type,
-                                       NULL);
+       if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+               /* assume that it's camera capture mode */
+               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "csc-range", 1);
+       }
 
-                       if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
-                               __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
-                               _mmcam_dbg_err("can not find max resolution limitation");
-                               return false;
-                       } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
-                               maxwidth = set_width;
-                               maxheight = set_height;
-                       }
+       if (!do_set_caps)
+               return TRUE;
+
+       switch (sc->info_image->preview_format) {
+       case MM_PIXEL_FORMAT_ENCODED_H264:
+#ifdef _MMCAMCORDER_PRODUCT_TV
+               mm_camcorder_get_attributes(handle, NULL,
+                       MMCAM_DISPLAY_SURFACE, &display_surface_type,
+                       NULL);
+               if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
+                       __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
+                       MMCAM_LOG_ERROR("can not find max resolution limitation");
+                       return false;
+               } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
+                       maxwidth = set_width;
+                       maxheight = set_height;
+               }
 #endif /* _MMCAMCORDER_PRODUCT_TV */
-                       caps = gst_caps_new_simple("video/x-h264",
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               "stream-format", G_TYPE_STRING, "byte-stream",
+               caps = gst_caps_new_simple("video/x-h264",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       "stream-format", G_TYPE_STRING, "byte-stream",
 #ifdef _MMCAMCORDER_PRODUCT_TV
-                               "maxwidth", G_TYPE_INT, maxwidth,
-                               "maxheight", G_TYPE_INT, maxheight,
-                               "alignment", G_TYPE_STRING, "au",
+                       "maxwidth", G_TYPE_INT, maxwidth,
+                       "maxheight", G_TYPE_INT, maxheight,
+                       "alignment", G_TYPE_STRING, "au",
 #endif /* _MMCAMCORDER_PRODUCT_TV */
-                               NULL);
-               } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG){
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_MJPEG:
 #ifdef _MMCAMCORDER_PRODUCT_TV
-                       caps = gst_caps_new_simple("video/x-jpeg",
+               caps = gst_caps_new_simple("video/x-jpeg",
 #else
-                       caps = gst_caps_new_simple("image/jpeg",
+               caps = gst_caps_new_simple("image/jpeg",
 #endif
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               NULL);
-               } else {
-                       char fourcc_string[sizeof(fourcc)+1];
-                       memcpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
-                       fourcc_string[sizeof(fourcc)] = '\0';
-                       caps = gst_caps_new_simple("video/x-raw",
-                               "format", G_TYPE_STRING, fourcc_string,
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               "rotate", G_TYPE_INT, set_rotate,
-                               NULL);
-               }
-
-               if (caps) {
-                       gchar *caps_str = gst_caps_to_string(caps);
-
-                       if (caps_str) {
-                               _mmcam_dbg_log("vidoesrc new caps set [%s]", caps_str);
-                               g_free(caps_str);
-                               caps_str = NULL;
-                       } else {
-                               _mmcam_dbg_warn("caps string failed");
-                       }
-
-                       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
-                       gst_caps_unref(caps);
-                       caps = NULL;
-               } else {
-                       _mmcam_dbg_err("There are no caps");
-               }
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_VP8:
+               caps = gst_caps_new_simple("video/x-vp8",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_VP9:
+               caps = gst_caps_new_simple("video/x-vp9",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+               break;
+       default:
+               memcpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
+               fourcc_string[sizeof(fourcc)] = '\0';
+               caps = gst_caps_new_simple("video/x-raw",
+                       "format", G_TYPE_STRING, fourcc_string,
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       "rotate", G_TYPE_INT, set_rotate,
+                       NULL);
+               break;
        }
 
-       if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
-               /* assume that it's camera capture mode */
-               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "csc-range", 1);
+       if (!caps) {
+               MMCAM_LOG_ERROR("There are no caps");
+               return FALSE;
        }
 
+       caps_str = gst_caps_to_string(caps);
+       MMCAM_LOG_INFO("vidoesrc new caps set [%s]", caps_str);
+       g_free(caps_str);
+
+       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
+       gst_caps_unref(caps);
+
        return TRUE;
 }
 
@@ -2809,7 +2825,7 @@ bool _mmcamcorder_set_videosrc_flip(MMHandleType handle, int videosrc_flip)
        if (!sc)
                return TRUE;
 
-       _mmcam_dbg_log("Set FLIP %d", videosrc_flip);
+       MMCAM_LOG_INFO("Set FLIP %d", videosrc_flip);
 
        if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
                int hflip = 0;
@@ -2820,16 +2836,16 @@ bool _mmcamcorder_set_videosrc_flip(MMHandleType handle, int videosrc_flip)
                        hflip = (videosrc_flip & MM_FLIP_HORIZONTAL) == MM_FLIP_HORIZONTAL;
                        vflip = (videosrc_flip & MM_FLIP_VERTICAL) == MM_FLIP_VERTICAL;
 
-                       _mmcam_dbg_log("videosrc flip H:%d, V:%d", hflip, vflip);
+                       MMCAM_LOG_INFO("videosrc flip H:%d, V:%d", hflip, vflip);
 
                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hflip", hflip);
                        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "vflip", vflip);
                } else {
-                       _mmcam_dbg_warn("ITLV format does not support FLIP. Ignore FLIP[%d]",
+                       MMCAM_LOG_WARNING("ITLV format does not support FLIP. Ignore FLIP[%d]",
                                videosrc_flip);
                }
        } else {
-               _mmcam_dbg_warn("element is NULL");
+               MMCAM_LOG_WARNING("element is NULL");
                return FALSE;
        }
 
@@ -2854,7 +2870,7 @@ bool _mmcamcorder_set_videosrc_anti_shake(MMHandleType handle, int anti_shake)
        v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
 
        if (!v_src) {
-               _mmcam_dbg_warn("videosrc element is NULL");
+               MMCAM_LOG_WARNING("videosrc element is NULL");
                return FALSE;
        }
 
@@ -2862,16 +2878,16 @@ bool _mmcamcorder_set_videosrc_anti_shake(MMHandleType handle, int anti_shake)
 
        /* set anti-shake with camera control */
        if (!GST_IS_CAMERA_CONTROL(v_src)) {
-               _mmcam_dbg_warn("Can't cast Video source into camera control.");
+               MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
                return FALSE;
        }
 
        control = GST_CAMERA_CONTROL(v_src);
        if (gst_camera_control_set_ahs(control, set_value)) {
-               _mmcam_dbg_log("Succeed in operating anti-handshake. value[%d]", set_value);
+               MMCAM_LOG_INFO("Succeed in operating anti-handshake. value[%d]", set_value);
                return TRUE;
        } else {
-               _mmcam_dbg_warn("Failed to operate anti-handshake. value[%d]", set_value);
+               MMCAM_LOG_WARNING("Failed to operate anti-handshake. value[%d]", set_value);
        }
 
        return FALSE;
@@ -2891,7 +2907,7 @@ bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilizat
 
        v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
        if (!v_src) {
-               _mmcam_dbg_warn("videosrc element is NULL");
+               MMCAM_LOG_WARNING("videosrc element is NULL");
                return FALSE;
        }
 
@@ -2901,7 +2917,7 @@ bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilizat
                int video_height = 0;
 
                if (stabilization == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
-                       _mmcam_dbg_log("ENABLE video stabilization");
+                       MMCAM_LOG_INFO("ENABLE video stabilization");
 
                        /* VDIS mode only supports NV12 and [720p or 1080p or 1088 * 1088] */
                        mm_camcorder_get_attributes(handle, NULL,
@@ -2910,14 +2926,14 @@ bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilizat
                                NULL);
 
                        if (sc->info_image->preview_format == MM_PIXEL_FORMAT_NV12 && video_width >= 1080 && video_height >= 720) {
-                               _mmcam_dbg_log("NV12, video size %dx%d, ENABLE video stabilization",
+                               MMCAM_LOG_INFO("NV12, video size %dx%d, ENABLE video stabilization",
                                        video_width, video_height);
                                /* set vdis mode */
                                g_object_set(G_OBJECT(v_src),
                                                         "enable-vdis-mode", TRUE,
                                                         NULL);
                        } else {
-                               _mmcam_dbg_warn("invalid preview format %c%c%c%c or video size %dx%d",
+                               MMCAM_LOG_WARNING("invalid preview format %c%c%c%c or video size %dx%d",
                                                                sc->fourcc, sc->fourcc>>8, sc->fourcc>>16, sc->fourcc>>24,
                                                                video_width, video_height);
                                return FALSE;
@@ -2928,13 +2944,13 @@ bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilizat
                                                "enable-vdis-mode", FALSE,
                                                NULL);
 
-                       _mmcam_dbg_log("DISABLE video stabilization");
+                       MMCAM_LOG_INFO("DISABLE video stabilization");
                }
        } else if (stabilization == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
-               _mmcam_dbg_err("no property for video stabilization, so can not set ON");
+               MMCAM_LOG_ERROR("no property for video stabilization, so can not set ON");
                return FALSE;
        } else {
-               _mmcam_dbg_warn("no property for video stabilization");
+               MMCAM_LOG_WARNING("no property for video stabilization");
        }
 
        return TRUE;
@@ -2958,7 +2974,7 @@ bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int heig
                MMCAM_CAMERA_FPS, &fps,
                NULL);
 
-       _mmcam_dbg_log("set %dx%d", width, height);
+       MMCAM_LOG_INFO("set %dx%d", width, height);
 
        return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, sc->videosrc_rotate);
 }
@@ -2969,22 +2985,22 @@ bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
        _MMCamcorderSubContext *sc = NULL;
 
        if ((void *)handle == NULL) {
-               _mmcam_dbg_warn("handle is NULL");
+               MMCAM_LOG_WARNING("handle is NULL");
                return FALSE;
        }
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        if (!sc) {
-               _mmcam_dbg_warn("subcontext is NULL");
+               MMCAM_LOG_WARNING("subcontext is NULL");
                return FALSE;
        }
 
        if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
-               _mmcam_dbg_warn("videosrc plugin is NULL");
+               MMCAM_LOG_WARNING("videosrc plugin is NULL");
                return FALSE;
        }
 
-       _mmcam_dbg_log("set encoded preview bitrate : %d bps", bitrate);
+       MMCAM_LOG_INFO("set encoded preview bitrate : %d bps", bitrate);
 
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", bitrate);
 
@@ -2997,22 +3013,22 @@ bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop_
        _MMCamcorderSubContext *sc = NULL;
 
        if ((void *)handle == NULL) {
-               _mmcam_dbg_warn("handle is NULL");
+               MMCAM_LOG_WARNING("handle is NULL");
                return FALSE;
        }
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        if (!sc) {
-               _mmcam_dbg_warn("subcontext is NULL");
+               MMCAM_LOG_WARNING("subcontext is NULL");
                return FALSE;
        }
 
        if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
-               _mmcam_dbg_warn("videosrc plugin is NULL");
+               MMCAM_LOG_WARNING("videosrc plugin is NULL");
                return FALSE;
        }
 
-       _mmcam_dbg_log("set encoded preview GOP interval : %d ms", gop_interval);
+       MMCAM_LOG_INFO("set encoded preview GOP interval : %d ms", gop_interval);
 
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "gop-interval", gop_interval);
 
@@ -3026,7 +3042,7 @@ bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type,
        char stream_props[64] = {'\0',};
 
        if (element == NULL || stream_type == NULL || stream_index < 0) {
-               _mmcam_dbg_err("invalid argument %p %p %d", element, stream_type, stream_index);
+               MMCAM_LOG_ERROR("invalid argument %p %p %d", element, stream_type, stream_index);
                return FALSE;
        }
 
@@ -3034,11 +3050,11 @@ bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type,
                "props,media.role=%s, media.parent_id=%d",
                stream_type, stream_index);
 
-       _mmcam_dbg_warn("stream type %s, index %d -> [%s]", stream_type, stream_index, stream_props);
+       MMCAM_LOG_WARNING("stream type %s, index %d -> [%s]", stream_type, stream_index, stream_props);
 
        props = gst_structure_from_string(stream_props, NULL);
        if (!props) {
-               _mmcam_dbg_err("failed to create GstStructure");
+               MMCAM_LOG_ERROR("failed to create GstStructure");
                return FALSE;
        }
 
@@ -3057,14 +3073,14 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
        _MMCamcorderSubContext *sc = NULL;
        mmf_camcorder_t *hcamcorder = NULL;
        const char *videodecoder_name = NULL;
+       char videodecoder_name_final[32] = {'\0',};
        int display_surface_type = MM_DISPLAY_SURFACE_NULL;
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       char decoder_name[20] = {'\0',};
        int decoder_index = 0;
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
        if ((void *)handle == NULL) {
-               _mmcam_dbg_warn("handle is NULL");
+               MMCAM_LOG_WARNING("handle is NULL");
                return FALSE;
        }
 
@@ -3072,13 +3088,13 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        if (!sc) {
-               _mmcam_dbg_warn("subcontext is NULL");
+               MMCAM_LOG_WARNING("subcontext is NULL");
                return FALSE;
        }
 
        if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format) == false ||
                hcamcorder->recreate_decoder == FALSE) {
-               _mmcam_dbg_log("skip this fuction - format %d, recreate decoder %d",
+               MMCAM_LOG_INFO("skip this fuction - format %d, recreate decoder %d",
                        sc->info_image->preview_format, hcamcorder->recreate_decoder);
                return TRUE;
        }
@@ -3088,41 +3104,41 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
                NULL);
 
        if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
-               _mmcam_dbg_log("no need to control decoder element");
+               MMCAM_LOG_INFO("no need to control decoder element");
                return TRUE;
        }
 
        if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst == NULL ||
            sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
-               _mmcam_dbg_warn("main pipeline or decoder plugin is NULL");
+               MMCAM_LOG_WARNING("main pipeline or decoder plugin is NULL");
                return FALSE;
        }
 
-       _mmcam_dbg_log("start");
+       MMCAM_LOG_INFO("start");
 
-       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264, &videodecoder_name);
+       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElement, &videodecoder_name);
        if (videodecoder_name == NULL) {
-               _mmcam_dbg_err("failed to get decoder element name from %p", sc->VideodecoderElementH264);
+               MMCAM_LOG_ERROR("failed to get decoder element name from %p", sc->VideodecoderElement);
                return FALSE;
        }
 
        /* set state as NULL */
        ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_NULL);
        if (ret != MM_ERROR_NONE) {
-               _mmcam_dbg_err("failed to set NULL to decoder");
+               MMCAM_LOG_ERROR("failed to set NULL to decoder");
                return FALSE;
        }
 
        /* remove decoder - pads will be unlinked automatically in remove function */
        if (!gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
                            sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
-               _mmcam_dbg_err("failed to remove decoder from pipeline");
+               MMCAM_LOG_ERROR("failed to remove decoder from pipeline");
                return FALSE;
        }
 
        /* check decoder element */
        if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst) {
-               _mmcam_dbg_log("decoder[%p] is still alive - ref count %d",
+               MMCAM_LOG_INFO("decoder[%p] is still alive - ref count %d",
                        G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
                        ((GObject *)sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)->ref_count);
        }
@@ -3132,32 +3148,28 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
                if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
                        decoder_index = 1;
 
-               snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
-               _mmcam_dbg_log("encoded preview decoder_name %s", decoder_name);
-       } else {
+               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s%d", videodecoder_name, decoder_index);
+       } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
                /* MJPEG */
                if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
-                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_uhd_mjpegdec");
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_uhd_mjpegdec");
                else
-                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_mjpegdec");
-               _mmcam_dbg_log("encoded preview decoder_name %s", decoder_name);
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_mjpegdec");
+       } else {
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", videodecoder_name);
+#ifdef _MMCAMCORDER_RM_SUPPORT
        }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
 
        /* create decoder */
-       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(decoder_name, "videosrc_decode");
-       if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
-               _mmcam_dbg_err("Decoder[%s] creation fail", decoder_name);
-               return FALSE;
-       }
-#else /* _MMCAMCORDER_RM_SUPPORT */
-       /* create new decoder */
-       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name, "videosrc_decode");
+       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name_final, "videosrc_decode");
        if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
-               _mmcam_dbg_err("Decoder [%s] creation fail", videodecoder_name);
+               MMCAM_LOG_ERROR("Decoder[%s] creation fail", videodecoder_name_final);
                return FALSE;
        }
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-       _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
+
+       _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElement);
 
        sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].id = _MMCAMCORDER_VIDEOSRC_DECODE;
        g_object_weak_ref(G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
@@ -3166,7 +3178,7 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
        /* add to pipeline */
        if (!gst_bin_add(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
                sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
-               _mmcam_dbg_err("failed to add decoder to pipeline");
+               MMCAM_LOG_ERROR("failed to add decoder to pipeline");
                gst_object_unref(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst);
                return FALSE;
        }
@@ -3174,28 +3186,28 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
        /* link */
        if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst),
                GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst))) {
-               _mmcam_dbg_log("Link videosrc_queue to decoder OK");
+               MMCAM_LOG_INFO("Link videosrc_queue to decoder OK");
        } else {
-               _mmcam_dbg_err("Link videosrc_queue to decoder FAILED");
+               MMCAM_LOG_ERROR("Link videosrc_queue to decoder FAILED");
                return FALSE;
        }
 
        if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
                GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst))) {
-               _mmcam_dbg_log("Link decoder to videosink_queue OK");
+               MMCAM_LOG_INFO("Link decoder to videosink_queue OK");
        } else {
-               _mmcam_dbg_err("Link decoder to videosink_queue FAILED");
+               MMCAM_LOG_ERROR("Link decoder to videosink_queue FAILED");
                return FALSE;
        }
 
        /* set state READY */
        ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_READY);
        if (ret != MM_ERROR_NONE) {
-               _mmcam_dbg_err("failed to set READY to decoder");
+               MMCAM_LOG_ERROR("failed to set READY to decoder");
                return FALSE;
        }
 
-       _mmcam_dbg_log("done");
+       MMCAM_LOG_INFO("done");
 
        return TRUE;
 }
@@ -3222,35 +3234,35 @@ static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_wid
 
        sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
        if (!sinkpad) {
-               _mmcam_dbg_err("There are no decoder caps");
+               MMCAM_LOG_ERROR("There are no decoder caps");
                return false;
        }
 
        decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
        if (!decsink_caps) {
                gst_object_unref(sinkpad);
-               _mmcam_dbg_err("There is no decoder sink caps");
+               MMCAM_LOG_ERROR("There is no decoder sink caps");
                return false;
        }
 
        for (index = 0; index < gst_caps_get_size(decsink_caps); index++) {
                decsink_struct = gst_caps_get_structure(decsink_caps, index);
                if (!decsink_struct) {
-                       _mmcam_dbg_err("There are no structure from caps");
+                       MMCAM_LOG_ERROR("There are no structure from caps");
                        gst_object_unref(decsink_caps);
                        gst_object_unref(sinkpad);
                        return false;
                }
                mime = gst_structure_get_name(decsink_struct);
                if (!strcmp(mime, "video/x-h264")) {
-                       _mmcam_dbg_log("h264 caps structure found");
+                       MMCAM_LOG_INFO("h264 caps structure found");
                        if (gst_structure_has_field(decsink_struct, "maxwidth"))
                                *max_width = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxwidth"));
                        if (gst_structure_has_field(decsink_struct, "maxheight"))
                                *max_height = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxheight"));
                        break;
                } else if (!strcmp(mime, "video/x-jpeg")) {
-                       _mmcam_dbg_log("mjpeg caps structure found");
+                       MMCAM_LOG_INFO("mjpeg caps structure found");
                        if (gst_structure_has_field(decsink_struct, "maxwidth"))
                                *max_width = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxwidth"));
                        if (gst_structure_has_field(decsink_struct, "maxheight"))
@@ -3258,7 +3270,7 @@ static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_wid
                        break;
                }
        }
-       _mmcam_dbg_log("maxwidth = %d , maxheight = %d", (int)*max_width, (int)*max_height);
+       MMCAM_LOG_INFO("maxwidth = %d , maxheight = %d", (int)*max_width, (int)*max_height);
        gst_object_unref(decsink_caps);
        gst_object_unref(sinkpad);