#include <asm/types.h>
#include <system_info.h>
-#include <mm_session.h>
-#include <mm_session_private.h>
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
#include <murphy/common/glib-glue.h>
#define DPM_DISALLOWED 0
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
-#define __MMCAMCORDER_RESOURCE_WAIT_TIME 5
+#define __MMCAMCORDER_RESOURCE_WAIT_TIME 3
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
#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);
+ 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);
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);
/* init for sound thread */
g_mutex_init(&hcamcorder->task_thread_lock);
g_cond_init(&hcamcorder->task_thread_cond);
- hcamcorder->task_thread_state = _MMCAMCORDER_SOUND_STATE_NONE;
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
+
+ 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);
+
+ 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",
hcamcorder->device_type = info->videodev_type;
_mmcam_dbg_warn("Device Type : %d", hcamcorder->device_type);
- 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 (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;
- }
-
- 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 {
- _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 */
ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
if (ret != MM_ERROR_NONE) {
goto _ERR_DEFAULT_VALUE_INIT;
}
- /* get DPM context for camera/microphone restriction */
- hcamcorder->dpm_context = dpm_context_create();
- if (hcamcorder->dpm_context) {
- hcamcorder->dpm_policy = dpm_context_acquire_restriction_policy(hcamcorder->dpm_context);
- if (hcamcorder->dpm_policy == NULL) {
- _mmcam_dbg_err("dpm_context_acquire_restriction_policy failed");
- dpm_context_destroy(hcamcorder->dpm_context);
- hcamcorder->dpm_context = NULL;
- }
- }
+ /* get DPM handle for camera/microphone restriction */
+ hcamcorder->dpm_handle = dpm_manager_create();
- _mmcam_dbg_warn("DPM context %p, policy %p", hcamcorder->dpm_context, hcamcorder->dpm_policy);
+ _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;
}
/* 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);
+ 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);
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);
}
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);
SAFE_FREE(err_attr_name);
/* 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.");
SAFE_FREE(err_attr_name);
}
_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_context) {
- if (dpm_context_add_policy_changed_cb(hcamcorder->dpm_context,
- "camera", _mmcamcorder_dpm_camera_policy_changed_cb,
- (void *)hcamcorder, &hcamcorder->dpm_camera_cb_id) != DPM_ERROR_NONE) {
+ 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
+ /* initialize resource manager */
+ ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager, (void *)hcamcorder);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to initialize resource manager");
+ 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);
SAFE_FREE(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) {
- _mmcam_dbg_err("failed to initialize resource manager");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
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) {
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ if (hcamcorder->resource_manager.is_connected == FALSE) {
+ gint64 end_time = 0;
+
+ /* 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);
_mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
- /* 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);
- }
-
/* release DPM related handle */
- if (hcamcorder->dpm_context) {
- _mmcam_dbg_log("release DPM context %p, camera changed cb id %d",
- hcamcorder->dpm_context, hcamcorder->dpm_camera_cb_id);
+ 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_context_remove_policy_changed_cb(hcamcorder->dpm_context, hcamcorder->dpm_camera_cb_id);
+ 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);
}
- if (hcamcorder->dpm_policy) {
- dpm_context_release_restriction_policy(hcamcorder->dpm_context, hcamcorder->dpm_policy);
- hcamcorder->dpm_policy = NULL;
- }
-
- dpm_context_destroy(hcamcorder->dpm_context);
- hcamcorder->dpm_context = NULL;
+ dpm_manager_destroy(hcamcorder->dpm_handle);
+ hcamcorder->dpm_handle = NULL;
}
/* Remove attributes */
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);
g_cond_clear(&hcamcorder->snd_info.open_cond);
g_mutex_clear(&hcamcorder->restart_preview_lock);
- if (hcamcorder->conf_ctrl) {
- _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_ctrl);
+ 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_main) {
+ 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);
{
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;
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);
/* 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) {
+ if (ret != MM_ERROR_NONE)
_mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
- }
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
/* Remove idle function which is not called yet */
/* 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 && 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);
+ /* 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);
hcamcorder->software_version = NULL;
}
- /* release DPM related handle */
- if (hcamcorder->dpm_context) {
- _mmcam_dbg_log("release DPM context %p, camera changed cb id %d",
- hcamcorder->dpm_context, hcamcorder->dpm_camera_cb_id);
+ /* 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_context_remove_policy_changed_cb(hcamcorder->dpm_context, hcamcorder->dpm_camera_cb_id);
+ 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);
}
- if (hcamcorder->dpm_policy) {
- dpm_context_release_restriction_policy(hcamcorder->dpm_context, hcamcorder->dpm_policy);
- hcamcorder->dpm_policy = NULL;
- }
-
- dpm_context_destroy(hcamcorder->dpm_context);
- hcamcorder->dpm_context = NULL;
+ dpm_manager_destroy(hcamcorder->dpm_handle);
+ hcamcorder->dpm_handle = NULL;
}
/* join task thread */
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);
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 */
memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
free(hcamcorder);
_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_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;
+ int socket_path_len = 0;
+ int conn_size = 0;
#ifdef _MMCAMCORDER_RM_SUPPORT
- int iret = RM_OK;
+ 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 */
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);
+ MMCAM_MODE, &hcamcorder->type,
+ MMCAM_GDBUS_CONNECTION, &hcamcorder->gdbus_conn, &conn_size,
+ NULL);
- /* Get profile mode */
- _mmcam_dbg_log("Profile mode [%d]", hcamcorder->type);
+ if (!hcamcorder->gdbus_conn) {
+ _mmcam_dbg_err("gdbus connection NULL");
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+
+ _mmcam_dbg_log("Profile mode [%d], gdbus connection [%p]",
+ hcamcorder->type, hcamcorder->gdbus_conn);
mm_camcorder_get_attributes(handle, NULL,
MMCAM_DISPLAY_SURFACE, &display_surface_type,
/* 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);
+ ret_sound = mm_sound_acquire_focus(hcamcorder->sound_focus_id, 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;
}
/* do nothing */
_mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
} else {
+ /* 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) {
+ 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("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->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);
}
if (socket_path == NULL) {
_mmcam_dbg_warn("REMOTE surface, but socket path is NULL -> to NullSink");
videosink_element_type = strdup("VideosinkElementNull");
- } else
+ } else {
videosink_element_type = strdup("VideosinkElementRemote");
+ }
break;
default:
videosink_element_type = strdup("VideosinkElementOverlay");
/* 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;
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- gint64 end_time = 0;
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
/* check camera policy from DPM */
- if (hcamcorder->dpm_policy) {
- if (dpm_restriction_get_camera_state(hcamcorder->dpm_policy, &dpm_camera_state) == DPM_ERROR_NONE) {
+ 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_policy");
+ _mmcam_dbg_warn("NULL dpm_handle");
}
+
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ 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 */
}
/* prepare resource manager for "video_overlay only if display surface is X" */
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_DISPLAY_SURFACE, &display_surface_type,
- NULL);
-
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) {
+ 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);
- if (hcamcorder->resource_manager.rset && _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager)) {
+ ret = _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
_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) {
+ if (hcamcorder->resource_manager.acquire_remain > 0) {
+ gint64 end_time = 0;
+
_mmcam_dbg_warn("wait for resource state change");
/* wait for resource state change */
_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 */
goto _ERR_CAMCORDER_CMD;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
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) {
+ } else if (ret_resource != MM_ERROR_NONE) {
_mmcam_dbg_err("failed to release resource, ret_resource(0x%x)", ret_resource);
}
- ret_resource = _mmcamcorder_resource_manager_unprepare(&hcamcorder->resource_manager);
- if (ret_resource != MM_ERROR_NONE) {
- _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);
-
- 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);
- }
- }
- }
#ifdef _MMCAMCORDER_RM_SUPPORT
if (hcamcorder->rm_handle) {
if (hcamcorder->returned_devices.allocated_num > 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++) {
+ 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)
}
#endif /* _MMCAMCORDER_RM_SUPPORT*/
+_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
+
+ 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;
+ }
+
+ if (hcamcorder->acquired_focus > 0) {
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, NULL);
+ _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;
}
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
+ if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
+ hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM) {
+ gint64 end_time = 0;
+
+ _mmcam_dbg_log("lock resource");
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
/* release resource */
ret = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
if (ret == MM_ERROR_RESOURCE_INVALID_STATE) {
} 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;
}
- _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);
+
+ 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...");
+
+ end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
+
+ _MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time);
}
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ _mmcam_dbg_log("unlock resource");
}
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
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++) {
+ 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 ");
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);
+ 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("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);
- _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->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;
}
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);
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, NULL);
+ _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) {
- /* init for gdbus */
- hcamcorder->gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
- if (hcamcorder->gdbus_conn == NULL) {
- _mmcam_dbg_err("failed to get gdbus");
- ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- g_mutex_init(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_init(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_init(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_init(&hcamcorder->gdbus_info_solo_sound.sync_cond);
-
+ 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);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
+
+ /* set attributes related sensor - after start preview */
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO)
+ _mmcamcorder_set_attribute_to_camsensor2(handle);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
- if (hcamcorder->gdbus_conn) {
- g_object_unref(hcamcorder->gdbus_conn);
- hcamcorder->gdbus_conn = NULL;
-
- g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
- }
-
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
}
_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) {
+ /* 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);
+ _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);
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);
+ _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);
-
- g_object_unref(hcamcorder->gdbus_conn);
- hcamcorder->gdbus_conn = NULL;
-
- g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
}
_MMCAMCORDER_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 = 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);
}
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;
hcamcorder->error_code = MM_ERROR_NONE;
/* check mic policy from DPM */
- if (hcamcorder->dpm_policy) {
- if (dpm_restriction_get_microphone_state(hcamcorder->dpm_policy, &dpm_mic_state) == DPM_ERROR_NONE) {
+ if (hcamcorder->dpm_handle) {
+ 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("NULL dpm_policy");
+ _mmcam_dbg_warn("NULL dpm_handle");
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_RECORD);
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _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);
+ _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;
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;
- }
- _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
- _mmcamcorder_set_state(handle,state_TO);
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
_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);
+ _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");
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);
/* 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 */
_MMCAMCORDER_LOCK_STATE(handle);
old_state = hcamcorder->state;
- if(old_state != state) {
+ if (old_state != state) {
hcamcorder->state = state;
hcamcorder->target_state = state;
/* 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;
/* alloc info for each mode */
switch (type) {
case MM_CAMCORDER_MODE_AUDIO:
- sc->info_audio = g_malloc0( 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;
}
break;
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
default:
- sc->info_image = g_malloc0( 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;
}
/* init sound status */
sc->info_image->sound_status = _SOUND_STATUS_INIT;
- sc->info_video = g_malloc0( 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;
}
/* 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;
}
if (sc) {
SAFE_G_FREE(sc->info_audio);
SAFE_G_FREE(sc->info_image);
- if (sc->info_video) {
+ 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);
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:
{
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");
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 {
}
} 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);
switch (err->code) {
case GST_RESOURCE_ERROR_WRITE:
- _mmcam_dbg_err("File write error");
- hcamcorder->error_code = MM_ERROR_FILE_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");
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
- }
- goto DROP_MESSAGE;
+ goto DROP_MESSAGE;
+ }
}
if (err) {
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;
}
- _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);
/* 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) ||
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);
+ _mmcam_dbg_warn("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");
+ _mmcam_dbg_warn("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);
+ _mmcam_dbg_warn("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");
+ _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 */
_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, NULL);
+ _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;
return;
}
- _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);
/* 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) ||
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);
- _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 */
_MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _mmcam_dbg_warn("done");
+
return;
}
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) {
+ 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;
}
hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
_MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
}
_mmcam_dbg_warn("done");
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;
}
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);
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) {
/* 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." );
+ _mmcam_dbg_warn("Done.");
return;
}
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
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;
}
}
_MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
+
return MM_ERROR_POLICY_RESTRICTED;
}
}
{
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;
}
-int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps)
+
+void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
+ const char *interface_name, const char *signal_name, int value)
{
- GstPad *pad = NULL;
- GstCaps *sink_caps = NULL;
- _MMCamcorderSubContext *sc = NULL;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- 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;
- }
+ mmf_return_if_fail(hcamcorder && object_name && interface_name && signal_name);
- 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;
- }
+ _mmcam_dbg_log("object %s, interface %s, signal %s, value %d",
+ object_name, interface_name, signal_name, value);
- *caps = gst_caps_to_string(sink_caps);
- _mmcam_dbg_err("video caps : %s", *caps);
- gst_caps_unref(sink_caps);
+ _mmcamcorder_emit_dbus_signal(hcamcorder->gdbus_conn, object_name, interface_name, signal_name, value);
- return MM_ERROR_NONE;
+ 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)
+ 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;
+ rm_cb_result cb_res = RM_CB_RESULT_OK;
- mmf_return_val_if_fail((MMHandleType)hcamcorder, 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) {
+ 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_UNLOCK_ASM(hcamcorder);
- return cb_res;
+ return cb_res;
}
-#endif /* _MMCAMCORDER_RM_SUPPORT */
\ No newline at end of file
+#endif /* _MMCAMCORDER_RM_SUPPORT */