#include <mm_session.h>
#include <mm_session_private.h>
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
#include <murphy/common/glib-glue.h>
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#ifdef _MMCAMCORDER_RM_SUPPORT
+#include <aul.h>
+#endif /* _MMCAMCORDER_RM_SUPPORT */
/*---------------------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
#define DPM_ALLOWED 1
#define DPM_DISALLOWED 0
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#define __MMCAMCORDER_RESOURCE_WAIT_TIME 5
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
/*---------------------------------------------------------------------------------------
| 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 */
const char *ConfCtrlFile = NULL;
mmf_camcorder_t *hcamcorder = NULL;
type_element *EvasSurfaceElement = NULL;
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ gint64 end_time = 0;
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
_mmcam_dbg_log("Entered");
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).vcapture_cb_lock);
g_mutex_init(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_init(&(hcamcorder->mtsafe).astream_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);
"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,
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) {
} 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,
}
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* initialize resource manager */
ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager, (void *)hcamcorder);
if (ret != MM_ERROR_NONE) {
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:CREATE:INIT_GSTREAMER");
_mmcam_dbg_warn("failed get software version, sys_info_ret 0x%x", sys_info_ret);
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ if (hcamcorder->resource_manager.is_connected == FALSE) {
+ /* wait for resource manager connected */
+ _mmcam_dbg_log("resource manager is not connected. wait for signal...");
+
+ 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_DEFAULT_VALUE_INIT;
+ }
+ }
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
/* Set initial state */
_mmcamcorder_set_state((MMHandleType)hcamcorder, MM_CAMCORDER_STATE_NULL);
return MM_ERROR_NONE;
_ERR_DEFAULT_VALUE_INIT:
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* de-initialize resource manager */
_mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
/* unregister sound focus */
if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) {
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).vcapture_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).astream_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);
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);
g_cond_signal(&hcamcorder->task_thread_cond);
g_mutex_unlock(&hcamcorder->task_thread_lock);
+ /* 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("remove sink element %p, set state NULL result %d", sink_element, result);
+
+ gst_object_unref(sink_element);
+ sink_element = NULL;
+ }
+
/* wait for completion of sound play */
_mmcamcorder_sound_solo_play_wait(handle);
hcamcorder->sub_context = NULL;
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* de-initialize resource manager */
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);
}
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
/* Remove idle function which is not called yet */
if (hcamcorder->setting_event_id) {
_mmcam_dbg_log("no need to unregister sound focus.[%d, id %d]",
hcamcorder->sound_focus_register, hcamcorder->sound_focus_id);
}
+#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) {
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).vcapture_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
g_mutex_clear(&(hcamcorder->mtsafe).astream_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);
{
int ret = MM_ERROR_NONE;
int ret_sound = MM_ERROR_NONE;
- int ret_resource = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
int state_FROM = MM_CAMCORDER_STATE_NULL;
int state_TO = MM_CAMCORDER_STATE_READY;
const char *videosink_name = NULL;
char *socket_path = NULL;
int socket_path_len;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int iret = RM_OK;
+#endif /* _MMCAMCORDER_RM_SUPPORT */
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_mmcam_dbg_log("no need to register sound focus");
}
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int preview_format = MM_PIXEL_FORMAT_NV12;
+ int qret = RM_OK;
+ int qret_avail = RM_OK;
+ rm_consumer_info rci;
+ int app_pid = 0;
+ int resource_count = 0;
+
+ 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);
+
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO && preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+
+ resource_count = 0;
+ memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+ memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
+ _mmcam_dbg_log("request video decoder resource - device category 0x%x",hcamcorder->request_resources.category_id[resource_count]);
+
+ resource_count++;
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+ hcamcorder->request_resources.request_num = resource_count + 1;
+ _mmcam_dbg_log("request scaler resource - device category 0x%x",hcamcorder->request_resources.category_id[resource_count]);
+
+
+ qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
+
+ if (qret != RM_OK || qret_avail != RM_OK) {
+ _mmcam_dbg_log("Resource manager main device request fail");
+
+ resource_count = 0;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+ _mmcam_dbg_log("request video decoder resource - device category 0x%x",hcamcorder->request_resources.category_id[resource_count]);
+
+ resource_count++;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+ _mmcam_dbg_log("request scaler resource - device category 0x%x",hcamcorder->request_resources.category_id[resource_count]);
+ }
+
+ 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 resource - device category 0x%x",hcamcorder->request_resources.category_id[resource_count]);
+
+ 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 */
/* alloc sub context */
hcamcorder->sub_context = _mmcamcorder_alloc_subcontext(hcamcorder->type);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
int dpm_camera_state = DPM_ALLOWED;
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ gint64 end_time = 0;
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
/* check camera policy from DPM */
if (hcamcorder->dpm_policy) {
_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_COMMON_INVALID_PERMISSION;
+ ret = MM_ERROR_POLICY_RESTRICTED;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
} else {
} else {
_mmcam_dbg_warn("NULL dpm_policy");
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ hcamcorder->resource_manager.acquire_count = 0;
/* prepare resource manager for camera */
ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_CAMERA);
}
/* acquire resources */
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
if (hcamcorder->resource_manager.rset && _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager)) {
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
_mmcam_dbg_err("could not acquire resources");
+
_mmcamcorder_resource_manager_unprepare(&hcamcorder->resource_manager);
+
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
+
+ if (hcamcorder->resource_manager.acquire_count > 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 */
}
/* create pipeline */
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD:
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* release hw resources */
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
- ret_resource = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
+ 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");
}
_mmcam_dbg_err("failed to unprepare resource manager, ret_resource(0x%x)", ret_resource);
}
}
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
}
}
}
+#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 ");
+ }
+ /* 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:
_mmcam_dbg_err("Realize fail (type %d, state %d, ret %x)",
hcamcorder->sub_context = NULL;
}
+#ifdef _MMCAMCORDER_MURPHY_SUPPORT
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
/* release resource */
ret = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
ret = _mmcamcorder_resource_manager_unprepare(&hcamcorder->resource_manager);
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_err("failed to unprepare resource manager, ret(0x%x)", ret);
}
}
+#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+
+#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*/
/* Deinitialize main context member */
hcamcorder->command = NULL;
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 &&
+ if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_FOCUS &&
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) {
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) {
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
/* To discern who changes the state */
switch (hcamcorder->state_change_by_system) {
- case _MMCAMCORDER_STATE_CHANGE_BY_ASM:
+ case _MMCAMCORDER_STATE_CHANGE_BY_FOCUS:
msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM;
msg.param.state.code = hcamcorder->interrupt_code;
break;
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:
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_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);
/* set videosrc element to compare */
element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
- /* check domain[RESOURCE] and element[VIDEOSRC] */
+ /* check domain[RESOURCE] and element[AUDIOSRC] */
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_OPEN_WRITE:
_mmcam_dbg_err(" error : sc->error_occurs %d", hcamcorder->error_occurs);
- g_error_free(err);
- gst_message_unref(message);
- message = NULL;
+ goto DROP_MESSAGE;
+ default:
+ break;
+ }
+ } else {
+ gboolean b_commiting = FALSE;
+
+ 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;
+ }
- return GST_BUS_DROP;
+ _MMCAMCORDER_LOCK(hcamcorder);
+
+ switch (err->code) {
+ case GST_RESOURCE_ERROR_WRITE:
+ _mmcam_dbg_err("File write error");
+ hcamcorder->error_code = MM_ERROR_FILE_WRITE;
+ 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("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;
+
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ }
}
+ 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;
}
_MMCAMCORDER_LOCK_ASM(hcamcorder);
/* set value to inform a status is changed by asm */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_ASM;
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_FOCUS;
/* check the reason */
if (!strncmp(reason_for_change, "ringtone-voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
_MMCAMCORDER_LOCK_ASM(hcamcorder);
/* set value to inform a status is changed by asm */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_ASM;
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_FOCUS;
/* check the reason */
if (!strncmp(reason_for_change, "ringtone-voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
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) {
return MM_ERROR_NONE;
}
+#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 value to inform a status is changed by RM */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_RM;
+
+ /* 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);
+ break;
+ default:
+ break;
+ }
+
+ /* restore value */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ return cb_res;
+}
+#endif /* _MMCAMCORDER_RM_SUPPORT */