#include <asm/types.h>
#include <system_info.h>
-#include <mm_session.h>
-#include <mm_session_private.h>
-#include <cynara-client.h>
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#include <murphy/common/glib-glue.h>
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-/*---------------------------------------------------------------------------------------
-| GLOBAL VARIABLE DEFINITIONS for internal |
----------------------------------------------------------------------------------------*/
-int g_mm_camcorder_type = -255;
-struct sigaction mm_camcorder_int_old_action;
-struct sigaction mm_camcorder_abrt_old_action;
-struct sigaction mm_camcorder_segv_old_action;
-struct sigaction mm_camcorder_term_old_action;
-struct sigaction mm_camcorder_sys_old_action;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+#include <aul.h>
+#endif /* _MMCAMCORDER_RM_SUPPORT */
/*---------------------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------------------*/
#define __MMCAMCORDER_CMD_ITERATE_MAX 3
-#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT 3
+#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT 5
#define __MMCAMCORDER_FORCE_STOP_TRY_COUNT 30
#define __MMCAMCORDER_FORCE_STOP_WAIT_TIME 100000 /* us */
#define __MMCAMCORDER_SOUND_WAIT_TIMEOUT 3
-#define __MMCAMCORDER_PATH_CAMERA_RESOURCE "/usr/share/sounds/mm-camcorder/camera_resource"
-#define __MMCAMCORDER_PATH_RECORDER_RESOURCE "/usr/share/sounds/mm-camcorder/recorder_resource"
+#define __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN 64
+#define DPM_ALLOWED 1
+#define DPM_DISALLOWED 0
/*---------------------------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
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_RM_SUPPORT
+rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
+ rm_device_request_s *info, void *cb_data);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
-static void __mm_camcorder_signal_handler(int signo);
-static void _mmcamcorder_constructor() __attribute__((constructor));
-
/*=======================================================================================
| FUNCTION DEFINITIONS |
=======================================================================================*/
| GLOBAL FUNCTION DEFINITIONS: |
---------------------------------------------------------------------------------------*/
-
-static void __mm_camcorder_signal_handler(int signo)
-{
- pid_t my_pid = getpid();
- pid_t vconf_recorder_pid = -1;
- pid_t vconf_camera_pid = -1;
- int vconf_flash_state = VCONFKEY_CAMERA_FLASH_STATE_OFF;
-
- _mmcam_dbg_warn("start - signo [%d], pid [%d], device type [%d]", signo, my_pid, g_mm_camcorder_type);
-
- /* reset vconf key */
- switch (g_mm_camcorder_type) {
- case MM_VIDEO_DEVICE_NONE:
- vconf_get_int(VCONFKEY_RECORDER_PID, (int *)&vconf_recorder_pid);
- if (my_pid == vconf_recorder_pid) {
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_NULL);
- vconf_set_int(VCONFKEY_RECORDER_PID, -1);
- _mmcam_dbg_warn("set recorder state NULL");
- } else {
- _mmcam_dbg_warn("different pid : my[%d] vconf[%d]", my_pid, vconf_recorder_pid);
- }
- break;
- case MM_VIDEO_DEVICE_CAMERA0:
- case MM_VIDEO_DEVICE_CAMERA1:
- vconf_get_int(VCONFKEY_CAMERA_FLASH_STATE, &vconf_flash_state);
- vconf_get_int(VCONFKEY_CAMERA_PID, (int *)&vconf_camera_pid);
- if (my_pid == vconf_camera_pid &&
- vconf_flash_state == VCONFKEY_CAMERA_FLASH_STATE_ON) {
- vconf_set_int(VCONFKEY_CAMERA_FLASH_STATE, VCONFKEY_CAMERA_FLASH_STATE_OFF);
- vconf_set_int(VCONFKEY_CAMERA_PID, -1);
- _mmcam_dbg_warn("set camera flash state OFF");
- }
-
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_NULL);
- _mmcam_dbg_warn("set camera state NULL");
- break;
- default:
- _mmcam_dbg_warn("unknown type [%d]", g_mm_camcorder_type);
- break;
- }
-
- /* call old signal handler */
- switch (signo) {
- case SIGINT:
- sigaction(SIGINT, &mm_camcorder_int_old_action, NULL);
- raise(signo);
- break;
- case SIGABRT:
- sigaction(SIGABRT, &mm_camcorder_abrt_old_action, NULL);
- raise(signo);
- break;
- case SIGSEGV:
- sigaction(SIGSEGV, &mm_camcorder_segv_old_action, NULL);
- raise(signo);
- break;
- case SIGTERM:
- sigaction(SIGTERM, &mm_camcorder_term_old_action, NULL);
- raise(signo);
- break;
- case SIGSYS:
- sigaction(SIGSYS, &mm_camcorder_sys_old_action, NULL);
- raise(signo);
- break;
- default:
- break;
- }
-
- _mmcam_dbg_warn("done");
-
- return;
-}
-
-
-static void _mmcamcorder_constructor()
-{
- struct sigaction mm_camcorder_action;
- mm_camcorder_action.sa_handler = __mm_camcorder_signal_handler;
- mm_camcorder_action.sa_flags = SA_NOCLDSTOP;
-
- _mmcam_dbg_warn("start");
-
- sigemptyset(&mm_camcorder_action.sa_mask);
-
- sigaction(SIGINT, &mm_camcorder_action, &mm_camcorder_int_old_action);
- sigaction(SIGABRT, &mm_camcorder_action, &mm_camcorder_abrt_old_action);
- sigaction(SIGSEGV, &mm_camcorder_action, &mm_camcorder_segv_old_action);
- sigaction(SIGTERM, &mm_camcorder_action, &mm_camcorder_term_old_action);
- sigaction(SIGSYS, &mm_camcorder_action, &mm_camcorder_sys_old_action);
-
- _mmcam_dbg_warn("done");
-
- return;
-}
-
-
/* Internal command functions {*/
int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
{
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;
-#if 0
- int resource_fd = -1;
-#endif
char *err_attr_name = NULL;
const char *ConfCtrlFile = NULL;
mmf_camcorder_t *hcamcorder = NULL;
hcamcorder->type = 0;
hcamcorder->state = MM_CAMCORDER_STATE_NONE;
hcamcorder->sub_context = NULL;
- hcamcorder->target_state = MM_CAMCORDER_STATE_NULL;
+ hcamcorder->old_state = MM_CAMCORDER_STATE_NONE;
hcamcorder->capture_in_recording = FALSE;
hcamcorder->session_type = MM_SESSION_TYPE_MEDIA;
- pthread_mutex_init(&((hcamcorder->mtsafe).lock), NULL);
- pthread_cond_init(&((hcamcorder->mtsafe).cond), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).cmd_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).asm_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).state_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).gst_state_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).gst_encode_state_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).message_cb_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).vcapture_cb_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).vstream_cb_lock), NULL);
- pthread_mutex_init(&((hcamcorder->mtsafe).astream_cb_lock), NULL);
-
- pthread_mutex_init(&(hcamcorder->sound_lock), NULL);
- pthread_cond_init(&(hcamcorder->sound_cond), NULL);
- pthread_mutex_init(&(hcamcorder->restart_preview_lock), NULL);
+ g_mutex_init(&(hcamcorder->mtsafe).lock);
+ g_cond_init(&(hcamcorder->mtsafe).cond);
+ g_mutex_init(&(hcamcorder->mtsafe).cmd_lock);
+ g_cond_init(&(hcamcorder->mtsafe).cmd_cond);
+ g_mutex_init(&(hcamcorder->mtsafe).asm_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).state_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).gst_state_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).gst_encode_state_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).message_cb_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).vcapture_cb_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).vstream_cb_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).astream_cb_lock);
+ g_mutex_init(&(hcamcorder->mtsafe).mstream_cb_lock);
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ g_cond_init(&(hcamcorder->mtsafe).resource_cond);
+ g_mutex_init(&(hcamcorder->mtsafe).resource_lock);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
+ g_mutex_init(&hcamcorder->restart_preview_lock);
/* Sound mutex/cond init */
- pthread_mutex_init(&(hcamcorder->snd_info.open_mutex), NULL);
- pthread_cond_init(&(hcamcorder->snd_info.open_cond), NULL);
+ g_mutex_init(&hcamcorder->snd_info.open_mutex);
+ g_cond_init(&hcamcorder->snd_info.open_cond);
+ g_mutex_init(&hcamcorder->snd_info.play_mutex);
+ g_cond_init(&hcamcorder->snd_info.play_cond);
/* init for sound thread */
- pthread_mutex_init(&(hcamcorder->task_thread_lock), NULL);
- pthread_cond_init(&(hcamcorder->task_thread_cond), NULL);
- hcamcorder->task_thread_state = _MMCAMCORDER_SOUND_STATE_NONE;
+ g_mutex_init(&hcamcorder->task_thread_lock);
+ g_cond_init(&hcamcorder->task_thread_cond);
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
- /* create task thread */
- pthread_create(&(hcamcorder->task_thread), NULL, _mmcamcorder_util_task_thread_func, (void *)hcamcorder);
+ if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
+ /* init for gdbus */
+ hcamcorder->gdbus_info_sound.mm_handle = hcamcorder;
+ g_mutex_init(&hcamcorder->gdbus_info_sound.sync_mutex);
+ g_cond_init(&hcamcorder->gdbus_info_sound.sync_cond);
- /* get root directory */
- ret = _mmcamcorder_get_root_directory(&hcamcorder->root_directory);
- if (ret != MM_ERROR_NONE) {
+ hcamcorder->gdbus_info_solo_sound.mm_handle = hcamcorder;
+ g_mutex_init(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
+ g_cond_init(&hcamcorder->gdbus_info_solo_sound.sync_cond);
+ }
+
+ /* create task thread */
+ hcamcorder->task_thread = g_thread_try_new("MMCAM_TASK_THREAD",
+ (GThreadFunc)_mmcamcorder_util_task_thread_func, (gpointer)hcamcorder, NULL);
+ if (hcamcorder->task_thread == NULL) {
+ _mmcam_dbg_err("_mmcamcorder_create::failed to create task thread");
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto _ERR_DEFAULT_VALUE_INIT;
}
/* set device type */
hcamcorder->device_type = info->videodev_type;
_mmcam_dbg_warn("Device Type : %d", hcamcorder->device_type);
-#if 0
- if (hcamcorder->device_type == MM_VIDEO_DEVICE_NONE) {
- resource_fd = open(__MMCAMCORDER_PATH_RECORDER_RESOURCE, O_RDONLY);
- } else {
- resource_fd = open(__MMCAMCORDER_PATH_CAMERA_RESOURCE, O_RDONLY);
- }
-
- if (resource_fd < 0) {
- _mmcam_dbg_log("open error %s : cur %d",strerror(errno),errno);
- if(errno == EPERM || errno == EACCES) {
- ret = MM_ERROR_COMMON_INVALID_PERMISSION;
- } else {
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- }
- goto _ERR_DEFAULT_VALUE_INIT;
- } else {
- close(resource_fd);
- resource_fd = -1;
- _mmcam_dbg_warn("permission check done");
- }
-#else
- {
- FILE *fp = NULL;;
- int length_read = 0;
- int priv_check = FALSE;
- uid_t my_uid = 0;
- char *client_session = "";
- char *smack_string = NULL;
- char uid_string[50];
- size_t buffer_length = 0;
- cynara *p_cynara = NULL;
-
- if (cynara_initialize(&p_cynara, NULL) != CYNARA_API_SUCCESS) {
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
- fp = fopen("/proc/self/attr/current", "r");
- if (fp == NULL) {
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
- length_read = getline(&smack_string, &buffer_length, fp);
- if (length_read > 0) {
- int cynara_ret = 0;
-
- my_uid = getuid();
- snprintf(uid_string, 50, "%d", my_uid);
- _mmcam_dbg_log("label %s, uid %u, %s", smack_string, my_uid, uid_string);
-
- if (hcamcorder->device_type == MM_VIDEO_DEVICE_NONE) {
- cynara_ret = cynara_check(p_cynara, smack_string, client_session, uid_string,
- "http://tizen.org/privilege/recorder");
- } else {
- cynara_ret = cynara_check(p_cynara, smack_string, client_session, uid_string,
- "http://tizen.org/privilege/camera");
- }
- if (cynara_ret == CYNARA_API_ACCESS_ALLOWED) {
- priv_check = TRUE;
- _mmcam_dbg_err("privilege check done");
- } else {
- ret = MM_ERROR_COMMON_INVALID_PERMISSION;
- _mmcam_dbg_err("permission denied");
- }
- } else {
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- _mmcam_dbg_err("getline failed");
- }
-
- if (smack_string) {
- free(smack_string);
- smack_string = NULL;
- }
-
- fclose(fp);
- fp = NULL;
-
- cynara_finish(p_cynara);
- p_cynara = NULL;
-
- if (priv_check == FALSE) {
- goto _ERR_DEFAULT_VALUE_INIT;
- }
- }
-#endif
/* Get Camera Configure information from Camcorder INI file */
- _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
-
- if (!(hcamcorder->conf_main)) {
- _mmcam_dbg_err( "Failed to get configure(main) info." );
-
- ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
+ ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("Failed to get configure(main) info.");
goto _ERR_DEFAULT_VALUE_INIT;
}
goto _ERR_DEFAULT_VALUE_INIT;
}
+ /* get DPM handle for camera/microphone restriction */
+ hcamcorder->dpm_handle = dpm_manager_create();
+
+ _mmcam_dbg_warn("DPM handle %p", hcamcorder->dpm_handle);
+
if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "UseConfCtrl", &UseConfCtrl);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "UseConfCtrl", &UseConfCtrl);
if (UseConfCtrl) {
int resolution_width = 0;
int resolution_height = 0;
MMCamAttrsInfo fps_info;
- _mmcam_dbg_log( "Enable Configure Control system." );
+ _mmcam_dbg_log("Enable Configure Control system.");
switch (info->videodev_type) {
case MM_VIDEO_DEVICE_CAMERA0:
_mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "ConfCtrlFile0", &ConfCtrlFile);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "ConfCtrlFile0", &ConfCtrlFile);
break;
case MM_VIDEO_DEVICE_CAMERA1:
_mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "ConfCtrlFile1", &ConfCtrlFile);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "ConfCtrlFile1", &ConfCtrlFile);
break;
default:
- _mmcam_dbg_err( "Not supported camera type." );
+ _mmcam_dbg_err("Not supported camera type.");
ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("videodev_type : [%d], ConfCtrlPath : [%s]", info->videodev_type, ConfCtrlFile);
- _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_CTRL, ConfCtrlFile, &hcamcorder->conf_ctrl);
+ ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_CTRL, ConfCtrlFile, &hcamcorder->conf_ctrl);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("Failed to get configure(control) info.");
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
/*
_mmcamcorder_conf_print_info(&hcamcorder->conf_main);
_mmcamcorder_conf_print_info(&hcamcorder->conf_ctrl);
*/
- if (!(hcamcorder->conf_ctrl)) {
- _mmcam_dbg_err( "Failed to get configure(control) info." );
- ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
ret = _mmcamcorder_init_convert_table((MMHandleType)hcamcorder);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("converting table initialize error!!");
goto _ERR_DEFAULT_VALUE_INIT;
}
- ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, info->videodev_type);
+ ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_ALL);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("converting table initialize error!!");
ret = MM_ERROR_CAMCORDER_INTERNAL;
/* Get device info, recommend preview fmt and display rotation from INI */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "RecommendPreviewFormatCapture",
- &rcmd_fmt_capture);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "RecommendPreviewFormatCapture",
+ &rcmd_fmt_capture);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "RecommendPreviewFormatRecord",
- &rcmd_fmt_recording);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "RecommendPreviewFormatRecord",
+ &rcmd_fmt_recording);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "RecommendDisplayRotation",
- &rcmd_dpy_rotation);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "RecommendDisplayRotation",
+ &rcmd_dpy_rotation);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_CAPTURE,
- "PlayCaptureSound",
- &play_capture_sound);
+ CONFIGURE_CATEGORY_MAIN_CAPTURE,
+ "PlayCaptureSound",
+ &play_capture_sound);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "DeviceCount",
- &camera_device_count);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "DeviceCount",
+ &camera_device_count);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "FacingDirection",
- &camera_facing_direction);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "FacingDirection",
+ &camera_facing_direction);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_EFFECT,
- "BrightnessStepDenominator",
- &hcamcorder->brightness_step_denominator);
+ CONFIGURE_CATEGORY_CTRL_EFFECT,
+ "BrightnessStepDenominator",
+ &hcamcorder->brightness_step_denominator);
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAPTURE,
- "SupportZSL",
- &hcamcorder->support_zsl_capture);
+ CONFIGURE_CATEGORY_CTRL_CAPTURE,
+ "SupportZSL",
+ &hcamcorder->support_zsl_capture);
_mmcam_dbg_log("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);
+ 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);
/* Get UseZeroCopyFormat value from INI */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "UseZeroCopyFormat",
- &(hcamcorder->use_zero_copy_format));
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "UseZeroCopyFormat",
+ &(hcamcorder->use_zero_copy_format));
/* Get SupportMediaPacketPreviewCb value from INI */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "SupportMediaPacketPreviewCb",
- &(hcamcorder->support_media_packet_preview_cb));
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "SupportMediaPacketPreviewCb",
+ &(hcamcorder->support_media_packet_preview_cb));
+
+ /* Get UseVideoconvert value from INI */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "UseVideoconvert",
+ &hcamcorder->use_videoconvert);
ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
- MMCAM_CAMERA_WIDTH, &resolution_width,
- MMCAM_CAMERA_HEIGHT, &resolution_height,
- NULL);
+ MMCAM_CAMERA_WIDTH, &resolution_width,
+ MMCAM_CAMERA_HEIGHT, &resolution_height,
+ NULL);
mm_camcorder_get_fps_list_by_resolution((MMHandleType)hcamcorder, resolution_width, resolution_height, &fps_info);
- _mmcam_dbg_log("UseZeroCopyFormat : %d", hcamcorder->use_zero_copy_format);
- _mmcam_dbg_log("SupportMediaPacketPreviewCb : %d", hcamcorder->support_media_packet_preview_cb);
- _mmcam_dbg_log("res : %d X %d, Default FPS by resolution : %d", resolution_width, resolution_height, fps_info.int_array.def);
+ _mmcam_dbg_log("UseZeroCopyFormat %d, UseVideoconvert %d, SupportMediaPacketPreviewCb %d",
+ hcamcorder->use_zero_copy_format, hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
+ _mmcam_dbg_log("res : %d X %d, Default FPS by resolution : %d",
+ resolution_width, resolution_height, fps_info.int_array.def);
if (camera_facing_direction == 1) {
- if (rcmd_dpy_rotation == MM_DISPLAY_ROTATION_270 || rcmd_dpy_rotation == MM_DISPLAY_ROTATION_90) {
+ if (rcmd_dpy_rotation == MM_DISPLAY_ROTATION_270 || rcmd_dpy_rotation == MM_DISPLAY_ROTATION_90)
camera_default_flip = MM_FLIP_VERTICAL;
- } else {
+ else
camera_default_flip = MM_FLIP_HORIZONTAL;
- }
- _mmcam_dbg_log("camera_default_flip : [%d]",camera_default_flip);
+
+ _mmcam_dbg_log("camera_default_flip : [%d]", camera_default_flip);
}
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,
- MMCAM_RECOMMEND_DISPLAY_ROTATION, rcmd_dpy_rotation,
- 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_CAMERA_FPS, fps_info.int_array.def,
- MMCAM_DISPLAY_FLIP, camera_default_flip,
- "capture-sound-enable", play_capture_sound,
- NULL);
+ 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,
+ MMCAM_RECOMMEND_DISPLAY_ROTATION, rcmd_dpy_rotation,
+ 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_CAMERA_FPS, fps_info.int_array.def,
+ MMCAM_DISPLAY_FLIP, camera_default_flip,
+ "capture-sound-enable", play_capture_sound,
+ NULL);
if (err_attr_name) {
_mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get default value of brightness */
mm_camcorder_get_attributes((MMHandleType)hcamcorder, &err_attr_name,
- MMCAM_FILTER_BRIGHTNESS, &hcamcorder->brightness_default,
- NULL);
+ MMCAM_FILTER_BRIGHTNESS, &hcamcorder->brightness_default,
+ NULL);
if (err_attr_name) {
_mmcam_dbg_err("Get brightness FAILED.");
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("Default brightness : %d", hcamcorder->brightness_default);
} else {
- _mmcam_dbg_log( "Disable Configure Control system." );
+ _mmcam_dbg_log("Disable Configure Control system.");
hcamcorder->conf_ctrl = NULL;
}
+
+ /* add DPM camera policy changed callback */
+ if (hcamcorder->dpm_handle) {
+ ret = dpm_add_policy_changed_cb(hcamcorder->dpm_handle, "camera",
+ _mmcamcorder_dpm_camera_policy_changed_cb, (void *)hcamcorder, &hcamcorder->dpm_camera_cb_id);
+ if (ret != DPM_ERROR_NONE) {
+ _mmcam_dbg_err("add DPM changed cb failed, keep going...");
+ hcamcorder->dpm_camera_cb_id = 0;
+ }
+
+ _mmcam_dbg_log("DPM camera changed cb id %d", hcamcorder->dpm_camera_cb_id);
+ }
+
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* set camcorder handle */
+ hcamcorder->resource_manager.id = MM_CAMCORDER_RESOURCE_ID_MAIN;
+ hcamcorder->resource_manager.hcamcorder = hcamcorder;
+ hcamcorder->resource_manager_sub.id = MM_CAMCORDER_RESOURCE_ID_SUB;
+ hcamcorder->resource_manager_sub.hcamcorder = hcamcorder;
+
+ /* initialize resource manager */
+ ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to initialize resource manager");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
+ ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager_sub);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to initialize resource manager sub");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
} else {
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "DeviceCount",
- &camera_device_count);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "DeviceCount",
+ &camera_device_count);
+
mm_camcorder_set_attributes((MMHandleType)hcamcorder, &err_attr_name,
- MMCAM_CAMERA_DEVICE_COUNT, camera_device_count,
- NULL);
+ MMCAM_CAMERA_DEVICE_COUNT, camera_device_count,
+ NULL);
if (err_attr_name) {
_mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
- ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, info->videodev_type);
+ ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_AUDIO);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_warn("init attribute from configure error : 0x%x", ret);
- ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _mmcam_dbg_err("there is no audio device");
+ ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
goto _ERR_DEFAULT_VALUE_INIT;
}
}
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:CREATE:INIT_GSTREAMER");
+
ret = __mmcamcorder_gstreamer_init(hcamcorder->conf_main);
+
+ traceEnd(TTRACE_TAG_CAMERA);
+
if (!ret) {
- _mmcam_dbg_err( "Failed to initialize gstreamer!!" );
+ _mmcam_dbg_err("Failed to initialize gstreamer!!");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get videosink name for evas surface */
_mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "VideosinkElementEvas",
- &EvasSurfaceElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "VideosinkElementEvas",
+ &EvasSurfaceElement);
if (EvasSurfaceElement) {
int attr_index = 0;
const char *evassink_name = NULL;
_mmcam_dbg_warn("failed get software version, sys_info_ret 0x%x", sys_info_ret);
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
+ ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to connect resource manager");
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
+ ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager_sub);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to connect resource manager");
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+ }
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
/* Set initial state */
_mmcamcorder_set_state((MMHandleType)hcamcorder, MM_CAMCORDER_STATE_NULL);
_mmcam_dbg_log("created handle %p", hcamcorder);
- /* set device type */
- g_mm_camcorder_type = info->videodev_type;
-
*handle = (MMHandleType)hcamcorder;
return MM_ERROR_NONE;
_ERR_DEFAULT_VALUE_INIT:
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* de-initialize resource manager */
+ _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
+ _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
+ /* release DPM related handle */
+ if (hcamcorder->dpm_handle) {
+ _mmcam_dbg_log("release DPM handle %p, camera changed cb id %d",
+ hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
+
+ /* remove camera policy changed callback */
+ if (hcamcorder->dpm_camera_cb_id > 0) {
+ dpm_remove_policy_changed_cb(hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
+ hcamcorder->dpm_camera_cb_id = 0;
+ } else {
+ _mmcam_dbg_warn("invalid dpm camera cb id %d", hcamcorder->dpm_camera_cb_id);
+ }
+
+ dpm_manager_destroy(hcamcorder->dpm_handle);
+ hcamcorder->dpm_handle = NULL;
+ }
+
/* Remove attributes */
if (hcamcorder->attributes) {
_mmcamcorder_dealloc_attribute((MMHandleType)hcamcorder, hcamcorder->attributes);
}
/* Release lock, cond */
- pthread_mutex_destroy(&((hcamcorder->mtsafe).lock));
- pthread_cond_destroy(&((hcamcorder->mtsafe).cond));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).cmd_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).asm_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).gst_state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).gst_encode_state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).message_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).vcapture_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).vstream_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).astream_cb_lock));
-
- pthread_mutex_destroy(&(hcamcorder->sound_lock));
- pthread_cond_destroy(&(hcamcorder->sound_cond));
- pthread_mutex_destroy(&(hcamcorder->snd_info.open_mutex));
- pthread_cond_destroy(&(hcamcorder->snd_info.open_cond));
- pthread_mutex_destroy(&(hcamcorder->restart_preview_lock));
-
- if (hcamcorder->conf_ctrl) {
- _mmcamcorder_conf_release_info(handle, &hcamcorder->conf_ctrl);
- }
+ g_mutex_clear(&(hcamcorder->mtsafe).lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cmd_cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).asm_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_encode_state_lock);
+ 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).astream_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
+#endif /* _MMCAMCORDER_MURPHY_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->conf_main) {
- _mmcamcorder_conf_release_info(handle, &hcamcorder->conf_main);
+ if (info->videodev_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);
}
+ if (hcamcorder->conf_ctrl)
+ _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_ctrl);
+
+ if (hcamcorder->conf_main)
+ _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_main);
+
if (hcamcorder->model_name) {
free(hcamcorder->model_name);
hcamcorder->model_name = NULL;
}
if (hcamcorder->task_thread) {
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ g_mutex_lock(&hcamcorder->task_thread_lock);
_mmcam_dbg_log("send signal for task thread exit");
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
- pthread_cond_signal(&(hcamcorder->task_thread_cond));
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
- pthread_join(hcamcorder->task_thread, NULL);
- }
- pthread_mutex_destroy(&(hcamcorder->task_thread_lock));
- pthread_cond_destroy(&(hcamcorder->task_thread_cond));
-
- if (hcamcorder->root_directory) {
- free(hcamcorder->root_directory);
- hcamcorder->root_directory = NULL;
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
+ g_thread_join(hcamcorder->task_thread);
+ hcamcorder->task_thread = NULL;
}
+ g_mutex_clear(&hcamcorder->task_thread_lock);
+ g_cond_clear(&hcamcorder->task_thread_cond);
/* Release handle */
memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_NULL;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int iret = RM_OK;
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ GstElement *sink_element = NULL;
+ int sink_element_size = 0;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_NULL) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* set exit state for sound thread */
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ g_mutex_lock(&hcamcorder->task_thread_lock);
_mmcam_dbg_log("send signal for task thread exit");
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
- pthread_cond_signal(&(hcamcorder->task_thread_cond));
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
- pthread_mutex_lock(&(hcamcorder->sound_lock));
- while (hcamcorder->capture_sound_count > 0) {
- struct timespec timeout;
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- timeout.tv_sec = tv.tv_sec + __MMCAMCORDER_SOUND_WAIT_TIMEOUT;
- timeout.tv_nsec = tv.tv_usec * 1000;
+ /* remove kept, but not used sink element in attribute */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_REUSE_ELEMENT, &sink_element, &sink_element_size,
+ NULL);
+ if (sink_element) {
+ GstStateChangeReturn result = gst_element_set_state(sink_element, GST_STATE_NULL);
- _mmcam_dbg_warn("capture_sound_count[%d] is not zero. wait signal...",
- hcamcorder->capture_sound_count);
+ _mmcam_dbg_warn("remove sink element %p, set state NULL result %d", sink_element, result);
- if (!pthread_cond_timedwait(&(hcamcorder->sound_cond), &(hcamcorder->sound_lock), &timeout)) {
- _mmcam_dbg_warn("signal received. check again...");
- } else {
- hcamcorder->capture_sound_count = 0;
- _mmcam_dbg_err("capture sound completion wait time out");
- break;
- }
+ gst_object_unref(sink_element);
+ sink_element = NULL;
}
- pthread_mutex_unlock(&(hcamcorder->sound_lock));
+
+ /* wait for completion of sound play */
+ _mmcamcorder_sound_solo_play_wait(handle);
/* Release SubContext and pipeline */
if (hcamcorder->sub_context) {
- if (hcamcorder->sub_context->element) {
+ if (hcamcorder->sub_context->element)
_mmcamcorder_destroy_pipeline(handle, hcamcorder->type);
- }
_mmcamcorder_dealloc_subcontext(hcamcorder->sub_context);
hcamcorder->sub_context = NULL;
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* de-initialize resource manager */
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE)
+ _mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
+
+ ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
+ if (ret != MM_ERROR_NONE)
+ _mmcam_dbg_err("failed to de-initialize resource manager sub 0x%x", ret);
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
/* Remove idle function which is not called yet */
if (hcamcorder->setting_event_id) {
_mmcam_dbg_log("Remove remaining idle function");
hcamcorder->setting_event_id = 0;
}
- /* check current strobe mode */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- pid_t my_pid = getpid();
- int camera_pid = -1;
- vconf_get_int(VCONFKEY_CAMERA_PID, &camera_pid);
-
- if (camera_pid > -1 && my_pid == camera_pid) {
- int strobe_mode = MM_CAMCORDER_STROBE_MODE_OFF;
-
- vconf_set_int(VCONFKEY_CAMERA_PID, -1);
- _mmcam_dbg_log("reset camera pid");
-
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_STROBE_MODE, &strobe_mode,
- NULL);
- if (strobe_mode != MM_CAMCORDER_STROBE_MODE_OFF) {
- /* set OFF state of vconf key */
- vconf_set_int(VCONFKEY_CAMERA_FLASH_STATE, VCONFKEY_CAMERA_FLASH_STATE_OFF);
- _mmcam_dbg_log("reset flash state");
- }
- }
- }
-
/* Remove attributes */
if (hcamcorder->attributes) {
_mmcamcorder_dealloc_attribute(handle, hcamcorder->attributes);
/* Remove exif info */
if (hcamcorder->exif_info) {
mm_exif_destory_exif_info(hcamcorder->exif_info);
- hcamcorder->exif_info=NULL;
-
+ hcamcorder->exif_info = NULL;
}
/* Release configure info */
- if (hcamcorder->conf_ctrl) {
+ if (hcamcorder->conf_ctrl)
_mmcamcorder_conf_release_info(handle, &hcamcorder->conf_ctrl);
- }
- if (hcamcorder->conf_main) {
+
+ if (hcamcorder->conf_main)
_mmcamcorder_conf_release_info(handle, &hcamcorder->conf_main);
- }
/* Remove messages which are not called yet */
_mmcamcorder_remove_message_all(handle);
- /* unregister sound focus */
- if(hcamcorder->sound_focus_register) {
- if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) {
- _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id);
- }
+ /* unset remained watch cb */
+ if (hcamcorder->sound_focus_watch_id > 0) {
+ mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
+ _mmcam_dbg_warn("unset sound focus watch cb [id %d] done", hcamcorder->sound_focus_watch_id);
+ hcamcorder->sound_focus_watch_id = 0;
}
+ /* unregister sound focus and unsubscribe sound signal */
+ _mmcam_dbg_log("sound focus id %d, sound signal subscribe id %u",
+ hcamcorder->sound_focus_id, hcamcorder->sound_focus_subscribe_id);
+
+ if (hcamcorder->sound_focus_id > 0) {
+ mm_sound_unregister_focus(hcamcorder->sound_focus_id);
+ _mmcam_dbg_log("unregister sound focus done");
+ hcamcorder->sound_focus_id = 0;
+ }
+
+ if (hcamcorder->sound_focus_subscribe_id > 0) {
+ mm_sound_unsubscribe_signal(hcamcorder->sound_focus_subscribe_id);
+ _mmcam_dbg_log("unsubscribe sound signal done");
+ hcamcorder->sound_focus_subscribe_id = 0;
+ }
+
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->rm_handle != 0) {
+ iret = rm_unregister(hcamcorder->rm_handle);
+ if (iret != RM_OK)
+ _mmcam_dbg_err("rm_unregister() failed");
+ hcamcorder->rm_handle = 0;
+ }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
/* release model_name */
if (hcamcorder->model_name) {
free(hcamcorder->model_name);
hcamcorder->software_version = NULL;
}
+ /* release DPM handle */
+ if (hcamcorder->dpm_handle) {
+ _mmcam_dbg_log("release DPM handle %p, camera changed cb id %d",
+ hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
+
+ /* remove camera policy changed callback */
+ if (hcamcorder->dpm_camera_cb_id > 0) {
+ dpm_remove_policy_changed_cb(hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
+ hcamcorder->dpm_camera_cb_id = 0;
+ } else {
+ _mmcam_dbg_warn("invalid dpm camera cb id %d", hcamcorder->dpm_camera_cb_id);
+ }
+
+ dpm_manager_destroy(hcamcorder->dpm_handle);
+ hcamcorder->dpm_handle = NULL;
+ }
+
/* join task thread */
_mmcam_dbg_log("task thread join");
- pthread_join(hcamcorder->task_thread, NULL);
+ g_thread_join(hcamcorder->task_thread);
+ hcamcorder->task_thread = NULL;
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
/* Release lock, cond */
- pthread_mutex_destroy(&((hcamcorder->mtsafe).lock));
- pthread_cond_destroy(&((hcamcorder->mtsafe).cond));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).cmd_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).asm_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).gst_state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).gst_encode_state_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).message_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).vcapture_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).vstream_cb_lock));
- pthread_mutex_destroy(&((hcamcorder->mtsafe).astream_cb_lock));
-
- pthread_mutex_destroy(&(hcamcorder->sound_lock));
- pthread_cond_destroy(&(hcamcorder->sound_cond));
- pthread_mutex_destroy(&(hcamcorder->snd_info.open_mutex));
- pthread_cond_destroy(&(hcamcorder->snd_info.open_cond));
- pthread_mutex_destroy(&(hcamcorder->restart_preview_lock));
- pthread_mutex_destroy(&(hcamcorder->task_thread_lock));
- pthread_cond_destroy(&(hcamcorder->task_thread_cond));
-
- /* Release internal root directory string */
- if (hcamcorder->root_directory) {
- free(hcamcorder->root_directory);
- hcamcorder->root_directory = NULL;
+ g_mutex_clear(&(hcamcorder->mtsafe).lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cmd_cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).asm_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_encode_state_lock);
+ 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).astream_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
+ g_mutex_clear(&hcamcorder->snd_info.open_mutex);
+ g_cond_clear(&hcamcorder->snd_info.open_cond);
+ g_mutex_clear(&hcamcorder->restart_preview_lock);
+ g_mutex_clear(&hcamcorder->task_thread_lock);
+ g_cond_clear(&hcamcorder->task_thread_cond);
+
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ 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);
}
/* Release handle */
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
- if (hcamcorder) {
+ if (hcamcorder)
_mmcam_dbg_err("Destroy fail (type %d, state %d)", hcamcorder->type, state);
- }
_mmcam_dbg_err("Destroy fail (ret %x)", ret);
int ret = MM_ERROR_NONE;
int ret_sound = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_NULL;
- int state_TO = MM_CAMCORDER_STATE_READY;
- int display_surface_type = MM_DISPLAY_SURFACE_X;
+ int display_surface_type = MM_DISPLAY_SURFACE_OVERLAY;
int pid_for_sound_focus = 0;
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;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int iret = RM_OK;
+ int preview_format = MM_PIXEL_FORMAT_NV12;
+ int qret = RM_OK;
+ int qret_avail = 0; /* 0: not available, 1: available */
+ rm_consumer_info rci;
+ int app_pid = 0;
+ int resource_count = 0;
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ char *stream_type = NULL;
+ char *ext_info = NULL;
+ int option = 0;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_NULL) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
+ /* Get profile mode and gdbus connection */
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_MODE, &hcamcorder->type,
- NULL);
-
- /* Get profile mode */
- _mmcam_dbg_log("Profile mode [%d]", hcamcorder->type);
-
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_DISPLAY_SURFACE, &display_surface_type,
- MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
- MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus,
- NULL);
+ MMCAM_MODE, &hcamcorder->type,
+ MMCAM_GDBUS_CONNECTION, &hcamcorder->gdbus_conn, &conn_size,
+ NULL);
- /* set camera/recorder state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- if (vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_OPEN)) {
- _mmcam_dbg_log("VCONF ERROR %s : cur %d",strerror(errno),errno);
- if(errno == EPERM || errno == EACCES) {
- ret = MM_ERROR_COMMON_INVALID_PERMISSION;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- }
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_OPEN);
- } else {
- int vconf_recorder_state = 0;
+ if (!hcamcorder->gdbus_conn) {
+ _mmcam_dbg_err("gdbus connection NULL");
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- if (vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_CREATED)) {
- _mmcam_dbg_log("VCONF ERROR %s : cur %d",strerror(errno),errno);
- if (errno == EPERM || errno == EACCES) {
- ret = MM_ERROR_COMMON_INVALID_PERMISSION;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- }
+ _mmcam_dbg_log("Profile mode [%d], gdbus connection [%p]",
+ hcamcorder->type, hcamcorder->gdbus_conn);
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_CREATED);
- }
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_SURFACE, &display_surface_type,
+ MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ NULL);
- /* acquire sound focus or set sound focus watch callback */
- if(hcamcorder->sound_focus_register) {
- /* check session flags */
+ /* sound focus */
+ if (hcamcorder->sound_focus_register) {
+ /* acquire sound focus or set sound focus watch callback */
if (hcamcorder->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) {
/* acquire sound focus */
_mmcam_dbg_log("PAUSE_OTHERS - acquire sound focus");
- ret_sound = mm_sound_acquire_focus(0, FOCUS_FOR_BOTH, NULL);
+ ret_sound = mm_sound_acquire_focus(hcamcorder->sound_focus_id, FOCUS_FOR_BOTH, "mm-camcorder acquire focus");
if (ret_sound != MM_ERROR_NONE) {
_mmcam_dbg_err("mm_sound_acquire_focus failed [0x%x]", ret_sound);
- /* TODO: MM_ERROR_POLICY_BLOCKED_BY_CALL, MM_ERROR_POLICY_BLOCKED_BY_ALARM*/
ret = MM_ERROR_POLICY_BLOCKED;
-
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
+
+ hcamcorder->acquired_focus = FOCUS_FOR_BOTH;
} else if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
/* do nothing */
_mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
} else {
+ /* check previous acquired focus */
+ ret = mm_sound_get_stream_type_of_acquired_focus(FOCUS_FOR_BOTH, &stream_type, &option, &ext_info);
+ if (ret == MM_ERROR_NONE && stream_type) {
+ if (!strcmp(stream_type, "alarm") ||
+ !strcmp(stream_type, "ringtone-voip") ||
+ !strcmp(stream_type, "ringtone-call") ||
+ !strcmp(stream_type, "voip") ||
+ !strcmp(stream_type, "call-voice") ||
+ !strcmp(stream_type, "call-video")) {
+ _mmcam_dbg_err("Blocked by session policy, stream_type [%s]", stream_type);
+ ret = MM_ERROR_POLICY_BLOCKED;
+ }
+ } else {
+ _mmcam_dbg_warn("get stream type failed 0x%x, stream type %s, but ignore it",
+ ret, stream_type ? stream_type : "NULL");
+ ret = MM_ERROR_NONE;
+ }
+
+ if (stream_type) {
+ free(stream_type);
+ stream_type = NULL;
+ }
+
+ if (ext_info) {
+ free(ext_info);
+ ext_info = NULL;
+ }
+
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+
+ /* unset remained watch cb */
+ if (hcamcorder->sound_focus_watch_id > 0) {
+ mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
+ _mmcam_dbg_warn("unset sound focus watch cb [id %d] done", hcamcorder->sound_focus_watch_id);
+ hcamcorder->sound_focus_watch_id = 0;
+ }
+
/* set sound focus watch callback */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus,
+ NULL);
+
if (pid_for_sound_focus == 0) {
- _mmcam_dbg_warn("pid for sound focus is not set, so call getpid");
pid_for_sound_focus = getpid();
+ _mmcam_dbg_warn("pid for sound focus is not set, use my pid %d", pid_for_sound_focus);
}
_mmcam_dbg_log("ETC - set sound focus watch callback - pid %d", pid_for_sound_focus);
ret_sound = mm_sound_set_focus_watch_callback_for_session(pid_for_sound_focus,
- FOCUS_FOR_BOTH,
- (mm_sound_focus_changed_watch_cb)_mmcamcorder_sound_focus_watch_cb,
- hcamcorder,
- &hcamcorder->sound_focus_watch_id);
+ FOCUS_FOR_BOTH,
+ (mm_sound_focus_changed_watch_cb)_mmcamcorder_sound_focus_watch_cb,
+ hcamcorder,
+ &hcamcorder->sound_focus_watch_id);
if (ret_sound != MM_ERROR_NONE) {
_mmcam_dbg_err("mm_sound_set_focus_watch_callback failed [0x%x]", ret_sound);
- /* TODO: MM_ERROR_POLICY_BLOCKED_BY_CALL, MM_ERROR_POLICY_BLOCKED_BY_ALARM*/
ret = MM_ERROR_POLICY_BLOCKED;
-
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
_mmcam_dbg_log("sound focus watch cb id %d", hcamcorder->sound_focus_watch_id);
}
+ } else {
+ _mmcam_dbg_log("no need to register sound focus");
}
/* alloc sub context */
hcamcorder->sub_context = _mmcamcorder_alloc_subcontext(hcamcorder->type);
- if(!hcamcorder->sub_context) {
+ if (!hcamcorder->sub_context) {
ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_CAMCORDER_CMD;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* Set basic configure information */
- if (motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) {
+ 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));
+ CONFIGURE_CATEGORY_MAIN_CAPTURE,
+ "UseEncodebin",
+ &(hcamcorder->sub_context->bencbin_capture));
_mmcam_dbg_warn("UseEncodebin [%d]", hcamcorder->sub_context->bencbin_capture);
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
/* get dual stream support info */
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "SupportDualStream",
- &(hcamcorder->sub_context->info_video->support_dual_stream));
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "SupportDualStream",
+ &(hcamcorder->sub_context->info_video->support_dual_stream));
+
_mmcam_dbg_warn("SupportDualStream [%d]", hcamcorder->sub_context->info_video->support_dual_stream);
}
switch (display_surface_type) {
- case MM_DISPLAY_SURFACE_X:
- videosink_element_type = strdup("VideosinkElementX");
+ case MM_DISPLAY_SURFACE_OVERLAY:
+ videosink_element_type = strdup("VideosinkElementOverlay");
break;
case MM_DISPLAY_SURFACE_EVAS:
videosink_element_type = strdup("VideosinkElementEvas");
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_dbg_warn("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("VideosinkElementX");
+ videosink_element_type = strdup("VideosinkElementOverlay");
break;
}
/* check string of videosink element */
if (videosink_element_type) {
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- videosink_element_type,
- &hcamcorder->sub_context->VideosinkElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ videosink_element_type,
+ &hcamcorder->sub_context->VideosinkElement);
free(videosink_element_type);
videosink_element_type = NULL;
} else {
_mmcam_dbg_warn("strdup failed(display_surface_type %d). Use default X type",
- display_surface_type);
+ display_surface_type);
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE,
- &hcamcorder->sub_context->VideosinkElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE,
+ &hcamcorder->sub_context->VideosinkElement);
}
_mmcamcorder_conf_get_value_element_name(hcamcorder->sub_context->VideosinkElement, &videosink_name);
/* get videoconvert element */
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "VideoconvertElement",
- &hcamcorder->sub_context->VideoconvertElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "VideoconvertElement",
+ &hcamcorder->sub_context->VideoconvertElement);
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAPTURE,
- "SensorEncodedCapture",
- &(hcamcorder->sub_context->SensorEncodedCapture));
+ CONFIGURE_CATEGORY_CTRL_CAPTURE,
+ "SensorEncodedCapture",
+ &(hcamcorder->sub_context->SensorEncodedCapture));
_mmcam_dbg_log("Support sensor encoded capture : %d", hcamcorder->sub_context->SensorEncodedCapture);
+ if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
+ int dpm_camera_state = DPM_ALLOWED;
+
+ /* check camera policy from DPM */
+ if (hcamcorder->dpm_handle) {
+ if (dpm_restriction_get_camera_state(hcamcorder->dpm_handle, &dpm_camera_state) == DPM_ERROR_NONE) {
+ _mmcam_dbg_log("DPM camera state %d", dpm_camera_state);
+ if (dpm_camera_state == DPM_DISALLOWED) {
+ _mmcam_dbg_err("CAMERA DISALLOWED by DPM");
+ ret = MM_ERROR_POLICY_RESTRICTED;
+
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
+
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ _mmcam_dbg_err("get DPM camera state failed, keep going...");
+ }
+ } else {
+ _mmcam_dbg_warn("NULL dpm_handle");
+ }
+
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* check connection */
+ ret = _mmcamcorder_resource_check_connection(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+
+ /* create resource set */
+ ret = _mmcamcorder_resource_create_resource_set(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+
+ hcamcorder->resource_manager.acquire_count = 0;
+
+ /* prepare resource manager for camera */
+ ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_CAMERA);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("could not prepare for camera resource");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+
+ /* prepare resource manager for "video_overlay only if display surface is X" */
+ if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_VIDEO_OVERLAY);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("could not prepare for video overlay resource");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ }
+
+ /* acquire resources */
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ ret = _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
+ _mmcam_dbg_err("could not acquire resources");
+
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+
+ if (hcamcorder->resource_manager.acquire_remain > 0) {
+ gint64 end_time = 0;
+
+ _mmcam_dbg_warn("wait for resource state change");
+
+ /* wait for resource state change */
+ end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
+
+ if (_MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time)) {
+ _mmcam_dbg_warn("signal received");
+ } else {
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_err("timeout");
+ ret = MM_ERROR_RESOURCE_INTERNAL;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ _mmcam_dbg_log("already all acquired");
+ }
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_PID_FOR_SOUND_FOCUS, &app_pid,
+ NULL);
+ rci.app_pid = app_pid;
+ aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
+
+ /* RM register */
+ if (hcamcorder->rm_handle == 0) {
+ iret = rm_register((rm_resource_cb)_mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
+ if (iret != RM_OK) {
+ _mmcam_dbg_err("rm_register fail");
+ ret = MM_ERROR_POLICY_BLOCKED;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_CAMERA_FORMAT, &preview_format,
+ NULL);
+
+ resource_count = 0;
+ memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+ memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+
+ if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
+
+ _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
+
+ resource_count++;
+ }
+
+ if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+
+ _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
+
+ resource_count++;
+ }
+
+ hcamcorder->request_resources.request_num = resource_count;
+
+ if (resource_count > 0) {
+ qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
+ if (qret != RM_OK || qret_avail != 1) {
+ _mmcam_dbg_log("rm query failed. retry with sub devices");
+
+ resource_count = 0;
+
+ if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+ _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
+ resource_count++;
+ }
+
+ if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+ _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
+ resource_count++;
+ }
+ }
+ }
+
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
+
+ hcamcorder->request_resources.request_num = resource_count + 1;
+ _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
+
+ iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
+ if (iret != RM_OK) {
+ _mmcam_dbg_err("Resource allocation request failed");
+ ret = MM_ERROR_POLICY_BLOCKED;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ }
+
/* create pipeline */
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:REALIZE:CREATE_PIPELINE");
+
ret = _mmcamcorder_create_pipeline(handle, hcamcorder->type);
+
+ traceEnd(TTRACE_TAG_CAMERA);
+
if (ret != MM_ERROR_NONE) {
/* check internal error of gstreamer */
if (hcamcorder->error_code != MM_ERROR_NONE) {
goto _ERR_CAMCORDER_CMD;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD:
- /* rollback camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_NULL);
-
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_NULL);
- } else {
- int vconf_recorder_state = 0;
-
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_NULL);
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* release hw resources */
+ if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
+ int ret_resource = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
+ if (ret_resource == MM_ERROR_RESOURCE_INVALID_STATE) {
+ _mmcam_dbg_warn("it could be in the middle of resource callback or there's no acquired resource");
+ } else if (ret_resource != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to release resource, ret_resource(0x%x)", ret_resource);
+ }
+ }
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->rm_handle) {
+ if (hcamcorder->returned_devices.allocated_num > 0) {
+ int idx = 0;
+ rm_device_request_s requested;
+ memset(&requested, 0x0, sizeof(rm_device_request_s));
+ requested.request_num = hcamcorder->returned_devices.allocated_num;
+ for (idx = 0; idx < requested.request_num; idx++)
+ requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
+
+ iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
+ if (iret != RM_OK)
+ _mmcam_dbg_err("Resource deallocation request failed ");
+ }
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_NULL);
+ /* unregister RM */
+ int ires = rm_unregister(hcamcorder->rm_handle);
+ if (ires != RM_OK)
+ _mmcam_dbg_err("rm_unregister() failed");
+ hcamcorder->rm_handle = 0;
}
+#endif /* _MMCAMCORDER_RM_SUPPORT*/
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
if (hcamcorder->sound_focus_watch_id > 0) {
- ret_sound = mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
- if (ret_sound != MM_ERROR_NONE) {
- _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback failed [0x%x]", ret_sound);
- }
-
+ mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
+ _mmcam_dbg_warn("unset sound focus watch cb [id %d] done", hcamcorder->sound_focus_watch_id);
hcamcorder->sound_focus_watch_id = 0;
}
+ if (hcamcorder->acquired_focus > 0) {
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
+ _mmcam_dbg_warn("release sound focus [focus %d] done", hcamcorder->acquired_focus);
+ hcamcorder->acquired_focus = 0;
+ }
+
_ERR_CAMCORDER_CMD_PRECON:
- _mmcam_dbg_err("Realize fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ _mmcam_dbg_err("Realize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_READY;
- int state_TO = MM_CAMCORDER_STATE_NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_READY) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
hcamcorder->sub_context = NULL;
}
- /* Deinitialize main context member */
- hcamcorder->command = NULL;
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->resource_manager.is_release_cb_calling);
+
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
+ hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM &&
+ hcamcorder->resource_manager.is_release_cb_calling == FALSE) {
+ gint64 end_time = 0;
+
+ /* release resource */
+ ret = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
+ if (ret == MM_ERROR_RESOURCE_INVALID_STATE) {
+ _mmcam_dbg_warn("it could be in the middle of resource callback or there's no acquired resource");
+ ret = MM_ERROR_NONE;
+ } else if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to release resource, ret(0x%x)", ret);
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_log("unlock resource");
+
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+
+ if (hcamcorder->resource_manager.acquire_remain < hcamcorder->resource_manager.acquire_count) {
+ /* wait for resource release */
+ _mmcam_dbg_log("resource is not released all. wait for signal...");
- /* check who calls unrealize. it's no need to do nothing if caller is sound focus callback */
- if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_ASM) {
- /* release sound focus or unset sound focus watch callback */
- if(hcamcorder->sound_focus_register) {
- int ret_sound = MM_ERROR_NONE;
+ end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
- /* check session flags */
- if (hcamcorder->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) {
- /* release sound focus */
- _mmcam_dbg_log("PAUSE_OTHERS - release sound focus");
+ _MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time);
+ }
+ }
- ret_sound = mm_sound_release_focus(0, FOCUS_FOR_BOTH, NULL);
- if (ret_sound != MM_ERROR_NONE) {
- _mmcam_dbg_warn("mm_sound_release_focus failed [0x%x]", ret_sound);
- }
- } else if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- /* do nothing */
- _mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
- } else {
- /* unset sound focus watch callback */
- _mmcam_dbg_log("ETC - unset sound focus watch callback - id %d", hcamcorder->sound_focus_watch_id);
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- if (hcamcorder->sound_focus_watch_id > 0) {
- ret_sound = mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
- if (ret_sound != MM_ERROR_NONE) {
- _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback failed [0x%x]", ret_sound);
- }
- } else {
- _mmcam_dbg_warn("invalid sound focus id %d", hcamcorder->sound_focus_watch_id);
- }
+ _mmcam_dbg_warn("unlock resource");
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
- hcamcorder->sound_focus_watch_id = 0;
- }
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->rm_handle && (hcamcorder->returned_devices.allocated_num > 0)) {
+ int iret = RM_OK;
+ int idx = 0;
+ rm_device_request_s requested;
+ memset(&requested, 0x0, sizeof(rm_device_request_s));
+ requested.request_num = hcamcorder->returned_devices.allocated_num;
+ for (idx = 0; idx < requested.request_num; idx++)
+ requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
+
+ iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
+ if (iret != RM_OK)
+ _mmcam_dbg_err("Resource deallocation request failed ");
}
- }
+#endif /* _MMCAMCORDER_RM_SUPPORT*/
- /* set camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
+ /* Deinitialize main context member */
+ hcamcorder->command = NULL;
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_NULL);
+ _mmcam_dbg_log("focus register %d, session flag 0x%x, state_change_by_system %d",
+ hcamcorder->sound_focus_register, hcamcorder->session_flags, hcamcorder->state_change_by_system);
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_NULL);
- } else {
- int vconf_recorder_state = 0;
+ /* release sound focus or unset sound focus watch callback */
+ _mmcam_dbg_log("by_system %d, flag 0x%x, acquired_focus %d, focus_id %d, watch_id %d",
+ hcamcorder->state_change_by_system, hcamcorder->session_flags, hcamcorder->acquired_focus,
+ hcamcorder->sound_focus_id, hcamcorder->sound_focus_watch_id);
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_NULL);
+ if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_FOCUS) {
+ if (hcamcorder->sound_focus_watch_id > 0) {
+ mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
+ _mmcam_dbg_warn("unset sound focus watch cb [id %d] done", hcamcorder->sound_focus_watch_id);
+ hcamcorder->sound_focus_watch_id = 0;
+ }
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_NULL);
+ if (hcamcorder->acquired_focus > 0) {
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
+ _mmcam_dbg_warn("release sound focus [focus %d] done", hcamcorder->acquired_focus);
+ hcamcorder->acquired_focus = 0;
+ }
+ } else {
+ _mmcam_dbg_warn("state change by focus. so, no need to unset watch callback");
+ /* acquired focus will be released automatically */
+ hcamcorder->acquired_focus = 0;
}
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_NULL);
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Unrealize fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ _mmcam_dbg_err("Unrealize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_READY;
- int state_TO =MM_CAMCORDER_STATE_PREPARE;
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_READY) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
hcamcorder->error_code = MM_ERROR_NONE;
/* set attributes related sensor */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO)
_mmcamcorder_set_attribute_to_camsensor(handle);
- }
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_PREVIEW_START);
if (ret != MM_ERROR_NONE) {
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- _mmcamcorder_set_state(handle, state_TO);
-
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* check camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
-
- /* set camera state to vconf key */
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_PREVIEW);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_PREVIEW);
- }
+ /* set attributes related sensor - after start preview */
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO)
+ _mmcamcorder_set_attribute_to_camsensor2(handle);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
}
_mmcam_dbg_err("Start fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_PREPARE;
- int state_TO = MM_CAMCORDER_STATE_READY;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_PREPARE) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_PREVIEW_STOP);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* check camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
-
- /* set camera state to vconf key */
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_OPEN);
+ /* unsubscribe remained unsubscribed signal */
+ g_mutex_lock(&hcamcorder->gdbus_info_sound.sync_mutex);
+ if (hcamcorder->gdbus_info_sound.subscribe_id > 0) {
+ _mmcam_dbg_warn("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);
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_OPEN);
+ g_mutex_lock(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
+ if (hcamcorder->gdbus_info_solo_sound.subscribe_id > 0) {
+ _mmcam_dbg_warn("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);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Stop fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ _mmcam_dbg_err("Stop fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
int state_FROM_0 = MM_CAMCORDER_STATE_PREPARE;
int state_FROM_1 = MM_CAMCORDER_STATE_RECORDING;
int state_FROM_2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_CAPTURING;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM_0 &&
- state != state_FROM_1 &&
- state != state_FROM_2) {
+ if (state != state_FROM_0 && state != state_FROM_1 && state != state_FROM_2) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
ret = MM_ERROR_CAMCORDER_DEVICE_BUSY;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
} else {
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ g_mutex_lock(&hcamcorder->task_thread_lock);
if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_NONE) {
hcamcorder->capture_in_recording = TRUE;
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING;
_mmcam_dbg_log("send signal for capture in recording");
- pthread_cond_signal(&(hcamcorder->task_thread_cond));
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
} else {
_mmcam_dbg_err("task thread busy : %d", hcamcorder->task_thread_state);
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_CAPTURE);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD;
- }
/* Do not change state when recording snapshot capture */
- if (state == state_FROM_0) {
- _mmcamcorder_set_state(handle, state_TO);
- }
+ if (state == state_FROM_0)
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_CAPTURING);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
/* Init break continuous shot attr */
- if (mm_camcorder_set_attributes(handle, NULL, "capture-break-cont-shot", 0, NULL) != MM_ERROR_NONE) {
+ if (mm_camcorder_set_attributes(handle, NULL, "capture-break-cont-shot", 0, NULL) != MM_ERROR_NONE)
_mmcam_dbg_warn("capture-break-cont-shot set 0 failed");
- }
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD:
- if (hcamcorder->capture_in_recording) {
+ if (hcamcorder->capture_in_recording)
hcamcorder->capture_in_recording = FALSE;
- }
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
_mmcam_dbg_err("Capture start fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_CAPTURING;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_mmcam_dbg_log("");
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_CAPTURING) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_PREVIEW_START);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
_mmcam_dbg_err("Capture stop fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_PREPARE;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_RECORDING;
+ int dpm_mic_state = DPM_ALLOWED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
_mmcam_dbg_log("");
- if (!hcamcorder) {
+ if (!hcamcorder || !MMF_CAMCORDER_SUBCONTEXT(hcamcorder)) {
_mmcam_dbg_err("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
_mmcam_dbg_err("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
/* initialize error code */
hcamcorder->error_code = MM_ERROR_NONE;
+ /* get audio disable */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_AUDIO_DISABLE, &sc->audio_disable,
+ NULL);
+
+ sc->audio_disable |= sc->is_modified_rate;
+
+ /* check mic policy from DPM */
+ if (hcamcorder->dpm_handle && sc->audio_disable == FALSE) {
+ if (dpm_restriction_get_microphone_state(hcamcorder->dpm_handle, &dpm_mic_state) == DPM_ERROR_NONE) {
+ _mmcam_dbg_log("DPM mic state %d", dpm_mic_state);
+ if (dpm_mic_state == DPM_DISALLOWED) {
+ _mmcam_dbg_err("MIC DISALLOWED by DPM");
+ ret = MM_ERROR_COMMON_INVALID_PERMISSION;
+
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
+
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ _mmcam_dbg_err("get DPM mic state failed, keep going...");
+ }
+ } else {
+ _mmcam_dbg_warn("skip dpm check - handle %p, audio disable %d",
+ hcamcorder->dpm_handle, sc->audio_disable);
+ }
+
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_RECORD);
if (ret != MM_ERROR_NONE) {
/* check internal error of gstreamer */
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- _mmcamcorder_set_state(handle, state_TO);
-
- /* set camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_RECORDING);
-
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_RECORDING);
- } else {
- int vconf_recorder_state = 0;
-
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_RECORDING);
-
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_RECORDING);
- }
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_RECORDING);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
}
_mmcam_dbg_err("Record fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_RECORDING;
- int state_TO = MM_CAMCORDER_STATE_PAUSED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_RECORDING) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_PAUSE);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- _mmcamcorder_set_state(handle, state_TO);
-
- /* set camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_RECORDING_PAUSE);
-
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_RECORDING_PAUSE);
- } else {
- int vconf_recorder_state = 0;
-
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_RECORDING_PAUSE);
-
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_RECORDING_PAUSE);
- }
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PAUSED);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Pause fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ _mmcam_dbg_err("Pause fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_RECORDING;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
+ /* initialize error code */
+ hcamcorder->error_code = MM_ERROR_NONE;
+
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_COMMIT);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- /* set camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
-
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_PREVIEW);
-
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_PREVIEW);
- } else {
- int vconf_recorder_state = 0;
-
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_CREATED);
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_CREATED);
- }
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
- _mmcamcorder_set_state(handle,state_TO);
-
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Commit fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ _mmcam_dbg_err("Commit fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_RECORDING;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_CANCEL);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- _mmcamcorder_set_state(handle, state_TO);
-
- /* set camera state to vconf key */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- int vconf_camera_state = 0;
- /* get current camera state of vconf key */
- vconf_get_int(VCONFKEY_CAMERA_STATE, &vconf_camera_state);
- vconf_set_int(VCONFKEY_CAMERA_STATE, VCONFKEY_CAMERA_STATE_PREVIEW);
-
- _mmcam_dbg_log("VCONFKEY_CAMERA_STATE prev %d -> cur %d",
- vconf_camera_state, VCONFKEY_CAMERA_STATE_PREVIEW);
- } else {
- int vconf_recorder_state = 0;
-
- /* get current recorder state of vconf key */
- vconf_get_int(VCONFKEY_RECORDER_STATE, &vconf_recorder_state);
- vconf_set_int(VCONFKEY_RECORDER_STATE, VCONFKEY_RECORDER_STATE_CREATED);
-
- _mmcam_dbg_log("VCONFKEY_RECORDER_STATE prev %d -> cur %d",
- vconf_recorder_state, VCONFKEY_RECORDER_STATE_CREATED);
- }
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
_mmcam_dbg_err("Cancel fail (type %d, state %d, ret %x)",
- hcamcorder->type, state, ret);
+ hcamcorder->type, state, ret);
return ret;
}
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (callback == NULL) {
+ if (callback == NULL)
_mmcam_dbg_warn("Message Callback is disabled, because application sets it to NULL");
- }
if (!_MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(hcamcorder)) {
_mmcam_dbg_warn("Application's message callback is running now");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (callback == NULL) {
+ if (callback == NULL)
_mmcam_dbg_warn("Video Stream Callback is disabled, because application sets it to NULL");
- }
- if (!_MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(hcamcorder)) {
- _mmcam_dbg_warn("Application's video stream callback is running now");
- return MM_ERROR_CAMCORDER_INVALID_CONDITION;
- }
+ _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
hcamcorder->vstream_cb = callback;
hcamcorder->vstream_cb_param = user_data;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (callback == NULL) {
+ if (callback == NULL)
_mmcam_dbg_warn("Audio Stream Callback is disabled, because application sets it to NULL");
- }
if (!_MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(hcamcorder)) {
_mmcam_dbg_warn("Application's audio stream callback is running now");
}
+int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle, mm_camcorder_muxed_stream_callback callback, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ _mmcam_dbg_log("");
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ if (callback == NULL)
+ _mmcam_dbg_warn("Muxed Stream Callback is disabled, because application sets it to NULL");
+
+ if (!_MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(hcamcorder)) {
+ _mmcam_dbg_warn("Application's muxed stream callback is running now");
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
+
+ hcamcorder->mstream_cb = callback;
+ hcamcorder->mstream_cb_param = user_data;
+
+ _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(hcamcorder);
+
+ return MM_ERROR_NONE;
+}
+
+
int _mmcamcorder_set_video_capture_callback(MMHandleType handle, mm_camcorder_video_capture_callback callback, void *user_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (callback == NULL) {
+ if (callback == NULL)
_mmcam_dbg_warn("Video Capture Callback is disabled, because application sets it to NULLL");
- }
if (!_MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(hcamcorder)) {
_mmcam_dbg_warn("Application's video capture callback is running now");
if (state == MM_CAMCORDER_STATE_CAPTURING ||
state < MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_err( "Not proper state. state[%d]", state );
+ _mmcam_dbg_err("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INVALID_STATE;
}
return MM_ERROR_NONE;
}
- control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control == NULL) {
_mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INTERNAL;
}
/* Initialize lens position */
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
- MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
- NULL);
+ MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
+ MMCAM_CAMERA_AF_SCAN_RANGE, &af_range,
+ NULL);
sensor_af_range = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_AF_SCAN_RANGE, af_range);
sensor_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, focus_mode);
gst_camera_control_get_focus(control, ¤t_focus_mode, ¤t_af_range);
- if (current_focus_mode != sensor_focus_mode ||
- current_af_range != sensor_af_range) {
+ if (current_focus_mode != sensor_focus_mode || current_af_range != sensor_af_range) {
ret = gst_camera_control_set_focus(control, sensor_focus_mode, sensor_af_range);
} else {
- _mmcam_dbg_log("No need to init FOCUS [mode:%d, range:%d]", focus_mode, af_range );
+ _mmcam_dbg_log("No need to init FOCUS [mode:%d, range:%d]", focus_mode, af_range);
ret = TRUE;
}
}
state = _mmcamcorder_get_state(handle);
- if (state == MM_CAMCORDER_STATE_CAPTURING ||
- state < MM_CAMCORDER_STATE_PREPARE) {
+ if (state == MM_CAMCORDER_STATE_CAPTURING || state < MM_CAMCORDER_STATE_PREPARE) {
_mmcam_dbg_err("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(handle);
return MM_ERROR_CAMCORDER_INVALID_STATE;
/* TODO : call a auto or manual focus function */
ret = mm_camcorder_get_attributes(handle, &err_attr_name,
- MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
- NULL);
+ MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
+ NULL);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get focus-mode fail. (%s:%x)", err_attr_name, ret);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
_MMCAMCORDER_UNLOCK_CMD(handle);
return ret;
}
- if (focus_mode == MM_CAMCORDER_FOCUS_MODE_MANUAL) {
+ switch (focus_mode) {
+ case MM_CAMCORDER_FOCUS_MODE_MANUAL:
ret = _mmcamcorder_adjust_manual_focus(handle, direction);
- } else if (focus_mode == MM_CAMCORDER_FOCUS_MODE_AUTO ||
- focus_mode == MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO ||
- focus_mode == MM_CAMCORDER_FOCUS_MODE_CONTINUOUS) {
+ break;
+ case MM_CAMCORDER_FOCUS_MODE_AUTO:
+ case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO:
+ case MM_CAMCORDER_FOCUS_MODE_CONTINUOUS:
ret = _mmcamcorder_adjust_auto_focus(handle);
- } else {
+ break;
+ default:
_mmcam_dbg_err("It doesn't adjust focus. Focusing mode(%d)", focus_mode);
ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
}
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(_MMFCAMCORDER_FOCUS_TOTAL_LEVEL != 1, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
mmf_return_val_if_fail((direction >= MM_CAMCORDER_MF_LENS_DIR_FORWARD) &&
- (direction <= MM_CAMCORDER_MF_LENS_DIR_BACKWARD),
- MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
+ (direction <= MM_CAMCORDER_MF_LENS_DIR_BACKWARD),
+ MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
return MM_ERROR_NONE;
}
- control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control == NULL) {
_mmcam_dbg_err("cast CAMERA_CONTROL failed");
return MM_ERROR_CAMCORDER_INTERNAL;
}
/* TODO : get max, min level */
- if (max_level - min_level + 1 < _MMFCAMCORDER_FOCUS_TOTAL_LEVEL) {
+ if (max_level - min_level + 1 < _MMFCAMCORDER_FOCUS_TOTAL_LEVEL)
_mmcam_dbg_warn("Total level of manual focus of MMF is greater than that of the camera driver.");
- }
unit_level = ((float)max_level - (float)min_level)/(float)(_MMFCAMCORDER_FOCUS_TOTAL_LEVEL - 1);
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
- //TODO : adjust unit level value
- if (direction == MM_CAMCORDER_MF_LENS_DIR_FORWARD) {
+ /* TODO : adjust unit level value */
+ if (direction == MM_CAMCORDER_MF_LENS_DIR_FORWARD)
focus_level = cur_level + unit_level;
- } else if (direction == MM_CAMCORDER_MF_LENS_DIR_BACKWARD) {
+ else if (direction == MM_CAMCORDER_MF_LENS_DIR_BACKWARD)
focus_level = cur_level - unit_level;
- }
- if (focus_level > max_level) {
+ if (focus_level > max_level)
focus_level = max_level;
- } else if (focus_level < min_level) {
+ else if (focus_level < min_level)
focus_level = min_level;
- }
if (!gst_camera_control_set_focus_level(control, focus_level)) {
_mmcam_dbg_err("Manual focusing fail.");
return MM_ERROR_NONE;
}
- control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control) {
/* Start AF */
ret = gst_camera_control_start_auto_focus(control);
}
state = _mmcamcorder_get_state(handle);
- if (state == MM_CAMCORDER_STATE_CAPTURING ||
- state < MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_err( "Not proper state. state[%d]", state );
+ if (state == MM_CAMCORDER_STATE_CAPTURING || state < MM_CAMCORDER_STATE_PREPARE) {
+ _mmcam_dbg_err("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INVALID_STATE;
}
argc = malloc(sizeof(int));
argv = malloc(sizeof(gchar *) * max_argc);
- if (!argc || !argv) {
+ if (!argc || !argv)
goto ERROR;
- }
memset(argv, 0, sizeof(gchar *) * max_argc);
/* add gst_param */
_mmcamcorder_conf_get_value_string_array(conf,
- CONFIGURE_CATEGORY_MAIN_GENERAL,
- "GSTInitOption",
- &GSTInitOption);
+ CONFIGURE_CATEGORY_MAIN_GENERAL,
+ "GSTInitOption",
+ &GSTInitOption);
if (GSTInitOption != NULL && GSTInitOption->value) {
cnt_str = GSTInitOption->count;
- for( ; *argc < max_argc && *argc <= cnt_str ; (*argc)++ )
- {
+ for ( ; *argc < max_argc && *argc <= cnt_str ; (*argc)++)
argv[*argc] = g_strdup(GSTInitOption->value[(*argc)-1]);
- }
}
_mmcam_dbg_log("initializing gstreamer with following parameter[argc:%d]", *argc);
- for (i = 0; i < *argc; i++) {
+ for (i = 0; i < *argc; i++)
_mmcam_dbg_log("argv[%d] : %s", i, argv[i]);
- }
/* initializing gstreamer */
- ret = gst_init_check (argc, &argv, &err);
+ ret = gst_init_check(argc, &argv, &err);
if (!ret) {
- _mmcam_dbg_err("Could not initialize GStreamer: %s ",
- err ? err->message : "unknown error occurred");
- if (err) {
- g_error_free (err);
- }
+ _mmcam_dbg_err("Could not initialize GStreamer: %s ", err ? err->message : "unknown error occurred");
+ if (err)
+ g_error_free(err);
}
/* release */
for (i = 0; i < *argc; i++) {
if (argv[i]) {
- free(argv[i]);
+ g_free(argv[i]);
argv[i] = NULL;
}
}
}
+int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder && state && old_state, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ _MMCAMCORDER_LOCK_STATE(handle);
+
+ *state = hcamcorder->state;
+ *old_state = hcamcorder->old_state;
+
+ _MMCAMCORDER_UNLOCK_STATE(handle);
+
+ return MM_ERROR_NONE;
+}
+
+
void _mmcamcorder_set_state(MMHandleType handle, int state)
{
int old_state;
_MMCAMCORDER_LOCK_STATE(handle);
old_state = hcamcorder->state;
- if(old_state != state) {
+ if (old_state != state) {
hcamcorder->state = state;
- hcamcorder->target_state = state;
+ hcamcorder->old_state = old_state;
- _mmcam_dbg_log("set state[%d] and send state-changed message", state);
+ _mmcam_dbg_log("set state[%d -> %d] and send state-changed message", old_state, state);
+
+ /* To discern who changes the state */
+ switch (hcamcorder->state_change_by_system) {
+ case _MMCAMCORDER_STATE_CHANGE_BY_FOCUS:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM;
+ msg.param.state.code = hcamcorder->interrupt_code;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_RM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_RM;
+ msg.param.state.code = MM_ERROR_NONE;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_DPM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY;
+ msg.param.state.code = MM_ERROR_NONE;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_NORMAL:
+ default:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED;
+ msg.param.state.code = MM_ERROR_NONE;
+ break;
+ }
- msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED;
- msg.param.state.code = MM_ERROR_NONE;
msg.param.state.previous = old_state;
msg.param.state.current = state;
}
-int _mmcamcorder_get_async_state(MMHandleType handle)
-{
- int state;
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
-
- _MMCAMCORDER_LOCK_STATE(handle);
- state = hcamcorder->target_state;
-
- _MMCAMCORDER_UNLOCK_STATE(handle);
-
- return state;
-}
-
-
_MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type)
{
int i;
/* alloc info for each mode */
switch (type) {
case MM_CAMCORDER_MODE_AUDIO:
- sc->info_audio = malloc( sizeof(_MMCamcorderAudioInfo));
- if(!sc->info_audio) {
+ sc->info_audio = g_malloc0(sizeof(_MMCamcorderAudioInfo));
+ if (!sc->info_audio) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_audio, 0x00, sizeof(_MMCamcorderAudioInfo));
break;
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
default:
- sc->info_image = malloc( sizeof(_MMCamcorderImageInfo));
- if(!sc->info_image) {
+ sc->info_image = g_malloc0(sizeof(_MMCamcorderImageInfo));
+ if (!sc->info_image) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_image, 0x00, sizeof(_MMCamcorderImageInfo));
/* init sound status */
sc->info_image->sound_status = _SOUND_STATUS_INIT;
- sc->info_video = malloc( sizeof(_MMCamcorderVideoInfo));
- if(!sc->info_video) {
+ sc->info_video = g_malloc0(sizeof(_MMCamcorderVideoInfo));
+ if (!sc->info_video) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_video, 0x00, sizeof(_MMCamcorderVideoInfo));
- pthread_mutex_init(&(sc->info_video->size_check_lock), NULL);
+ g_mutex_init(&sc->info_video->size_check_lock);
break;
}
/* alloc element array */
sc->element = (_MMCamcorderGstElement *)malloc(sizeof(_MMCamcorderGstElement) * sc->element_num);
- if(!sc->element) {
+ if (!sc->element) {
_mmcam_dbg_err("Failed to alloc element structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
sc->encode_element = (_MMCamcorderGstElement *)malloc(sizeof(_MMCamcorderGstElement) * sc->encode_element_num);
- if(!sc->encode_element) {
+ if (!sc->encode_element) {
_mmcam_dbg_err("Failed to alloc encode element structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
ALLOC_SUBCONTEXT_FAILED:
if (sc) {
- if (sc->info_audio) {
- free(sc->info_audio);
- sc->info_audio = NULL;
- }
- if (sc->info_image) {
- free(sc->info_image);
- sc->info_image = NULL;
- }
- if (sc->info_video) {
- pthread_mutex_destroy(&(sc->info_video->size_check_lock));
- free(sc->info_video);
- sc->info_video = NULL;
- }
+ SAFE_G_FREE(sc->info_audio);
+ SAFE_G_FREE(sc->info_image);
+ if (sc->info_video)
+ g_mutex_clear(&sc->info_video->size_check_lock);
+
+ SAFE_G_FREE(sc->info_video);
if (sc->element) {
free(sc->element);
sc->element = NULL;
if (sc->info_video) {
_mmcam_dbg_log("release info_video");
- if (sc->info_video->filename) {
- free(sc->info_video->filename);
- sc->info_video->filename = NULL;
- }
- pthread_mutex_destroy(&(sc->info_video->size_check_lock));
+ SAFE_G_FREE(sc->info_video->filename);
+ g_mutex_clear(&sc->info_video->size_check_lock);
free(sc->info_video);
sc->info_video = NULL;
}
if (sc->info_audio) {
_mmcam_dbg_log("release info_audio");
- if (sc->info_audio->filename) {
- free(sc->info_audio->filename);
- sc->info_audio->filename = NULL;
- }
+ SAFE_G_FREE(sc->info_audio->filename);
free(sc->info_audio);
sc->info_audio = NULL;
}
mmf_return_val_if_fail(hcamcorder, FALSE);
mmf_return_val_if_fail(message, FALSE);
- //_mmcam_dbg_log("message type=(%d)", GST_MESSAGE_TYPE(message));
+ /* _mmcam_dbg_log("message type=(%d)", GST_MESSAGE_TYPE(message)); */
switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_UNKNOWN:
break;
case GST_MESSAGE_EOS:
{
- _mmcam_dbg_log ("Got EOS from element \"%s\".",
- GST_STR_NULL(GST_ELEMENT_NAME(GST_MESSAGE_SRC(message))));
-
- sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
- mmf_return_val_if_fail(sc, TRUE);
-
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- mmf_return_val_if_fail(sc->info_video, TRUE);
- if (sc->info_video->b_commiting) {
- _mmcamcorder_video_handle_eos((MMHandleType)hcamcorder);
- }
- } else {
- mmf_return_val_if_fail(sc->info_audio, TRUE);
- if (sc->info_audio->b_commiting) {
- _mmcamcorder_audio_handle_eos((MMHandleType)hcamcorder);
- }
- }
-
- sc->bget_eos = TRUE;
-
+ _mmcam_dbg_err("Got EOS from element \"%s\"... but should not be reached here!",
+ GST_STR_NULL(GST_ELEMENT_NAME(GST_MESSAGE_SRC(message))));
break;
}
case GST_MESSAGE_ERROR:
{
- GError *err;
- gchar *debug;
- gst_message_parse_error(message, &err, &debug);
+ GError *err = NULL;
+ gchar *debug = NULL;
- _mmcam_dbg_err ("GSTERR: %s", err->message);
- _mmcam_dbg_err ("Error Debug: %s", debug);
+ gst_message_parse_error(message, &err, &debug);
__mmcamcorder_handle_gst_error((MMHandleType)hcamcorder, message, err);
- g_error_free (err);
- g_free (debug);
+ if (err) {
+ _mmcam_dbg_err("GSTERR: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ }
+
+ if (debug) {
+ _mmcam_dbg_err("Error Debug: %s", debug);
+ g_free(debug);
+ debug = NULL;
+ }
break;
}
case GST_MESSAGE_WARNING:
{
GError *err;
gchar *debug;
- gst_message_parse_warning (message, &err, &debug);
+ gst_message_parse_warning(message, &err, &debug);
_mmcam_dbg_warn("GSTWARN: %s", err->message);
__mmcamcorder_handle_gst_warning((MMHandleType)hcamcorder, message, err);
- g_error_free (err);
- g_free (debug);
+ g_error_free(err);
+ g_free(debug);
break;
}
case GST_MESSAGE_INFO:
pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
if (message->src == (GstObject*)pipeline) {
vnewstate = gst_structure_get_value(gst_message_get_structure(message), "new-state");
- newstate = (GstState)vnewstate->data[0].v_int;
- _mmcam_dbg_log("GST_MESSAGE_STATE_CHANGED[%s]",gst_element_state_get_name(newstate));
+ if (vnewstate) {
+ newstate = (GstState)vnewstate->data[0].v_int;
+ _mmcam_dbg_log("GST_MESSAGE_STATE_CHANGED[%s]", gst_element_state_get_name(newstate));
+ } else {
+ _mmcam_dbg_warn("get new state failed from msg");
+ }
}
}
}
_mmcam_dbg_log("GST_MESSAGE_ANY");
break;
case GST_MESSAGE_QOS:
-// _mmcam_dbg_log("GST_MESSAGE_QOS");
+ /* _mmcam_dbg_log("GST_MESSAGE_QOS"); */
break;
default:
_mmcam_dbg_log("not handled message type=(%d)", GST_MESSAGE_TYPE(message));
element = GST_ELEMENT_CAST(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
/* check domain[RESOURCE] and element[VIDEOSRC] */
- if (err->domain == GST_RESOURCE_ERROR &&
- GST_ELEMENT_CAST(message->src) == element) {
+ if (err->domain == GST_RESOURCE_ERROR && GST_ELEMENT_CAST(message->src) == element) {
switch (err->code) {
case GST_RESOURCE_ERROR_BUSY:
_mmcam_dbg_err("Camera device [busy]");
case GST_RESOURCE_ERROR_OPEN_WRITE:
_mmcam_dbg_err("Camera device [open failed]");
hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
- //sc->error_code = MM_ERROR_CAMCORDER_DEVICE_OPEN; // SECURITY PART REQUEST PRIVILEGE
+ /* sc->error_code = MM_ERROR_CAMCORDER_DEVICE_OPEN; // SECURITY PART REQUEST PRIVILEGE */
break;
case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
_mmcam_dbg_err("Camera device [open failed]");
GstCameraControlFaceDetectInfo *fd_info = NULL;
MMCamFaceDetectInfo *cam_fd_info = NULL;
- if (g_value) {
+ if (g_value)
fd_info = (GstCameraControlFaceDetectInfo *)g_value_get_pointer(g_value);
- }
if (fd_info == NULL) {
_mmcam_dbg_warn("fd_info is NULL");
goto DROP_MESSAGE;
}
- cam_fd_info = (MMCamFaceDetectInfo *)malloc(sizeof(MMCamFaceDetectInfo));
+ cam_fd_info = (MMCamFaceDetectInfo *)g_malloc(sizeof(MMCamFaceDetectInfo));
if (cam_fd_info == NULL) {
_mmcam_dbg_warn("cam_fd_info alloc failed");
-
- free(fd_info);
- fd_info = NULL;
-
+ SAFE_FREE(fd_info);
goto DROP_MESSAGE;
}
cam_fd_info->num_of_faces = fd_info->num_of_faces;
if (cam_fd_info->num_of_faces > 0) {
- cam_fd_info->face_info = (MMCamFaceInfo *)malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
+ cam_fd_info->face_info = (MMCamFaceInfo *)g_malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
if (cam_fd_info->face_info) {
/* set information of each face */
for (i = 0 ; i < fd_info->num_of_faces ; i++) {
cam_fd_info->face_info[i].rect.height = fd_info->face_info[i].rect.height;
/*
_mmcam_dbg_log("id %d, score %d, [%d,%d,%dx%d]",
- fd_info->face_info[i].id,
- fd_info->face_info[i].score,
- fd_info->face_info[i].rect.x,
- fd_info->face_info[i].rect.y,
- fd_info->face_info[i].rect.width,
- fd_info->face_info[i].rect.height);
+ fd_info->face_info[i].id,
+ fd_info->face_info[i].score,
+ fd_info->face_info[i].rect.x,
+ fd_info->face_info[i].rect.y,
+ fd_info->face_info[i].rect.width,
+ fd_info->face_info[i].rect.height);
*/
}
} else {
_mmcam_dbg_warn("MMCamFaceInfo alloc failed");
/* free allocated memory that is not sent */
- free(cam_fd_info);
- cam_fd_info = NULL;
+ SAFE_G_FREE(cam_fd_info);
}
} else {
cam_fd_info->face_info = NULL;
int capture_done = FALSE;
if (gst_structure_get_int(gst_message_get_structure(message), "capture-done", &capture_done)) {
- sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
- if (sc && sc->info_image) {
+ if (sc->info_image) {
/* play capture sound */
- _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_FILEPATH_CAPTURE_SND, FALSE);
+ _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
}
}
}
return GST_BUS_PASS;
+
DROP_MESSAGE:
gst_message_unref(message);
message = NULL;
}
-GstBusSyncReply _mmcamcorder_audio_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
+GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
{
GstElement *element = NULL;
GError *err = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_val_if_fail(sc, GST_BUS_PASS);
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
+ if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
+ _mmcam_dbg_log("got EOS from pipeline");
+
+ _MMCAMCORDER_LOCK(hcamcorder);
+
+ sc->bget_eos = TRUE;
+ _MMCAMCORDER_SIGNAL(hcamcorder);
+
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+
+ goto DROP_MESSAGE;
+ } else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
+ _MMCamcorderMsgItem msg;
+
/* parse error message */
gst_message_parse_error(message, &err, &debug_info);
return GST_BUS_PASS;
}
- /* set videosrc element to compare */
- element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
+ /* set videosrc element to compare */
+ element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
+
+ /* check domain[RESOURCE] and element[AUDIOSRC] */
+ if (err->domain == GST_RESOURCE_ERROR &&
+ GST_ELEMENT_CAST(message->src) == element) {
+ switch (err->code) {
+ case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
+ case GST_RESOURCE_ERROR_OPEN_WRITE:
+ _mmcam_dbg_err("audio device [open failed]");
+
+ /* post error to application */
+ hcamcorder->error_occurs = TRUE;
+ hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
+
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ msg.param.code = hcamcorder->error_code;
+
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+
+ _mmcam_dbg_err(" error : sc->error_occurs %d", hcamcorder->error_occurs);
+
+ goto DROP_MESSAGE;
+ default:
+ break;
+ }
+ } else {
+ gboolean b_commiting = FALSE;
+ storage_state_e storage_state = STORAGE_STATE_UNMOUNTABLE;
+
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ mmf_return_val_if_fail(sc->info_video, GST_BUS_PASS);
+ b_commiting = sc->info_video->b_commiting;
+ } else {
+ mmf_return_val_if_fail(sc->info_audio, GST_BUS_PASS);
+ b_commiting = sc->info_audio->b_commiting;
+ }
+
+ _MMCAMCORDER_LOCK(hcamcorder);
- /* check domain[RESOURCE] and element[VIDEOSRC] */
- if (err->domain == GST_RESOURCE_ERROR &&
- GST_ELEMENT_CAST(message->src) == element) {
- _MMCamcorderMsgItem msg;
switch (err->code) {
- case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
+ case GST_RESOURCE_ERROR_WRITE:
+ storage_get_state(hcamcorder->storage_info.id, &storage_state);
+ if (storage_state == STORAGE_STATE_REMOVED ||
+ storage_state == STORAGE_STATE_UNMOUNTABLE) {
+ _mmcam_dbg_err("storage was removed! [storage state %d]", storage_state);
+ hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
+ } else {
+ _mmcam_dbg_err("File write error, storage state %d", storage_state);
+ hcamcorder->error_code = MM_ERROR_FILE_WRITE;
+ }
+
+ if (sc->ferror_send == FALSE) {
+ sc->ferror_send = TRUE;
+ } else {
+ _mmcam_dbg_err("error was already sent");
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+ goto DROP_MESSAGE;
+ }
+ break;
+ case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
+ _mmcam_dbg_err("No left space");
+ hcamcorder->error_code = MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
+ break;
case GST_RESOURCE_ERROR_OPEN_WRITE:
- _mmcam_dbg_err("audio device [open failed]");
- hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
- /* post error to application */
- hcamcorder->error_occurs = TRUE;
+ _mmcam_dbg_err("Out of storage");
+ hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
+ break;
+ case GST_RESOURCE_ERROR_SEEK:
+ _mmcam_dbg_err("File read(seek)");
+ hcamcorder->error_code = MM_ERROR_FILE_READ;
+ break;
+ default:
+ _mmcam_dbg_err("Resource error(%d)", err->code);
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_GST_RESOURCE;
+ break;
+ }
+
+ if (b_commiting) {
+ _MMCAMCORDER_SIGNAL(hcamcorder);
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+ } else {
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
msg.param.code = hcamcorder->error_code;
- _mmcam_dbg_err(" error : sc->error_occurs %d", hcamcorder->error_occurs);
- g_error_free(err);
+
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
- gst_message_unref(message);
- message = NULL;
- return GST_BUS_DROP;
- default:
- break;
}
+
+ goto DROP_MESSAGE;
}
+ }
+ if (err) {
g_error_free(err);
-
+ err = NULL;
}
return GST_BUS_PASS;
+
+DROP_MESSAGE:
+ if (err) {
+ g_error_free(err);
+ err = NULL;
+ }
+
+ gst_message_unref(message);
+ message = NULL;
+
+ return GST_BUS_DROP;
}
void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
- mm_sound_focus_state_e focus_state, const char *reason_for_change,
- const char *additional_info, void *user_data)
+ mm_sound_focus_state_e focus_state, const char *reason_for_change,
+ int option, const char *additional_info, void *user_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
int current_state = MM_CAMCORDER_STATE_NONE;
mmf_return_if_fail((MMHandleType)hcamcorder);
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (current_state <= MM_CAMCORDER_STATE_NONE ||
- current_state >= MM_CAMCORDER_STATE_NUM) {
+ if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
_mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
return;
}
- /* set value to inform a status is changed by asm */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_ASM;
-
- _mmcam_dbg_log("sound focus callback : focus state %d, reason %s",
- focus_state, reason_for_change ? reason_for_change : "N/A");
+ _mmcam_dbg_warn("sound focus callback : focus state %d, reason %s",
+ focus_state, reason_for_change ? reason_for_change : "N/A");
if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
_mmcam_dbg_warn("session flag is UNINTERRUPTIBLE. do nothing.");
_MMCAMCORDER_LOCK_ASM(hcamcorder);
+ /* check the reason */
+ if (!strncmp(reason_for_change, "ringtone-voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "ringtone-call", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "call-voice", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_CALL_START;
+ } else if (!strncmp(reason_for_change, "alarm", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_ALARM_START;
+ } else {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_MEDIA;
+ }
+
if (focus_state == FOCUS_IS_RELEASED) {
- _mmcam_dbg_log("FOCUS is released : Stop pipeline[state:%d]", current_state);
+ hcamcorder->acquired_focus &= ~focus_type;
- __mmcamcorder_force_stop(hcamcorder);
+ _mmcam_dbg_warn("FOCUS is released [type %d, remained focus %d] : Stop pipeline[state:%d]",
+ focus_type, hcamcorder->acquired_focus, current_state);
- _mmcam_dbg_log("Finish opeartion. Pipeline is released");
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_FOCUS);
+
+ _mmcam_dbg_warn("Finish opeartion. Pipeline is released");
} else if (focus_state == FOCUS_IS_ACQUIRED) {
_MMCamcorderMsgItem msg;
- _mmcam_dbg_log("FOCUS is acquired");
+ _mmcam_dbg_warn("FOCUS is ready to acquired [type %d, current %d]",
+ focus_type, hcamcorder->acquired_focus);
msg.id = MM_MESSAGE_READY_TO_RESUME;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
- _mmcam_dbg_log("Finish opeartion");
+ _mmcam_dbg_warn("Finish opeartion");
} else {
- _mmcam_dbg_log("unknown focus state %d", focus_state);
+ _mmcam_dbg_warn("unknown focus state %d", focus_state);
}
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _mmcam_dbg_warn("done");
+
+ return;
+}
+
+
+void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
+
+ mmf_return_if_fail(hcamcorder);
+
+ _mmcam_dbg_warn("sound signal %d - value %d", signal, value);
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS && value == 1) {
+ _mmcam_dbg_warn("focus id %d, focus watch id %d",
+ hcamcorder->sound_focus_id, hcamcorder->sound_focus_watch_id);
+
+ /* unregister focus related callback */
+ if (hcamcorder->sound_focus_id > 0) {
+ if (hcamcorder->acquired_focus > 0) {
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
+ _mmcam_dbg_warn("release acquired focus [focus %d] done", hcamcorder->acquired_focus);
+ hcamcorder->acquired_focus = 0;
+ }
+
+ mm_sound_unregister_focus(hcamcorder->sound_focus_id);
+ _mmcam_dbg_warn("unregister sound focus done");
+ hcamcorder->sound_focus_id = 0;
+ }
+
+ if (hcamcorder->sound_focus_watch_id > 0) {
+ mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
+ _mmcam_dbg_warn("unset watch cb done");
+ hcamcorder->sound_focus_watch_id = 0;
+ }
+ }
+
+ /* reset flag not to run sound focus related code since now */
+ hcamcorder->sound_focus_register = FALSE;
_MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _mmcam_dbg_warn("done");
+
return;
}
-void _mmcamcorder_sound_focus_watch_cb(mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
- const char *reason_for_change, const char *additional_info, void *user_data)
+void _mmcamcorder_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
+ const char *reason_for_change, const char *additional_info, void *user_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
int current_state = MM_CAMCORDER_STATE_NONE;
- mmf_return_if_fail((MMHandleType)hcamcorder);
+ mmf_return_if_fail(hcamcorder);
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
if (current_state <= MM_CAMCORDER_STATE_NONE ||
return;
}
- /* set value to inform a status is changed by asm */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_ASM;
-
- _mmcam_dbg_log("sound focus watch callback : focus state %d, reason %s",
- focus_state, reason_for_change ? reason_for_change : "N/A");
+ _mmcam_dbg_warn("sound focus watch callback : id %d, focus state %d, reason %s",
+ id, focus_state, reason_for_change ? reason_for_change : "N/A");
if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
_mmcam_dbg_warn("session flag is UNINTERRUPTIBLE. do nothing.");
_MMCAMCORDER_LOCK_ASM(hcamcorder);
+ /* check the reason */
+ if (!strncmp(reason_for_change, "ringtone-voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "ringtone-call", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
+ !strncmp(reason_for_change, "call-voice", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_CALL_START;
+ } else if (!strncmp(reason_for_change, "alarm", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_ALARM_START;
+ } else {
+ hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_MEDIA;
+ }
+
if (focus_state == FOCUS_IS_RELEASED) {
_MMCamcorderMsgItem msg;
- _mmcam_dbg_log("other process's FOCUS is acquired");
+ _mmcam_dbg_warn("other process's FOCUS is released");
msg.id = MM_MESSAGE_READY_TO_RESUME;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
- _mmcam_dbg_log("Finish opeartion");
+ _mmcam_dbg_warn("Finish opeartion");
} else if (focus_state == FOCUS_IS_ACQUIRED) {
- _mmcam_dbg_log("other process's FOCUS is released : Stop pipeline[state:%d]", current_state);
+ _mmcam_dbg_warn("other process's FOCUS is acquired : Stop pipeline[state:%d]", current_state);
- __mmcamcorder_force_stop(hcamcorder);
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_FOCUS);
- _mmcam_dbg_log("Finish opeartion. Pipeline is released");
+ _mmcam_dbg_warn("Finish opeartion. Pipeline is released");
} else {
- _mmcam_dbg_log("unknown focus state %d", focus_state);
+ _mmcam_dbg_warn("unknown focus state %d", focus_state);
}
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
-
_MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _mmcam_dbg_warn("done");
+
+ return;
+}
+
+
+void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
+ int current_state = MM_CAMCORDER_STATE_NONE;
+
+ mmf_return_if_fail(hcamcorder);
+ mmf_return_if_fail(value);
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+ if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
+ _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
+ return;
+ }
+
+ _mmcam_dbg_warn("camera policy [%s], current state [%d]", value, current_state);
+
+ if (!strcmp(value, "disallowed")) {
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_DPM);
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
+ }
+
+ _mmcam_dbg_warn("done");
+
return;
}
switch (type) {
case MM_CAMCORDER_MODE_AUDIO:
ret = _mmcamcorder_create_audio_pipeline(handle);
- if (ret != MM_ERROR_NONE) {
+ if (ret != MM_ERROR_NONE)
return ret;
- }
+
break;
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
default:
ret = _mmcamcorder_create_preview_pipeline(handle);
- if (ret != MM_ERROR_NONE) {
+ 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) {
+ if (ret != MM_ERROR_NONE)
return ret;
- }
}
break;
}
pipeline = sc->element[_MMCAMCORDER_MAIN_PIPE].gst;
if (type != MM_CAMCORDER_MODE_AUDIO) {
+ traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:REALIZE:SET_READY_TO_PIPELINE");
+
ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
+
+ traceEnd(TTRACE_TAG_CAMERA);
}
#ifdef _MMCAMCORDER_GET_DEVICE_INFO
- if (!_mmcamcorder_get_device_info(handle)) {
+ if (!_mmcamcorder_get_device_info(handle))
_mmcam_dbg_err("Getting device information error!!");
- }
#endif
_mmcam_dbg_log("ret[%x]", ret);
GstMessage *gst_msg = NULL;
while ((gst_msg = gst_bus_pop(bus)) != NULL) {
_mmcamcorder_pipeline_cb_message(bus, gst_msg, (gpointer)hcamcorder);
- gst_message_unref( gst_msg );
+ gst_message_unref(gst_msg);
gst_msg = NULL;
}
- gst_object_unref( bus );
+ gst_object_unref(bus);
bus = NULL;
}
/* checking unreleased element */
- for (i = 0 ; i < element_num ; i++ ) {
+ for (i = 0 ; i < element_num ; i++) {
if (element[i].gst) {
if (GST_IS_ELEMENT(element[i].gst)) {
_mmcam_dbg_warn("Still alive element - ID[%d], name [%s], ref count[%d], status[%s]",
- element[i].id,
- GST_OBJECT_NAME(element[i].gst),
- GST_OBJECT_REFCOUNT(element[i].gst),
- gst_element_state_get_name(GST_STATE(element[i].gst)));
+ element[i].id,
+ GST_OBJECT_NAME(element[i].gst),
+ GST_OBJECT_REFCOUNT(element[i].gst),
+ gst_element_state_get_name(GST_STATE(element[i].gst)));
g_object_weak_unref(G_OBJECT(element[i].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sc);
} else {
_mmcam_dbg_warn("The element[%d] is still aliving, check it", element[i].id);
}
-int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state)
-{
- GstStateChangeReturn setChangeReturn = GST_STATE_CHANGE_FAILURE;
-
- _MMCAMCORDER_LOCK_GST_STATE(handle);
- setChangeReturn = gst_element_set_state(pipeline, target_state);
- _MMCAMCORDER_UNLOCK_GST_STATE(handle);
-
- return setChangeReturn;
-}
-
-
#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data)
{
GstStateChangeReturn setChangeReturn = GST_STATE_CHANGE_FAILURE;
GstStateChangeReturn getChangeReturn = GST_STATE_CHANGE_FAILURE;
GstClockTime get_timeout = __MMCAMCORDER_SET_GST_STATE_TIMEOUT * GST_SECOND;
- pthread_mutex_t *state_lock = NULL;
+ GMutex *state_lock = NULL;
mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
state_lock = &_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle);
}
- pthread_mutex_lock(state_lock);
+ g_mutex_lock(state_lock);
for (k = 0; k < _MMCAMCORDER_STATE_SET_COUNT; k++) {
setChangeReturn = gst_element_set_state(pipeline, target_state);
- _mmcam_dbg_log("gst_element_set_state[%d] return %d",
- target_state, setChangeReturn);
+ _mmcam_dbg_log("gst_element_set_state[%d] return %d", target_state, setChangeReturn);
+
if (setChangeReturn != GST_STATE_CHANGE_FAILURE) {
getChangeReturn = gst_element_get_state(pipeline, &pipeline_state, NULL, get_timeout);
switch (getChangeReturn) {
case GST_STATE_CHANGE_NO_PREROLL:
_mmcam_dbg_log("status=GST_STATE_CHANGE_NO_PREROLL.");
+ /* fall through */
case GST_STATE_CHANGE_SUCCESS:
/* if we reached the final target state, exit */
if (pipeline_state == target_state) {
_mmcam_dbg_log("Set state to %d - DONE", target_state);
- pthread_mutex_unlock(state_lock);
+ g_mutex_unlock(state_lock);
return MM_ERROR_NONE;
}
break;
_mmcam_dbg_log("status=GST_STATE_CHANGE_ASYNC.");
break;
default:
- pthread_mutex_unlock(state_lock);
+ g_mutex_unlock(state_lock);
_mmcam_dbg_log("status=GST_STATE_CHANGE_FAILURE.");
return MM_ERROR_CAMCORDER_GST_STATECHANGE;
}
- pthread_mutex_unlock(state_lock);
+ g_mutex_unlock(state_lock);
_mmcam_dbg_err("timeout of gst_element_get_state()!!");
usleep(_MMCAMCORDER_STATE_CHECK_INTERVAL);
}
- pthread_mutex_unlock(state_lock);
+ g_mutex_unlock(state_lock);
_mmcam_dbg_err("Failure. gst_element_set_state timeout!!");
}
-void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder)
+void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system)
{
int i = 0;
int loop = 0;
int result = MM_ERROR_NONE;
int cmd_try_count = 0;
int current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderMsgItem msg;
mmf_return_if_fail(hcamcorder);
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- _mmcam_dbg_warn("Force STOP MMFW Camcorder");
+ _mmcam_dbg_warn("Force STOP MMFW Camcorder by %d", state_change_by_system);
+
+ /* set state_change_by_system for state change message */
+ hcamcorder->state_change_by_system = state_change_by_system;
+
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ _mmcam_dbg_warn("send state change started message to notify");
+
+ memset(&msg, 0x0, sizeof(_MMCamcorderMsgItem));
+
+ switch (state_change_by_system) {
+ case _MMCAMCORDER_STATE_CHANGE_BY_FOCUS:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_ASM;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_RM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_RM;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_DPM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_SECURITY;
+ break;
+ default:
+ break;
+ }
+
+ if (msg.id != 0) {
+ msg.param.state.code = hcamcorder->interrupt_code;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ } else {
+ _mmcam_dbg_err("should not be reached here %d", state_change_by_system);
+ }
+ }
for (loop = 0 ; current_state > MM_CAMCORDER_STATE_NULL && loop < __MMCAMCORDER_CMD_ITERATE_MAX * 3 ; loop++) {
itr_cnt = __MMCAMCORDER_CMD_ITERATE_MAX;
/* if caturing isn't finished, waiting for 2 sec to finish real capture operation. check 'info->capturing'. */
mm_camcorder_set_attributes((MMHandleType)hcamcorder, NULL,
- MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT, TRUE,
- NULL);
+ MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT, TRUE,
+ NULL);
- for (i = 0; i < 20 && info->capturing; i++) {
+ for (i = 0; i < 20 && info->capturing; i++)
usleep(100000);
- }
- if (i == 20) {
+ if (i == 20)
_mmcam_dbg_err("Timeout. Can't check stop capturing.");
- }
- while ((itr_cnt--) && ((result = _mmcamcorder_capture_stop((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
- _mmcam_dbg_warn("Can't stop capturing.(%x)", result);
- }
+ while ((itr_cnt--) && ((result = _mmcamcorder_capture_stop((MMHandleType)hcamcorder)) != MM_ERROR_NONE))
+ _mmcam_dbg_warn("Can't stop capturing.(%x)", result);
break;
}
_mmcam_dbg_warn("Stop recording.");
while ((itr_cnt--) && ((result = _mmcamcorder_commit((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
- _mmcam_dbg_warn("Can't commit.(%x)", result);
+ _mmcam_dbg_warn("Can't commit.(%x), cancel it.", result);
+ _mmcamcorder_cancel((MMHandleType)hcamcorder);
}
+
break;
}
case MM_CAMCORDER_STATE_PREPARE:
while ((itr_cnt--) && ((result = _mmcamcorder_stop((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
_mmcam_dbg_warn("Can't stop preview.(%x)", result);
}
+
break;
}
case MM_CAMCORDER_STATE_READY:
if ((result = _mmcamcorder_unrealize((MMHandleType)hcamcorder)) != MM_ERROR_NONE) {
_mmcam_dbg_warn("Can't unrealize.(%x)", result);
}
+
break;
}
case MM_CAMCORDER_STATE_NULL:
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
}
- _mmcam_dbg_warn( "Done." );
+ /* restore */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ _mmcam_dbg_warn("Done.");
return;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderMsgItem msg;
- gchar *msg_src_element;
+ gchar *msg_src_element = NULL;
_MMCamcorderSubContext *sc = NULL;
return_val_if_fail(hcamcorder, FALSE);
if (message->src) {
msg_src_element = GST_ELEMENT_NAME(GST_ELEMENT_CAST(message->src));
_mmcam_dbg_err("-Msg src : [%s] Domain : [%s] Error : [%s] Code : [%d] is tranlated to error code : [0x%x]",
- msg_src_element, g_quark_to_string (error->domain), error->message, error->code, msg.param.code);
+ msg_src_element, g_quark_to_string(error->domain), error->message, error->code, msg.param.code);
} else {
_mmcam_dbg_err("Domain : [%s] Error : [%s] Code : [%d] is tranlated to error code : [0x%x]",
- g_quark_to_string (error->domain), error->message, error->code, msg.param.code);
+ g_quark_to_string(error->domain), error->message, error->code, msg.param.code);
}
#ifdef _MMCAMCORDER_SKIP_GST_FLOW_ERROR
}
#endif /* _MMCAMCORDER_SKIP_GST_FLOW_ERROR */
- /* post error to application */
- hcamcorder->error_occurs = TRUE;
- msg.id = MM_MESSAGE_CAMCORDER_ERROR;
- _mmcamcorder_send_message(handle, &msg);
+ /* post error to application except RESTRICTED case */
+ if (msg.param.code != MM_ERROR_POLICY_RESTRICTED) {
+ hcamcorder->error_occurs = TRUE;
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ _mmcamcorder_send_message(handle, &msg);
+ }
return TRUE;
}
element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
if (GST_ELEMENT_CAST(message->src) == element) {
- if (code == GST_CORE_ERROR_NEGOTIATION) {
+ if (code == GST_CORE_ERROR_NEGOTIATION)
return MM_ERROR_CAMCORDER_GST_NEGOTIATION;
- } else {
+ else
return MM_ERROR_CAMCORDER_ENCODER;
- }
}
/* General */
- switch (code)
- {
- case GST_CORE_ERROR_STATE_CHANGE:
- return MM_ERROR_CAMCORDER_GST_STATECHANGE;
- case GST_CORE_ERROR_NEGOTIATION:
- return MM_ERROR_CAMCORDER_GST_NEGOTIATION;
- case GST_CORE_ERROR_MISSING_PLUGIN:
- case GST_CORE_ERROR_SEEK:
- case GST_CORE_ERROR_NOT_IMPLEMENTED:
- case GST_CORE_ERROR_FAILED:
- case GST_CORE_ERROR_TOO_LAZY:
- case GST_CORE_ERROR_PAD:
- case GST_CORE_ERROR_THREAD:
- case GST_CORE_ERROR_EVENT:
- case GST_CORE_ERROR_CAPS:
- case GST_CORE_ERROR_TAG:
- case GST_CORE_ERROR_CLOCK:
- case GST_CORE_ERROR_DISABLED:
- default:
- return MM_ERROR_CAMCORDER_GST_CORE;
- break;
+ switch (code) {
+ case GST_CORE_ERROR_STATE_CHANGE:
+ return MM_ERROR_CAMCORDER_GST_STATECHANGE;
+ case GST_CORE_ERROR_NEGOTIATION:
+ return MM_ERROR_CAMCORDER_GST_NEGOTIATION;
+ case GST_CORE_ERROR_MISSING_PLUGIN:
+ case GST_CORE_ERROR_SEEK:
+ case GST_CORE_ERROR_NOT_IMPLEMENTED:
+ case GST_CORE_ERROR_FAILED:
+ case GST_CORE_ERROR_TOO_LAZY:
+ case GST_CORE_ERROR_PAD:
+ case GST_CORE_ERROR_THREAD:
+ case GST_CORE_ERROR_EVENT:
+ case GST_CORE_ERROR_CAPS:
+ case GST_CORE_ERROR_TAG:
+ case GST_CORE_ERROR_CLOCK:
+ case GST_CORE_ERROR_DISABLED:
+ default:
+ return MM_ERROR_CAMCORDER_GST_CORE;
+ break;
}
}
}
}
+ /* audiosrc */
+ element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
+ if (GST_ELEMENT_CAST(message->src) == element) {
+ if (code == GST_RESOURCE_ERROR_FAILED) {
+ int ret = MM_ERROR_NONE;
+ int current_state = MM_CAMCORDER_STATE_NONE;
+
+ _mmcam_dbg_err("DPM mic DISALLOWED - current state %d", current_state);
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+ if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
+ /* set value to inform a status is changed by DPM */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_DPM;
+
+ ret = _mmcamcorder_commit((MMHandleType)hcamcorder);
+ _mmcam_dbg_log("commit result : 0x%x", ret);
+
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("commit failed, cancel it");
+ ret = _mmcamcorder_cancel((MMHandleType)hcamcorder);
+ }
+ }
+
+ /* restore value */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
+
+ return MM_ERROR_POLICY_RESTRICTED;
+ }
+ }
+
/* encodebin */
element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
if (GST_ELEMENT_CAST(message->src) == element) {
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- GstElement *element =NULL;
+ GstElement *element = NULL;
- mmf_return_val_if_fail( hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED );
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
}
-static gboolean __mmcamcorder_handle_gst_warning (MMHandleType handle, GstMessage *message, GError *error)
+static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage *message, GError *error)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
gchar *debug = NULL;
} else if (error->domain == GST_RESOURCE_ERROR) {
_mmcam_dbg_warn("GST warning: GST_RESOURCE domain");
__mmcamcorder_gst_handle_resource_warning(handle, message, error);
- } else if (error->domain == GST_STREAM_ERROR ) {
+ } else if (error->domain == GST_STREAM_ERROR) {
_mmcam_dbg_warn("GST warning: GST_STREAM domain");
} else {
_mmcam_dbg_warn("This error domain(%d) is not defined.", error->domain);
err = NULL;
}
if (debug != NULL) {
- _mmcam_dbg_err ("Debug: %s", debug);
+ _mmcam_dbg_err("Debug: %s", debug);
g_free(debug);
debug = NULL;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- GstElement *element =NULL;
+ GstElement *element = NULL;
gchar *msg_src_element;
- mmf_return_val_if_fail( hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED );
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (error->code == GST_RESOURCE_ERROR_FAILED) {
msg_src_element = GST_ELEMENT_NAME(GST_ELEMENT_CAST(message->src));
_mmcam_dbg_warn("-Msg src:[%s] Domain:[%s] Error:[%s]",
- msg_src_element, g_quark_to_string(error->domain), error->message);
+ msg_src_element, g_quark_to_string(error->domain), error->message);
return MM_ERROR_NONE;
}
}
return MM_ERROR_NONE;
}
+
+
+void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
+ const char *interface_name, const char *signal_name, int value)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_if_fail(hcamcorder && object_name && interface_name && signal_name);
+
+ _mmcam_dbg_log("object %s, interface %s, signal %s, value %d",
+ object_name, interface_name, signal_name, value);
+
+ _mmcamcorder_emit_dbus_signal(hcamcorder->gdbus_conn, object_name, interface_name, signal_name, value);
+
+ return;
+}
+
+
+#ifdef _MMCAMCORDER_RM_SUPPORT
+rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
+ rm_device_request_s *info, void* cb_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
+ int current_state = MM_CAMCORDER_STATE_NONE;
+ rm_cb_result cb_res = RM_CB_RESULT_OK;
+
+ mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+ if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
+ _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
+ }
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ /* set RM event code for sending it to application */
+ hcamcorder->interrupt_code = event_src;
+
+ _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
+ switch (event_src) {
+ case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
+ case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
+ break;
+ default:
+ break;
+ }
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ return cb_res;
+}
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
+
+int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
+{
+ int ret = MM_ERROR_NONE;
+ int current_state = MM_CAMCORDER_STATE_NONE;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderMsgItem msg;
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ _mmcam_dbg_warn("storage state %d", storage_state);
+
+ /* check storage state */
+ if (storage_state != STORAGE_STATE_UNMOUNTABLE &&
+ storage_state != STORAGE_STATE_REMOVED) {
+ _mmcam_dbg_warn("nothing to do");
+ return MM_ERROR_NONE;
+ }
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ /* check recording state */
+ current_state = _mmcamcorder_get_state(handle);
+
+ _mmcam_dbg_warn("current_state %d", current_state);
+
+ if (current_state < MM_CAMCORDER_STATE_RECORDING) {
+ _mmcam_dbg_warn("no recording now");
+ goto _MANAGE_DONE;
+ }
+
+ /* check storage type */
+ if (hcamcorder->storage_info.type != STORAGE_TYPE_EXTERNAL) {
+ _mmcam_dbg_warn("external storage is not used");
+ goto _MANAGE_DONE;
+ }
+
+ /* cancel recording */
+ ret = _mmcamcorder_cancel(handle);
+
+ /* send error message */
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ msg.param.code = MM_ERROR_OUT_OF_STORAGE;
+
+ _mmcamcorder_send_message(handle, &msg);
+
+_MANAGE_DONE:
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _mmcam_dbg_warn("done - ret 0x%x", ret);
+
+ return ret;
+}