Add new field to frame meta for lux index
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_internal.c
index ee7596a..fd4e76b 100644 (file)
 
 #include <mm_error.h>
 #include "mm_camcorder_internal.h"
+#include "mm_camcorder_capability.h"
 #include <mm_types.h>
 
 #include <gst/video/colorbalance.h>
-#include <gst/video/cameracontrol.h>
 #include <asm/types.h>
 
 #include <system_info.h>
 #include "mm_camcorder_rm.h"
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
-/* log level */
-int mmcam_log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
-
 /*---------------------------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS for internal                                           |
 ---------------------------------------------------------------------------------------*/
 #define __MMCAMCORDER_CMD_ITERATE_MAX           3
-#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT     5
+#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT     10
 #define __MMCAMCORDER_FORCE_STOP_TRY_COUNT      30
 #define __MMCAMCORDER_FORCE_STOP_WAIT_TIME      100000  /* us */
 #define __MMCAMCORDER_SOUND_WAIT_TIMEOUT        3
@@ -75,6 +72,7 @@ static gint     __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int devi
 static void     __mmcamcorder_deinit_handle(mmf_camcorder_t *hcamcorder);
 static gint     __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcorder);
 static gint     __mmcamcorder_init_configure_audio(mmf_camcorder_t *hcamcorder);
+static gint     __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder);
 static void     __mmcamcorder_deinit_configure(mmf_camcorder_t *hcamcorder);
 static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf);
 static void     __mmcamcorder_get_system_info(mmf_camcorder_t *hcamcorder);
@@ -89,10 +87,6 @@ static gint     __mmcamcorder_gst_handle_library_error(MMHandleType handle, int
 static gint     __mmcamcorder_gst_handle_core_error(MMHandleType handle, int code, GstMessage *message);
 static gint     __mmcamcorder_gst_handle_resource_warning(MMHandleType handle, GstMessage *message , GError *error);
 static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage *message, GError *error);
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-static int      __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
-       mm_resource_manager_res_h res, void *user_data);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
 /*=======================================================================================
 |  FUNCTION DEFINITIONS                                                                        |
@@ -100,6 +94,7 @@ static int      __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
 static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_type)
 {
        int ret = MM_ERROR_NONE;
+       int log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
        mmf_camcorder_t *new_handle = NULL;
 
        if (!hcamcorder) {
@@ -138,12 +133,10 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
        g_mutex_init(&(new_handle->mtsafe).message_cb_lock);
        g_mutex_init(&(new_handle->mtsafe).vcapture_cb_lock);
        g_mutex_init(&(new_handle->mtsafe).vstream_cb_lock);
+       g_mutex_init(&(new_handle->mtsafe).vstream_cb_flag_lock);
        g_mutex_init(&(new_handle->mtsafe).astream_cb_lock);
        g_mutex_init(&(new_handle->mtsafe).mstream_cb_lock);
        g_mutex_init(&(new_handle->mtsafe).vedecision_cb_lock);
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       g_mutex_init(&(new_handle->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
        g_mutex_init(&new_handle->restart_preview_lock);
 
@@ -157,17 +150,15 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
        new_handle->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
 
        if (device_type != MM_VIDEO_DEVICE_NONE) {
-               new_handle->gdbus_info_sound.mm_handle = new_handle;
-               g_mutex_init(&new_handle->gdbus_info_sound.sync_mutex);
-               g_cond_init(&new_handle->gdbus_info_sound.sync_cond);
+               new_handle->gdbus_info_sound = _mmcamcorder_gdbus_info_new();
+               new_handle->gdbus_info_solo_sound = _mmcamcorder_gdbus_info_new();
 
-               new_handle->gdbus_info_solo_sound.mm_handle = new_handle;
-               g_mutex_init(&new_handle->gdbus_info_solo_sound.sync_mutex);
-               g_cond_init(&new_handle->gdbus_info_solo_sound.sync_cond);
+               if (_mmcamcorder_capability_init((MMHandleType)new_handle) != MM_ERROR_NONE)
+                       MMCAM_LOG_WARNING("failed to init capability");
        }
 
        /* create task thread */
-       new_handle->task_thread = g_thread_try_new("MMCAM_TASK_THREAD",
+       new_handle->task_thread = g_thread_try_new("mmcam:util_task",
                (GThreadFunc)_mmcamcorder_util_task_thread_func, (gpointer)new_handle, NULL);
        if (new_handle->task_thread == NULL) {
                MMCAM_LOG_ERROR("_mmcamcorder_create::failed to create task thread");
@@ -186,7 +177,9 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
        _mmcamcorder_conf_get_value_int((MMHandleType)new_handle, new_handle->conf_main,
                CONFIGURE_CATEGORY_MAIN_GENERAL,
                "LogLevel",
-               &mmcam_log_level);
+               &log_level);
+
+       _mmcamcorder_set_log_level(log_level);
 
        /* allocate attribute */
        new_handle->attributes = _mmcamcorder_alloc_attribute((MMHandleType)new_handle);
@@ -195,13 +188,6 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
                goto _INIT_HANDLE_FAILED;
        }
 
-       /* Set log level to attribute */
-       ret = mm_camcorder_set_attributes((MMHandleType)new_handle, NULL,
-               MMCAM_LOG_LEVEL, mmcam_log_level,
-               NULL);
-
-       MMCAM_LOG_INFO("set log level[%d], ret[0x%x]", mmcam_log_level, ret);
-
        *hcamcorder = new_handle;
 
        MMCAM_LOG_INFO("new handle %p", new_handle);
@@ -259,27 +245,28 @@ static void __mmcamcorder_deinit_handle(mmf_camcorder_t *hcamcorder)
        g_mutex_clear(&(hcamcorder->mtsafe).message_cb_lock);
        g_mutex_clear(&(hcamcorder->mtsafe).vcapture_cb_lock);
        g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
+       g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_flag_lock);
        g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
        g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
        g_mutex_clear(&(hcamcorder->mtsafe).vedecision_cb_lock);
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
        g_mutex_clear(&hcamcorder->snd_info.open_mutex);
        g_cond_clear(&hcamcorder->snd_info.open_cond);
        g_mutex_clear(&hcamcorder->restart_preview_lock);
 
        if (hcamcorder->device_type != MM_VIDEO_DEVICE_NONE) {
-               g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
-               g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
-               g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
-               g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
+               _mmcamcorder_gdbus_info_check_free(hcamcorder->gdbus_info_sound);
+               _mmcamcorder_gdbus_info_check_free(hcamcorder->gdbus_info_solo_sound);
        }
 
        g_mutex_clear(&hcamcorder->task_thread_lock);
        g_cond_clear(&hcamcorder->task_thread_cond);
 
+       if (hcamcorder->mmcam_capability) {
+               if (_mmcamcorder_capability_deinit((MMHandleType)hcamcorder) != MM_ERROR_NONE)
+                       MMCAM_LOG_WARNING("failed to deinit capability");
+       }
+
        if (hcamcorder->model_name)
                free(hcamcorder->model_name);
 
@@ -333,13 +320,15 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
        int rcmd_fmt_recording = MM_PIXEL_FORMAT_NV12;
        int rcmd_dpy_rotation = MM_DISPLAY_ROTATION_270;
        int play_capture_sound = TRUE;
-       int camera_device_count = MM_VIDEO_DEVICE_NUM;
        int camera_default_flip = MM_FLIP_NONE;
        int camera_facing_direction = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR;
+       int wb_temp_step = 1;
+       int gain_step = 1;
        char *err_attr_name = NULL;
        char conf_file_name[__MMCAMCORDER_CONF_FILENAME_LENGTH] = {'\0',};
        const char *platform_privilege_camera = NULL;
        MMCamAttrsInfo fps_info;
+       type_element *videofilt2_element = NULL;
 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
        camera_conf_error_e ret_conf = CAMERA_CONF_MGR_ERROR_NONE;
        char devicetype[__MMCAMCORDER_CONF_FILENAME_LENGTH] = {'\0',};
@@ -350,27 +339,34 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
 
+       if (hcamcorder->is_network) {
+               snprintf(conf_file_name, sizeof(conf_file_name), "%s_network.ini",
+                       CONFIGURE_CTRL_FILE_PREFIX);
+       } else {
 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
-       snprintf(devicetype, sizeof(devicetype), "%d", hcamcorder->device_type);
-       memset(&hcamcorder->conf_device_info, 0x00, sizeof(camera_conf_device_info_s));
-       ret_conf = camera_conf_mgr_get_ids(devicetype, __MMCAMCORDER_DEVICE_TYPE_STRING_LEN,
-               &hcamcorder->conf_device_info);
-       if (ret_conf !=  CAMERA_CONF_MGR_ERROR_NONE) {
-               MMCAM_LOG_ERROR("Device [%s] is not found", devicetype);
-               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
-       }
+               snprintf(devicetype, sizeof(devicetype), "%d", hcamcorder->device_type);
+               memset(&hcamcorder->conf_device_info, 0x00, sizeof(camera_conf_device_info_s));
+               ret_conf = camera_conf_mgr_get_ids(devicetype, __MMCAMCORDER_DEVICE_TYPE_STRING_LEN,
+                       &hcamcorder->conf_device_info);
+               if (ret_conf !=  CAMERA_CONF_MGR_ERROR_NONE) {
+                       MMCAM_LOG_ERROR("Device [%s] is not found", devicetype);
+                       return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+               }
 
-       snprintf(conf_file_name, sizeof(conf_file_name), "%s_%s_%s.ini",
-               CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->conf_device_info.vendor_id,
-               hcamcorder->conf_device_info.product_id);
+               snprintf(conf_file_name, sizeof(conf_file_name), "%s_%s_%s.ini",
+                       CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->conf_device_info.vendor_id,
+                       hcamcorder->conf_device_info.product_id);
 
-       MMCAM_LOG_INFO("Load control configure file [%d][%s][%s]", hcamcorder->device_type,
-               conf_file_name, hcamcorder->conf_device_info.node);
+               MMCAM_LOG_INFO("device info : node[%s]",
+                       hcamcorder->conf_device_info.node);
 #else
-       snprintf(conf_file_name, sizeof(conf_file_name), "%s%d.ini",
-               CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->device_type);
-       MMCAM_LOG_INFO("Load control configure file [%d][%s]", hcamcorder->device_type, conf_file_name);
+               snprintf(conf_file_name, sizeof(conf_file_name), "%s%d.ini",
+                       CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->device_type);
 #endif
+       }
+
+       MMCAM_LOG_INFO("Load control configure file [%d][%s]",
+               hcamcorder->device_type, conf_file_name);
 
        ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder,
                CONFIGURE_TYPE_CTRL, (const char *)conf_file_name, &hcamcorder->conf_ctrl);
@@ -421,15 +417,15 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "RecommendDisplayRotation",
                &rcmd_dpy_rotation);
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_CAPTURE,
-               "PlayCaptureSound",
-               &play_capture_sound);
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "SupportExtraPreview",
+               (int *)&hcamcorder->extra_preview.is_supported);
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
-               "DeviceCount",
-               &camera_device_count);
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "ExtraPreviewMode",
+               (int *)&hcamcorder->extra_preview.mode);
 
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
                CONFIGURE_CATEGORY_CTRL_CAMERA,
@@ -446,15 +442,34 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "SupportZSL",
                &hcamcorder->support_zsl_capture);
 
-       MMCAM_LOG_INFO("Recommend fmt[cap:%d,rec:%d], dpy rot %d, cap snd %d, dev cnt %d, cam facing dir %d, step denom %d, support zsl %d",
-               rcmd_fmt_capture, rcmd_fmt_recording, rcmd_dpy_rotation,
-               play_capture_sound, camera_device_count, camera_facing_direction,
-               hcamcorder->brightness_step_denominator, hcamcorder->support_zsl_capture);
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_EFFECT,
+               "WhiteBalanceTemperatureStep",
+               &wb_temp_step);
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
-               "UseZeroCopyFormat",
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
+               "GainStep",
+               &gain_step);
+
+       MMCAM_LOG_INFO("Recommend format[capture:%d, recording:%d]", rcmd_fmt_capture, rcmd_fmt_recording);
+       MMCAM_LOG_INFO("Recommend display rotation[%d]", rcmd_dpy_rotation);
+       MMCAM_LOG_INFO("Camera facing direction[%d]", camera_facing_direction);
+       MMCAM_LOG_INFO("Brightness step denominator[%d]", hcamcorder->brightness_step_denominator);
+       MMCAM_LOG_INFO("Support ZSL capture[%d]", hcamcorder->support_zsl_capture);
+       MMCAM_LOG_INFO("Step: wb_temp[%d], gain[%d]", wb_temp_step, gain_step);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "AltUseZeroCopyFormat",
                &hcamcorder->use_zero_copy_format);
+       if (hcamcorder->use_zero_copy_format == -1) {
+               MMCAM_LOG_WARNING("AltUseZeroCopyFormat is not set, so use \"UseZeroCopyFormat\".");
+               _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+                       CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+                       "UseZeroCopyFormat",
+                       &hcamcorder->use_zero_copy_format);
+       }
 
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
                CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
@@ -471,6 +486,50 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "UseVideoconvert",
                &hcamcorder->use_videoconvert);
 
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+               "MeasurePreviewFPS",
+               &hcamcorder->measure_preview_fps);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+               "DefaultEncodedPreviewBitrate",
+               &hcamcorder->default_encoded_preview_bitrate);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+               "UpdateCapsByRotation",
+               &hcamcorder->update_caps_by_stream_rotation);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_CAPTURE,
+               "CaptureMode",
+               &hcamcorder->capture_mode);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_CAPTURE,
+               "PlayCaptureSound",
+               &play_capture_sound);
+
+       _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "VideoFilter2Element",
+               &videofilt2_element);
+       hcamcorder->support_media_packet_preview_internal_cb = videofilt2_element ? TRUE : FALSE;
+
+       MMCAM_LOG_INFO("Support user buffer[%d]", hcamcorder->support_user_buffer);
+       MMCAM_LOG_INFO("Support media packet preview cb[%d]", hcamcorder->support_media_packet_preview_cb);
+       MMCAM_LOG_INFO("Support media packet preview internal cb[%d]", hcamcorder->support_media_packet_preview_internal_cb);
+       MMCAM_LOG_INFO("Support extra preview[%d]", hcamcorder->extra_preview.is_supported);
+       MMCAM_LOG_INFO("Extra preview mode[%d]", hcamcorder->extra_preview.mode);
+       MMCAM_LOG_INFO("Capture mode[%d]", hcamcorder->capture_mode);
+       MMCAM_LOG_INFO("Use zero copy format[%d]", hcamcorder->use_zero_copy_format);
+       MMCAM_LOG_INFO("Use video convert[%d]", hcamcorder->use_videoconvert);
+       MMCAM_LOG_INFO("Measure preview FPS[%d]", hcamcorder->measure_preview_fps);
+       MMCAM_LOG_INFO("Default encoded preview bitrate[%d]", hcamcorder->default_encoded_preview_bitrate);
+       MMCAM_LOG_INFO("Update capsfilter by stream rotation[%d]", hcamcorder->update_caps_by_stream_rotation);
+       MMCAM_LOG_INFO("Play capture sound[%d]", play_capture_sound);
+
        ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
                MMCAM_CAMERA_WIDTH, &resolution_width,
                MMCAM_CAMERA_HEIGHT, &resolution_height,
@@ -486,10 +545,6 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                return MM_ERROR_CAMCORDER_INTERNAL;
        }
 
-       MMCAM_LOG_INFO("ZeroCopy %d, UserBuffer %d, Videoconvert %d, MPPreviewCb %d",
-               hcamcorder->use_zero_copy_format, hcamcorder->support_user_buffer,
-               hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
-
        MMCAM_LOG_INFO("res : %d X %d, Default FPS by resolution : %d",
                resolution_width, resolution_height, fps_info.int_array.def);
 
@@ -507,8 +562,16 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "PlatformPrivilegeCamera",
                &platform_privilege_camera);
 
+       if (hcamcorder->is_network) {
+               _mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
+                       CONFIGURE_CATEGORY_MAIN_GENERAL,
+                       "NetworkCameraHALName",
+                       &hcamcorder->network_hal_name);
+
+               MMCAM_LOG_INFO("network HAL name[%s]", hcamcorder->network_hal_name);
+       }
+
        ret = mm_camcorder_set_attributes((MMHandleType)hcamcorder, &err_attr_name,
-               MMCAM_CAMERA_DEVICE_COUNT, camera_device_count,
                MMCAM_CAMERA_FACING_DIRECTION, camera_facing_direction,
                MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, rcmd_fmt_capture,
                MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING, rcmd_fmt_recording,
@@ -516,12 +579,17 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                MMCAM_SUPPORT_ZSL_CAPTURE, hcamcorder->support_zsl_capture,
                MMCAM_SUPPORT_ZERO_COPY_FORMAT, hcamcorder->use_zero_copy_format,
                MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, hcamcorder->support_media_packet_preview_cb,
+               MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_INTERNAL_CB, hcamcorder->support_media_packet_preview_internal_cb,
                MMCAM_SUPPORT_USER_BUFFER, hcamcorder->support_user_buffer,
+               MMCAM_SUPPORT_EXTRA_PREVIEW, hcamcorder->extra_preview.is_supported,
                MMCAM_CAMERA_FPS, fps_info.int_array.def,
                MMCAM_DISPLAY_FLIP, camera_default_flip,
                MMCAM_CAPTURE_SOUND_ENABLE, play_capture_sound,
                MMCAM_PLATFORM_PRIVILEGE_CAMERA, platform_privilege_camera,
                        platform_privilege_camera ? strlen(platform_privilege_camera) : 0,
+               MMCAM_ENCODED_PREVIEW_BITRATE, hcamcorder->default_encoded_preview_bitrate,
+               MMCAM_FILTER_WB_TEMPERATURE_STEP, wb_temp_step,
+               MMCAM_CAMERA_GAIN_STEP, gain_step,
                NULL);
        if (ret != MM_ERROR_NONE) {
                MMCAM_LOG_ERROR("[0x%x] Set %s FAILED.", ret, err_attr_name ? err_attr_name : "[UNKNOWN]");
@@ -547,7 +615,28 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
 static gint __mmcamcorder_init_configure_audio(mmf_camcorder_t *hcamcorder)
 {
        int ret = MM_ERROR_NONE;
-       int camera_device_count = 0;
+
+       if (!hcamcorder) {
+               MMCAM_LOG_ERROR("NULL handle");
+               return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+       }
+
+       ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_AUDIO);
+       if (ret != MM_ERROR_NONE) {
+               MMCAM_LOG_ERROR("there is no audio device");
+               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+       }
+
+       return ret;
+}
+
+
+static gint __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder)
+{
+       int ret = MM_ERROR_NONE;
+       int device_count = 0;
+       const char *videosrc_name = NULL;
+       const char *audiosrc_name = NULL;
 
        if (!hcamcorder) {
                MMCAM_LOG_ERROR("NULL handle");
@@ -557,21 +646,26 @@ static gint __mmcamcorder_init_configure_audio(mmf_camcorder_t *hcamcorder)
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
                CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
                "DeviceCount",
-               &camera_device_count);
+               &device_count);
+
+       _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+               hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement",
+               NULL, &videosrc_name);
+
+       _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+               hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, "AudiosrcElement",
+               NULL, &audiosrc_name);
+
+       MMCAM_LOG_INFO("Device count[%d], Videosrc[%s], Audiosrc[%s]",
+               device_count, videosrc_name, audiosrc_name);
 
        ret = mm_camcorder_set_attributes((MMHandleType)hcamcorder, NULL,
-               MMCAM_CAMERA_DEVICE_COUNT, camera_device_count,
+               MMCAM_CAMERA_DEVICE_COUNT, device_count,
+               MMCAM_VIDEOSRC_ELEMENT_NAME, videosrc_name, videosrc_name ? strlen(videosrc_name) : 0,
+               MMCAM_AUDIOSRC_ELEMENT_NAME, audiosrc_name, audiosrc_name ? strlen(audiosrc_name) : 0,
                NULL);
-       if (ret != MM_ERROR_NONE) {
-               MMCAM_LOG_ERROR("Set device count FAILED");
-               return MM_ERROR_CAMCORDER_INTERNAL;
-       }
-
-       ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_AUDIO);
-       if (ret != MM_ERROR_NONE) {
-               MMCAM_LOG_ERROR("there is no audio device");
-               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
-       }
+       if (ret != MM_ERROR_NONE)
+               MMCAM_LOG_ERROR("Set FAILED[0x%x]", ret);
 
        return ret;
 }
@@ -619,16 +713,25 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
        if (ret != MM_ERROR_NONE)
                return ret;
 
+       /* set network camera flag */
+       hcamcorder->is_network = (gboolean)info->reserved[0];
+
        /* get DPM handle for camera/microphone restriction */
        hcamcorder->dpm_handle = dpm_manager_create();
 
        MMCAM_LOG_WARNING("DPM handle %p", hcamcorder->dpm_handle);
 
+       ret = __mmcamcorder_init_configure_common(hcamcorder);
+       if (ret != MM_ERROR_NONE)
+               goto _ERR_DEFAULT_VALUE_INIT;
+
        if (hcamcorder->device_type != MM_VIDEO_DEVICE_NONE) {
                ret = __mmcamcorder_init_configure_video_capture(hcamcorder);
-               if (ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE)
                        goto _ERR_DEFAULT_VALUE_INIT;
-               }
+
+               if (_mmcamcorder_capability_update_preview_format_list((MMHandleType)hcamcorder) != MM_ERROR_NONE)
+                       MMCAM_LOG_WARNING("update preview format list failed");
 
                /* add DPM camera policy changed callback */
                if (hcamcorder->dpm_handle) {
@@ -641,23 +744,10 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
 
                        MMCAM_LOG_INFO("DPM camera changed cb id %d", hcamcorder->dpm_camera_cb_id);
                }
-
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-               /* initialize resource manager */
-               ret = mm_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
-                               __mmcamcorder_resource_release_cb, hcamcorder,
-                               &hcamcorder->resource_manager);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMCAM_LOG_ERROR("failed to initialize resource manager");
-                       ret = MM_ERROR_CAMCORDER_INTERNAL;
-                       goto _ERR_DEFAULT_VALUE_INIT;
-               }
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
        } else {
                ret = __mmcamcorder_init_configure_audio(hcamcorder);
-               if (ret != MM_ERROR_NONE) {
+               if (ret != MM_ERROR_NONE)
                        goto _ERR_DEFAULT_VALUE_INIT;
-               }
        }
 
        traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:CREATE:INIT_GSTREAMER");
@@ -675,9 +765,6 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
        /* Make some attributes as read-only type */
        _mmcamcorder_lock_readonly_attributes((MMHandleType)hcamcorder);
 
-       /* Disable attributes in each model */
-       _mmcamcorder_set_disabled_attributes((MMHandleType)hcamcorder);
-
        /* get system information */
        __mmcamcorder_get_system_info(hcamcorder);
 
@@ -691,11 +778,6 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
        return MM_ERROR_NONE;
 
 _ERR_DEFAULT_VALUE_INIT:
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       /* de-initialize resource manager */
-       if (hcamcorder->resource_manager != NULL)
-               mm_resource_manager_destroy(hcamcorder->resource_manager);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
        /* release DPM related handle */
        if (hcamcorder->dpm_handle) {
@@ -779,19 +861,6 @@ int _mmcamcorder_destroy(MMHandleType handle)
                hcamcorder->sub_context = NULL;
        }
 
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       /* de-initialize resource manager */
-       _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
-       if (hcamcorder->resource_manager != NULL) {
-               ret = mm_resource_manager_destroy(hcamcorder->resource_manager);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
-                       MMCAM_LOG_ERROR("failed to de-initialize resource manager 0x%x", ret);
-       }
-
-       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-
        /* Remove messages which are not called yet */
        _mmcamcorder_remove_message_all(handle);
 
@@ -843,8 +912,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
        char *videosink_element_type = NULL;
        const char *videosink_name = NULL;
-       char *socket_path = NULL;
-       int socket_path_len = 0;
        int conn_size = 0;
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
@@ -901,12 +968,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        if (motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
                hcamcorder->sub_context->is_modified_rate = TRUE;
 
-       _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_CAPTURE,
-               "UseEncodebin",
-               &(hcamcorder->sub_context->bencbin_capture));
-       MMCAM_LOG_WARNING("UseEncodebin [%d]", hcamcorder->sub_context->bencbin_capture);
-
        if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
                /* get video recording info */
                _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
@@ -935,17 +996,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        case MM_DISPLAY_SURFACE_NULL:
                videosink_element_type = strdup("VideosinkElementNull");
                break;
-       case MM_DISPLAY_SURFACE_REMOTE:
-               mm_camcorder_get_attributes(handle, NULL,
-                       MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
-                       NULL);
-               if (socket_path == NULL) {
-                       MMCAM_LOG_WARNING("REMOTE surface, but socket path is NULL -> to NullSink");
-                       videosink_element_type = strdup("VideosinkElementNull");
-               } else {
-                       videosink_element_type = strdup("VideosinkElementRemote");
-               }
-               break;
        default:
                videosink_element_type = strdup("VideosinkElementOverlay");
                break;
@@ -960,7 +1010,7 @@ int _mmcamcorder_realize(MMHandleType handle)
                free(videosink_element_type);
                videosink_element_type = NULL;
        } else {
-               MMCAM_LOG_WARNING("strdup failed(display_surface_type %d). Use default X type",
+               MMCAM_LOG_WARNING("strdup failed(display_surface_type %d). Use default Overlay type",
                        display_surface_type);
 
                _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
@@ -1006,53 +1056,6 @@ int _mmcamcorder_realize(MMHandleType handle)
                        MMCAM_LOG_WARNING("NULL dpm_handle");
                }
 
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-               _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-               /* prepare resource manager for camera */
-               if (hcamcorder->camera_resource == NULL) {
-                       ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
-                                       MM_RESOURCE_MANAGER_RES_TYPE_CAMERA,
-                                       1,
-                                       &hcamcorder->camera_resource);
-                       if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               MMCAM_LOG_ERROR("could not prepare for camera resource");
-                               ret = MM_ERROR_RESOURCE_INTERNAL;
-                               _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                       }
-               } else {
-                       MMCAM_LOG_INFO("camera already acquired");
-               }
-
-               /* prepare resource manager for "video_overlay only if display surface is X" */
-               if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
-                       if (hcamcorder->video_overlay_resource == NULL) {
-                               ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
-                                               MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY,
-                                               MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
-                                               &hcamcorder->video_overlay_resource);
-                               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                                       MMCAM_LOG_ERROR("could not prepare for overlay resource");
-                                       ret = MM_ERROR_RESOURCE_INTERNAL;
-                                       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                               }
-                       } else {
-                               MMCAM_LOG_INFO("overlay already acquired");
-                       }
-               }
-
-               /* acquire resources */
-               ret = mm_resource_manager_commit(hcamcorder->resource_manager);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMCAM_LOG_ERROR("could not acquire resources");
-                       ret = MM_ERROR_RESOURCE_INTERNAL;
-                       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-               }
-               _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-
 #ifdef _MMCAMCORDER_RM_SUPPORT
                ret = _mmcamcorder_rm_create(handle);
                if (ret != MM_ERROR_NONE) {
@@ -1104,24 +1107,7 @@ int _mmcamcorder_realize(MMHandleType handle)
        return MM_ERROR_NONE;
 
 _ERR_CAMCORDER_CMD:
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       /* release hw resources */
-       _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-       if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
-               if (hcamcorder->camera_resource != NULL) {
-                       mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
-                                       hcamcorder->camera_resource);
-                       hcamcorder->camera_resource = NULL;
-               }
-               if (hcamcorder->video_overlay_resource != NULL) {
-                       mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
-                                       hcamcorder->video_overlay_resource);
-                       hcamcorder->video_overlay_resource = NULL;
-               }
-               mm_resource_manager_commit(hcamcorder->resource_manager);
-       }
-       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
 #ifdef _MMCAMCORDER_RM_SUPPORT
        _mmcamcorder_rm_deallocate(handle);
        _mmcamcorder_rm_release(handle);
@@ -1174,62 +1160,6 @@ int _mmcamcorder_unrealize(MMHandleType handle)
                hcamcorder->sub_context = NULL;
        }
 
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-       _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-       MMCAM_LOG_WARNING("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
-
-       if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
-               hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM &&
-               hcamcorder->is_release_cb_calling == FALSE) {
-
-               /* release resource */
-               if (hcamcorder->camera_resource != NULL) {
-                       ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
-                                       hcamcorder->camera_resource);
-                       if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               MMCAM_LOG_ERROR("could not mark camera resource for release");
-                               ret = MM_ERROR_CAMCORDER_INTERNAL;
-                               _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                               MMCAM_LOG_INFO("unlock resource");
-                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                       }
-               }
-
-               if (hcamcorder->video_overlay_resource != NULL) {
-                       ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
-                                       hcamcorder->video_overlay_resource);
-                       if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                               MMCAM_LOG_ERROR("could not mark overlay resource for release");
-                               ret = MM_ERROR_CAMCORDER_INTERNAL;
-                               _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                               MMCAM_LOG_INFO("unlock resource");
-                               goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-                       }
-               }
-
-               ret = mm_resource_manager_commit(hcamcorder->resource_manager);
-
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMCAM_LOG_ERROR("failed to release resource, ret(0x%x)", ret);
-                       ret = MM_ERROR_CAMCORDER_INTERNAL;
-
-                       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-                       MMCAM_LOG_INFO("unlock resource");
-
-                       goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
-               } else {
-                       if (hcamcorder->camera_resource != NULL)
-                               hcamcorder->camera_resource = NULL;
-                       if (hcamcorder->video_overlay_resource != NULL)
-                               hcamcorder->video_overlay_resource = NULL;
-               }
-       }
-
-       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
-       MMCAM_LOG_WARNING("unlock resource");
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-
 #ifdef _MMCAMCORDER_RM_SUPPORT
        _mmcamcorder_rm_deallocate(handle);
 #endif /* _MMCAMCORDER_RM_SUPPORT*/
@@ -1364,23 +1294,6 @@ int _mmcamcorder_stop(MMHandleType handle)
 
        _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
 
-       if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
-               /* unsubscribe remained unsubscribed signal */
-               g_mutex_lock(&hcamcorder->gdbus_info_sound.sync_mutex);
-               if (hcamcorder->gdbus_info_sound.subscribe_id > 0) {
-                       MMCAM_LOG_WARNING("subscribe_id[%u] is remained. remove it.", hcamcorder->gdbus_info_sound.subscribe_id);
-                       g_dbus_connection_signal_unsubscribe(hcamcorder->gdbus_conn, hcamcorder->gdbus_info_sound.subscribe_id);
-               }
-               g_mutex_unlock(&hcamcorder->gdbus_info_sound.sync_mutex);
-
-               g_mutex_lock(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
-               if (hcamcorder->gdbus_info_solo_sound.subscribe_id > 0) {
-                       MMCAM_LOG_WARNING("subscribe_id[%u] is remained. remove it.", hcamcorder->gdbus_info_solo_sound.subscribe_id);
-                       g_dbus_connection_signal_unsubscribe(hcamcorder->gdbus_conn, hcamcorder->gdbus_info_solo_sound.subscribe_id);
-               }
-               g_mutex_unlock(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
-       }
-
        _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
 
        return MM_ERROR_NONE;
@@ -1823,9 +1736,6 @@ int _mmcamcorder_set_video_stream_callback(MMHandleType handle, mm_camcorder_vid
 
        mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       if (callback == NULL)
-               MMCAM_LOG_WARNING("Video Stream Callback is disabled, because application sets it to NULL");
-
        _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
 
        hcamcorder->vstream_cb = callback;
@@ -2237,6 +2147,51 @@ int _mmcamcorder_stop_focusing(MMHandleType handle)
        }
 }
 
+int _mmcamcorder_get_exposure(MMHandleType handle, int *exposure)
+{
+       int ret = MM_ERROR_NONE;
+       int state = MM_CAMCORDER_STATE_NONE;
+       GstCameraControl *control = NULL;
+       _MMCamcorderSubContext *sc = NULL;
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+       mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+       mmf_return_val_if_fail(exposure, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+       state = _mmcamcorder_get_state(handle);
+       if (state < MM_CAMCORDER_STATE_READY) {
+               ret = mm_camcorder_get_attributes(handle, NULL,
+                       MMCAM_CAMERA_EXPOSURE_VALUE, exposure,
+                       NULL);
+
+               MMCAM_LOG_INFO("exposure[%d] from attribute[ret:0x%x]", *exposure, ret);
+
+               return ret;
+       }
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+       mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+       if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
+               MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
+               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+       }
+
+       control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+       if (!control) {
+               MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
+               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+       }
+
+       if (!gst_camera_control_get_exposure(control, GST_CAMERA_CONTROL_EXPOSURE_VALUE, exposure, NULL)) {
+               MMCAM_LOG_ERROR("get exposure failed");
+               return MM_ERROR_CAMCORDER_INTERNAL;
+       }
+
+       MMCAM_LOG_INFO("exposure[%d] from device", *exposure);
+
+       return MM_ERROR_NONE;
+}
 
 /*-----------------------------------------------
 |        CAMCORDER INTERNAL LOCAL              |
@@ -2257,8 +2212,8 @@ static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf)
        MMCAM_LOG_INFO("");
 
        /* alloc */
-       argc = malloc(sizeof(int));
-       argv = malloc(sizeof(gchar *) * max_argc);
+       argc = g_new(int, 1);
+       argv = g_new(gchar *, max_argc);
 
        if (!argc || !argv)
                goto ERROR;
@@ -2301,30 +2256,16 @@ static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf)
                }
        }
 
-       if (argv) {
-               free(argv);
-               argv = NULL;
-       }
-
-       if (argc) {
-               free(argc);
-               argc = NULL;
-       }
+       g_free(argv);
+       g_free(argc);
 
        return ret;
 
 ERROR:
        MMCAM_LOG_ERROR("failed to initialize gstreamer");
 
-       if (argv) {
-               free(argv);
-               argv = NULL;
-       }
-
-       if (argc) {
-               free(argc);
-               argc = NULL;
-       }
+       g_free(argv);
+       g_free(argc);
 
        return FALSE;
 }
@@ -2516,6 +2457,8 @@ int _mmcamcorder_set_functions(MMHandleType handle, int type)
 {
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
 
+       mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
        /*MMCAM_LOG_INFO("");*/
 
        switch (type) {
@@ -3036,17 +2979,11 @@ int _mmcamcorder_create_pipeline(MMHandleType handle, int type)
 
                break;
        case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
+               /* fall through */
        default:
                ret = _mmcamcorder_create_preview_pipeline(handle);
                if (ret != MM_ERROR_NONE)
                        return ret;
-
-               /* connect capture signal */
-               if (!sc->bencbin_capture) {
-                       ret = _mmcamcorder_connect_capture_signal(handle);
-                       if (ret != MM_ERROR_NONE)
-                               return ret;
-               }
                break;
        }
 
@@ -3793,58 +3730,6 @@ void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
 }
 
 
-#ifdef _MMCAMCORDER_MM_RM_SUPPORT
-static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
-       mm_resource_manager_res_h res, void *user_data)
-{
-       mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *) user_data;
-
-       mmf_return_val_if_fail(hcamcorder, FALSE);
-
-       MMCAM_LOG_WARNING("enter");
-
-       _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
-       /* set flag for resource release callback */
-       hcamcorder->is_release_cb_calling = TRUE;
-
-       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
-       _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
-
-       if (res == hcamcorder->video_encoder_resource) {
-               /* Stop video recording */
-               if (_mmcamcorder_commit((MMHandleType)hcamcorder) != MM_ERROR_NONE) {
-                       MMCAM_LOG_ERROR("commit failed, cancel it");
-                       _mmcamcorder_cancel((MMHandleType)hcamcorder);
-               }
-       } else {
-               /* Stop camera */
-               __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
-       }
-
-       _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
-
-       _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
-       if (res == hcamcorder->camera_resource)
-               hcamcorder->camera_resource = NULL;
-       else if (res == hcamcorder->video_overlay_resource)
-               hcamcorder->video_overlay_resource = NULL;
-       else if (res == hcamcorder->video_encoder_resource)
-               hcamcorder->video_encoder_resource = NULL;
-
-       /* restore flag for resource release callback */
-       hcamcorder->is_release_cb_calling = FALSE;
-
-       _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
-       MMCAM_LOG_WARNING("leave");
-
-       return TRUE;
-}
-#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-
 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
 {
        int ret = MM_ERROR_NONE;