summaryrefslogtreecommitdiff
path: root/src/cam_mm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cam_mm.c')
-rwxr-xr-xsrc/cam_mm.c2431
1 files changed, 2431 insertions, 0 deletions
diff --git a/src/cam_mm.c b/src/cam_mm.c
new file mode 100755
index 0000000..5d799ad
--- /dev/null
+++ b/src/cam_mm.c
@@ -0,0 +1,2431 @@
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <string.h>
+#include "cam_mm.h"
+#include "cam_debug.h"
+#include "cam_ta.h"
+#include "cam_property.h"
+#include "cam_typeconverter.h"
+
+typedef struct _CamMMHandle {
+ camera_h hcam;
+ recorder_h hrec;
+ camera_device_e hdev;
+} CamMMHandle;
+
+static unsigned int g_caps = 0;
+static int g_caps_cb_cnt = 0;
+
+
+static void __get_iso_cb(camera_attr_iso_e iso, void *user_data);
+static void __get_effect_cb(camera_attr_effect_mode_e effect, void *user_data);
+static void __get_fps_cb(camera_attr_fps_e fps, void *user_data);
+static void __get_wb_cb(camera_attr_whitebalance_e wb, void *user_data);
+static void __get_focus_cb(camera_attr_af_mode_e focus, void *user_data);
+static void __get_metering_cb(camera_attr_exposure_mode_e metering, void *user_data);
+static void __get_scene_cb(camera_attr_scene_mode_e scene, void *user_data);
+static void __get_flash_cb(camera_attr_flash_mode_e flash, void *user_data);
+static void __get_capture_res_cb(int width, int height, void *user_data);
+static void __get_recording_res_cb(int width, int height, void *user_data);
+
+
+
+void rec_detail_error_get(int err_no)
+{
+ switch(err_no) {
+ case RECORDER_ERROR_INVALID_PARAMETER:
+ DEBUG_TRACE("RECORDER_ERROR_INVALID_PARAMETER");
+ break;
+ case RECORDER_ERROR_INVALID_STATE:
+ DEBUG_TRACE("RECORDER_ERROR_INVALID_STATE");
+ break;
+ case RECORDER_ERROR_OUT_OF_MEMORY:
+ DEBUG_TRACE("RECORDER_ERROR_OUT_OF_MEMORY");
+ break;
+ case RECORDER_ERROR_DEVICE:
+ DEBUG_TRACE("RECORDER_ERROR_DEVICE");
+ break;
+ case RECORDER_ERROR_INVALID_OPERATION:
+ DEBUG_TRACE("RECORDER_ERROR_INVALID_OPERATION");
+ break;
+ case RECORDER_ERROR_SOUND_POLICY:
+ DEBUG_TRACE("RECORDER_ERROR_SOUND_POLICY");
+ break;
+ case RECORDER_ERROR_NONE:
+ DEBUG_TRACE("NO ERROR");
+ break;
+ default:
+ DEBUG_TRACE("unknown error,err_no = %d", err_no);
+
+ }
+
+}
+void cam_detail_error_get(int err_no)
+{
+ switch(err_no) {
+ case CAMERA_ERROR_INVALID_PARAMETER:
+ DEBUG_TRACE("CAMERA_ERROR_INVALID_PARAMETER");
+ break;
+ case CAMERA_ERROR_INVALID_STATE:
+ DEBUG_TRACE("CAMERA_ERROR_INVALID_STATE");
+ break;
+ case CAMERA_ERROR_OUT_OF_MEMORY:
+ DEBUG_TRACE("CAMERA_ERROR_OUT_OF_MEMORY");
+ break;
+ case CAMERA_ERROR_DEVICE:
+ DEBUG_TRACE("CAMERA_ERROR_DEVICE");
+ break;
+ case CAMERA_ERROR_INVALID_OPERATION:
+ DEBUG_TRACE("CAMERA_ERROR_INVALID_OPERATION");
+ break;
+ case CAMERA_ERROR_SOUND_POLICY:
+ DEBUG_TRACE("CAMERA_ERROR_SOUND_POLICY");
+ break;
+ case CAMERA_ERROR_NONE:
+ DEBUG_TRACE("NO ERROR");
+ break;
+ default:
+ DEBUG_TRACE("unknown error,err_no = %d", err_no);
+
+ }
+}
+
+
+static CamMMHandle *g_mm_handle = NULL;
+
+int cam_mm_get_cam_state(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ int ret = 0;
+ camera_state_e state = 0;
+ ret = camera_get_state(g_mm_handle->hcam, &state);
+ if (ret == CAMERA_ERROR_NONE)
+ return (int)state;
+ else
+ return -1;
+}
+
+int cam_mm_get_state(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ int ret = 0;
+ camera_state_e state = 0;
+ struct appdata *ad = (struct appdata *)cam_appdata_get();
+ g_return_val_if_fail(ad, FALSE);
+ CamAppData *camapp = ad->camapp_handle;
+ g_return_val_if_fail(camapp, FALSE);
+ if (camapp->camera_mode == CAM_CAMERA_MODE) {
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ ret = camera_get_state(g_mm_handle->hcam, (camera_state_e *)&state);
+ if (ret == CAMERA_ERROR_NONE)
+ return (int)state;
+ else
+ return -1;
+ }
+ if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ ret = recorder_get_state(g_mm_handle->hrec, (recorder_state_e *)&state);
+ if (ret == RECORDER_ERROR_NONE)
+ return (int)state;
+ else
+ return -1;
+ }
+ return -1;
+}
+
+int cam_mm_get_rec_state(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ int ret = 0;
+ recorder_state_e state = 0;
+ ret = recorder_get_state(g_mm_handle->hrec, (recorder_state_e *)&state);
+ if (ret == RECORDER_ERROR_NONE)
+ return (int)state;
+ else
+ return -1;
+}
+
+gboolean cam_mm_get_video_device(int *device)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+
+ if (g_mm_handle->hdev > CAMERA_DEVICE_CAMERA1)
+ return FALSE;
+
+ *device = g_mm_handle->hdev;
+ DEBUG_TRACE("%d,%d",g_mm_handle->hdev,*device);
+ return TRUE;
+}
+
+gboolean cam_mm_get_video_size(int *width, int *height)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ ret = camera_get_preview_resolution(g_mm_handle->hcam, width, height);
+
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("camera_get_preview_resolution error code = %d" , ret);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_video_size(int width, int height)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_preview_resolution(g_mm_handle->hcam, width, height);
+
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_zoom(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ ret = camera_attr_get_zoom(g_mm_handle->hcam, value);
+ if (ret) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_zoom(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_zoom(g_mm_handle->hcam, value);
+ if (ret) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_wdr(int *value)
+{
+/*TODO:we do not need set this attribute now*/
+#ifdef TODO_SURRPORT
+ return TRUE;
+#endif
+}
+
+gboolean cam_mm_set_wdr(int value)
+{
+/*TODO:we do not need set this attribute now*/
+#ifdef TODO_SURRPORT
+ return TRUE;
+#endif
+}
+
+gboolean cam_mm_is_support_anti_hand_shake()
+{
+ bool ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_is_supported_anti_shake(g_mm_handle->hcam);
+
+ return ret;
+
+}
+
+gboolean cam_mm_get_anti_hand_shake(gboolean *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_is_enabled_anti_shake(g_mm_handle->hcam, (bool *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_anti_hand_shake(gboolean value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_enable_anti_shake(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_auto_exposure(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_exposure_mode(g_mm_handle->hcam, (camera_attr_exposure_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_auto_exposure(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_exposure_mode(g_mm_handle->hcam, (camera_attr_exposure_mode_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_fps(camera_attr_fps_e value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_preview_fps(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+ cam_detail_error_get(ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_iso(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_iso(g_mm_handle->hcam, (camera_attr_iso_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_iso(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_iso(g_mm_handle->hcam, (camera_attr_iso_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_focus_mode(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_af_mode(g_mm_handle->hcam, (camera_attr_af_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_focus_mode(int value)
+{
+ int ret = 0;
+ ret = camera_attr_set_af_mode(g_mm_handle->hcam, (camera_attr_af_mode_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_zoom_valid_intrange(int *min, int *max)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_zoom_range(g_mm_handle->hcam, min, max);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_brightless_valid_intrange(int *min, int *max)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_brightness_range(g_mm_handle->hcam, min, max);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_exposure_valid_intrange(int *min, int *max)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_exposure_range(g_mm_handle->hcam, min, max);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_af_area(int x, int y, int w, int h)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ DEBUG_TRACE("\n Touch AF area ![ x,y,width,height: %d,%d,%d,%d ]\n", x, y, w, h);
+
+ ret = camera_attr_set_af_area(g_mm_handle->hcam, x, y);
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("camera_attr_set_af_area failed [%d]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_detect_mode(int *value)
+{
+#ifndef TODO_SURRPORT
+/*TODO:framework not surrport it*/
+#endif
+ return TRUE;
+}
+
+gboolean cam_mm_set_detect_mode(int value)
+{
+/*TODO:libmm-camcorder not surrport it*/
+#ifdef TODO_SURRPORT
+ return TRUE;
+#endif
+}
+
+gboolean cam_mm_get_image_enc_quality(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_image_quality(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_image_enc_quality(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_image_quality(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_flash(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_flash_mode(g_mm_handle->hcam, (camera_attr_flash_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_flash(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_flash_mode(g_mm_handle->hcam, (camera_attr_flash_mode_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_enable_auto_contrast(gboolean enable)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_enable_auto_contrast(g_mm_handle->hcam, enable);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_is_enabled_auto_contrast(gboolean *enable)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_is_enabled_auto_contrast(g_mm_handle->hcam, (bool *)enable);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_brightness(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_brightness(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_brightness(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_brightness(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_white_balance(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_whitebalance(g_mm_handle->hcam, (camera_attr_whitebalance_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_white_balance(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_whitebalance(g_mm_handle->hcam, (camera_attr_whitebalance_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_effect(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_effect(g_mm_handle->hcam, (camera_attr_effect_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_effect(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_effect(g_mm_handle->hcam, (camera_attr_effect_mode_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_program_mode(int *value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_get_scene_mode(g_mm_handle->hcam, (camera_attr_scene_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_program_mode(int value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_set_scene_mode(g_mm_handle->hcam, value);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_outdoor_visibility(gboolean on)
+{
+ int scenario = -1;
+
+ if (cam_mm_get_mdnie_mode(&scenario) == FALSE || scenario != SCENARIO_CAMERA) {
+ if (cam_mm_set_mdnie_mode(TRUE) == FALSE) {
+ cam_critical(LOG_MM, "device_set_image_enhance_scenario() fail");
+ return FALSE;
+ }
+ }
+
+ if (on) {
+ if (device_set_image_enhance_outdoor(OUTDOOR_ON) < 0) {
+ cam_critical(LOG_MM, "device_set_image_enhance_outdoor(on) fail");
+ return FALSE;
+ }
+ } else {
+ if (device_set_image_enhance_outdoor(OUTDOOR_OFF) < 0) {
+ cam_critical(LOG_MM, "device_set_image_enhance_outdoor(off) fail");
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_get_outdoor_visibility(gboolean *on)
+{
+ int val = -1;
+ if ((val = device_get_image_enhance_outdoor()) < 0)
+ return FALSE;
+ if (val == OUTDOOR_OFF)
+ *on = FALSE;
+ else
+ *on = TRUE;
+ return TRUE;
+}
+
+
+gboolean cam_mm_is_supported_outdoor_visibility(void)
+{
+ if (device_get_image_enhance_info() < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_mdnie_mode(gboolean on)
+{
+ DEBUG_TRACE("mode :%d", on);
+ if (cam_mm_is_supported_outdoor_visibility()) {
+
+ if (on) {
+ if (device_set_image_enhance_scenario(SCENARIO_CAMERA) < 0) {
+ cam_critical(LOG_MM, "device_set_image_enhance_scenario(SCENARIO_CAMERA) fail");
+ return FALSE;
+ }
+ } else {
+ if (device_set_image_enhance_scenario(SCENARIO_UI) < 0) {
+ cam_critical(LOG_MM, "device_set_image_enhance_scenario(SCENARIO_UI) fail");
+ return FALSE;
+ }
+ }
+ } else {
+ cam_critical(LOG_MM, "cam_mm_is_supported_outdoor_visibility() false");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_get_mdnie_mode(int *val)
+{
+ int ret = -1;
+ if ((ret = device_get_image_enhance_scenario()) < 0) {
+ cam_critical(LOG_MM, "device_get_image_enhance_scenario() fail");
+ return FALSE;
+ }
+
+ *val = ret;
+ return TRUE;
+}
+
+
+
+gboolean cam_mm_set_audio_recording(gboolean b_on)
+{
+ int ret = 0;
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ if (b_on)
+ ret = recorder_attr_set_mute(g_mm_handle->hrec, FALSE);
+ else
+ ret = recorder_attr_set_mute(g_mm_handle->hrec, TRUE);
+
+ if (ret != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_image_count(int value)
+{
+ return TRUE;
+}
+
+gboolean cam_mm_get_recommanded_preview_size(int *width, int *height)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_get_recommended_preview_resolution(g_mm_handle->hcam, width, height);
+
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("camera_get_recommended_preview_resolution failed - code[%x] name[%s]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+gboolean cam_mm_get_image_size(int *width, int *height)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_get_capture_resolution(g_mm_handle->hcam, width, height);
+
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x] name[%s]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_image_size(int width, int height)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_capture_resolution(g_mm_handle->hcam, width, height);
+
+ if (ret != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("cam_mm_set_image_size failed");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_video_encoder_bitrate(int bitrate)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_attr_set_video_encoder_bitrate(g_mm_handle->hrec, bitrate);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_audio_encoder_bitrate(int bitrate)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_attr_set_audio_encoder_bitrate(g_mm_handle->hrec, bitrate);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_display_device(int display_device, void *xid)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_display(g_mm_handle->hcam, display_device, xid);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_display_rotate(int rotate)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_x11_display_rotation(g_mm_handle->hcam, rotate);
+ if (ret != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_camera_rotate(int camera_rotate)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ #ifdef CAMERA_MACHINE_I686
+ ret = camera_attr_set_stream_rotation(g_mm_handle->hcam, 0);
+ #else
+ ret = camera_attr_set_stream_rotation(g_mm_handle->hcam, camera_rotate);
+ #endif
+ if (ret != CAMERA_ERROR_NONE) {
+ cam_detail_error_get(ret);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_display_geometry_method(int *value)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_get_x11_display_mode(g_mm_handle->hcam, (camera_display_mode_e *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_display_geometry_method(int value)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_x11_display_mode(g_mm_handle->hcam, (camera_display_mode_e)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_display_visible(gboolean visible)
+{
+ int ret = 0;
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_set_x11_display_visible(g_mm_handle->hcam, visible);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_filename(const gchar *filename)
+{
+ int ret = 0;
+ /*char *err_name = NULL;*/
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ if (filename) {
+ ret = recorder_set_filename(g_mm_handle->hrec, filename);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+ } else {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_filename(char **filename, gint *size)
+{
+ int ret = 0;
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_get_filename(g_mm_handle->hrec, filename);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_max_size(int *value)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ ret = recorder_attr_get_time_limit(g_mm_handle->hrec, value);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_max_time(int *value)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_attr_get_time_limit(g_mm_handle->hrec, value);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_max_size(int max_val)
+{
+
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_attr_set_size_limit(g_mm_handle->hrec, max_val);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_max_time(int max_val)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ ret = recorder_attr_set_time_limit(g_mm_handle->hrec, max_val);
+ if (ret != RECORDER_ERROR_NONE) {
+ return FALSE;
+
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_tag_enable(int *value)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_is_enabled_tag(g_mm_handle->hcam, (bool *)value);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_tag_enable(gboolean bvalue)
+{
+ int ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ ret = camera_attr_enable_tag(g_mm_handle->hcam, (bool)bvalue);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_tag_img_orient(int orient)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ camera_error_e ret;
+ ret = camera_attr_set_tag_orientation(g_mm_handle->hcam, (camera_attr_tag_orientation_e)orient);
+ if (ret != CAMERA_ERROR_NONE) {
+ cam_detail_error_get(ret);
+ return FALSE;
+
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_file_format(int format)
+{
+ recorder_error_e ret;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ ret = recorder_set_file_format(g_mm_handle->hrec, format);
+ if (ret != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("recorder_set_file_format failed - [%d]", ret);
+ return FALSE;
+
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_video_profile(void)
+{
+ recorder_error_e e;
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_attr_set_audio_device(g_mm_handle->hrec, RECORDER_AUDIO_DEVICE_MIC);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_codec(int audio_codec, int video_codec)
+{
+ int ret = 0;
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_set_audio_encoder(g_mm_handle->hrec, audio_codec);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ rec_detail_error_get(ret);
+ return FALSE;
+ }
+ e = recorder_set_video_encoder(g_mm_handle->hrec, video_codec);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_audio_source(int sample_rate, int channel)
+{
+ int ret = 0;
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ e = recorder_attr_set_audio_samplerate(g_mm_handle->hrec, sample_rate);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ return FALSE;
+ }
+ e = recorder_attr_set_audio_channel(g_mm_handle->hrec, channel);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("set attr failed - code[%x]\n", ret);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_video_source_format(int format)
+{
+ if (format <= CAMERA_PIXEL_FORMAT_INVALID || format > CAMERA_PIXEL_FORMAT_JPEG)
+ return FALSE;
+
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ err = camera_set_preview_format(g_mm_handle->hcam, format);
+
+ DEBUG_TRACE("!!!!!!!!!!!!!!!! format:%d !!!!!!!!!!!!!!!!!!!", format);
+ if (err != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_video_source_format(const char *attribute_name, int *format)
+{
+ DEBUG_TRACE("attribute_name = %s", attribute_name);
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ err = camera_get_preview_format(g_mm_handle->hcam, format);
+ if (err != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_front_cam_display_rotate_value(int *value, int *rotate)
+{
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ err = camera_attr_get_lens_orientation(g_mm_handle->hcam, value);
+ switch (*value) {
+ case 0:
+ *rotate = CAMERA_ROTATION_NONE;
+ break;
+ case 90:
+ *rotate = CAMERA_ROTATION_90;
+ break;
+ case 180:
+ *rotate = CAMERA_ROTATION_180;
+ break;
+ case 270:
+ *rotate = CAMERA_ROTATION_270;
+ break;
+ default:
+ *rotate = CAMERA_ROTATION_NONE;
+
+ }
+ if (err != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_get_scene_mode(camera_attr_scene_mode_e *mode)
+{
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ err = camera_attr_get_scene_mode(g_mm_handle->hcam, mode);
+ if (err != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_scene_mode(camera_attr_scene_mode_e mode)
+{
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ err = camera_attr_set_scene_mode(g_mm_handle->hcam, mode);
+ if (err != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_conti_shot_break(gboolean bvalue)
+{
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ if (bvalue) {
+ err = camera_stop_continuous_capture(g_mm_handle->hcam);
+ if (err != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_capture_format(int value)
+{
+ int err;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ err = camera_set_capture_format(g_mm_handle->hcam, value);
+ if (err != CAMERA_ERROR_NONE) {
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_get_shutter_sound(int *value)
+{
+/*todo:for lawer policy, capi could not surport it*/
+#ifndef TODO_SURRPORT
+ return cam_mm_get_attr_int(MMCAM_SHUTTER_SOUND, value);
+#else
+ return TRUE;
+#endif
+
+}
+gboolean cam_mm_set_shutter_sound(int value)
+{
+/*todo:for lawer policy, capi could not surport it*/
+#ifndef TODO_SURRPORT
+ return cam_mm_set_attr_int(MMCAM_SHUTTER_SOUND, value);
+#else
+ return TRUE;
+#endif
+
+}
+
+gboolean cam_mm_remove_geo_tag(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+#ifdef TODO_SURRPORT
+ int ret = 0;
+ ret = camera_attr_remove_geotag(g_mm_handle->hcam);
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+#endif /*TODO:capi has issue.if it fix, I will open it*/
+ return TRUE;
+}
+
+gboolean cam_mm_enable_geo_tag(gboolean value)
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ if (value) {
+ ret = camera_attr_set_geotag(g_mm_handle->hcam, -1.0, -1.0, -1.0);
+ } else {
+ ret = camera_attr_remove_geotag(g_mm_handle->hcam);
+ }
+ if (ret != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_reset_recording_motion_fps()
+{
+ int ret = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_attr_set_recording_motion_rate(g_mm_handle->hrec, DEFAULT_REC_FPS);
+ if (ret != RECORDER_ERROR_NONE) {
+
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_gps_data(double lat, double lon, double alt)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ e = camera_attr_set_geotag(g_mm_handle->hcam, lat, lon, alt);
+ if (e != CAMERA_ERROR_NONE) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_is_preview_started(int mode)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ int mm_state = 0;
+ mm_state = cam_mm_get_state();
+
+ if ((CAM_CAMERA_MODE == mode && mm_state < CAMERA_STATE_PREVIEW)
+ || (mode == CAM_CAMCORDER_MODE && mm_state < RECORDER_STATE_READY) ) {
+ cam_critical(LOG_MM, "cur_state:%d", mm_state);
+ return FALSE;
+ } else
+ return TRUE;
+}
+
+gboolean cam_mm_preview_start(int mode)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ struct appdata *ad = (struct appdata *)cam_appdata_get();
+ g_return_val_if_fail(ad, FALSE);
+
+ int ret = (mode == CAM_CAMERA_MODE) ? CAMERA_ERROR_NONE : RECORDER_ERROR_NONE;
+ if (CAM_CAMERA_MODE == mode) {
+
+ ret = camera_start_preview(g_mm_handle->hcam);
+ if (ret != CAMERA_ERROR_NONE) {
+ if (ret == CAMERA_ERROR_SOUND_POLICY) {
+ ad->fw_error_type = CAMERA_ERROR_SOUND_POLICY;
+ } else if (ret == CAMERA_ERROR_SECURITY_RESTRICTED) {
+ cam_app_mdm_syspopup(ad);
+ return FALSE;
+ } else {
+ cam_critical(LOG_MM, "camera_start_preview failed");
+ return FALSE;
+ }
+ }
+ cam_debug(LOG_MM, " ret : %d", ret);
+
+ }else if (CAM_CAMCORDER_MODE == mode) {
+
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ ret = recorder_prepare(g_mm_handle->hrec);
+ if (ret != RECORDER_ERROR_NONE) {
+ if (ret == RECORDER_ERROR_SOUND_POLICY) {
+ ad->fw_error_type = RECORDER_ERROR_SOUND_POLICY;
+ } else if (ret == RECORDER_ERROR_SECURITY_RESTRICTED) {
+ cam_app_mdm_syspopup(ad);
+ return FALSE;
+ } else {
+ cam_critical(LOG_MM, "camera_start_preview failed");
+ return FALSE;
+ }
+ }
+ cam_debug(LOG_MM, " ret : %d", ret);
+ }
+
+ return TRUE;
+
+}
+
+gboolean cam_mm_preview_stop(int mode)
+{
+ int state = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ if (CAM_CAMERA_MODE == mode) {
+ state = cam_mm_get_cam_state();
+ cam_critical(LOG_MM, " camera state : %d", state);
+ /*todo:please consider recorder and camera*/
+ if (state < 0)
+ return FALSE;
+
+ switch (state) {
+ case CAMERA_STATE_NONE:
+ case CAMERA_STATE_CAPTURING:
+ case CAMERA_STATE_CREATED:
+ return FALSE;
+ case CAMERA_STATE_PREVIEW:
+ CHECK_MM_ERROR(camera_stop_preview(g_mm_handle->hcam));
+ break;
+ case CAMERA_STATE_CAPTURED:
+ break;
+ }
+ return TRUE;
+ }else if (CAM_CAMCORDER_MODE == mode) {
+
+ state = cam_mm_get_rec_state();
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+ cam_debug(LOG_MM, " camera state : %d", state);
+ /*todo:please consider recorder and camera*/
+ if (state < 0)
+ return FALSE;
+
+ switch (state) {
+ case RECORDER_STATE_NONE:
+ case RECORDER_STATE_RECORDING:
+ case RECORDER_STATE_PAUSED:
+ return FALSE;
+
+ case RECORDER_STATE_READY:
+ CHECK_MM_ERROR(recorder_unprepare(g_mm_handle->hrec));
+ break;
+
+ case RECORDER_STATE_CREATED:
+ break;
+
+ }
+ return TRUE;
+
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_is_created(void)
+{
+ debug_fenter(LOG_MM);
+ if (g_mm_handle) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean cam_mm_create(int camera_type, int mode)
+{
+ CAM_TA_ACUM_ITEM_BEGIN("----cam_mm_create", 0);
+ DEBUG_TRACE
+ ("--------------------------------START----------------------------");
+ DEBUG_TRACE("camera_type = %d" ,camera_type);
+ if (g_mm_handle) {
+ cam_critical(LOG_MM, "The mm handle is already created");
+ return FALSE;
+ }
+ g_return_val_if_fail(g_mm_handle == NULL, FALSE);
+ camera_h hcam;
+ camera_error_e e;
+ e = camera_create(camera_type, &hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_create - error(%d)", e);
+ return FALSE;
+ }
+ g_return_val_if_fail(hcam, FALSE);
+ recorder_h hrec = NULL;
+ recorder_error_e re;
+ re = recorder_create_videorecorder(hcam, &hrec);
+ if (re != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_create - error(%d)", e);
+ recorder_destroy(hrec);
+ CHECK_MM_ERROR(camera_destroy(hcam));
+ return FALSE;
+ }
+ g_return_val_if_fail(hrec, FALSE);
+ g_mm_handle = g_new0(CamMMHandle, 1);
+ if (g_mm_handle) {
+ g_mm_handle->hcam = hcam;
+ g_mm_handle->hdev = camera_type;
+ g_mm_handle->hrec = hrec;
+ } else {
+ DEBUG_TRACE("[ERROR] memory allocation failed", e);
+ recorder_destroy(hrec);
+ CHECK_MM_ERROR(camera_destroy(hcam));
+ return FALSE;
+ }
+
+ DEBUG_TRACE("camera_type = %d" , g_mm_handle->hdev);
+
+ DEBUG_TRACE("--------------END---------------");
+ CAM_TA_ACUM_ITEM_BEGIN("----cam_mm_create", 0);
+
+ return TRUE;
+}
+
+gboolean cam_mm_destory(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+
+ if( g_mm_handle->hrec != 0){
+ recorder_destroy(g_mm_handle->hrec);
+ g_mm_handle->hrec = 0;
+ }
+
+ if(g_mm_handle->hcam != 0){
+ camera_destroy(g_mm_handle->hcam);
+ g_mm_handle->hcam = 0;
+ }
+
+ g_mm_handle->hdev = -1;
+
+ g_free(g_mm_handle);
+ g_mm_handle = NULL;
+
+ return TRUE;
+}
+
+gboolean cam_mm_continuous_capture_start(int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ cam_debug(LOG_MM, "");
+ CAM_TA_ACUM_ITEM_END(" camera key to capture start", 0);
+
+ if (cam_mm_get_state() == CAMERA_STATE_PREVIEW) {
+ CAM_TA_ACUM_ITEM_BEGIN("camera_start_continuous_capture", 0);
+ CHECK_MM_ERROR(camera_start_continuous_capture(g_mm_handle->hcam, count, interval, capturing_cb, completed_cb, user_data));
+ CAM_TA_ACUM_ITEM_END("camera_start_continuous_capture", 0);
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__, __LINE__, cam_mm_get_state());
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+gboolean cam_mm_capture_start(camera_capturing_cb capturing_cb , camera_capture_completed_cb completed_cb , void *user_data)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ struct appdata *ad = (struct appdata *)user_data;
+ g_return_val_if_fail(ad, FALSE);
+ CamAppData *camapp = ad->camapp_handle;
+ g_return_val_if_fail(camapp, FALSE);
+
+ cam_debug(LOG_MM, "");
+ CAM_TA_ACUM_ITEM_END(" camera key to capture start", 0);
+
+ gboolean do_capture = FALSE;
+ if (camapp->camera_mode == CAM_CAMERA_MODE) {
+ if (cam_mm_get_state() == CAMERA_STATE_PREVIEW)
+ do_capture = TRUE;
+ } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
+ if (cam_mm_get_state() == RECORDER_STATE_RECORDING
+ || cam_mm_get_state() == RECORDER_STATE_PAUSED)
+ do_capture = TRUE;
+ }
+
+ if (do_capture){
+ CAM_TA_ACUM_ITEM_BEGIN("camera_start_capture", 0);
+ CHECK_MM_ERROR(camera_start_capture(g_mm_handle->hcam, capturing_cb, completed_cb, user_data));
+ CAM_TA_ACUM_ITEM_END("camera_start_capture", 0);
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__,
+ __LINE__, cam_mm_get_state());
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_capture_stop(gboolean skip_preview, CamMode mode)
+{
+ int state = CAMERA_STATE_NONE;/*TODO:now the value is same to record*/
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ cam_debug(LOG_MM, " start");
+
+ state = cam_mm_get_state();
+ if (state == RECORDER_STATE_READY && skip_preview == FALSE && mode == CAM_CAMCORDER_MODE) {
+ CHECK_MM_ERROR(recorder_prepare(g_mm_handle->hrec));
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__,
+ __LINE__, cam_mm_get_state());
+ return FALSE;
+ }
+
+ cam_debug(LOG_MM, " done");
+
+ return TRUE;
+}
+
+gboolean cam_mm_rec_start()
+{
+ int state = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ state = cam_mm_get_state();
+ if ((state == RECORDER_STATE_READY)
+ || (state == RECORDER_STATE_PAUSED)) {
+ CHECK_MM_ERROR(recorder_start(g_mm_handle->hrec));
+ } else {
+ DEBUG_TRACE("operation failed - state:%d \n", state);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_rec_stop(gboolean to_stop)
+{
+ int state = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ state = cam_mm_get_state();
+ if ((state == RECORDER_STATE_RECORDING)
+ || (state == RECORDER_STATE_PAUSED)) {
+ if (!to_stop) {
+ CHECK_MM_ERROR(recorder_commit(g_mm_handle->hrec));
+ } else {
+ CHECK_MM_ERROR(recorder_commit(g_mm_handle->hrec));
+ CHECK_MM_ERROR(recorder_unprepare(g_mm_handle->hrec));
+ }
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__,
+ __LINE__, state);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_rec_pause()
+{
+ int state = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ state = cam_mm_get_state();
+ if ((state == RECORDER_STATE_RECORDING)) {
+ CHECK_MM_ERROR(recorder_pause(g_mm_handle->hrec));
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__,
+ __LINE__, state);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_rec_cancel()
+{
+ int state = 0;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ state = cam_mm_get_state();
+ if ((state == RECORDER_STATE_RECORDING)
+ || (state == RECORDER_STATE_PAUSED)) {
+ CHECK_MM_ERROR(recorder_cancel(g_mm_handle->hrec));
+ } else {
+ printf("[%s:%d] operation failed - state:%d \n", __func__,
+ __LINE__, state);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_session_init(sound_session_type_e session_type)
+{
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ if (ret != sound_manager_set_session_type(session_type)) {
+ DEBUG_TRACE("[%s:%d] operation failed - session_type:%d \n",
+ __func__, __LINE__, session_type);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+gboolean cam_mm_start_focusing(gint af_mode)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ struct appdata *ad = (struct appdata *)cam_appdata_get();
+ g_return_val_if_fail(ad, FALSE);
+ CamAppData *camapp = ad->camapp_handle;
+ g_return_val_if_fail(camapp, FALSE);
+
+ cam_debug(LOG_UI, "");
+
+ int state = 0;
+ state = cam_mm_get_state();
+
+ if (camapp->camera_mode == CAM_CAMERA_MODE) {
+ if (state == CAMERA_STATE_PREVIEW
+ || state == CAMERA_STATE_CREATED
+ || state == CAMERA_STATE_CAPTURED) {
+ if ((CamAppFocusMode)af_mode == CAM_FOCUS_MODE_CONTINUOUS) {
+ cam_debug(LOG_UI, "continuous");
+ CHECK_MM_ERROR(camera_start_focusing(g_mm_handle->hcam, TRUE));
+ } else {
+ cam_debug(LOG_UI, "touchAF");
+ CHECK_MM_ERROR(camera_start_focusing(g_mm_handle->hcam, FALSE));
+ }
+ } else {
+ DEBUG_TRACE("Start focus operation failed in camera mode - invalid state:%d \n", state);
+ return FALSE;
+ }
+ } else if (camapp->camera_mode == CAM_CAMCORDER_MODE) {
+ if (state == RECORDER_STATE_CREATED
+ || state == RECORDER_STATE_READY
+ || state == RECORDER_STATE_RECORDING
+ || state == RECORDER_STATE_PAUSED) {
+ if ((CamAppFocusMode)af_mode == CAM_FOCUS_MODE_CONTINUOUS) {
+ CHECK_MM_ERROR(camera_start_focusing(g_mm_handle->hcam, TRUE));
+ } else {
+ CHECK_MM_ERROR(camera_start_focusing(g_mm_handle->hcam, FALSE));
+ }
+ } else {
+ DEBUG_TRACE("Start focus operation failed in camcorder mode- invalid state:%d \n", state);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_stop_focusing()
+{
+ int state = 0;
+
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ cam_debug(LOG_UI, "");
+
+ state = cam_mm_get_state();
+ if (state == CAMERA_STATE_PREVIEW
+ || state == CAMERA_STATE_CREATED
+ || state == RECORDER_STATE_RECORDING) {
+ /*TODO:please think rec mod, but now the rec and cam mode state value is same*/
+ CHECK_MM_ERROR(camera_cancel_focusing(g_mm_handle->hcam));
+ } else {
+ printf
+ ("[%s:%d] Stop focus operation failed - invalid state:%d \n",
+ __func__, __LINE__, state);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_set_error_cb(camera_error_cb error_cb, void *data)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ e = camera_set_error_cb(g_mm_handle->hcam, error_cb, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_set_error_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_unset_error_cb(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+ e = camera_unset_error_cb(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_unset_error_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_state_changed_cb(camera_state_changed_cb state_cb, void *data)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_set_state_changed_cb(g_mm_handle->hcam, state_cb, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_set_state_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_unset_state_changed_cb(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_unset_state_changed_cb(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_unset_state_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+gboolean cam_mm_set_focus_changed_cb(camera_focus_changed_cb focus_cb, void *data)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_set_focus_changed_cb(g_mm_handle->hcam, focus_cb, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_set_focus_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_unset_focus_changed_cb(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_unset_focus_changed_cb(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_unset_focus_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_set_preview_cb(camera_preview_cb preview_cb, void *data)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_set_preview_cb(g_mm_handle->hcam, preview_cb, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_set_preview_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_unset_preview_cb(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_unset_preview_cb(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_unset_preview_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_camera_interrupted_cb(camera_interrupted_cb callback, void *data){
+
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_set_interrupted_cb(g_mm_handle->hcam, callback, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_state_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+gboolean cam_mm_set_recorder_interrupted_cb(recorder_interrupted_cb callback, void *data){
+
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_set_interrupted_cb(g_mm_handle->hrec, callback, data);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_state_changed_cb - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_recorder_set_state_changed_cb(recorder_state_changed_cb callback, void* user_data)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_set_state_changed_cb(g_mm_handle->hrec, callback, user_data);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_state_changed_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_recorder_unset_state_changed_cb(void)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_unset_state_changed_cb(g_mm_handle->hrec);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_state_changed_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_recorder_set_recording_status_cb(recorder_recording_status_cb callback, void* user_data)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_set_recording_status_cb(g_mm_handle->hrec, callback, user_data);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_recording_status_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_recorder_unset_recording_status_cb(void)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_unset_recording_status_cb(g_mm_handle->hrec);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_unset_recording_status_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_recorder_set_recording_limit_reached_cb(recorder_recording_limit_reached_cb callback, void* user_data)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_set_recording_limit_reached_cb(g_mm_handle->hrec, callback, user_data);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_set_recording_status_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_recorder_unset_recording_limit_reached_cb(void)
+{
+ recorder_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ e = recorder_unset_recording_limit_reached_cb(g_mm_handle->hrec);
+ if (e != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] recorder_unset_recording_status_cb - error(%d)", e);
+ rec_detail_error_get(e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_recording_motion(double rate)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hrec, FALSE);
+
+ int err;
+ err = recorder_attr_set_recording_motion_rate(g_mm_handle->hrec, rate);
+ if (err != RECORDER_ERROR_NONE) {
+ DEBUG_TRACE("recorder_attr_set_recording_motion_rate failed");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean cam_mm_start_camera_face_detection(camera_face_detected_cb callback, void *data)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_start_face_detection(g_mm_handle->hcam, callback, data);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_start_face_detection - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_stop_camera_face_detection(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_stop_face_detection(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_stop_face_detection - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_is_supported_face_detection(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ return camera_is_supported_face_detection(g_mm_handle->hcam);
+
+}
+
+gboolean cam_mm_set_camera_face_zoom(int face_id)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_face_zoom(g_mm_handle->hcam, face_id);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_face_zoom - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_camera_cancel_face_zoom(void)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ e = camera_cancel_face_zoom(g_mm_handle->hcam);
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("[ERROR] camera_cancel_face_zoom - error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+gboolean cam_mm_set_image_flip(gboolean value)
+{
+ camera_error_e e;
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ if (value) {
+ e = camera_attr_set_stream_flip(g_mm_handle->hcam, CAMERA_FLIP_HORIZONTAL);
+
+ if (g_mm_handle->hdev == 0) {
+ e = camera_set_x11_display_flip(g_mm_handle->hcam, CAMERA_FLIP_VERTICAL);
+ } else {
+ e = camera_set_x11_display_flip(g_mm_handle->hcam, CAMERA_FLIP_NONE);
+ }
+ } else {
+ e = camera_attr_set_stream_flip(g_mm_handle->hcam, CAMERA_FLIP_NONE);
+
+ if (g_mm_handle->hdev == 0) {
+ e = camera_set_x11_display_flip(g_mm_handle->hcam, CAMERA_FLIP_NONE);
+ } else {
+ e = camera_set_x11_display_flip(g_mm_handle->hcam, CAMERA_FLIP_VERTICAL);
+ }
+ }
+
+ if (e != CAMERA_ERROR_NONE) {
+ DEBUG_TRACE("recorder_attr_set_recording_flip() error(%d)", e);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean cam_mm_get_caps_minmax(unsigned int type, int *min, int *max)
+{
+ if (!cam_mm_is_created()) {
+ cam_debug(LOG_CAM, "cam_mm_is_created() false");
+ return FALSE;
+ }
+
+ gboolean ret = TRUE;
+ int tempmin, tempmax = 0;
+
+ switch(type) {
+ case CAM_CP_FUNC_EXPOSURE:
+ {
+ if (camera_attr_get_exposure_range(g_mm_handle->hcam, &tempmin, &tempmax) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_get_exposure_range() is false");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_BRIGHTNESS:
+ {
+ if (camera_attr_get_brightness_range(g_mm_handle->hcam, &tempmin, &tempmax) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_get_brightness_range() is false");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_ZOOM:
+ {
+ if (camera_attr_get_zoom_range(g_mm_handle->hcam, &tempmin, &tempmax) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_get_zoom_range() is false");
+ ret = FALSE;
+ }
+
+ if (tempmin == tempmax) {
+ cam_debug(LOG_CAM, "zoom is not supported");
+ ret = FALSE;
+ }
+ }
+ break;
+ default:
+ {
+ cam_debug(LOG_CAM, "not support get_minmax() about this type[%d]", type);
+ ret = FALSE;
+ }
+ break;
+ }
+
+ if (!ret) {
+ tempmin = 0;
+ tempmax = 0;
+ }
+
+ *min = tempmin;
+ *max = tempmax;
+
+ return ret;
+}
+
+gboolean cam_mm_get_caps_range(unsigned int type, unsigned int *caps, void *user_data)
+{
+ if (!cam_mm_is_created()) {
+ cam_debug(LOG_CAM, "cam_mm_is_created() false");
+ return FALSE;
+ }
+
+ g_caps = 0;
+ g_caps_cb_cnt = 0;
+ gboolean ret = TRUE;
+
+ switch(type) {
+ case CAM_CP_FUNC_FLASH_MODE:
+ {
+ if (camera_attr_foreach_supported_flash_mode(g_mm_handle->hcam,
+ (camera_attr_supported_flash_mode_cb)__get_flash_cb, user_data) != CAMERA_ERROR_NONE ) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_flash_mode() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_ISO:
+ {
+ if (camera_attr_foreach_supported_iso(g_mm_handle->hcam,
+ (camera_attr_supported_iso_cb)__get_iso_cb, user_data) != CAMERA_ERROR_NONE ) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_iso() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_SCENE_MODE:
+ {
+ if (camera_attr_foreach_supported_scene_mode(g_mm_handle->hcam,
+ (camera_attr_supported_scene_mode_cb)__get_scene_cb, user_data) != CAMERA_ERROR_NONE ) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_scene_mode() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_METERING:
+ {
+ if (camera_attr_foreach_supported_exposure_mode(g_mm_handle->hcam,
+ (camera_attr_supported_exposure_mode_cb)__get_metering_cb, user_data) != CAMERA_ERROR_NONE ) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_exposure_mode() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_EFFECT_MODE:
+ {
+ if (camera_attr_foreach_supported_effect(g_mm_handle->hcam,
+ (camera_attr_supported_effect_cb)__get_effect_cb, user_data) != CAMERA_ERROR_NONE ) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_effect() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_WHITE_BALANCE:
+ {
+ if (camera_attr_foreach_supported_whitebalance(g_mm_handle->hcam,
+ (camera_attr_supported_whitebalance_cb)__get_wb_cb, user_data) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_whitebalance() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_FOCUS_MODE:
+ {
+ if (camera_attr_foreach_supported_af_mode(g_mm_handle->hcam,
+ (camera_attr_supported_af_mode_cb)__get_focus_cb, user_data) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_exposure_mode() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_FPS:
+ {
+ if (camera_attr_foreach_supported_fps(g_mm_handle->hcam,
+ (camera_attr_supported_fps_cb)__get_fps_cb, user_data) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_attr_foreach_supported_fps() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_CAM_RESOLUTION:
+ {
+ if(camera_foreach_supported_capture_resolution(g_mm_handle->hcam,
+ (camera_supported_capture_resolution_cb)__get_capture_res_cb, user_data) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_foreach_supported_capture_resolution() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ case CAM_CP_FUNC_REC_RESOLUTION:
+ {
+ if(camera_foreach_supported_preview_resolution(g_mm_handle->hcam,
+ (camera_supported_preview_resolution_cb)__get_recording_res_cb, user_data) != CAMERA_ERROR_NONE) {
+ cam_debug(LOG_CAM, "camera_foreach_supported_capture_resolution() is fail");
+ ret = FALSE;
+ }
+ }
+ break;
+ default:
+ {
+ cam_debug(LOG_CAM, "not support get_range() about this type[%d]", type);
+ ret = FALSE;
+ }
+ break;
+ }
+
+ *caps = g_caps;
+ return ret;
+}
+
+const int cam_mm_get_caps_cb_cnt()
+{
+ return g_caps_cb_cnt;
+}
+
+static void __get_iso_cb(camera_attr_iso_e iso, void *user_data)
+{
+ cam_retm_if(iso > CAMERA_ATTR_ISO_3200, "input is invalid");
+
+ unsigned int uRet = cam_iso_dev_convert_caps(iso);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_effect_cb(camera_attr_effect_mode_e effect, void *user_data)
+{
+ cam_retm_if(effect > CAMERA_ATTR_EFFECT_SKETCH, "input is invalid");
+
+ unsigned int uRet = cam_effect_dev_convert_caps(effect);
+ if (uRet != 0 ) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_fps_cb(camera_attr_fps_e fps, void *user_data)
+{
+ cam_retm_if(fps > CAMERA_ATTR_FPS_120, "input is invalid");
+
+ unsigned int uRet = cam_fps_dev_convert_caps(fps);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_wb_cb(camera_attr_whitebalance_e wb, void *user_data)
+{
+ cam_retm_if(wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM, "input is invalid");
+
+ unsigned int uRet = cam_wb_dev_convert_caps(wb);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_focus_cb(camera_attr_af_mode_e focus, void *user_data)
+{
+ cam_retm_if(focus > CAMERA_ATTR_AF_FULL, "input is invalid");
+
+ unsigned int uRet = cam_focus_dev_convert_caps(focus);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_metering_cb(camera_attr_exposure_mode_e metering, void *user_data)
+{
+ cam_retm_if(metering > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, "input is invalid");
+
+ unsigned int uRet = cam_metering_dev_convert_caps(metering);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_scene_cb(camera_attr_scene_mode_e scene, void *user_data)
+{
+ cam_retm_if(scene > CAMERA_ATTR_SCENE_MODE_BACKLIGHT, "input is invalid");
+
+ unsigned int uRet = cam_scene_dev_convert_caps(scene);
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_flash_cb(camera_attr_flash_mode_e flash, void *user_data)
+{
+ cam_retm_if(flash > CAMERA_ATTR_FLASH_MODE_PERMANENT, "input is invalid");
+
+ unsigned int uRet = cam_flash_dev_convert_caps(flash);
+ if (uRet != 0 ) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_capture_res_cb(int width, int height, void *user_data)
+{
+ unsigned int uRet = cam_resolution_cam_convert_caps((unsigned int)CAM_RESOLUTION(width, height));
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+static void __get_recording_res_cb(int width, int height, void *user_data)
+{
+ unsigned int uRet = cam_resolution_cam_convert_caps((unsigned int)CAM_RESOLUTION(width, height));
+ if (uRet != 0) {
+ g_caps |= uRet;
+ g_caps_cb_cnt++;
+ }
+}
+
+gboolean cam_mm_is_support_front_camera(void)
+{
+ g_return_val_if_fail(g_mm_handle, FALSE);
+ g_return_val_if_fail(g_mm_handle->hcam, FALSE);
+
+ bool ret = 0;
+ int device_count = 0;
+
+ camera_get_device_count(g_mm_handle->hcam, &device_count);
+ cam_debug(LOG_MM, "device count is [%d]", device_count);
+
+ if (device_count == 2) {
+ ret = TRUE;
+ } else {
+ ret = FALSE;
+ }
+
+ return ret;
+}
+//end of file