#include <asm/types.h>
#include <system_info.h>
+#include <mm_session.h>
+#include <mm_session_private.h>
+
/*---------------------------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------------------*/
#define __MMCAMCORDER_CMD_ITERATE_MAX 3
#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT 3
+#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"
/*---------------------------------------------------------------------------------------
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_USE_SET_ATTR_CB
static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
int rcmd_dpy_rotation = MM_DISPLAY_ROTATION_270;
int play_capture_sound = TRUE;
int camera_device_count = MM_VIDEO_DEVICE_NUM;
+ int camera_default_flip = MM_FLIP_NONE;
int camera_facing_direction = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR;
- int resource_fd = -1;
char *err_attr_name = NULL;
const char *ConfCtrlFile = NULL;
mmf_camcorder_t *hcamcorder = NULL;
hcamcorder->sub_context = NULL;
hcamcorder->target_state = MM_CAMCORDER_STATE_NULL;
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);
hcamcorder->device_type = info->videodev_type;
_mmcam_dbg_warn("Device Type : %d", hcamcorder->device_type);
- 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 (MM_ERROR_NONE == _mm_session_util_read_information(-1, &hcamcorder->session_type, &hcamcorder->session_flags)) {
+ _mmcam_dbg_log("use sound focus function.");
+ hcamcorder->sound_focus_register = TRUE;
- 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;
+ if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) {
+ _mmcam_dbg_err("mm_sound_focus_get_uniq failed");
+ ret = MM_ERROR_POLICY_BLOCKED;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
- goto _ERR_DEFAULT_VALUE_INIT;
+
+ if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id,
+ getpid(),
+ "media",
+ _mmcamcorder_sound_focus_cb,
+ hcamcorder)) {
+ _mmcam_dbg_err("mm_sound_register_focus failed");
+ ret = MM_ERROR_POLICY_BLOCKED;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
+ _mmcam_dbg_log("mm_sound_register_focus done - id %d, session type %d, flags 0x%x",
+ hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags);
} else {
- close(resource_fd);
- resource_fd = -1;
- _mmcam_dbg_warn("permission check done");
+ _mmcam_dbg_log("_mm_session_util_read_information failed. skip sound focus function.");
+ hcamcorder->sound_focus_register = FALSE;
}
/* Get Camera Configure information from Camcorder INI file */
_mmcam_dbg_err( "Failed to get configure(main) info." );
ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- goto _ERR_AFTER_ASM_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
hcamcorder->attributes = _mmcamcorder_alloc_attribute((MMHandleType)hcamcorder, info);
_mmcam_dbg_err("_mmcamcorder_create::alloc attribute error.");
ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_AFTER_ASM_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
default:
_mmcam_dbg_err( "Not supported camera type." );
ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
- goto _ERR_AFTER_ASM_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("videodev_type : [%d], ConfCtrlPath : [%s]", info->videodev_type, ConfCtrlFile);
if (!(hcamcorder->conf_ctrl)) {
_mmcam_dbg_err( "Failed to get configure(control) info." );
ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- goto _ERR_AFTER_ASM_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
ret = _mmcamcorder_init_convert_table((MMHandleType)hcamcorder);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("converting table initialize error!!");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
- ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder);
+ ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_CAMERA|MM_CAMCONVERT_CATEGORY_DISPLAY);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("converting table initialize error!!");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get device info, recommend preview fmt and display rotation from INI */
_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);
+ if (camera_facing_direction == 1) {
+ if (rcmd_dpy_rotation == MM_DISPLAY_ROTATION_270 || rcmd_dpy_rotation == MM_DISPLAY_ROTATION_90) {
+ camera_default_flip = MM_FLIP_VERTICAL;
+ } else {
+ camera_default_flip = MM_FLIP_HORIZONTAL;
+ }
+ _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_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;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get default value of brightness */
_mmcam_dbg_err("Get brightness FAILED.");
free(err_attr_name);
err_attr_name = NULL;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("Default brightness : %d", hcamcorder->brightness_default);
} else {
_mmcam_dbg_err("Set %s FAILED.", err_attr_name);
free(err_attr_name);
err_attr_name = NULL;
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
+ 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;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
}
if (!ret) {
_mmcam_dbg_err( "Failed to initialize gstreamer!!" );
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
- goto _ERR_AFTER_ASM_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Make some attributes as read-only type */
return MM_ERROR_NONE;
-_ERR_AFTER_ASM_REGISTER:
-
_ERR_DEFAULT_VALUE_INIT:
+ /* unregister sound focus */
+ if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) {
+ 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);
+ } else {
+ _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id);
+ }
+ } else {
+ _mmcam_dbg_warn("no need to unregister sound focus[%d, id %d]",
+ hcamcorder->sound_focus_register, hcamcorder->sound_focus_id);
+ }
+
+ /* Remove attributes */
+ if (hcamcorder->attributes) {
+ _mmcamcorder_dealloc_attribute((MMHandleType)hcamcorder, hcamcorder->attributes);
+ hcamcorder->attributes = 0;
+ }
+
/* Release lock, cond */
pthread_mutex_destroy(&((hcamcorder->mtsafe).lock));
pthread_cond_destroy(&((hcamcorder->mtsafe).cond));
}
/* Remove messages which are not called yet */
- _mmcamcroder_remove_message_all(handle);
+ _mmcamcorder_remove_message_all(handle);
+
+ /* unregister sound focus */
+ if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) {
+ if (mm_sound_unregister_focus(hcamcorder->sound_focus_id) != MM_ERROR_NONE) {
+ _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed",
+ hcamcorder->sound_focus_id);
+ } else {
+ _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done",
+ hcamcorder->sound_focus_id);
+ }
+ } else {
+ _mmcam_dbg_log("no need to unregister sound focus.[%d, id %d]",
+ hcamcorder->sound_focus_register, hcamcorder->sound_focus_id);
+ }
/* release model_name */
if (hcamcorder->model_name) {
int _mmcamcorder_realize(MMHandleType handle)
{
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 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;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
mm_camcorder_get_attributes(handle, NULL,
MMCAM_DISPLAY_SURFACE, &display_surface_type,
MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ MMCAM_DISPLAY_SHM_SOCKET_PATH, &socket_path, &socket_path_len,
NULL);
/* set camera/recorder state to vconf key */
vconf_recorder_state, VCONFKEY_RECORDER_STATE_CREATED);
}
+ /* sound focus */
+ if (hcamcorder->sound_focus_register) {
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus,
+ NULL);
+
+ if (pid_for_sound_focus == 0) {
+ pid_for_sound_focus = getpid();
+ _mmcam_dbg_warn("pid for sound focus is not set, use my pid %d", pid_for_sound_focus);
+ }
+
+ /* acquire sound focus or set sound focus watch callback */
+ hcamcorder->acquired_focus = 0;
+ hcamcorder->sound_focus_watch_id = 0;
+
+ /* check session flags */
+ 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);
+ 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 {
+ /* set sound focus watch callback */
+ _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);
+ 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) {
case MM_DISPLAY_SURFACE_NULL:
videosink_element_type = strdup("VideosinkElementNull");
break;
+ case MM_DISPLAY_SURFACE_REMOTE:
+ videosink_element_type = strdup("VideosinkElementRemote");
+ break;
default:
videosink_element_type = strdup("VideosinkElementX");
break;
}
+ if (socket_path == NULL) {
+ _mmcam_dbg_warn("Socket Path is not properly set, -> to NullSink.");
+ videosink_element_type = strdup("VideosinkElementNull");
+ }
+
/* check string of videosink element */
if (videosink_element_type) {
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
+ if (hcamcorder->sound_focus_register) {
+ if (hcamcorder->sound_focus_watch_id > 0) {
+ if (mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id) != MM_ERROR_NONE) {
+ _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback[id %d] failed",
+ hcamcorder->sound_focus_watch_id);
+ } else {
+ _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback[id %d] done",
+ hcamcorder->sound_focus_watch_id);
+ }
+ }
+
+ if (hcamcorder->acquired_focus > 0) {
+ if (mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL) != MM_ERROR_NONE) {
+ _mmcam_dbg_err("mm_sound_release_focus[focus %d] failed",
+ hcamcorder->acquired_focus);
+ } else {
+ _mmcam_dbg_err("mm_sound_release_focus[focus %d] done",
+ hcamcorder->acquired_focus);
+ }
+ }
+ }
+
_ERR_CAMCORDER_CMD_PRECON:
_mmcam_dbg_err("Realize fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
/* Deinitialize main context member */
hcamcorder->command = 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);
+
+ /* release sound focus or unset sound focus watch callback */
+ if (hcamcorder->sound_focus_register) {
+ int ret_sound = MM_ERROR_NONE;
+
+ _mmcam_dbg_log("state_change_by_system %d, session flag 0x%x, acquired_focus %d, sound_focus_id %d, sound_focus_watch_id %d",
+ hcamcorder->state_change_by_system, hcamcorder->session_flags, hcamcorder->acquired_focus,
+ hcamcorder->sound_focus_id, hcamcorder->sound_focus_watch_id);
+
+ if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_ASM &&
+ 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("mm_sound_unset_focus_watch_callback done");
+ }
+ } else {
+ _mmcam_dbg_warn("no need to unset watch callback.[state_change_by_system %d, sound_focus_watch_id %d]",
+ hcamcorder->state_change_by_system, hcamcorder->sound_focus_watch_id);
+ }
+
+ if (hcamcorder->acquired_focus > 0) {
+ ret_sound = mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL);
+ if (ret_sound != MM_ERROR_NONE) {
+ _mmcam_dbg_warn("mm_sound_release_focus failed [0x%x]",
+ ret_sound);
+ } else {
+ _mmcam_dbg_log("mm_sound_release_focus done");
+ }
+ } else {
+ _mmcam_dbg_warn("no need to release focus - current acquired focus %d",
+ hcamcorder->acquired_focus);
+ }
+ }
/* set camera state to vconf key */
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
ret = MM_ERROR_CAMCORDER_DEVICE_BUSY;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
} else {
- hcamcorder->capture_in_recording = TRUE;
+ pthread_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));
+ } else {
+ _mmcam_dbg_err("task thread busy : %d", hcamcorder->task_thread_state);
+ pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ ret = MM_ERROR_CAMCORDER_INVALID_STATE;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
}
}
msg.param.state.previous = old_state;
msg.param.state.current = state;
- /*_mmcam_dbg_log("_mmcamcroder_send_message : msg : %p, id:%x", &msg, msg.id);*/
- _mmcamcroder_send_message(handle, &msg);
+ /*_mmcam_dbg_log("_mmcamcorder_send_message : msg : %p, id:%x", &msg, msg.id);*/
+ _mmcamcorder_send_message(handle, &msg);
}
_MMCAMCORDER_UNLOCK_STATE(handle);
hcamcorder->error_occurs = TRUE;
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
msg.param.code = hcamcorder->error_code;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
goto DROP_MESSAGE;
}
msg.id = MM_MESSAGE_CAMCORDER_FOCUS_CHANGED;
msg.param.code = focus_state;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
goto DROP_MESSAGE;
} else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-HDR")) {
msg.id = MM_MESSAGE_CAMCORDER_HDR_PROGRESS;
msg.param.code = progress;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
goto DROP_MESSAGE;
msg.param.size = sizeof(MMCamFaceDetectInfo);
msg.param.code = 0;
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
/* free fd_info allocated by plugin */
msg.param.code = hcamcorder->error_code;
_mmcam_dbg_err(" error : sc->error_occurs %d", hcamcorder->error_occurs);
g_error_free(err);
- _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg);
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
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)
+{
+ 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) {
+ _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");
+
+ if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
+ _mmcam_dbg_warn("session flag is UNINTERRUPTIBLE. do nothing.");
+ return;
+ }
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ if (focus_state == FOCUS_IS_RELEASED) {
+ hcamcorder->acquired_focus &= ~focus_type;
+
+ _mmcam_dbg_log("FOCUS is released [type %d, remained focus %d] : Stop pipeline[state:%d]",
+ focus_type, hcamcorder->acquired_focus, current_state);
+
+ __mmcamcorder_force_stop(hcamcorder);
+
+ _mmcam_dbg_log("Finish opeartion. Pipeline is released");
+ } else if (focus_state == FOCUS_IS_ACQUIRED) {
+ _MMCamcorderMsgItem msg;
+
+ hcamcorder->acquired_focus |= focus_type;
+
+ _mmcam_dbg_log("FOCUS is acquired [type %d, new focus %d]",
+ focus_type, hcamcorder->acquired_focus);
+
+ msg.id = MM_MESSAGE_READY_TO_RESUME;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+
+ _mmcam_dbg_log("Finish opeartion");
+ } else {
+ _mmcam_dbg_log("unknown focus state %d", focus_state);
+ }
+
+ /* restore value */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ 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)
+{
+ 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) {
+ _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 watch 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.");
+ return;
+ }
+
+ _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+ if (focus_state == FOCUS_IS_RELEASED) {
+ _MMCamcorderMsgItem msg;
+
+ _mmcam_dbg_log("other process's FOCUS is acquired");
+
+ msg.id = MM_MESSAGE_READY_TO_RESUME;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+
+ _mmcam_dbg_log("Finish opeartion");
+ } else if (focus_state == FOCUS_IS_ACQUIRED) {
+ _mmcam_dbg_log("other process's FOCUS is released : Stop pipeline[state:%d]", current_state);
+
+ __mmcamcorder_force_stop(hcamcorder);
+
+ _mmcam_dbg_log("Finish opeartion. Pipeline is released");
+ } else {
+ _mmcam_dbg_log("unknown focus state %d", focus_state);
+ }
+
+ /* restore value */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ return;
+}
+
+
int _mmcamcorder_create_pipeline(MMHandleType handle, int type)
{
int ret = MM_ERROR_NONE;
}
+void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder)
+{
+ int i = 0;
+ int loop = 0;
+ int itr_cnt = 0;
+ int result = MM_ERROR_NONE;
+ int cmd_try_count = 0;
+ int current_state = MM_CAMCORDER_STATE_NONE;
+
+ mmf_return_if_fail(hcamcorder);
+
+ /* check command running */
+ do {
+ if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
+ if (cmd_try_count++ < __MMCAMCORDER_FORCE_STOP_TRY_COUNT) {
+ _mmcam_dbg_warn("Another command is running. try again after %d ms", __MMCAMCORDER_FORCE_STOP_WAIT_TIME/1000);
+ usleep(__MMCAMCORDER_FORCE_STOP_WAIT_TIME);
+ } else {
+ _mmcam_dbg_err("wait timeout");
+ break;
+ }
+ } else {
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
+ break;
+ }
+ } while (TRUE);
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+
+ _mmcam_dbg_warn("Force STOP MMFW Camcorder");
+
+ for (loop = 0 ; current_state > MM_CAMCORDER_STATE_NULL && loop < __MMCAMCORDER_CMD_ITERATE_MAX * 3 ; loop++) {
+ itr_cnt = __MMCAMCORDER_CMD_ITERATE_MAX;
+ switch (current_state) {
+ case MM_CAMCORDER_STATE_CAPTURING:
+ {
+ _MMCamcorderSubContext *sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ _MMCamcorderImageInfo *info = NULL;
+
+ mmf_return_if_fail(sc);
+ mmf_return_if_fail((info = sc->info_image));
+
+ _mmcam_dbg_warn("Stop capturing.");
+
+ /* 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);
+
+ for (i = 0; i < 20 && info->capturing; i++) {
+ usleep(100000);
+ }
+
+ 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);
+ }
+
+ break;
+ }
+ case MM_CAMCORDER_STATE_RECORDING:
+ case MM_CAMCORDER_STATE_PAUSED:
+ {
+ _mmcam_dbg_warn("Stop recording.");
+
+ while ((itr_cnt--) && ((result = _mmcamcorder_commit((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
+ _mmcam_dbg_warn("Can't commit.(%x)", result);
+ }
+ break;
+ }
+ case MM_CAMCORDER_STATE_PREPARE:
+ {
+ _mmcam_dbg_warn("Stop preview.");
+
+ 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:
+ {
+ _mmcam_dbg_warn("unrealize");
+
+ if ((result = _mmcamcorder_unrealize((MMHandleType)hcamcorder)) != MM_ERROR_NONE) {
+ _mmcam_dbg_warn("Can't unrealize.(%x)", result);
+ }
+ break;
+ }
+ case MM_CAMCORDER_STATE_NULL:
+ default:
+ _mmcam_dbg_warn("Already stopped.");
+ break;
+ }
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+ }
+
+ _mmcam_dbg_warn( "Done." );
+
+ return;
+}
+
+
static gboolean __mmcamcorder_handle_gst_error(MMHandleType handle, GstMessage *message, GError *error)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
/* post error to application */
hcamcorder->error_occurs = TRUE;
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
- _mmcamcroder_send_message(handle, &msg);
+ _mmcamcorder_send_message(handle, &msg);
return TRUE;
}
return MM_ERROR_NONE;
}
+
+int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps)
+{
+ GstPad *pad = NULL;
+ GstCaps *sink_caps = NULL;
+ _MMCamcorderSubContext *sc = NULL;
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ _mmcam_dbg_warn("Entered ");
+ pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "sink");
+ if(!pad) {
+ _mmcam_dbg_err("static pad is NULL");
+ return MM_ERROR_CAMCORDER_INVALID_STATE;
+ }
+
+ sink_caps = gst_pad_get_current_caps(pad);
+ gst_object_unref( pad );
+ if(!sink_caps) {
+ _mmcam_dbg_err("fail to get caps");
+ return MM_ERROR_CAMCORDER_INVALID_STATE;
+ }
+
+ *caps = gst_caps_to_string(sink_caps);
+ _mmcam_dbg_err("video caps : %s", *caps);
+ gst_caps_unref(sink_caps);
+
+ return MM_ERROR_NONE;
+}
\ No newline at end of file