| INCLUDE FILES |
========================================================================================*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <gst/gst.h>
#include <mm_types.h>
#include <gst/video/colorbalance.h>
-#include <gst/video/cameracontrol.h>
#include <asm/types.h>
#include <system_info.h>
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
-#include <murphy/common/glib-glue.h>
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
#ifdef _MMCAMCORDER_RM_SUPPORT
-#include <aul.h>
+#include "mm_camcorder_rm.h"
#endif /* _MMCAMCORDER_RM_SUPPORT */
/*---------------------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS for internal |
---------------------------------------------------------------------------------------*/
#define __MMCAMCORDER_CMD_ITERATE_MAX 3
-#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT 5
+#define __MMCAMCORDER_SET_GST_STATE_TIMEOUT 10
#define __MMCAMCORDER_FORCE_STOP_TRY_COUNT 30
#define __MMCAMCORDER_FORCE_STOP_WAIT_TIME 100000 /* us */
#define __MMCAMCORDER_SOUND_WAIT_TIMEOUT 3
#define __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN 64
+#define __MMCAMCORDER_CONF_FILENAME_LENGTH 64
+
+#ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
+#define __MMCAMCORDER_DEVICE_TYPE_STRING_LEN 1
+#endif
+
#define DPM_ALLOWED 1
#define DPM_DISALLOWED 0
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------------------*/
/* STATIC INTERNAL FUNCTION */
-static gboolean __mmcamcorder_gstreamer_init(camera_conf * conf);
-
+static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_type);
+static void __mmcamcorder_deinit_handle(mmf_camcorder_t *hcamcorder);
+static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcorder);
+static gint __mmcamcorder_init_configure_audio(mmf_camcorder_t *hcamcorder);
+static gint __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder);
+static void __mmcamcorder_deinit_configure(mmf_camcorder_t *hcamcorder);
+static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf);
+static void __mmcamcorder_get_system_info(mmf_camcorder_t *hcamcorder);
+
+static void __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message);
+static void __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code);
+static void __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code);
static gboolean __mmcamcorder_handle_gst_error(MMHandleType handle, GstMessage *message, GError *error);
static gint __mmcamcorder_gst_handle_stream_error(MMHandleType handle, int code, GstMessage *message);
static gint __mmcamcorder_gst_handle_resource_error(MMHandleType handle, int code, GstMessage *message);
static gint __mmcamcorder_gst_handle_core_error(MMHandleType handle, int code, GstMessage *message);
static gint __mmcamcorder_gst_handle_resource_warning(MMHandleType handle, GstMessage *message , GError *error);
static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage *message, GError *error);
-
-#ifdef _MMCAMCORDER_RM_SUPPORT
-rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
- rm_device_request_s *info, void *cb_data);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
-static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
-#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
+ mm_resource_manager_res_h res, void *user_data);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/*=======================================================================================
| FUNCTION DEFINITIONS |
=======================================================================================*/
-/*---------------------------------------------------------------------------------------
-| GLOBAL FUNCTION DEFINITIONS: |
----------------------------------------------------------------------------------------*/
+static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_type)
+{
+ int ret = MM_ERROR_NONE;
+ int log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
+ mmf_camcorder_t *new_handle = NULL;
-/* Internal command functions {*/
-int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ }
+
+ /* Create mmf_camcorder_t handle and initialize every variable */
+ new_handle = (mmf_camcorder_t *)malloc(sizeof(mmf_camcorder_t));
+ if (!new_handle) {
+ MMCAM_LOG_ERROR("new handle allocation failed");
+ return MM_ERROR_CAMCORDER_LOW_MEMORY;
+ }
+
+ memset(new_handle, 0x00, sizeof(mmf_camcorder_t));
+
+ /* set device type */
+ new_handle->device_type = device_type;
+
+ MMCAM_LOG_WARNING("Device Type : %d", new_handle->device_type);
+
+ new_handle->type = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
+ new_handle->state = MM_CAMCORDER_STATE_NONE;
+ new_handle->old_state = MM_CAMCORDER_STATE_NONE;
+ new_handle->capture_in_recording = FALSE;
+
+ /* init mutex and cond */
+ g_mutex_init(&(new_handle->mtsafe).lock);
+ g_cond_init(&(new_handle->mtsafe).cond);
+ g_mutex_init(&(new_handle->mtsafe).cmd_lock);
+ g_cond_init(&(new_handle->mtsafe).cmd_cond);
+ g_mutex_init(&(new_handle->mtsafe).interrupt_lock);
+ g_mutex_init(&(new_handle->mtsafe).state_lock);
+ g_mutex_init(&(new_handle->mtsafe).gst_state_lock);
+ g_mutex_init(&(new_handle->mtsafe).gst_encode_state_lock);
+ g_mutex_init(&(new_handle->mtsafe).message_cb_lock);
+ g_mutex_init(&(new_handle->mtsafe).vcapture_cb_lock);
+ g_mutex_init(&(new_handle->mtsafe).vstream_cb_lock);
+ g_mutex_init(&(new_handle->mtsafe).astream_cb_lock);
+ g_mutex_init(&(new_handle->mtsafe).mstream_cb_lock);
+ g_mutex_init(&(new_handle->mtsafe).vedecision_cb_lock);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+ g_mutex_init(&(new_handle->mtsafe).resource_lock);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
+ g_mutex_init(&new_handle->restart_preview_lock);
+
+ g_mutex_init(&new_handle->snd_info.open_mutex);
+ g_cond_init(&new_handle->snd_info.open_cond);
+ g_mutex_init(&new_handle->snd_info.play_mutex);
+ g_cond_init(&new_handle->snd_info.play_cond);
+
+ g_mutex_init(&new_handle->task_thread_lock);
+ g_cond_init(&new_handle->task_thread_cond);
+ new_handle->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
+
+ if (device_type != MM_VIDEO_DEVICE_NONE) {
+ new_handle->gdbus_info_sound.mm_handle = new_handle;
+ g_mutex_init(&new_handle->gdbus_info_sound.sync_mutex);
+ g_cond_init(&new_handle->gdbus_info_sound.sync_cond);
+
+ new_handle->gdbus_info_solo_sound.mm_handle = new_handle;
+ g_mutex_init(&new_handle->gdbus_info_solo_sound.sync_mutex);
+ g_cond_init(&new_handle->gdbus_info_solo_sound.sync_cond);
+ }
+
+ /* create task thread */
+ new_handle->task_thread = g_thread_try_new("MMCAM_TASK_THREAD",
+ (GThreadFunc)_mmcamcorder_util_task_thread_func, (gpointer)new_handle, NULL);
+ if (new_handle->task_thread == NULL) {
+ MMCAM_LOG_ERROR("_mmcamcorder_create::failed to create task thread");
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto _INIT_HANDLE_FAILED;
+ }
+
+ /* Get Camera Configure information from Camcorder INI file */
+ ret = _mmcamcorder_conf_get_info((MMHandleType)new_handle, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &new_handle->conf_main);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Failed to get configure(main) info.");
+ goto _INIT_HANDLE_FAILED;
+ }
+
+ /* Get log level from conf */
+ _mmcamcorder_conf_get_value_int((MMHandleType)new_handle, new_handle->conf_main,
+ CONFIGURE_CATEGORY_MAIN_GENERAL,
+ "LogLevel",
+ &log_level);
+
+ _mmcamcorder_set_log_level(log_level);
+
+ /* allocate attribute */
+ new_handle->attributes = _mmcamcorder_alloc_attribute((MMHandleType)new_handle);
+ if (!new_handle->attributes) {
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto _INIT_HANDLE_FAILED;
+ }
+
+ *hcamcorder = new_handle;
+
+ MMCAM_LOG_INFO("new handle %p", new_handle);
+
+ return MM_ERROR_NONE;
+
+_INIT_HANDLE_FAILED:
+ __mmcamcorder_deinit_handle(new_handle);
+ return ret;
+}
+
+
+static void __mmcamcorder_deinit_handle(mmf_camcorder_t *hcamcorder)
+{
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return;
+ }
+
+ /* Remove exif info */
+ if (hcamcorder->exif_info) {
+ mm_exif_destory_exif_info(hcamcorder->exif_info);
+ hcamcorder->exif_info = NULL;
+ }
+
+ /* remove attributes */
+ if (hcamcorder->attributes) {
+ _mmcamcorder_dealloc_attribute((MMHandleType)hcamcorder, hcamcorder->attributes);
+ hcamcorder->attributes = 0;
+ }
+
+ /* Release configure info */
+ __mmcamcorder_deinit_configure(hcamcorder);
+
+ /* remove task thread */
+ if (hcamcorder->task_thread) {
+ g_mutex_lock(&hcamcorder->task_thread_lock);
+ MMCAM_LOG_INFO("send signal for task thread exit");
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
+ g_cond_signal(&hcamcorder->task_thread_cond);
+ g_mutex_unlock(&hcamcorder->task_thread_lock);
+ g_thread_join(hcamcorder->task_thread);
+ hcamcorder->task_thread = NULL;
+ }
+
+ /* Release lock, cond */
+ g_mutex_clear(&(hcamcorder->mtsafe).lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock);
+ g_cond_clear(&(hcamcorder->mtsafe).cmd_cond);
+ g_mutex_clear(&(hcamcorder->mtsafe).interrupt_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).gst_encode_state_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).message_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).vcapture_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
+ g_mutex_clear(&(hcamcorder->mtsafe).vedecision_cb_lock);
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+ g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
+ g_mutex_clear(&hcamcorder->snd_info.open_mutex);
+ g_cond_clear(&hcamcorder->snd_info.open_cond);
+ g_mutex_clear(&hcamcorder->restart_preview_lock);
+
+ if (hcamcorder->device_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);
+ }
+
+ g_mutex_clear(&hcamcorder->task_thread_lock);
+ g_cond_clear(&hcamcorder->task_thread_cond);
+
+ if (hcamcorder->model_name)
+ free(hcamcorder->model_name);
+
+ if (hcamcorder->software_version)
+ free(hcamcorder->software_version);
+
+ /* Release handle */
+ memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
+
+ free(hcamcorder);
+
+ return;
+}
+
+
+static void __mmcamcorder_get_system_info(mmf_camcorder_t *hcamcorder)
+{
+ int ret = 0;
+
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return;
+ }
+
+ /* get shutter sound policy */
+ vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &hcamcorder->shutter_sound_policy);
+ MMCAM_LOG_INFO("current shutter sound policy : %d", hcamcorder->shutter_sound_policy);
+
+ /* get model name */
+ ret = system_info_get_platform_string("http://tizen.org/system/model_name", &hcamcorder->model_name);
+
+ MMCAM_LOG_WARNING("model name [%s], ret 0x%x",
+ hcamcorder->model_name ? hcamcorder->model_name : "NULL", ret);
+
+ /* get software version */
+ ret = system_info_get_platform_string("http://tizen.org/system/build.string", &hcamcorder->software_version);
+
+ MMCAM_LOG_WARNING("software version [%s], ret 0x%x",
+ hcamcorder->software_version ? hcamcorder->software_version : "NULL", ret);
+
+ return;
+}
+
+
+static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcorder)
{
int ret = MM_ERROR_NONE;
- int sys_info_ret = SYSTEM_INFO_ERROR_NONE;
- int UseConfCtrl = 0;
+ int resolution_width = 0;
+ int resolution_height = 0;
int rcmd_fmt_capture = MM_PIXEL_FORMAT_YUYV;
int rcmd_fmt_recording = MM_PIXEL_FORMAT_NV12;
int rcmd_dpy_rotation = MM_DISPLAY_ROTATION_270;
int play_capture_sound = TRUE;
- int camera_device_count = MM_VIDEO_DEVICE_NUM;
int camera_default_flip = MM_FLIP_NONE;
int camera_facing_direction = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR;
char *err_attr_name = NULL;
- const char *ConfCtrlFile = NULL;
- mmf_camcorder_t *hcamcorder = NULL;
- type_element *EvasSurfaceElement = NULL;
+ char conf_file_name[__MMCAMCORDER_CONF_FILENAME_LENGTH] = {'\0',};
+ const char *platform_privilege_camera = NULL;
+ MMCamAttrsInfo fps_info;
+#ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
+ camera_conf_error_e ret_conf = CAMERA_CONF_MGR_ERROR_NONE;
+ char devicetype[__MMCAMCORDER_CONF_FILENAME_LENGTH] = {'\0',};
+#endif
- _mmcam_dbg_log("Entered");
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ }
- mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+ if (hcamcorder->is_network) {
+ snprintf(conf_file_name, sizeof(conf_file_name), "%s_network.ini",
+ CONFIGURE_CTRL_FILE_PREFIX);
+ } else {
+#ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
+ snprintf(devicetype, sizeof(devicetype), "%d", hcamcorder->device_type);
+ memset(&hcamcorder->conf_device_info, 0x00, sizeof(camera_conf_device_info_s));
+ ret_conf = camera_conf_mgr_get_ids(devicetype, __MMCAMCORDER_DEVICE_TYPE_STRING_LEN,
+ &hcamcorder->conf_device_info);
+ if (ret_conf != CAMERA_CONF_MGR_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Device [%s] is not found", devicetype);
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
+
+ snprintf(conf_file_name, sizeof(conf_file_name), "%s_%s_%s.ini",
+ CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->conf_device_info.vendor_id,
+ hcamcorder->conf_device_info.product_id);
+
+ MMCAM_LOG_INFO("device info : node[%s]",
+ hcamcorder->conf_device_info.node);
+#else
+ snprintf(conf_file_name, sizeof(conf_file_name), "%s%d.ini",
+ CONFIGURE_CTRL_FILE_PREFIX, hcamcorder->device_type);
+#endif
+ }
- /* Create mmf_camcorder_t handle and initialize every variable */
- hcamcorder = (mmf_camcorder_t *)malloc(sizeof(mmf_camcorder_t));
- mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_LOW_MEMORY);
- memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
+ MMCAM_LOG_INFO("Load control configure file [%d][%s]",
+ hcamcorder->device_type, conf_file_name);
+
+ ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder,
+ CONFIGURE_TYPE_CTRL, (const char *)conf_file_name, &hcamcorder->conf_ctrl);
+ if (ret != MM_ERROR_NONE) {
+#ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
+ snprintf(conf_file_name, sizeof(conf_file_name), "%s.ini",
+ CONFIGURE_CTRL_FILE_PREFIX);
+ ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder,
+ CONFIGURE_TYPE_CTRL, (const char *)conf_file_name, &hcamcorder->conf_ctrl);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Failed to get configure(control) info.");
+ return ret;
+ }
+#else
+ MMCAM_LOG_ERROR("Failed to get configure(control) info.");
+ return ret;
+#endif
+ }
+/*
+ _mmcamcorder_conf_print_info(&hcamcorder->conf_main);
+ _mmcamcorder_conf_print_info(&hcamcorder->conf_ctrl);
+*/
+ ret = _mmcamcorder_init_convert_table((MMHandleType)hcamcorder);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_WARNING("converting table initialize error!!");
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
- /* init values */
- hcamcorder->type = 0;
- hcamcorder->state = MM_CAMCORDER_STATE_NONE;
- hcamcorder->sub_context = NULL;
- hcamcorder->target_state = MM_CAMCORDER_STATE_NULL;
- hcamcorder->capture_in_recording = FALSE;
- hcamcorder->session_type = MM_SESSION_TYPE_MEDIA;
-
- g_mutex_init(&(hcamcorder->mtsafe).lock);
- g_cond_init(&(hcamcorder->mtsafe).cond);
- g_mutex_init(&(hcamcorder->mtsafe).cmd_lock);
- g_cond_init(&(hcamcorder->mtsafe).cmd_cond);
- g_mutex_init(&(hcamcorder->mtsafe).asm_lock);
- g_mutex_init(&(hcamcorder->mtsafe).state_lock);
- g_mutex_init(&(hcamcorder->mtsafe).gst_state_lock);
- g_mutex_init(&(hcamcorder->mtsafe).gst_encode_state_lock);
- g_mutex_init(&(hcamcorder->mtsafe).message_cb_lock);
- g_mutex_init(&(hcamcorder->mtsafe).vcapture_cb_lock);
- g_mutex_init(&(hcamcorder->mtsafe).vstream_cb_lock);
- g_mutex_init(&(hcamcorder->mtsafe).astream_cb_lock);
- g_mutex_init(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_init(&(hcamcorder->mtsafe).resource_cond);
- g_mutex_init(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
- g_mutex_init(&hcamcorder->restart_preview_lock);
-
- /* Sound mutex/cond init */
- g_mutex_init(&hcamcorder->snd_info.open_mutex);
- g_cond_init(&hcamcorder->snd_info.open_cond);
- g_mutex_init(&hcamcorder->snd_info.play_mutex);
- g_cond_init(&hcamcorder->snd_info.play_cond);
-
- /* init for sound thread */
- g_mutex_init(&hcamcorder->task_thread_lock);
- g_cond_init(&hcamcorder->task_thread_cond);
- 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);
+ ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_ALL);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_WARNING("attribute initialize from configure error!!");
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
- /* create task thread */
- hcamcorder->task_thread = g_thread_try_new("MMCAM_TASK_THREAD",
- (GThreadFunc)_mmcamcorder_util_task_thread_func, (gpointer)hcamcorder, NULL);
- if (hcamcorder->task_thread == NULL) {
- _mmcam_dbg_err("_mmcamcorder_create::failed to create task thread");
- ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_DEFAULT_VALUE_INIT;
+ /* Get device information for supported features from INI */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+ 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);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+ 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);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+ 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);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+ CONFIGURE_CATEGORY_CTRL_CAPTURE,
+ "SupportZSL",
+ &hcamcorder->support_zsl_capture);
+
+ MMCAM_LOG_INFO("Recommend fmt[cap:%d,rec:%d], dpy rot %d, cap snd %d, cam facing dir %d, step denom %d, support zsl %d",
+ rcmd_fmt_capture, rcmd_fmt_recording, rcmd_dpy_rotation,
+ play_capture_sound, camera_facing_direction,
+ hcamcorder->brightness_step_denominator, hcamcorder->support_zsl_capture);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "UseZeroCopyFormat",
+ &hcamcorder->use_zero_copy_format);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "SupportUserBuffer",
+ &hcamcorder->support_user_buffer);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "SupportMediaPacketPreviewCb",
+ &hcamcorder->support_media_packet_preview_cb);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "SupportExtraPreview",
+ &hcamcorder->support_extra_preview);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "UseVideoconvert",
+ &hcamcorder->use_videoconvert);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "MeasurePreviewFPS",
+ &hcamcorder->measure_preview_fps);
+
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "DefaultEncodedPreviewBitrate",
+ &hcamcorder->default_encoded_preview_bitrate);
+
+ ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
+ MMCAM_CAMERA_WIDTH, &resolution_width,
+ MMCAM_CAMERA_HEIGHT, &resolution_height,
+ NULL);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("get attribute[resolution] error");
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
- if (info->videodev_type < MM_VIDEO_DEVICE_NONE ||
- info->videodev_type >= MM_VIDEO_DEVICE_NUM) {
- _mmcam_dbg_err("_mmcamcorder_create::video device type is out of range.");
- ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
- goto _ERR_DEFAULT_VALUE_INIT;
+ ret = mm_camcorder_get_fps_list_by_resolution((MMHandleType)hcamcorder, resolution_width, resolution_height, &fps_info);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("get fps list failed with [%dx%d]", resolution_width, resolution_height);
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
- /* set device type */
- hcamcorder->device_type = info->videodev_type;
- _mmcam_dbg_warn("Device Type : %d", hcamcorder->device_type);
+ MMCAM_LOG_INFO("ZC %d, UB %d, VC %d, MPPC %d, EP %d, MPFPS %d, DEPB %d",
+ hcamcorder->use_zero_copy_format, hcamcorder->support_user_buffer,
+ hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb,
+ hcamcorder->support_extra_preview, hcamcorder->measure_preview_fps,
+ hcamcorder->default_encoded_preview_bitrate);
- /* Get Camera Configure information from Camcorder INI file */
- ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
+ MMCAM_LOG_INFO("res : %d X %d, Default FPS by resolution : %d",
+ resolution_width, resolution_height, fps_info.int_array.def);
+
+ if (camera_facing_direction == 1) {
+ if (rcmd_dpy_rotation == MM_DISPLAY_ROTATION_270 || rcmd_dpy_rotation == MM_DISPLAY_ROTATION_90)
+ camera_default_flip = MM_FLIP_VERTICAL;
+ else
+ camera_default_flip = MM_FLIP_HORIZONTAL;
+
+ MMCAM_LOG_INFO("camera_default_flip : [%d]", camera_default_flip);
+ }
+
+ _mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_GENERAL,
+ "PlatformPrivilegeCamera",
+ &platform_privilege_camera);
+
+ if (hcamcorder->is_network) {
+ _mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_GENERAL,
+ "NetworkCameraHALName",
+ &hcamcorder->network_hal_name);
+
+ MMCAM_LOG_INFO("network HAL name[%s]", hcamcorder->network_hal_name);
+ }
+
+ ret = mm_camcorder_set_attributes((MMHandleType)hcamcorder, &err_attr_name,
+ 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_SUPPORT_USER_BUFFER, hcamcorder->support_user_buffer,
+ MMCAM_SUPPORT_EXTRA_PREVIEW, hcamcorder->support_extra_preview,
+ MMCAM_CAMERA_FPS, fps_info.int_array.def,
+ MMCAM_DISPLAY_FLIP, camera_default_flip,
+ MMCAM_CAPTURE_SOUND_ENABLE, play_capture_sound,
+ MMCAM_PLATFORM_PRIVILEGE_CAMERA, platform_privilege_camera,
+ platform_privilege_camera ? strlen(platform_privilege_camera) : 0,
+ MMCAM_ENCODED_PREVIEW_BITRATE, hcamcorder->default_encoded_preview_bitrate,
+ NULL);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("Failed to get configure(main) info.");
- goto _ERR_DEFAULT_VALUE_INIT;
+ MMCAM_LOG_ERROR("[0x%x] Set %s FAILED.", ret, err_attr_name ? err_attr_name : "[UNKNOWN]");
+ SAFE_FREE(err_attr_name);
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+
+ /* Get default value of brightness */
+ ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
+ MMCAM_FILTER_BRIGHTNESS, &hcamcorder->brightness_default,
+ NULL);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Get brightness FAILED.");
+ return MM_ERROR_CAMCORDER_INTERNAL;
}
- hcamcorder->attributes = _mmcamcorder_alloc_attribute((MMHandleType)hcamcorder, info);
- if (!(hcamcorder->attributes)) {
- _mmcam_dbg_err("_mmcamcorder_create::alloc attribute error.");
+ MMCAM_LOG_INFO("Default brightness : %d", hcamcorder->brightness_default);
- ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_DEFAULT_VALUE_INIT;
+ return ret;
+}
+
+
+static gint __mmcamcorder_init_configure_audio(mmf_camcorder_t *hcamcorder)
+{
+ int ret = MM_ERROR_NONE;
+
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
}
- /* get DPM handle for camera/microphone restriction */
- hcamcorder->dpm_handle = dpm_manager_create();
+ ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_AUDIO);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("there is no audio device");
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
- _mmcam_dbg_warn("DPM handle %p", hcamcorder->dpm_handle);
+ return ret;
+}
- 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);
- if (UseConfCtrl) {
- int resolution_width = 0;
- int resolution_height = 0;
- MMCamAttrsInfo fps_info;
+static gint __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder)
+{
+ int ret = MM_ERROR_NONE;
+ int device_count = 0;
+ const char *videosrc_name = NULL;
+ const char *audiosrc_name = NULL;
+ type_element *SrcElement = NULL;
- _mmcam_dbg_log("Enable Configure Control system.");
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ }
- 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);
- break;
- case MM_VIDEO_DEVICE_CAMERA1:
- _mmcamcorder_conf_get_value_string((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "ConfCtrlFile1", &ConfCtrlFile);
- break;
- default:
- _mmcam_dbg_err("Not supported camera type.");
- ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
+ /* Device count */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "DeviceCount",
+ &device_count);
- _mmcam_dbg_log("videodev_type : [%d], ConfCtrlPath : [%s]", info->videodev_type, ConfCtrlFile);
+ /* Videosrc element name */
+ _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "VideosrcElement",
+ &SrcElement);
+ _mmcamcorder_conf_get_value_element_name(SrcElement, &videosrc_name);
- ret = _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_CTRL, ConfCtrlFile, &hcamcorder->conf_ctrl);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("Failed to get configure(control) info.");
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-/*
- _mmcamcorder_conf_print_info(&hcamcorder->conf_main);
- _mmcamcorder_conf_print_info(&hcamcorder->conf_ctrl);
-*/
- ret = _mmcamcorder_init_convert_table((MMHandleType)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_warn("converting table initialize error!!");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
+ /* Audiosrc element name */
+ _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
+ "AudiosrcElement",
+ &SrcElement);
+ _mmcamcorder_conf_get_value_element_name(SrcElement, &audiosrc_name);
+
+ MMCAM_LOG_INFO("Device count[%d], Videosrc[%s], Audiosrc[%s]",
+ device_count, videosrc_name, audiosrc_name);
+
+ ret = mm_camcorder_set_attributes((MMHandleType)hcamcorder, NULL,
+ MMCAM_CAMERA_DEVICE_COUNT, device_count,
+ MMCAM_VIDEOSRC_ELEMENT_NAME, videosrc_name, videosrc_name ? strlen(videosrc_name) : 0,
+ MMCAM_AUDIOSRC_ELEMENT_NAME, audiosrc_name, audiosrc_name ? strlen(audiosrc_name) : 0,
+ NULL);
+ if (ret != MM_ERROR_NONE)
+ MMCAM_LOG_ERROR("Set FAILED[0x%x]", ret);
- ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_ALL);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_warn("converting table initialize error!!");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
+ return ret;
+}
- /* 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);
-
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- 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);
-
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- 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);
-
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- 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);
-
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
- 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);
-
- /* 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));
-
- /* 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));
-
- /* Get UseVideoconvert value from INI */
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "UseVideoconvert",
- &hcamcorder->use_videoconvert);
-
- ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
- MMCAM_CAMERA_WIDTH, &resolution_width,
- MMCAM_CAMERA_HEIGHT, &resolution_height,
- NULL);
- mm_camcorder_get_fps_list_by_resolution((MMHandleType)hcamcorder, resolution_width, resolution_height, &fps_info);
+static void __mmcamcorder_deinit_configure(mmf_camcorder_t *hcamcorder)
+{
+ if (!hcamcorder) {
+ MMCAM_LOG_ERROR("NULL handle");
+ return;
+ }
- _mmcam_dbg_log("UseZeroCopyFormat %d, UseVideoconvert %d, SupportMediaPacketPreviewCb %d",
- hcamcorder->use_zero_copy_format, hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
- _mmcam_dbg_log("res : %d X %d, Default FPS by resolution : %d",
- resolution_width, resolution_height, fps_info.int_array.def);
+ if (hcamcorder->conf_ctrl)
+ _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_ctrl);
- if (camera_facing_direction == 1) {
- if (rcmd_dpy_rotation == MM_DISPLAY_ROTATION_270 || rcmd_dpy_rotation == MM_DISPLAY_ROTATION_90)
- camera_default_flip = MM_FLIP_VERTICAL;
- else
- camera_default_flip = MM_FLIP_HORIZONTAL;
+ if (hcamcorder->conf_main)
+ _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_main);
- _mmcam_dbg_log("camera_default_flip : [%d]", camera_default_flip);
- }
+ return;
+}
- 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);
- if (err_attr_name) {
- _mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- SAFE_FREE(err_attr_name);
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
- /* Get default value of brightness */
- mm_camcorder_get_attributes((MMHandleType)hcamcorder, &err_attr_name,
- MMCAM_FILTER_BRIGHTNESS, &hcamcorder->brightness_default,
- NULL);
- if (err_attr_name) {
- _mmcam_dbg_err("Get brightness FAILED.");
- SAFE_FREE(err_attr_name);
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
- _mmcam_dbg_log("Default brightness : %d", hcamcorder->brightness_default);
- } else {
- _mmcam_dbg_log("Disable Configure Control system.");
- hcamcorder->conf_ctrl = NULL;
- }
+/*---------------------------------------------------------------------------------------
+| GLOBAL FUNCTION DEFINITIONS: |
+---------------------------------------------------------------------------------------*/
+/* Internal command functions {*/
+int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
+{
+ int ret = MM_ERROR_NONE;
+ mmf_camcorder_t *hcamcorder = NULL;
+
+ MMCAM_LOG_INFO("Entered");
+
+ mmf_return_val_if_fail(handle && info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ /* check device type */
+ if (info->videodev_type < MM_VIDEO_DEVICE_NONE ||
+ info->videodev_type >= MM_VIDEO_DEVICE_NUM) {
+ MMCAM_LOG_ERROR("video device type[%d] is out of range.", info->videodev_type);
+ return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ }
+
+ /* init handle */
+ ret = __mmcamcorder_init_handle(&hcamcorder, info->videodev_type);
+ if (ret != MM_ERROR_NONE)
+ return ret;
+
+ /* set network camera flag */
+ hcamcorder->is_network = (gboolean)info->reserved[0];
+
+ /* get DPM handle for camera/microphone restriction */
+ hcamcorder->dpm_handle = dpm_manager_create();
+
+ MMCAM_LOG_WARNING("DPM handle %p", hcamcorder->dpm_handle);
+
+ ret = __mmcamcorder_init_configure_common(hcamcorder);
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_DEFAULT_VALUE_INIT;
+
+ if (hcamcorder->device_type != MM_VIDEO_DEVICE_NONE) {
+ ret = __mmcamcorder_init_configure_video_capture(hcamcorder);
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_DEFAULT_VALUE_INIT;
/* add DPM camera policy changed callback */
if (hcamcorder->dpm_handle) {
ret = dpm_add_policy_changed_cb(hcamcorder->dpm_handle, "camera",
_mmcamcorder_dpm_camera_policy_changed_cb, (void *)hcamcorder, &hcamcorder->dpm_camera_cb_id);
if (ret != DPM_ERROR_NONE) {
- _mmcam_dbg_err("add DPM changed cb failed, keep going...");
+ MMCAM_LOG_ERROR("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);
+ MMCAM_LOG_INFO("DPM camera changed cb id %d", hcamcorder->dpm_camera_cb_id);
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_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_resource_manager_create(MM_RESOURCE_MANAGER_APP_CLASS_MEDIA,
+ __mmcamcorder_resource_release_cb, hcamcorder,
+ &hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to initialize resource manager");
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
} else {
- _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
- 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);
- if (err_attr_name) {
- _mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- SAFE_FREE(err_attr_name);
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
- ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, MM_CAMCONVERT_CATEGORY_AUDIO);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("there is no audio device");
- ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ ret = __mmcamcorder_init_configure_audio(hcamcorder);
+ if (ret != MM_ERROR_NONE)
goto _ERR_DEFAULT_VALUE_INIT;
- }
}
traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:CREATE:INIT_GSTREAMER");
- ret = __mmcamcorder_gstreamer_init(hcamcorder->conf_main);
+ ret = __mmcamcorder_init_gstreamer(hcamcorder->conf_main);
traceEnd(TTRACE_TAG_CAMERA);
if (!ret) {
- _mmcam_dbg_err("Failed to initialize gstreamer!!");
+ MMCAM_LOG_ERROR("Failed to initialize gstreamer!!");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
goto _ERR_DEFAULT_VALUE_INIT;
}
/* Disable attributes in each model */
_mmcamcorder_set_disabled_attributes((MMHandleType)hcamcorder);
- /* Get videosink name for evas surface */
- _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "VideosinkElementEvas",
- &EvasSurfaceElement);
- if (EvasSurfaceElement) {
- int attr_index = 0;
- const char *evassink_name = NULL;
- mmf_attribute_t *item_evassink_name = NULL;
- mmf_attrs_t *attrs = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(hcamcorder);
-
- _mmcamcorder_conf_get_value_element_name(EvasSurfaceElement, &evassink_name);
- mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_EVAS_SURFACE_SINK, &attr_index);
- item_evassink_name = &attrs->items[attr_index];
- mmf_attribute_set_string(item_evassink_name, evassink_name, strlen(evassink_name));
- mmf_attribute_commit(item_evassink_name);
-
- _mmcam_dbg_log("Evassink name : %s", evassink_name);
- }
-
- /* get shutter sound policy */
- vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &hcamcorder->shutter_sound_policy);
- _mmcam_dbg_log("current shutter sound policy : %d", hcamcorder->shutter_sound_policy);
-
- /* get model name */
- sys_info_ret = system_info_get_platform_string("http://tizen.org/system/model_name", &hcamcorder->model_name);
- if (hcamcorder->model_name) {
- _mmcam_dbg_log("model name [%s], sys_info_ret 0x%x", hcamcorder->model_name, sys_info_ret);
- } else {
- _mmcam_dbg_warn("failed get model name, sys_info_ret 0x%x", sys_info_ret);
- }
-
- /* get software version */
- sys_info_ret = system_info_get_platform_string("http://tizen.org/system/build.string", &hcamcorder->software_version);
- if (hcamcorder->software_version) {
- _mmcam_dbg_log("software version [%s], sys_info_ret 0x%d", hcamcorder->software_version, sys_info_ret);
- } else {
- _mmcam_dbg_warn("failed get software version, sys_info_ret 0x%x", sys_info_ret);
- }
-
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager, (void *)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to connect resource manager");
- goto _ERR_DEFAULT_VALUE_INIT;
- }
- }
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ /* get system information */
+ __mmcamcorder_get_system_info(hcamcorder);
/* Set initial state */
_mmcamcorder_set_state((MMHandleType)hcamcorder, MM_CAMCORDER_STATE_NULL);
- _mmcam_dbg_log("created handle %p", hcamcorder);
+ MMCAM_LOG_INFO("created handle %p", hcamcorder);
*handle = (MMHandleType)hcamcorder;
return MM_ERROR_NONE;
_ERR_DEFAULT_VALUE_INIT:
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* de-initialize resource manager */
- _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ if (hcamcorder->resource_manager != NULL)
+ mm_resource_manager_destroy(hcamcorder->resource_manager);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* release DPM related handle */
if (hcamcorder->dpm_handle) {
- _mmcam_dbg_log("release DPM handle %p, camera changed cb id %d",
+ MMCAM_LOG_INFO("release DPM handle %p, camera changed cb id %d",
hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
/* remove camera policy changed callback */
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);
+ MMCAM_LOG_WARNING("invalid dpm camera cb id %d", hcamcorder->dpm_camera_cb_id);
}
dpm_manager_destroy(hcamcorder->dpm_handle);
hcamcorder->dpm_handle = NULL;
}
- /* Remove attributes */
- if (hcamcorder->attributes) {
- _mmcamcorder_dealloc_attribute((MMHandleType)hcamcorder, hcamcorder->attributes);
- hcamcorder->attributes = 0;
- }
-
- /* Release lock, cond */
- g_mutex_clear(&(hcamcorder->mtsafe).lock);
- g_cond_clear(&(hcamcorder->mtsafe).cond);
- g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock);
- g_cond_clear(&(hcamcorder->mtsafe).cmd_cond);
- g_mutex_clear(&(hcamcorder->mtsafe).asm_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).gst_encode_state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).message_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).vcapture_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
- g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
- g_mutex_clear(&hcamcorder->snd_info.open_mutex);
- g_cond_clear(&hcamcorder->snd_info.open_cond);
- g_mutex_clear(&hcamcorder->restart_preview_lock);
-
- if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
- g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
- }
-
- if (hcamcorder->conf_ctrl)
- _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_ctrl);
-
- if (hcamcorder->conf_main)
- _mmcamcorder_conf_release_info((MMHandleType)hcamcorder, &hcamcorder->conf_main);
-
- if (hcamcorder->model_name) {
- free(hcamcorder->model_name);
- hcamcorder->model_name = NULL;
- }
-
- if (hcamcorder->software_version) {
- free(hcamcorder->software_version);
- hcamcorder->software_version = NULL;
- }
-
- if (hcamcorder->task_thread) {
- g_mutex_lock(&hcamcorder->task_thread_lock);
- _mmcam_dbg_log("send signal for task thread exit");
- hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
- g_cond_signal(&hcamcorder->task_thread_cond);
- g_mutex_unlock(&hcamcorder->task_thread_lock);
- g_thread_join(hcamcorder->task_thread);
- hcamcorder->task_thread = NULL;
- }
- g_mutex_clear(&hcamcorder->task_thread_lock);
- g_cond_clear(&hcamcorder->task_thread_cond);
+ /* release configure info */
+ __mmcamcorder_deinit_configure(hcamcorder);
- /* Release handle */
- memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
- free(hcamcorder);
+ /* deinitialize handle */
+ __mmcamcorder_deinit_handle(hcamcorder);
return ret;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
-#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);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
goto _ERR_CAMCORDER_CMD_PRECON;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_NULL) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- /* set exit state for sound thread */
- g_mutex_lock(&hcamcorder->task_thread_lock);
- _mmcam_dbg_log("send signal for task thread exit");
- hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_EXIT;
- 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,
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);
+ MMCAM_LOG_WARNING("remove sink element %p, set state NULL result %d", sink_element, result);
gst_object_unref(sink_element);
sink_element = NULL;
hcamcorder->sub_context = NULL;
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* de-initialize resource manager */
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
- ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE)
- _mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
- /* Remove idle function which is not called yet */
- if (hcamcorder->setting_event_id) {
- _mmcam_dbg_log("Remove remaining idle function");
- g_source_remove(hcamcorder->setting_event_id);
- hcamcorder->setting_event_id = 0;
- }
-
- /* Remove attributes */
- if (hcamcorder->attributes) {
- _mmcamcorder_dealloc_attribute(handle, hcamcorder->attributes);
- hcamcorder->attributes = 0;
- }
-
- /* Remove exif info */
- if (hcamcorder->exif_info) {
- mm_exif_destory_exif_info(hcamcorder->exif_info);
- hcamcorder->exif_info = NULL;
+ if (hcamcorder->resource_manager != NULL) {
+ ret = mm_resource_manager_destroy(hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
+ MMCAM_LOG_ERROR("failed to de-initialize resource manager 0x%x", ret);
}
- /* Release configure info */
- if (hcamcorder->conf_ctrl)
- _mmcamcorder_conf_release_info(handle, &hcamcorder->conf_ctrl);
-
- if (hcamcorder->conf_main)
- _mmcamcorder_conf_release_info(handle, &hcamcorder->conf_main);
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
/* Remove messages which are not called yet */
_mmcamcorder_remove_message_all(handle);
- /* unset remained watch cb */
- if (hcamcorder->sound_focus_watch_id > 0) {
- mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
- _mmcam_dbg_warn("unset sound focus watch cb [id %d] done", hcamcorder->sound_focus_watch_id);
- hcamcorder->sound_focus_watch_id = 0;
- }
-
- /* unregister sound focus and unsubscribe sound signal */
- _mmcam_dbg_log("sound focus id %d, sound signal subscribe id %u",
- hcamcorder->sound_focus_id, hcamcorder->sound_focus_subscribe_id);
-
- if (hcamcorder->sound_focus_id > 0) {
- mm_sound_unregister_focus(hcamcorder->sound_focus_id);
- _mmcam_dbg_log("unregister sound focus done");
- hcamcorder->sound_focus_id = 0;
- }
-
- if (hcamcorder->sound_focus_subscribe_id > 0) {
- mm_sound_unsubscribe_signal(hcamcorder->sound_focus_subscribe_id);
- _mmcam_dbg_log("unsubscribe sound signal done");
- hcamcorder->sound_focus_subscribe_id = 0;
- }
-
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle != 0) {
- iret = rm_unregister(hcamcorder->rm_handle);
- if (iret != RM_OK)
- _mmcam_dbg_err("rm_unregister() failed");
- hcamcorder->rm_handle = 0;
- }
+ _mmcamcorder_rm_release(handle);
#endif /* _MMCAMCORDER_RM_SUPPORT */
- /* release model_name */
- if (hcamcorder->model_name) {
- free(hcamcorder->model_name);
- hcamcorder->model_name = NULL;
- }
-
- if (hcamcorder->software_version) {
- free(hcamcorder->software_version);
- hcamcorder->software_version = NULL;
- }
-
/* release DPM handle */
if (hcamcorder->dpm_handle) {
- _mmcam_dbg_log("release DPM handle %p, camera changed cb id %d",
+ MMCAM_LOG_INFO("release DPM handle %p, camera changed cb id %d",
hcamcorder->dpm_handle, hcamcorder->dpm_camera_cb_id);
/* remove camera policy changed callback */
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);
+ MMCAM_LOG_WARNING("invalid dpm camera cb id %d", hcamcorder->dpm_camera_cb_id);
}
dpm_manager_destroy(hcamcorder->dpm_handle);
hcamcorder->dpm_handle = NULL;
}
- /* join task thread */
- _mmcam_dbg_log("task thread join");
- g_thread_join(hcamcorder->task_thread);
- hcamcorder->task_thread = NULL;
-
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
- /* Release lock, cond */
- g_mutex_clear(&(hcamcorder->mtsafe).lock);
- g_cond_clear(&(hcamcorder->mtsafe).cond);
- g_mutex_clear(&(hcamcorder->mtsafe).cmd_lock);
- g_cond_clear(&(hcamcorder->mtsafe).cmd_cond);
- g_mutex_clear(&(hcamcorder->mtsafe).asm_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).gst_state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).gst_encode_state_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).message_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).vcapture_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).vstream_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).astream_cb_lock);
- g_mutex_clear(&(hcamcorder->mtsafe).mstream_cb_lock);
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- g_cond_clear(&(hcamcorder->mtsafe).resource_cond);
- g_mutex_clear(&(hcamcorder->mtsafe).resource_lock);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-
- g_mutex_clear(&hcamcorder->snd_info.open_mutex);
- g_cond_clear(&hcamcorder->snd_info.open_cond);
- g_mutex_clear(&hcamcorder->restart_preview_lock);
- g_mutex_clear(&hcamcorder->task_thread_lock);
- g_cond_clear(&hcamcorder->task_thread_cond);
-
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
- }
-
- /* Release handle */
- memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
- free(hcamcorder);
+ __mmcamcorder_deinit_handle(hcamcorder);
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD_PRECON:
if (hcamcorder)
- _mmcam_dbg_err("Destroy fail (type %d, state %d)", hcamcorder->type, state);
+ MMCAM_LOG_ERROR("Destroy fail (type %d, state %d)", hcamcorder->type, state);
- _mmcam_dbg_err("Destroy fail (ret %x)", ret);
+ MMCAM_LOG_ERROR("Destroy fail (ret %x)", ret);
return ret;
}
int _mmcamcorder_realize(MMHandleType handle)
{
int ret = MM_ERROR_NONE;
- int ret_sound = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
int display_surface_type = MM_DISPLAY_SURFACE_OVERLAY;
- int pid_for_sound_focus = 0;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *videosink_element_type = NULL;
const char *videosink_name = NULL;
char *socket_path = NULL;
int socket_path_len = 0;
int conn_size = 0;
-#ifdef _MMCAMCORDER_RM_SUPPORT
- int iret = RM_OK;
- int preview_format = MM_PIXEL_FORMAT_NV12;
- int qret = RM_OK;
- int qret_avail = 0; /* 0: not available, 1: available */
- rm_consumer_info rci;
- int app_pid = 0;
- int resource_count = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_NULL) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
NULL);
if (!hcamcorder->gdbus_conn) {
- _mmcam_dbg_err("gdbus connection NULL");
+ MMCAM_LOG_ERROR("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]",
+ MMCAM_LOG_INFO("Profile mode [%d], gdbus connection [%p]",
hcamcorder->type, hcamcorder->gdbus_conn);
mm_camcorder_get_attributes(handle, NULL,
MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
NULL);
- /* sound focus */
- if (hcamcorder->sound_focus_register) {
- /* acquire sound focus or set sound focus watch callback */
- if (hcamcorder->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) {
- /* acquire sound focus */
- _mmcam_dbg_log("PAUSE_OTHERS - acquire sound focus");
-
- ret_sound = mm_sound_acquire_focus(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);
-
- ret = MM_ERROR_POLICY_BLOCKED;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- hcamcorder->acquired_focus = FOCUS_FOR_BOTH;
- } else if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- /* do nothing */
- _mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
- } else {
- /* 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);
- if (ret_sound != MM_ERROR_NONE) {
- _mmcam_dbg_err("mm_sound_set_focus_watch_callback failed [0x%x]", ret_sound);
-
- ret = MM_ERROR_POLICY_BLOCKED;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- _mmcam_dbg_log("sound focus watch cb id %d", hcamcorder->sound_focus_watch_id);
- }
- } else {
- _mmcam_dbg_log("no need to register sound focus");
- }
-
/* alloc sub context */
hcamcorder->sub_context = _mmcamcorder_alloc_subcontext(hcamcorder->type);
if (!hcamcorder->sub_context) {
CONFIGURE_CATEGORY_MAIN_CAPTURE,
"UseEncodebin",
&(hcamcorder->sub_context->bencbin_capture));
- _mmcam_dbg_warn("UseEncodebin [%d]", hcamcorder->sub_context->bencbin_capture);
+ MMCAM_LOG_WARNING("UseEncodebin [%d]", hcamcorder->sub_context->bencbin_capture);
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- /* get dual stream support info */
+ /* get video recording info */
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_RECORD,
"SupportDualStream",
&(hcamcorder->sub_context->info_video->support_dual_stream));
+ MMCAM_LOG_WARNING("SupportDualStream [%d]", hcamcorder->sub_context->info_video->support_dual_stream);
- _mmcam_dbg_warn("SupportDualStream [%d]", hcamcorder->sub_context->info_video->support_dual_stream);
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "UseVideoscale",
+ &(hcamcorder->sub_context->info_video->use_videoscale));
+ MMCAM_LOG_WARNING("UseVideoscale [%d]", hcamcorder->sub_context->info_video->use_videoscale);
}
switch (display_surface_type) {
MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
NULL);
if (socket_path == NULL) {
- _mmcam_dbg_warn("REMOTE surface, but socket path is NULL -> to NullSink");
+ MMCAM_LOG_WARNING("REMOTE surface, but socket path is NULL -> to NullSink");
videosink_element_type = strdup("VideosinkElementNull");
} else {
videosink_element_type = strdup("VideosinkElementRemote");
free(videosink_element_type);
videosink_element_type = NULL;
} else {
- _mmcam_dbg_warn("strdup failed(display_surface_type %d). Use default X type",
+ MMCAM_LOG_WARNING("strdup failed(display_surface_type %d). Use default X type",
display_surface_type);
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
}
_mmcamcorder_conf_get_value_element_name(hcamcorder->sub_context->VideosinkElement, &videosink_name);
- _mmcam_dbg_log("Videosink name : %s", videosink_name);
+ MMCAM_LOG_INFO("Videosink name : %s", videosink_name);
/* get videoconvert element */
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_CTRL_CAPTURE,
"SensorEncodedCapture",
&(hcamcorder->sub_context->SensorEncodedCapture));
- _mmcam_dbg_log("Support sensor encoded capture : %d", hcamcorder->sub_context->SensorEncodedCapture);
+ MMCAM_LOG_INFO("Support sensor encoded capture : %d", hcamcorder->sub_context->SensorEncodedCapture);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
int dpm_camera_state = DPM_ALLOWED;
/* check camera policy from DPM */
if (hcamcorder->dpm_handle) {
if (dpm_restriction_get_camera_state(hcamcorder->dpm_handle, &dpm_camera_state) == DPM_ERROR_NONE) {
- _mmcam_dbg_log("DPM camera state %d", dpm_camera_state);
+ MMCAM_LOG_INFO("DPM camera state %d", dpm_camera_state);
if (dpm_camera_state == DPM_DISALLOWED) {
- _mmcam_dbg_err("CAMERA DISALLOWED by DPM");
+ MMCAM_LOG_ERROR("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...");
+ MMCAM_LOG_ERROR("get DPM camera state failed, keep going...");
}
} else {
- _mmcam_dbg_warn("NULL dpm_handle");
+ MMCAM_LOG_WARNING("NULL dpm_handle");
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- /* check connection */
- if (hcamcorder->resource_manager.is_connected == FALSE) {
- _mmcam_dbg_warn("resource manager disconnected before, try to reconnect");
-
- /* release remained resource */
- _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
-
- /* init resource manager and wait for connection */
- 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_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager, (void *)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to connect resource manager");
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+ /* prepare resource manager for camera */
+ if (hcamcorder->camera_resource == NULL) {
+ ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_CAMERA,
+ 1,
+ &hcamcorder->camera_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("could not prepare for camera resource");
+ ret = MM_ERROR_RESOURCE_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- }
-
- ret = _mmcamcorder_resource_create_resource_set(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE) {
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- hcamcorder->resource_manager.acquire_count = 0;
-
- /* prepare resource manager for camera */
- ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_CAMERA);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("could not prepare for camera resource");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ } else {
+ MMCAM_LOG_INFO("camera already acquired");
}
/* prepare resource manager for "video_overlay only if display surface is X" */
if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
- ret = _mmcamcorder_resource_manager_prepare(&hcamcorder->resource_manager, MM_CAMCORDER_RESOURCE_TYPE_VIDEO_OVERLAY);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("could not prepare for video overlay resource");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ if (hcamcorder->video_overlay_resource == NULL) {
+ ret = mm_resource_manager_mark_for_acquire(hcamcorder->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_OVERLAY,
+ MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+ &hcamcorder->video_overlay_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("could not prepare for overlay resource");
+ ret = MM_ERROR_RESOURCE_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ } else {
+ MMCAM_LOG_INFO("overlay already acquired");
}
}
/* acquire resources */
- _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
-
- ret = _mmcamcorder_resource_manager_acquire(&hcamcorder->resource_manager);
- if (ret != MM_ERROR_NONE) {
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("could not acquire resources");
+ ret = MM_ERROR_RESOURCE_INTERNAL;
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-
- _mmcam_dbg_err("could not acquire resources");
-
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
-
- if (hcamcorder->resource_manager.acquire_remain > 0) {
- gint64 end_time = 0;
-
- _mmcam_dbg_warn("wait for resource state change");
-
- /* wait for resource state change */
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
-
- if (_MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time)) {
- _mmcam_dbg_warn("signal received");
- } else {
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_err("timeout");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- } else {
- _mmcam_dbg_log("already all acquired");
- }
-
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+#endif /* _MMCAMCORDER_MM_RM_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++;
- }
- }
+ ret = _mmcamcorder_rm_create(handle);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Resource create failed");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
-
- 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;
+ ret = _mmcamcorder_rm_allocate(handle);
+ if (ret != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("Resource allocation request failed");
+ _mmcamcorder_rm_release(handle);
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
#endif /* _MMCAMCORDER_RM_SUPPORT */
/* check internal error of gstreamer */
if (hcamcorder->error_code != MM_ERROR_NONE) {
ret = hcamcorder->error_code;
- _mmcam_dbg_log("gstreamer error is occurred. return it %x", ret);
+ MMCAM_LOG_INFO("gstreamer error is occurred. return it %x", ret);
}
/* release sub context */
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD:
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
/* release hw resources */
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
- int ret_resource = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
- if (ret_resource == MM_ERROR_RESOURCE_INVALID_STATE) {
- _mmcam_dbg_warn("it could be in the middle of resource callback or there's no acquired resource");
- } else if (ret_resource != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to release resource, ret_resource(0x%x)", ret_resource);
+ if (hcamcorder->camera_resource != NULL) {
+ mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->camera_resource);
+ hcamcorder->camera_resource = NULL;
}
- }
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
-#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle) {
- if (hcamcorder->returned_devices.allocated_num > 0) {
- int idx = 0;
- rm_device_request_s requested;
- memset(&requested, 0x0, sizeof(rm_device_request_s));
- requested.request_num = hcamcorder->returned_devices.allocated_num;
- for (idx = 0; idx < requested.request_num; idx++)
- requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
- iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
- if (iret != RM_OK)
- _mmcam_dbg_err("Resource deallocation request failed ");
+ if (hcamcorder->video_overlay_resource != NULL) {
+ mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->video_overlay_resource);
+ hcamcorder->video_overlay_resource = NULL;
}
-
- /* unregister RM */
- int ires = rm_unregister(hcamcorder->rm_handle);
- if (ires != RM_OK)
- _mmcam_dbg_err("rm_unregister() failed");
- hcamcorder->rm_handle = 0;
+ mm_resource_manager_commit(hcamcorder->resource_manager);
}
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ _mmcamcorder_rm_deallocate(handle);
+ _mmcamcorder_rm_release(handle);
#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;
- }
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
_ERR_CAMCORDER_CMD_PRECON:
- _mmcam_dbg_err("Realize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
+ MMCAM_LOG_ERROR("Realize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_READY) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
hcamcorder->sub_context = NULL;
}
-#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->resource_release_cb_calling);
-
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+ MMCAM_LOG_WARNING("lock resource - cb calling %d", hcamcorder->is_release_cb_calling);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM &&
- hcamcorder->resource_release_cb_calling == FALSE) {
- gint64 end_time = 0;
+ hcamcorder->is_release_cb_calling == FALSE) {
/* release resource */
- ret = _mmcamcorder_resource_manager_release(&hcamcorder->resource_manager);
- if (ret == MM_ERROR_RESOURCE_INVALID_STATE) {
- _mmcam_dbg_warn("it could be in the middle of resource callback or there's no acquired resource");
- ret = MM_ERROR_NONE;
- } else if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to release resource, ret(0x%x)", ret);
- ret = MM_ERROR_CAMCORDER_INTERNAL;
-
- _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_log("unlock resource");
+ if (hcamcorder->camera_resource != NULL) {
+ ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->camera_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("could not mark camera resource for release");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ MMCAM_LOG_INFO("unlock resource");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ }
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ if (hcamcorder->video_overlay_resource != NULL) {
+ ret = mm_resource_manager_mark_for_release(hcamcorder->resource_manager,
+ hcamcorder->video_overlay_resource);
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("could not mark overlay resource for release");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ MMCAM_LOG_INFO("unlock resource");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
}
- if (hcamcorder->resource_manager.acquire_remain < hcamcorder->resource_manager.acquire_count) {
- /* wait for resource release */
- _mmcam_dbg_log("resource is not released all. wait for signal...");
+ ret = mm_resource_manager_commit(hcamcorder->resource_manager);
+
+ if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ MMCAM_LOG_ERROR("failed to release resource, ret(0x%x)", ret);
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
- end_time = g_get_monotonic_time() + (__MMCAMCORDER_RESOURCE_WAIT_TIME * G_TIME_SPAN_SECOND);
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+ MMCAM_LOG_INFO("unlock resource");
- _MMCAMCORDER_RESOURCE_WAIT_UNTIL(hcamcorder, end_time);
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ } else {
+ if (hcamcorder->camera_resource != NULL)
+ hcamcorder->camera_resource = NULL;
+ if (hcamcorder->video_overlay_resource != NULL)
+ hcamcorder->video_overlay_resource = NULL;
}
}
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
- _mmcam_dbg_warn("unlock resource");
-#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
+ MMCAM_LOG_WARNING("unlock resource");
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle && (hcamcorder->returned_devices.allocated_num > 0)) {
- int iret = RM_OK;
- int idx = 0;
- rm_device_request_s requested;
- memset(&requested, 0x0, sizeof(rm_device_request_s));
- requested.request_num = hcamcorder->returned_devices.allocated_num;
- for (idx = 0; idx < requested.request_num; idx++)
- requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
- iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
- if (iret != RM_OK)
- _mmcam_dbg_err("Resource deallocation request failed ");
- }
+ _mmcamcorder_rm_deallocate(handle);
#endif /* _MMCAMCORDER_RM_SUPPORT*/
/* Deinitialize main context member */
hcamcorder->command = NULL;
- _mmcam_dbg_log("focus register %d, session flag 0x%x, state_change_by_system %d",
- hcamcorder->sound_focus_register, hcamcorder->session_flags, hcamcorder->state_change_by_system);
-
- /* release sound focus or unset sound focus watch callback */
- _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);
-
- 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) {
- 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, MM_CAMCORDER_STATE_NULL);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Unrealize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
+ MMCAM_LOG_ERROR("Unrealize fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_READY) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* check internal error of gstreamer */
if (hcamcorder->error_code != MM_ERROR_NONE) {
ret = hcamcorder->error_code;
- _mmcam_dbg_log("gstreamer error is occurred. return it %x", ret);
+ MMCAM_LOG_INFO("gstreamer error is occurred. return it %x", ret);
}
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->error_code;
hcamcorder->error_code = MM_ERROR_NONE;
- _mmcam_dbg_log("gstreamer error is occurred. return it %x", ret);
+ MMCAM_LOG_INFO("gstreamer error is occurred. return it %x", ret);
}
- _mmcam_dbg_err("Start fail (type %d, state %d, ret %x)",
+ MMCAM_LOG_ERROR("Start fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
return ret;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* 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);
+ MMCAM_LOG_WARNING("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);
+ MMCAM_LOG_WARNING("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);
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Stop fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
+ MMCAM_LOG_ERROR("Stop fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != state_FROM_0 && state != state_FROM_1 && state != state_FROM_2) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* Handle capture in recording case */
if (state == state_FROM_1 || state == state_FROM_2) {
if (hcamcorder->capture_in_recording == TRUE) {
- _mmcam_dbg_err("Capturing in recording (%d)", state);
+ MMCAM_LOG_ERROR("Capturing in recording (%d)", state);
ret = MM_ERROR_CAMCORDER_DEVICE_BUSY;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
} else {
if (hcamcorder->task_thread_state == _MMCAMCORDER_TASK_THREAD_STATE_NONE) {
hcamcorder->capture_in_recording = TRUE;
hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING;
- _mmcam_dbg_log("send signal for capture in recording");
+ MMCAM_LOG_INFO("send signal for capture in recording");
g_cond_signal(&hcamcorder->task_thread_cond);
g_mutex_unlock(&hcamcorder->task_thread_lock);
} else {
- _mmcam_dbg_err("task thread busy : %d", hcamcorder->task_thread_state);
+ MMCAM_LOG_ERROR("task thread busy : %d", hcamcorder->task_thread_state);
g_mutex_unlock(&hcamcorder->task_thread_lock);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
_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)
- _mmcam_dbg_warn("capture-break-cont-shot set 0 failed");
+ if (mm_camcorder_set_attributes(handle, NULL, MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT, 0, NULL) != MM_ERROR_NONE)
+ MMCAM_LOG_WARNING("capture-break-cont-shot set 0 failed");
return MM_ERROR_NONE;
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Capture start fail (type %d, state %d, ret %x)",
+ MMCAM_LOG_ERROR("Capture start fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
return ret;
int state = MM_CAMCORDER_STATE_NONE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_CAPTURING) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Capture stop fail (type %d, state %d, ret %x)",
+ MMCAM_LOG_ERROR("Capture stop fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
return ret;
int dpm_mic_state = DPM_ALLOWED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
- if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ if (!hcamcorder || !MMF_CAMCORDER_SUBCONTEXT(hcamcorder)) {
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_PAUSED) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
/* initialize error code */
hcamcorder->error_code = MM_ERROR_NONE;
+ /* get audio disable */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_AUDIO_DISABLE, &sc->audio_disable,
+ NULL);
+
+ sc->audio_disable |= sc->is_modified_rate;
+
/* check mic policy from DPM */
- if (hcamcorder->dpm_handle) {
+ if (hcamcorder->dpm_handle && sc->audio_disable == FALSE) {
if (dpm_restriction_get_microphone_state(hcamcorder->dpm_handle, &dpm_mic_state) == DPM_ERROR_NONE) {
- _mmcam_dbg_log("DPM mic state %d", dpm_mic_state);
+ MMCAM_LOG_INFO("DPM mic state %d", dpm_mic_state);
if (dpm_mic_state == DPM_DISALLOWED) {
- _mmcam_dbg_err("MIC DISALLOWED by DPM");
+ MMCAM_LOG_ERROR("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...");
+ MMCAM_LOG_ERROR("get DPM mic state failed, keep going...");
}
} else {
- _mmcam_dbg_warn("NULL dpm_handle");
+ MMCAM_LOG_WARNING("skip dpm check - handle %p, audio disable %d",
+ hcamcorder->dpm_handle, sc->audio_disable);
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_RECORD);
/* check internal error of gstreamer */
if (hcamcorder->error_code != MM_ERROR_NONE) {
ret = hcamcorder->error_code;
- _mmcam_dbg_log("gstreamer error is occurred. return it %x", ret);
+ MMCAM_LOG_INFO("gstreamer error is occurred. return it %x", ret);
}
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
ret = hcamcorder->error_code;
hcamcorder->error_code = MM_ERROR_NONE;
- _mmcam_dbg_log("gstreamer error is occurred. return it %x", ret);
+ MMCAM_LOG_INFO("gstreamer error is occurred. return it %x", ret);
}
- _mmcam_dbg_err("Record fail (type %d, state %d, ret %x)",
+ MMCAM_LOG_ERROR("Record fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
return ret;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_RECORDING) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Pause fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
+ MMCAM_LOG_ERROR("Pause fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Commit fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
+ MMCAM_LOG_ERROR("Commit fail (type %d, state %d, ret %x)", hcamcorder->type, state, ret);
return ret;
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (!hcamcorder) {
- _mmcam_dbg_err("Not initialized");
+ MMCAM_LOG_ERROR("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
goto _ERR_CAMCORDER_CMD_PRECON;
}
state = _mmcamcorder_get_state(handle);
if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
- _mmcam_dbg_err("Wrong state(%d)", state);
+ MMCAM_LOG_ERROR("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
_ERR_CAMCORDER_CMD_PRECON:
/* send message */
- _mmcam_dbg_err("Cancel fail (type %d, state %d, ret %x)",
+ MMCAM_LOG_ERROR("Cancel fail (type %d, state %d, ret %x)",
hcamcorder->type, state, ret);
return ret;
int _mmcamcorder_commit_async_end(MMHandleType handle)
{
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
- _mmcam_dbg_warn("_mmcamcorder_commit_async_end : MM_CAMCORDER_STATE_PREPARE");
+ MMCAM_LOG_WARNING("_mmcamcorder_commit_async_end : MM_CAMCORDER_STATE_PREPARE");
_mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
return MM_ERROR_NONE;
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("%p", hcamcorder);
+ MMCAM_LOG_INFO("%p", hcamcorder);
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (callback == NULL)
- _mmcam_dbg_warn("Message Callback is disabled, because application sets it to NULL");
+ MMCAM_LOG_WARNING("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");
+ MMCAM_LOG_WARNING("Application's message callback is running now");
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (callback == NULL)
- _mmcam_dbg_warn("Video Stream Callback is disabled, because application sets it to NULL");
+ MMCAM_LOG_WARNING("Video Stream Callback is disabled, because application sets it to NULL");
- if (!_MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(hcamcorder)) {
- _mmcam_dbg_warn("Application's video stream callback is running now");
- return MM_ERROR_CAMCORDER_INVALID_CONDITION;
- }
+ _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
hcamcorder->vstream_cb = callback;
hcamcorder->vstream_cb_param = user_data;
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (callback == NULL)
- _mmcam_dbg_warn("Audio Stream Callback is disabled, because application sets it to NULL");
+ MMCAM_LOG_WARNING("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");
+ MMCAM_LOG_WARNING("Application's audio stream callback is running now");
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
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");
+ MMCAM_LOG_WARNING("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");
+ MMCAM_LOG_WARNING("Application's muxed stream callback is running now");
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (callback == NULL)
- _mmcam_dbg_warn("Video Capture Callback is disabled, because application sets it to NULLL");
+ MMCAM_LOG_WARNING("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");
+ MMCAM_LOG_WARNING("Application's video capture callback is running now");
return MM_ERROR_CAMCORDER_INVALID_CONDITION;
}
return MM_ERROR_NONE;
}
+
+int _mmcamcorder_set_video_encode_decision_callback(MMHandleType handle, mm_camcorder_video_encode_decision_callback callback, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ MMCAM_LOG_INFO("");
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ if (callback == NULL)
+ MMCAM_LOG_WARNING("Video Encode Decision Callback is disabled, because application sets it to NULL");
+
+ if (!_MMCAMCORDER_TRYLOCK_VEDECISION_CALLBACK(hcamcorder)) {
+ MMCAM_LOG_WARNING("Application's video encode decision callback is running now");
+ return MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ }
+
+ hcamcorder->vedecision_cb = callback;
+ hcamcorder->vedecision_cb_param = user_data;
+
+ _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(hcamcorder);
+
+ return MM_ERROR_NONE;
+}
+
+
int _mmcamcorder_get_current_state(MMHandleType handle)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
_MMCamcorderSubContext *sc = NULL;
GstCameraControl *control = NULL;
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
hcamcorder = MMF_CAMCORDER(handle);
mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
if (state == MM_CAMCORDER_STATE_CAPTURING ||
state < MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_err("Not proper state. state[%d]", state);
+ MMCAM_LOG_ERROR("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INVALID_STATE;
}
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_log("Can't cast Video source into camera control.");
+ MMCAM_LOG_INFO("Can't cast Video source into camera control.");
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
}
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control == NULL) {
- _mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INTERNAL;
}
ret = gst_camera_control_stop_auto_focus(control);
if (!ret) {
- _mmcam_dbg_err("Auto focusing stop fail.");
+ MMCAM_LOG_ERROR("Auto focusing stop fail.");
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
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_LOG_INFO("No need to init FOCUS [mode:%d, range:%d]", focus_mode, af_range);
ret = TRUE;
}
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
if (ret) {
- _mmcam_dbg_log("Lens init success.");
+ MMCAM_LOG_INFO("Lens init success.");
return MM_ERROR_NONE;
} else {
- _mmcam_dbg_err("Lens init fail.");
+ MMCAM_LOG_ERROR("Lens init fail.");
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
}
mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(direction, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
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);
+ MMCAM_LOG_ERROR("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(handle);
return MM_ERROR_CAMCORDER_INVALID_STATE;
}
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);
+ MMCAM_LOG_WARNING("Get focus-mode fail. (%s:%x)", err_attr_name, ret);
SAFE_FREE(err_attr_name);
_MMCAMCORDER_UNLOCK_CMD(handle);
return ret;
ret = _mmcamcorder_adjust_auto_focus(handle);
break;
default:
- _mmcam_dbg_err("It doesn't adjust focus. Focusing mode(%d)", focus_mode);
+ MMCAM_LOG_ERROR("It doesn't adjust focus. Focusing mode(%d)", focus_mode);
ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
}
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
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(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_log("Can't cast Video source into camera control.");
+ MMCAM_LOG_INFO("Can't cast Video source into camera control.");
return MM_ERROR_NONE;
}
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control == NULL) {
- _mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
return MM_ERROR_CAMCORDER_INTERNAL;
}
/* TODO : get max, min 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.");
+ MMCAM_LOG_WARNING("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);
if (!gst_camera_control_get_focus_level(control, &cur_level)) {
- _mmcam_dbg_err("Can't get current level of manual focus.");
+ MMCAM_LOG_ERROR("Can't get current level of manual focus.");
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
focus_level = min_level;
if (!gst_camera_control_set_focus_level(control, focus_level)) {
- _mmcam_dbg_err("Manual focusing fail.");
+ MMCAM_LOG_ERROR("Manual focusing fail.");
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_log("Can't cast Video source into camera control.");
+ MMCAM_LOG_INFO("Can't cast Video source into camera control.");
return MM_ERROR_NONE;
}
/* Start AF */
ret = gst_camera_control_start_auto_focus(control);
} else {
- _mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
ret = FALSE;
}
if (ret) {
- _mmcam_dbg_log("Auto focusing start success.");
+ MMCAM_LOG_INFO("Auto focusing start success.");
return MM_ERROR_NONE;
} else {
- _mmcam_dbg_err("Auto focusing start fail.");
+ MMCAM_LOG_ERROR("Auto focusing start fail.");
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
}
mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
- _mmcam_dbg_err("Another command is running.");
+ MMCAM_LOG_ERROR("Another command is running.");
return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
}
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);
+ MMCAM_LOG_ERROR("Not proper state. state[%d]", state);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INVALID_STATE;
}
if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- _mmcam_dbg_log("Can't cast Video source into camera control.");
+ MMCAM_LOG_INFO("Can't cast Video source into camera control.");
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
}
if (control) {
ret = gst_camera_control_stop_auto_focus(control);
} else {
- _mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
ret = FALSE;
}
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
if (ret) {
- _mmcam_dbg_log("Auto focusing stop success.");
+ MMCAM_LOG_INFO("Auto focusing stop success.");
return MM_ERROR_NONE;
} else {
- _mmcam_dbg_err("Auto focusing stop fail.");
+ MMCAM_LOG_ERROR("Auto focusing stop fail.");
return MM_ERROR_CAMCORDER_DEVICE_IO;
}
}
+int _mmcamcorder_get_focus_level(MMHandleType handle, int *level)
+{
+ GstCameraControl *control = NULL;
+ _MMCamcorderSubContext *sc = NULL;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ mmf_return_val_if_fail(level, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
+ MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
+
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!control) {
+ MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
+
+ if (!gst_camera_control_get_focus_level(control, level)) {
+ MMCAM_LOG_ERROR("get focus level failed");
+ return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+ }
+
+ MMCAM_LOG_INFO("focus level[%d]", *level);
+
+ return MM_ERROR_NONE;
+}
+
/*-----------------------------------------------
| CAMCORDER INTERNAL LOCAL |
-----------------------------------------------*/
-static gboolean
-__mmcamcorder_gstreamer_init(camera_conf * conf)
+static gboolean __mmcamcorder_init_gstreamer(camera_conf *conf)
{
static const int max_argc = 10;
int i = 0;
mmf_return_val_if_fail(conf, FALSE);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* alloc */
argc = malloc(sizeof(int));
argv[*argc] = g_strdup(GSTInitOption->value[(*argc)-1]);
}
- _mmcam_dbg_log("initializing gstreamer with following parameter[argc:%d]", *argc);
+ MMCAM_LOG_INFO("initializing gstreamer with following parameter[argc:%d]", *argc);
for (i = 0; i < *argc; i++)
- _mmcam_dbg_log("argv[%d] : %s", i, argv[i]);
+ MMCAM_LOG_INFO("argv[%d] : %s", i, argv[i]);
/* initializing gstreamer */
ret = gst_init_check(argc, &argv, &err);
if (!ret) {
- _mmcam_dbg_err("Could not initialize GStreamer: %s ", err ? err->message : "unknown error occurred");
+ MMCAM_LOG_ERROR("Could not initialize GStreamer: %s ", err ? err->message : "unknown error occurred");
if (err)
g_error_free(err);
}
return ret;
ERROR:
- _mmcam_dbg_err("failed to initialize gstreamer");
+ MMCAM_LOG_ERROR("failed to initialize gstreamer");
if (argv) {
free(argv);
_MMCAMCORDER_LOCK_STATE(handle);
state = hcamcorder->state;
- /*_mmcam_dbg_log("state=%d",state);*/
+ /*MMCAM_LOG_INFO("state=%d",state);*/
_MMCAMCORDER_UNLOCK_STATE(handle);
}
+int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder && state && old_state, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ _MMCAMCORDER_LOCK_STATE(handle);
+
+ *state = hcamcorder->state;
+ *old_state = hcamcorder->old_state;
+
+ _MMCAMCORDER_UNLOCK_STATE(handle);
+
+ return MM_ERROR_NONE;
+}
+
+
void _mmcamcorder_set_state(MMHandleType handle, int state)
{
int old_state;
mmf_return_if_fail(hcamcorder);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
_MMCAMCORDER_LOCK_STATE(handle);
old_state = hcamcorder->state;
if (old_state != state) {
hcamcorder->state = state;
- hcamcorder->target_state = state;
+ hcamcorder->old_state = old_state;
- _mmcam_dbg_log("set state[%d] and send state-changed message", state);
+ MMCAM_LOG_INFO("set state[%d -> %d] and send state-changed message", old_state, state);
/* To discern who changes the state */
switch (hcamcorder->state_change_by_system) {
- case _MMCAMCORDER_STATE_CHANGE_BY_FOCUS:
- msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM;
- msg.param.state.code = hcamcorder->interrupt_code;
- break;
case _MMCAMCORDER_STATE_CHANGE_BY_RM:
msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_RM;
msg.param.state.code = MM_ERROR_NONE;
msg.param.state.previous = old_state;
msg.param.state.current = state;
- /*_mmcam_dbg_log("_mmcamcorder_send_message : msg : %p, id:%x", &msg, msg.id);*/
+ /*MMCAM_LOG_INFO("_mmcamcorder_send_message : msg : %p, id:%x", &msg, msg.id);*/
_mmcamcorder_send_message(handle, &msg);
}
}
-int _mmcamcorder_get_async_state(MMHandleType handle)
-{
- int state;
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
-
- _MMCAMCORDER_LOCK_STATE(handle);
- state = hcamcorder->target_state;
-
- _MMCAMCORDER_UNLOCK_STATE(handle);
-
- return state;
-}
-
-
_MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type)
{
int i;
_MMCamcorderSubContext *sc = NULL;
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
/* alloc container */
- sc = (_MMCamcorderSubContext *)malloc(sizeof(_MMCamcorderSubContext));
- mmf_return_val_if_fail(sc != NULL, NULL);
-
- /* init members */
- memset(sc, 0x00, sizeof(_MMCamcorderSubContext));
+ sc = (_MMCamcorderSubContext *)g_malloc0(sizeof(_MMCamcorderSubContext));
sc->element_num = _MMCAMCORDER_PIPELINE_ELEMENT_NUM;
sc->encode_element_num = _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM;
switch (type) {
case MM_CAMCORDER_MODE_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) {
- _mmcam_dbg_err("Failed to alloc info structure");
- goto ALLOC_SUBCONTEXT_FAILED;
- }
+ sc->info_video = g_malloc0(sizeof(_MMCamcorderVideoInfo));
- /* init sound status */
sc->info_image->sound_status = _SOUND_STATUS_INIT;
-
- sc->info_video = g_malloc0(sizeof(_MMCamcorderVideoInfo));
- if (!sc->info_video) {
- _mmcam_dbg_err("Failed to alloc info structure");
- goto ALLOC_SUBCONTEXT_FAILED;
- }
g_mutex_init(&sc->info_video->size_check_lock);
break;
}
/* alloc element array */
- sc->element = (_MMCamcorderGstElement *)malloc(sizeof(_MMCamcorderGstElement) * sc->element_num);
- if (!sc->element) {
- _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) {
- _mmcam_dbg_err("Failed to alloc encode element structure");
- goto ALLOC_SUBCONTEXT_FAILED;
- }
+ sc->element = (_MMCamcorderGstElement *)g_malloc(sizeof(_MMCamcorderGstElement) * sc->element_num);
+ sc->encode_element = (_MMCamcorderGstElement *)g_malloc(sizeof(_MMCamcorderGstElement) * sc->encode_element_num);
for (i = 0 ; i < sc->element_num ; i++) {
sc->element[i].id = _MMCAMCORDER_NONE;
}
sc->fourcc = 0x80000000;
- sc->cam_stability_count = 0;
+ sc->frame_stability_count = 0;
sc->drop_vframe = 0;
sc->pass_first_vframe = 0;
sc->is_modified_rate = FALSE;
return sc;
-
-ALLOC_SUBCONTEXT_FAILED:
- if (sc) {
- SAFE_G_FREE(sc->info_audio);
- SAFE_G_FREE(sc->info_image);
- if (sc->info_video)
- g_mutex_clear(&sc->info_video->size_check_lock);
-
- SAFE_G_FREE(sc->info_video);
- if (sc->element) {
- free(sc->element);
- sc->element = NULL;
- }
- if (sc->encode_element) {
- free(sc->encode_element);
- sc->encode_element = NULL;
- }
- free(sc);
- sc = NULL;
- }
-
- return NULL;
}
void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc)
{
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
if (sc) {
if (sc->element) {
- _mmcam_dbg_log("release element");
- free(sc->element);
+ MMCAM_LOG_INFO("release element");
+ g_free(sc->element);
sc->element = NULL;
}
if (sc->encode_element) {
- _mmcam_dbg_log("release encode_element");
- free(sc->encode_element);
+ MMCAM_LOG_INFO("release encode_element");
+ g_free(sc->encode_element);
sc->encode_element = NULL;
}
if (sc->info_image) {
- _mmcam_dbg_log("release info_image");
- free(sc->info_image);
+ MMCAM_LOG_INFO("release info_image");
+ g_free(sc->info_image);
sc->info_image = NULL;
}
if (sc->info_video) {
- _mmcam_dbg_log("release info_video");
+ MMCAM_LOG_INFO("release info_video");
SAFE_G_FREE(sc->info_video->filename);
g_mutex_clear(&sc->info_video->size_check_lock);
- free(sc->info_video);
+ g_free(sc->info_video);
sc->info_video = NULL;
}
if (sc->info_audio) {
- _mmcam_dbg_log("release info_audio");
+ MMCAM_LOG_INFO("release info_audio");
SAFE_G_FREE(sc->info_audio->filename);
- free(sc->info_audio);
+ g_free(sc->info_audio);
sc->info_audio = NULL;
}
- free(sc);
+ g_free(sc);
sc = NULL;
}
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- /*_mmcam_dbg_log("");*/
+ /*MMCAM_LOG_INFO("");*/
switch (type) {
case MM_CAMCORDER_MODE_AUDIO:
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_LOG_DEBUG("message type[0x%x]", GST_MESSAGE_TYPE(message));
switch (GST_MESSAGE_TYPE(message)) {
- case GST_MESSAGE_UNKNOWN:
- _mmcam_dbg_log("GST_MESSAGE_UNKNOWN");
- break;
case GST_MESSAGE_EOS:
{
- _mmcam_dbg_err("Got EOS from element \"%s\"... but should not be reached here!",
+ MMCAM_LOG_ERROR("Got EOS from element[%s]... but should not be reached here!",
GST_STR_NULL(GST_ELEMENT_NAME(GST_MESSAGE_SRC(message))));
break;
}
__mmcamcorder_handle_gst_error((MMHandleType)hcamcorder, message, err);
if (err) {
- _mmcam_dbg_err("GSTERR: %s", err->message);
+ MMCAM_LOG_ERROR("GSTERR: %s", err->message);
g_error_free(err);
err = NULL;
}
if (debug) {
- _mmcam_dbg_err("Error Debug: %s", debug);
+ MMCAM_LOG_ERROR("Error Debug: %s", debug);
g_free(debug);
debug = NULL;
}
gchar *debug;
gst_message_parse_warning(message, &err, &debug);
- _mmcam_dbg_warn("GSTWARN: %s", err->message);
+ MMCAM_LOG_WARNING("GSTWARN: %s", err->message);
__mmcamcorder_handle_gst_warning((MMHandleType)hcamcorder, message, err);
g_free(debug);
break;
}
- case GST_MESSAGE_INFO:
- _mmcam_dbg_log("GST_MESSAGE_INFO");
- break;
- case GST_MESSAGE_TAG:
- _mmcam_dbg_log("GST_MESSAGE_TAG");
- break;
- case GST_MESSAGE_BUFFERING:
- _mmcam_dbg_log("GST_MESSAGE_BUFFERING");
- break;
case GST_MESSAGE_STATE_CHANGED:
{
const GValue *vnewstate;
vnewstate = gst_structure_get_value(gst_message_get_structure(message), "new-state");
if (vnewstate) {
newstate = (GstState)vnewstate->data[0].v_int;
- _mmcam_dbg_log("GST_MESSAGE_STATE_CHANGED[%s]", gst_element_state_get_name(newstate));
+ MMCAM_LOG_INFO("GST_MESSAGE_STATE_CHANGED[%s]", gst_element_state_get_name(newstate));
} else {
- _mmcam_dbg_warn("get new state failed from msg");
+ MMCAM_LOG_WARNING("get new state failed from msg");
}
}
}
}
break;
}
- case GST_MESSAGE_STATE_DIRTY:
- _mmcam_dbg_log("GST_MESSAGE_STATE_DIRTY");
- break;
- case GST_MESSAGE_STEP_DONE:
- _mmcam_dbg_log("GST_MESSAGE_STEP_DONE");
- break;
- case GST_MESSAGE_CLOCK_PROVIDE:
- _mmcam_dbg_log("GST_MESSAGE_CLOCK_PROVIDE");
- break;
- case GST_MESSAGE_CLOCK_LOST:
- _mmcam_dbg_log("GST_MESSAGE_CLOCK_LOST");
- break;
case GST_MESSAGE_NEW_CLOCK:
{
GstClock *pipe_clock = NULL;
gst_message_parse_new_clock(message, &pipe_clock);
- /*_mmcam_dbg_log("GST_MESSAGE_NEW_CLOCK : %s", (clock ? GST_OBJECT_NAME (clock) : "NULL"));*/
+ MMCAM_LOG_INFO("GST_MESSAGE_NEW_CLOCK[%s]", (pipe_clock ? GST_OBJECT_NAME(pipe_clock) : "NULL"));
break;
}
- case GST_MESSAGE_STRUCTURE_CHANGE:
- _mmcam_dbg_log("GST_MESSAGE_STRUCTURE_CHANGE");
- break;
- case GST_MESSAGE_STREAM_STATUS:
- /*_mmcam_dbg_log("GST_MESSAGE_STREAM_STATUS");*/
- break;
- case GST_MESSAGE_APPLICATION:
- _mmcam_dbg_log("GST_MESSAGE_APPLICATION");
- break;
- case GST_MESSAGE_ELEMENT:
- /*_mmcam_dbg_log("GST_MESSAGE_ELEMENT");*/
- break;
- case GST_MESSAGE_SEGMENT_START:
- _mmcam_dbg_log("GST_MESSAGE_SEGMENT_START");
- break;
- case GST_MESSAGE_SEGMENT_DONE:
- _mmcam_dbg_log("GST_MESSAGE_SEGMENT_DONE");
- break;
- case GST_MESSAGE_DURATION_CHANGED:
- _mmcam_dbg_log("GST_MESSAGE_DURATION_CHANGED");
- break;
- case GST_MESSAGE_LATENCY:
- _mmcam_dbg_log("GST_MESSAGE_LATENCY");
- break;
- case GST_MESSAGE_ASYNC_START:
- _mmcam_dbg_log("GST_MESSAGE_ASYNC_START");
- break;
- case GST_MESSAGE_ASYNC_DONE:
- /*_mmcam_dbg_log("GST_MESSAGE_ASYNC_DONE");*/
- break;
- case GST_MESSAGE_ANY:
- _mmcam_dbg_log("GST_MESSAGE_ANY");
- break;
- case GST_MESSAGE_QOS:
- /* _mmcam_dbg_log("GST_MESSAGE_QOS"); */
- break;
default:
- _mmcam_dbg_log("not handled message type=(%d)", GST_MESSAGE_TYPE(message));
+ MMCAM_LOG_DEBUG("unhandled message type[0x%x]", GST_MESSAGE_TYPE(message));
break;
}
GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
{
- GstElement *element = NULL;
GError *err = NULL;
gchar *debug_info = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
_MMCamcorderSubContext *sc = NULL;
- mmf_return_val_if_fail(hcamcorder, GST_BUS_PASS);
- mmf_return_val_if_fail(message, GST_BUS_PASS);
+ mmf_return_val_if_fail(hcamcorder, GST_BUS_DROP);
+ mmf_return_val_if_fail(message, GST_BUS_DROP);
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
- mmf_return_val_if_fail(sc, GST_BUS_PASS);
+ mmf_return_val_if_fail(sc, GST_BUS_DROP);
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
/* parse error message */
gst_message_parse_error(message, &err, &debug_info);
if (debug_info) {
- _mmcam_dbg_err("GST ERROR : %s", debug_info);
+ MMCAM_LOG_ERROR("GST ERROR : %s", debug_info);
g_free(debug_info);
debug_info = NULL;
}
if (!err) {
- _mmcam_dbg_warn("failed to parse error message");
+ MMCAM_LOG_WARNING("failed to parse error message");
return GST_BUS_PASS;
}
- /* set videosrc element to compare */
- 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) == GST_ELEMENT_CAST(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
switch (err->code) {
case GST_RESOURCE_ERROR_BUSY:
- _mmcam_dbg_err("Camera device [busy]");
+ MMCAM_LOG_ERROR("Camera device [busy]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
break;
case GST_RESOURCE_ERROR_OPEN_WRITE:
- _mmcam_dbg_err("Camera device [open failed]");
+ MMCAM_LOG_ERROR("Camera device [open failed]");
hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
- /* 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]");
+ MMCAM_LOG_ERROR("Camera device [open failed]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_OPEN;
break;
case GST_RESOURCE_ERROR_OPEN_READ:
- _mmcam_dbg_err("Camera device [register trouble]");
+ MMCAM_LOG_ERROR("Camera device [register trouble]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE;
break;
case GST_RESOURCE_ERROR_NOT_FOUND:
- _mmcam_dbg_err("Camera device [device not found]");
+ MMCAM_LOG_ERROR("Camera device [device not found]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND;
break;
case GST_RESOURCE_ERROR_TOO_LAZY:
- _mmcam_dbg_err("Camera device [timeout]");
+ MMCAM_LOG_ERROR("Camera device [timeout]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_TIMEOUT;
break;
case GST_RESOURCE_ERROR_SETTINGS:
- _mmcam_dbg_err("Camera device [not supported]");
+ MMCAM_LOG_ERROR("Camera device [not supported]");
hcamcorder->error_code = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
break;
case GST_RESOURCE_ERROR_FAILED:
- _mmcam_dbg_err("Camera device [working failed].");
+ MMCAM_LOG_ERROR("Camera device [working failed].");
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_IO;
break;
default:
- _mmcam_dbg_err("Camera device [General(%d)]", err->code);
+ MMCAM_LOG_ERROR("Camera device [General(%d)]", err->code);
hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE;
break;
}
msg.id = MM_MESSAGE_CAMCORDER_ERROR;
msg.param.code = hcamcorder->error_code;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
- goto DROP_MESSAGE;
}
} else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ELEMENT) {
_MMCamcorderMsgItem msg;
int focus_state = 0;
gst_structure_get_int(gst_message_get_structure(message), "focus-state", &focus_state);
- _mmcam_dbg_log("Focus State:%d", focus_state);
+ MMCAM_LOG_INFO("Focus State:%d", focus_state);
msg.id = MM_MESSAGE_CAMCORDER_FOCUS_CHANGED;
msg.param.code = focus_state;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
- goto DROP_MESSAGE;
} else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-HDR")) {
int progress = 0;
int status = 0;
if (gst_structure_get_int(gst_message_get_structure(message), "progress", &progress)) {
gst_structure_get_int(gst_message_get_structure(message), "status", &status);
- _mmcam_dbg_log("HDR progress %d percent, status %d", progress, status);
+ MMCAM_LOG_INFO("HDR progress %d percent, status %d", progress, status);
msg.id = MM_MESSAGE_CAMCORDER_HDR_PROGRESS;
msg.param.code = progress;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
}
-
- goto DROP_MESSAGE;
} else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-FD")) {
int i = 0;
const GValue *g_value = gst_structure_get_value(gst_message_get_structure(message), "face-info");;
- GstCameraControlFaceDetectInfo *fd_info = NULL;
- MMCamFaceDetectInfo *cam_fd_info = NULL;
-
- if (g_value)
- fd_info = (GstCameraControlFaceDetectInfo *)g_value_get_pointer(g_value);
-
- if (fd_info == NULL) {
- _mmcam_dbg_warn("fd_info is NULL");
- goto DROP_MESSAGE;
- }
-
- cam_fd_info = (MMCamFaceDetectInfo *)g_malloc(sizeof(MMCamFaceDetectInfo));
- if (cam_fd_info == NULL) {
- _mmcam_dbg_warn("cam_fd_info alloc failed");
- SAFE_FREE(fd_info);
- goto DROP_MESSAGE;
- }
-
- /* set total face count */
- cam_fd_info->num_of_faces = fd_info->num_of_faces;
-
- if (cam_fd_info->num_of_faces > 0) {
- cam_fd_info->face_info = (MMCamFaceInfo *)g_malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
- if (cam_fd_info->face_info) {
- /* set information of each face */
- for (i = 0 ; i < fd_info->num_of_faces ; i++) {
- cam_fd_info->face_info[i].id = fd_info->face_info[i].id;
- cam_fd_info->face_info[i].score = fd_info->face_info[i].score;
- cam_fd_info->face_info[i].rect.x = fd_info->face_info[i].rect.x;
- cam_fd_info->face_info[i].rect.y = fd_info->face_info[i].rect.y;
- cam_fd_info->face_info[i].rect.width = fd_info->face_info[i].rect.width;
- 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);
- */
- }
- } else {
- _mmcam_dbg_warn("MMCamFaceInfo alloc failed");
-
- /* free allocated memory that is not sent */
- SAFE_G_FREE(cam_fd_info);
- }
- } else {
- cam_fd_info->face_info = NULL;
- }
-
- if (cam_fd_info) {
- /* send message - cam_fd_info should be freed by application */
- msg.id = MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO;
- msg.param.data = cam_fd_info;
- msg.param.size = sizeof(MMCamFaceDetectInfo);
- msg.param.code = 0;
-
- _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
- }
-
- /* free fd_info allocated by plugin */
- free(fd_info);
- fd_info = NULL;
-
- goto DROP_MESSAGE;
- } else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-Capture")) {
- int capture_done = FALSE;
-
- if (gst_structure_get_int(gst_message_get_structure(message), "capture-done", &capture_done)) {
- if (sc->info_image) {
- /* play capture sound */
- _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
- }
- }
-
- goto DROP_MESSAGE;
- }
- }
-
- return GST_BUS_PASS;
-
-DROP_MESSAGE:
- gst_message_unref(message);
- message = NULL;
-
- return GST_BUS_DROP;
-}
-
-
-GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
-{
- GstElement *element = NULL;
- GError *err = NULL;
- gchar *debug_info = NULL;
-
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
- _MMCamcorderSubContext *sc = NULL;
-
- mmf_return_val_if_fail(hcamcorder, GST_BUS_PASS);
- mmf_return_val_if_fail(message, GST_BUS_PASS);
-
- sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
- mmf_return_val_if_fail(sc, GST_BUS_PASS);
-
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
- _mmcam_dbg_log("got EOS from pipeline");
-
- _MMCAMCORDER_LOCK(hcamcorder);
-
- sc->bget_eos = TRUE;
- _MMCAMCORDER_SIGNAL(hcamcorder);
-
- _MMCAMCORDER_UNLOCK(hcamcorder);
-
- goto DROP_MESSAGE;
- } else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
- _MMCamcorderMsgItem msg;
-
- /* parse error message */
- gst_message_parse_error(message, &err, &debug_info);
-
- if (debug_info) {
- _mmcam_dbg_err("GST ERROR : %s", debug_info);
- g_free(debug_info);
- debug_info = NULL;
- }
-
- if (!err) {
- _mmcam_dbg_warn("failed to parse error message");
- return GST_BUS_PASS;
- }
-
- /* set videosrc element to compare */
- element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
-
- /* check domain[RESOURCE] and element[AUDIOSRC] */
- if (err->domain == GST_RESOURCE_ERROR &&
- GST_ELEMENT_CAST(message->src) == element) {
- switch (err->code) {
- case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
- case GST_RESOURCE_ERROR_OPEN_WRITE:
- _mmcam_dbg_err("audio device [open failed]");
-
- /* post error to application */
- hcamcorder->error_occurs = TRUE;
- hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
-
- msg.id = MM_MESSAGE_CAMCORDER_ERROR;
- msg.param.code = hcamcorder->error_code;
-
- _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
- _mmcam_dbg_err(" error : sc->error_occurs %d", hcamcorder->error_occurs);
+ GstCameraControlFaceDetectInfo *fd_info = NULL;
+ MMCamFaceDetectInfo *cam_fd_info = NULL;
- goto DROP_MESSAGE;
- default:
- break;
- }
- } else {
- gboolean b_commiting = FALSE;
- storage_state_e storage_state = STORAGE_STATE_UNMOUNTABLE;
+ if (g_value)
+ fd_info = (GstCameraControlFaceDetectInfo *)g_value_get_pointer(g_value);
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- mmf_return_val_if_fail(sc->info_video, GST_BUS_PASS);
- b_commiting = sc->info_video->b_commiting;
- } else {
- mmf_return_val_if_fail(sc->info_audio, GST_BUS_PASS);
- b_commiting = sc->info_audio->b_commiting;
+ if (fd_info == NULL) {
+ MMCAM_LOG_WARNING("fd_info is NULL");
+ gst_message_unref(message);
+ return GST_BUS_DROP;
}
- _MMCAMCORDER_LOCK(hcamcorder);
+ cam_fd_info = (MMCamFaceDetectInfo *)g_malloc(sizeof(MMCamFaceDetectInfo));
- switch (err->code) {
- case GST_RESOURCE_ERROR_WRITE:
- storage_get_state(hcamcorder->storage_info.id, &storage_state);
- if (storage_state == STORAGE_STATE_REMOVED ||
- storage_state == STORAGE_STATE_UNMOUNTABLE) {
- _mmcam_dbg_err("storage was removed! [storage state %d]", storage_state);
- hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
- } else {
- _mmcam_dbg_err("File write error, storage state %d", storage_state);
- hcamcorder->error_code = MM_ERROR_FILE_WRITE;
- }
+ /* set total face count */
+ cam_fd_info->num_of_faces = fd_info->num_of_faces;
- if (sc->ferror_send == FALSE) {
- sc->ferror_send = TRUE;
- } else {
- _mmcam_dbg_err("error was already sent");
- _MMCAMCORDER_UNLOCK(hcamcorder);
- goto DROP_MESSAGE;
+ if (cam_fd_info->num_of_faces > 0) {
+ cam_fd_info->face_info = (MMCamFaceInfo *)g_malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
+ MMCAM_LOG_DEBUG("face detection - count %d", cam_fd_info->num_of_faces);
+ /* set information of each face */
+ for (i = 0 ; i < cam_fd_info->num_of_faces ; i++) {
+ cam_fd_info->face_info[i].id = fd_info->face_info[i].id;
+ cam_fd_info->face_info[i].score = fd_info->face_info[i].score;
+ cam_fd_info->face_info[i].rect.x = fd_info->face_info[i].rect.x;
+ cam_fd_info->face_info[i].rect.y = fd_info->face_info[i].rect.y;
+ cam_fd_info->face_info[i].rect.width = fd_info->face_info[i].rect.width;
+ cam_fd_info->face_info[i].rect.height = fd_info->face_info[i].rect.height;
+
+ MMCAM_LOG_VERBOSE(" [%d] id %d, score %d, [%d,%d,%dx%d]",
+ i, 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);
}
- break;
- case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
- _mmcam_dbg_err("No left space");
- hcamcorder->error_code = MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
- break;
- case GST_RESOURCE_ERROR_OPEN_WRITE:
- _mmcam_dbg_err("Out of storage");
- hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
- break;
- case GST_RESOURCE_ERROR_SEEK:
- _mmcam_dbg_err("File read(seek)");
- hcamcorder->error_code = MM_ERROR_FILE_READ;
- break;
- default:
- _mmcam_dbg_err("Resource error(%d)", err->code);
- hcamcorder->error_code = MM_ERROR_CAMCORDER_GST_RESOURCE;
- break;
- }
-
- if (b_commiting) {
- _MMCAMCORDER_SIGNAL(hcamcorder);
- _MMCAMCORDER_UNLOCK(hcamcorder);
} else {
- _MMCAMCORDER_UNLOCK(hcamcorder);
-
- msg.id = MM_MESSAGE_CAMCORDER_ERROR;
- msg.param.code = hcamcorder->error_code;
-
- _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ cam_fd_info->face_info = NULL;
}
- goto DROP_MESSAGE;
- }
- }
+ /* send message - cam_fd_info should be freed by application */
+ msg.id = MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO;
+ msg.param.data = cam_fd_info;
+ msg.param.size = sizeof(MMCamFaceDetectInfo);
+ msg.param.code = 0;
- if (err) {
- g_error_free(err);
- err = NULL;
- }
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
- return GST_BUS_PASS;
+ /* free fd_info allocated by plugin */
+ free(fd_info);
+ fd_info = NULL;
+ } else if (gst_structure_has_name(gst_message_get_structure(message), "camerasrc-Capture")) {
+ int capture_done = FALSE;
-DROP_MESSAGE:
- if (err) {
- g_error_free(err);
- err = NULL;
+ if (gst_structure_get_int(gst_message_get_structure(message), "capture-done", &capture_done)) {
+ if (sc->info_image) {
+ /* play capture sound */
+ _mmcamcorder_sound_solo_play((MMHandleType)hcamcorder, _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE01, FALSE);
+ }
+ }
+ } else {
+ _mmcamcorder_pipeline_cb_message(bus, message, data);
+ }
+ } else {
+ _mmcamcorder_pipeline_cb_message(bus, message, data);
}
gst_message_unref(message);
- message = NULL;
return GST_BUS_DROP;
}
-void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
- mm_sound_focus_state_e focus_state, const char *reason_for_change,
- int option, const char *additional_info, void *user_data)
+static void __mmcamcorder_gst_handle_sync_audio_error(mmf_camcorder_t *hcamcorder, gint err_code)
{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
- int current_state = MM_CAMCORDER_STATE_NONE;
-
- mmf_return_if_fail((MMHandleType)hcamcorder);
-
- current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
- _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
- return;
- }
-
- _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.");
- return;
- }
-
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
-
- /* set value to inform a status is changed 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) ||
- !strncmp(reason_for_change, "ringtone-call", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
- !strncmp(reason_for_change, "voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
- !strncmp(reason_for_change, "call-voice", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_CALL_START;
- } else if (!strncmp(reason_for_change, "alarm", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_ALARM_START;
- } else {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_MEDIA;
- }
-
- if (focus_state == FOCUS_IS_RELEASED) {
- hcamcorder->acquired_focus &= ~focus_type;
-
- _mmcam_dbg_warn("FOCUS is released [type %d, remained focus %d] : Stop pipeline[state:%d]",
- focus_type, hcamcorder->acquired_focus, current_state);
+ _MMCamcorderMsgItem msg;
- __mmcamcorder_force_stop(hcamcorder);
+ mmf_return_if_fail(hcamcorder);
- _mmcam_dbg_warn("Finish opeartion. Pipeline is released");
- } else if (focus_state == FOCUS_IS_ACQUIRED) {
- _MMCamcorderMsgItem msg;
+ switch (err_code) {
+ case GST_RESOURCE_ERROR_OPEN_READ_WRITE:
+ case GST_RESOURCE_ERROR_OPEN_WRITE:
+ MMCAM_LOG_ERROR("audio device [open failed]");
- hcamcorder->acquired_focus |= focus_type;
+ /* post error to application */
+ hcamcorder->error_occurs = TRUE;
+ hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
- _mmcam_dbg_warn("FOCUS is acquired [type %d, new focus %d]",
- focus_type, hcamcorder->acquired_focus);
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ msg.param.code = hcamcorder->error_code;
- msg.id = MM_MESSAGE_READY_TO_RESUME;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
-
- _mmcam_dbg_warn("Finish opeartion");
- } else {
- _mmcam_dbg_warn("unknown focus state %d", focus_state);
+ break;
+ default:
+ MMCAM_LOG_ERROR("unhandled error code[%d]", err_code);
+ break;
}
-
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
-
- _mmcam_dbg_warn("done");
-
- return;
}
-void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
+static void __mmcamcorder_gst_handle_sync_others_error(mmf_camcorder_t *hcamcorder, gint err_code)
{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
+ gboolean b_committing = FALSE;
+ storage_state_e storage_state = STORAGE_STATE_UNMOUNTABLE;
+ _MMCamcorderMsgItem msg;
+ _MMCamcorderSubContext *sc = NULL;
mmf_return_if_fail(hcamcorder);
- _mmcam_dbg_warn("sound signal %d - value %d", signal, value);
-
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_if_fail(sc);
- 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);
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ mmf_return_if_fail(sc->info_video);
+ b_committing = sc->info_video->b_committing;
+ } else {
+ mmf_return_if_fail(sc->info_audio);
+ b_committing = sc->info_audio->b_committing;
+ }
- /* 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;
- }
+ _MMCAMCORDER_LOCK(hcamcorder);
- mm_sound_unregister_focus(hcamcorder->sound_focus_id);
- _mmcam_dbg_warn("unregister sound focus done");
- hcamcorder->sound_focus_id = 0;
+ switch (err_code) {
+ case GST_RESOURCE_ERROR_WRITE:
+ storage_get_state(hcamcorder->storage_info.id, &storage_state);
+ if (storage_state == STORAGE_STATE_REMOVED ||
+ storage_state == STORAGE_STATE_UNMOUNTABLE) {
+ MMCAM_LOG_ERROR("storage was removed! [storage state %d]", storage_state);
+ hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
+ } else {
+ MMCAM_LOG_ERROR("File write error, storage state %d", storage_state);
+ hcamcorder->error_code = MM_ERROR_FILE_WRITE;
}
- 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;
+ if (sc->ferror_send == FALSE) {
+ sc->ferror_send = TRUE;
+ } else {
+ MMCAM_LOG_ERROR("error was already sent");
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+ return;
}
+ break;
+ case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
+ MMCAM_LOG_ERROR("No left space");
+ hcamcorder->error_code = MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
+ break;
+ case GST_RESOURCE_ERROR_OPEN_WRITE:
+ MMCAM_LOG_ERROR("Out of storage");
+ hcamcorder->error_code = MM_ERROR_OUT_OF_STORAGE;
+ break;
+ case GST_RESOURCE_ERROR_SEEK:
+ MMCAM_LOG_ERROR("File read(seek)");
+ hcamcorder->error_code = MM_ERROR_FILE_READ;
+ break;
+ default:
+ MMCAM_LOG_ERROR("Resource error(%d)", err_code);
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_GST_RESOURCE;
+ break;
}
- /* reset flag not to run sound focus related code since now */
- hcamcorder->sound_focus_register = FALSE;
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ if (b_committing) {
+ _MMCAMCORDER_SIGNAL(hcamcorder);
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+ } else {
+ _MMCAMCORDER_UNLOCK(hcamcorder);
- _mmcam_dbg_warn("done");
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ msg.param.code = hcamcorder->error_code;
- return;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ }
}
-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)
+static void __mmcamcorder_handle_gst_sync_error(mmf_camcorder_t *hcamcorder, GstMessage *message)
{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
- int current_state = MM_CAMCORDER_STATE_NONE;
+ GError *err = NULL;
+ gchar *debug_info = NULL;
+ _MMCamcorderSubContext *sc = NULL;
mmf_return_if_fail(hcamcorder);
+ mmf_return_if_fail(message);
- current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (current_state <= MM_CAMCORDER_STATE_NONE ||
- current_state >= MM_CAMCORDER_STATE_NUM) {
- _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
- return;
- }
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_if_fail(sc);
+
+ /* parse error message */
+ gst_message_parse_error(message, &err, &debug_info);
- _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 (debug_info) {
+ MMCAM_LOG_ERROR("GST ERROR : %s", debug_info);
+ g_free(debug_info);
+ debug_info = NULL;
+ }
- if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
- _mmcam_dbg_warn("session flag is UNINTERRUPTIBLE. do nothing.");
+ if (!err) {
+ MMCAM_LOG_ERROR("failed to parse error message");
return;
}
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
+ /* check domain[RESOURCE] and element[AUDIOSRC] */
+ if (err->domain == GST_RESOURCE_ERROR &&
+ GST_ELEMENT_CAST(message->src) == GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst))
+ __mmcamcorder_gst_handle_sync_audio_error(hcamcorder, err->code);
+ else
+ __mmcamcorder_gst_handle_sync_others_error(hcamcorder, err->code);
- /* set value to inform a status is changed by asm */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_FOCUS;
+ g_error_free(err);
+}
- /* check the reason */
- if (!strncmp(reason_for_change, "ringtone-voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
- !strncmp(reason_for_change, "ringtone-call", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
- !strncmp(reason_for_change, "voip", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN) ||
- !strncmp(reason_for_change, "call-voice", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_CALL_START;
- } else if (!strncmp(reason_for_change, "alarm", __MMCAMCORDER_FOCUS_CHANGE_REASON_LEN)) {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_ALARM_START;
- } else {
- hcamcorder->interrupt_code = MM_MSG_CODE_INTERRUPTED_BY_MEDIA;
- }
- if (focus_state == FOCUS_IS_RELEASED) {
- _MMCamcorderMsgItem msg;
+GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
+ _MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_warn("other process's FOCUS is released");
+ mmf_return_val_if_fail(hcamcorder, GST_BUS_DROP);
+ mmf_return_val_if_fail(message, GST_BUS_DROP);
- msg.id = MM_MESSAGE_READY_TO_RESUME;
- _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, GST_BUS_DROP);
+
+ if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
+ MMCAM_LOG_INFO("got EOS from pipeline");
- _mmcam_dbg_warn("Finish opeartion");
- } else if (focus_state == FOCUS_IS_ACQUIRED) {
- _mmcam_dbg_warn("other process's FOCUS is acquired : Stop pipeline[state:%d]", current_state);
+ _MMCAMCORDER_LOCK(hcamcorder);
- __mmcamcorder_force_stop(hcamcorder);
+ sc->bget_eos = TRUE;
+ _MMCAMCORDER_SIGNAL(hcamcorder);
- _mmcam_dbg_warn("Finish opeartion. Pipeline is released");
+ _MMCAMCORDER_UNLOCK(hcamcorder);
+ } else if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
+ __mmcamcorder_handle_gst_sync_error(hcamcorder, message);
} else {
- _mmcam_dbg_warn("unknown focus state %d", focus_state);
+ _mmcamcorder_pipeline_cb_message(bus, message, data);
}
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
-
- _mmcam_dbg_warn("done");
+ gst_message_unref(message);
- return;
+ return GST_BUS_DROP;
}
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
- _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
+ MMCAM_LOG_ERROR("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
return;
}
- _mmcam_dbg_warn("camera policy [%s], current state [%d]", value, current_state);
+ MMCAM_LOG_WARNING("camera policy [%s], current state [%d]", value, current_state);
if (!strcmp(value, "disallowed")) {
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
+ _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
- /* set value to inform a status is changed by DPM */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_DPM;
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_DPM);
- __mmcamcorder_force_stop(hcamcorder);
-
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
-
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
_mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "camera");
}
- _mmcam_dbg_warn("done");
+ MMCAM_LOG_WARNING("done");
return;
}
_MMCamcorderSubContext *sc = NULL;
GstElement *pipeline = NULL;
- _mmcam_dbg_log("handle : %x, type : %d", handle, type);
+ MMCAM_LOG_INFO("handle : %p, type : %d", handle, type);
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
break;
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
+ /* fall through */
default:
ret = _mmcamcorder_create_preview_pipeline(handle);
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)
return ret;
}
+
+ if (hcamcorder->support_extra_preview &&
+ _mmcamcorder_initialize_extra_preview_stream(handle) != MM_ERROR_NONE)
+ MMCAM_LOG_WARNING("connect extra preview stream signal failed");
break;
}
}
#ifdef _MMCAMCORDER_GET_DEVICE_INFO
if (!_mmcamcorder_get_device_info(handle))
- _mmcam_dbg_err("Getting device information error!!");
+ MMCAM_LOG_ERROR("Getting device information error!!");
#endif
- _mmcam_dbg_log("ret[%x]", ret);
+ MMCAM_LOG_INFO("ret[%x]", ret);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("error : destroy pipeline");
+ MMCAM_LOG_ERROR("error : destroy pipeline");
_mmcamcorder_destroy_pipeline(handle, hcamcorder->type);
}
gint i = 0;
int element_num = 0;
_MMCamcorderGstElement *element = NULL;
- GstBus *bus = NULL;
mmf_return_if_fail(hcamcorder);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_if_fail(sc);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Inside each pipeline destroy function, Set GST_STATE_NULL to Main pipeline */
switch (type) {
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
element = sc->element;
element_num = sc->element_num;
- bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
_mmcamcorder_destroy_video_capture_pipeline(handle);
break;
case MM_CAMCORDER_MODE_AUDIO:
element = sc->encode_element;
element_num = sc->encode_element_num;
- bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
_mmcamcorder_destroy_audio_pipeline(handle);
break;
default:
- _mmcam_dbg_err("unknown type %d", type);
+ MMCAM_LOG_ERROR("unknown type %d", type);
break;
}
- _mmcam_dbg_log("Pipeline clear!!");
-
- /* Remove pipeline message callback */
- if (hcamcorder->pipeline_cb_event_id > 0) {
- g_source_remove(hcamcorder->pipeline_cb_event_id);
- hcamcorder->pipeline_cb_event_id = 0;
- }
-
- /* Remove remained message in bus */
- if (bus) {
- 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_msg = NULL;
- }
- gst_object_unref(bus);
- bus = NULL;
- }
+ MMCAM_LOG_INFO("Pipeline clear!!");
/* checking unreleased element */
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]",
+ MMCAM_LOG_WARNING("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)));
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);
+ MMCAM_LOG_WARNING("The element[%d] is still alive, check it", element[i].id);
}
element[i].id = _MMCAMCORDER_NONE;
}
-int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state)
-{
- GstStateChangeReturn setChangeReturn = GST_STATE_CHANGE_FAILURE;
-
- _MMCAMCORDER_LOCK_GST_STATE(handle);
- setChangeReturn = gst_element_set_state(pipeline, target_state);
- _MMCAMCORDER_UNLOCK_GST_STATE(handle);
-
- return setChangeReturn;
-}
-
-
-#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
-static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data)
-{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(data);
-
- mmf_return_val_if_fail(hcamcorder, FALSE);
-
- _mmcam_dbg_log("");
-
- _mmcamcorder_set_attribute_to_camsensor((MMHandleType)hcamcorder);
-
- /* initialize */
- hcamcorder->setting_event_id = 0;
-
- _mmcam_dbg_log("Done");
-
- /* once */
- return FALSE;
-}
-#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
-
-
int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state)
{
unsigned int k = 0;
mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst == pipeline) {
- _mmcam_dbg_log("Set state to %d - PREVIEW PIPELINE", target_state);
+ MMCAM_LOG_INFO("Set state to %d - PREVIEW PIPELINE", target_state);
state_lock = &_MMCAMCORDER_GET_GST_STATE_LOCK(handle);
} else {
- _mmcam_dbg_log("Set state to %d - ENDODE PIPELINE", target_state);
+ MMCAM_LOG_INFO("Set state to %d - ENDODE PIPELINE", target_state);
state_lock = &_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle);
}
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_LOG_INFO("gst_element_set_state[%d] return %d", target_state, setChangeReturn);
if (setChangeReturn != GST_STATE_CHANGE_FAILURE) {
getChangeReturn = gst_element_get_state(pipeline, &pipeline_state, NULL, get_timeout);
switch (getChangeReturn) {
case GST_STATE_CHANGE_NO_PREROLL:
- _mmcam_dbg_log("status=GST_STATE_CHANGE_NO_PREROLL.");
+ MMCAM_LOG_INFO("status=GST_STATE_CHANGE_NO_PREROLL.");
/* fall through */
case GST_STATE_CHANGE_SUCCESS:
/* if we reached the final target state, exit */
if (pipeline_state == target_state) {
- _mmcam_dbg_log("Set state to %d - DONE", target_state);
+ MMCAM_LOG_INFO("Set state to %d - DONE", target_state);
g_mutex_unlock(state_lock);
return MM_ERROR_NONE;
}
break;
case GST_STATE_CHANGE_ASYNC:
- _mmcam_dbg_log("status=GST_STATE_CHANGE_ASYNC.");
+ MMCAM_LOG_INFO("status=GST_STATE_CHANGE_ASYNC.");
break;
default:
g_mutex_unlock(state_lock);
- _mmcam_dbg_log("status=GST_STATE_CHANGE_FAILURE.");
+ MMCAM_LOG_INFO("status=GST_STATE_CHANGE_FAILURE.");
return MM_ERROR_CAMCORDER_GST_STATECHANGE;
}
g_mutex_unlock(state_lock);
- _mmcam_dbg_err("timeout of gst_element_get_state()!!");
+ MMCAM_LOG_ERROR("timeout of gst_element_get_state()!!");
return MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
}
g_mutex_unlock(state_lock);
- _mmcam_dbg_err("Failure. gst_element_set_state timeout!!");
+ MMCAM_LOG_ERROR("Failure. gst_element_set_state timeout!!");
return MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
}
}
-void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder)
+void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system)
{
int i = 0;
int loop = 0;
int result = MM_ERROR_NONE;
int cmd_try_count = 0;
int current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderMsgItem msg;
mmf_return_if_fail(hcamcorder);
do {
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
if (cmd_try_count++ < __MMCAMCORDER_FORCE_STOP_TRY_COUNT) {
- _mmcam_dbg_warn("Another command is running. try again after %d ms", __MMCAMCORDER_FORCE_STOP_WAIT_TIME/1000);
+ MMCAM_LOG_WARNING("Another command is running. try again after %d ms", __MMCAMCORDER_FORCE_STOP_WAIT_TIME/1000);
usleep(__MMCAMCORDER_FORCE_STOP_WAIT_TIME);
} else {
- _mmcam_dbg_err("wait timeout");
+ MMCAM_LOG_ERROR("wait timeout");
break;
}
} else {
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- _mmcam_dbg_warn("Force STOP MMFW Camcorder");
+ MMCAM_LOG_WARNING("Force STOP MMFW Camcorder by %d", state_change_by_system);
+
+ /* set state_change_by_system for state change message */
+ hcamcorder->state_change_by_system = state_change_by_system;
+
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ MMCAM_LOG_WARNING("send state change started message to notify");
+
+ memset(&msg, 0x0, sizeof(_MMCamcorderMsgItem));
+
+ switch (state_change_by_system) {
+ case _MMCAMCORDER_STATE_CHANGE_BY_RM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_RM;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_DPM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_SECURITY;
+ break;
+ default:
+ break;
+ }
+
+ if (msg.id != 0) {
+ msg.param.state.code = hcamcorder->interrupt_code;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ } else {
+ MMCAM_LOG_ERROR("should not be reached here %d", state_change_by_system);
+ }
+ }
for (loop = 0 ; current_state > MM_CAMCORDER_STATE_NULL && loop < __MMCAMCORDER_CMD_ITERATE_MAX * 3 ; loop++) {
itr_cnt = __MMCAMCORDER_CMD_ITERATE_MAX;
mmf_return_if_fail(sc);
mmf_return_if_fail((info = sc->info_image));
- _mmcam_dbg_warn("Stop capturing.");
+ MMCAM_LOG_WARNING("Stop capturing.");
- /* if caturing isn't finished, waiting for 2 sec to finish real capture operation. check 'info->capturing'. */
+ /* if capturing 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);
usleep(100000);
if (i == 20)
- _mmcam_dbg_err("Timeout. Can't check stop capturing.");
+ MMCAM_LOG_ERROR("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);
+ MMCAM_LOG_WARNING("Can't stop capturing.(%x)", result);
break;
}
case MM_CAMCORDER_STATE_RECORDING:
case MM_CAMCORDER_STATE_PAUSED:
{
- _mmcam_dbg_warn("Stop recording.");
+ MMCAM_LOG_WARNING("Stop recording.");
while ((itr_cnt--) && ((result = _mmcamcorder_commit((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
- _mmcam_dbg_warn("Can't commit.(%x), cancel it.", result);
+ MMCAM_LOG_WARNING("Can't commit.(%x), cancel it.", result);
_mmcamcorder_cancel((MMHandleType)hcamcorder);
}
}
case MM_CAMCORDER_STATE_PREPARE:
{
- _mmcam_dbg_warn("Stop preview.");
+ MMCAM_LOG_WARNING("Stop preview.");
- while ((itr_cnt--) && ((result = _mmcamcorder_stop((MMHandleType)hcamcorder)) != MM_ERROR_NONE)) {
- _mmcam_dbg_warn("Can't stop preview.(%x)", result);
- }
+ while ((itr_cnt--) && ((result = _mmcamcorder_stop((MMHandleType)hcamcorder)) != MM_ERROR_NONE))
+ MMCAM_LOG_WARNING("Can't stop preview.(%x)", result);
break;
}
case MM_CAMCORDER_STATE_READY:
{
- _mmcam_dbg_warn("unrealize");
+ MMCAM_LOG_WARNING("unrealize");
- if ((result = _mmcamcorder_unrealize((MMHandleType)hcamcorder)) != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Can't unrealize.(%x)", result);
- }
+ if ((result = _mmcamcorder_unrealize((MMHandleType)hcamcorder)) != MM_ERROR_NONE)
+ MMCAM_LOG_WARNING("Can't unrealize.(%x)", result);
break;
}
- case MM_CAMCORDER_STATE_NULL:
default:
- _mmcam_dbg_warn("Already stopped.");
+ MMCAM_LOG_WARNING("Already stopped.");
break;
}
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
}
- _mmcam_dbg_warn("Done.");
+ /* restore */
+ hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+
+ MMCAM_LOG_WARNING("Done.");
return;
}
gchar *msg_src_element = NULL;
_MMCamcorderSubContext *sc = NULL;
- return_val_if_fail(hcamcorder, FALSE);
- return_val_if_fail(error, FALSE);
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+ mmf_return_val_if_fail(error, FALSE);
+
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, FALSE);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("error code %d", error->code);
+
+ mmf_return_val_if_fail(hcamcorder->state >= MM_CAMCORDER_STATE_READY, FALSE);
/* filtering filesink related errors */
if (hcamcorder->state == MM_CAMCORDER_STATE_RECORDING &&
- (error->code == GST_RESOURCE_ERROR_WRITE || error->code == GST_RESOURCE_ERROR_SEEK)) {
+ (error->code == GST_RESOURCE_ERROR_WRITE || error->code == GST_RESOURCE_ERROR_SEEK)) {
if (sc->ferror_count == 2 && sc->ferror_send == FALSE) {
sc->ferror_send = TRUE;
msg.param.code = __mmcamcorder_gst_handle_resource_error(handle, error->code, message);
} else {
sc->ferror_count++;
- _mmcam_dbg_warn("Skip error");
+ MMCAM_LOG_WARNING("Skip error");
return TRUE;
}
}
} else if (error->domain == GST_STREAM_ERROR) {
msg.param.code = __mmcamcorder_gst_handle_stream_error(handle, error->code, message);
} else {
- _mmcam_dbg_warn("This error domain is not defined.");
+ MMCAM_LOG_WARNING("This error domain is not defined.");
/* we treat system error as an internal error */
msg.param.code = MM_ERROR_CAMCORDER_INTERNAL;
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]",
+ MMCAM_LOG_ERROR("-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);
} else {
- _mmcam_dbg_err("Domain : [%s] Error : [%s] Code : [%d] is tranlated to error code : [0x%x]",
+ MMCAM_LOG_ERROR("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);
}
#ifdef _MMCAMCORDER_SKIP_GST_FLOW_ERROR
/* Check whether send this error to application */
if (msg.param.code == MM_ERROR_CAMCORDER_GST_FLOW_ERROR) {
- _mmcam_dbg_log("We got the error. But skip it.");
+ MMCAM_LOG_INFO("We got the error. But skip it.");
return TRUE;
}
#endif /* _MMCAMCORDER_SKIP_GST_FLOW_ERROR */
_MMCamcorderSubContext *sc = NULL;
GstElement *element = NULL;
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
static gint __mmcamcorder_gst_handle_library_error(MMHandleType handle, int code, GstMessage *message)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Specific plugin - NONE */
case GST_LIBRARY_ERROR_SETTINGS:
case GST_LIBRARY_ERROR_ENCODE:
default:
- _mmcam_dbg_err("Library error(%d)", code);
+ MMCAM_LOG_ERROR("Library error(%d)", code);
return MM_ERROR_CAMCORDER_GST_LIBRARY;
}
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Specific plugin */
/* video sink */
element = GST_ELEMENT_CAST(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst);
if (GST_ELEMENT_CAST(message->src) == element) {
if (code == GST_RESOURCE_ERROR_WRITE) {
- _mmcam_dbg_err("Display device [Off]");
+ MMCAM_LOG_ERROR("Display device [Off]");
return MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF;
} else {
- _mmcam_dbg_err("Display device [General(%d)]", code);
+ MMCAM_LOG_ERROR("Display device [General(%d)]", code);
}
}
int ret = MM_ERROR_NONE;
int current_state = MM_CAMCORDER_STATE_NONE;
- _mmcam_dbg_err("DPM mic DISALLOWED - current state %d", current_state);
+ MMCAM_LOG_ERROR("DPM mic DISALLOWED - current state %d", current_state);
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
+ _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_DPM;
ret = _mmcamcorder_commit((MMHandleType)hcamcorder);
- _mmcam_dbg_log("commit result : 0x%x", ret);
+ MMCAM_LOG_INFO("commit result : 0x%x", ret);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("commit failed, cancel it");
+ MMCAM_LOG_ERROR("commit failed, cancel it");
ret = _mmcamcorder_cancel((MMHandleType)hcamcorder);
}
}
/* restore value */
hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
_mmcamcorder_request_dpm_popup(hcamcorder->gdbus_conn, "microphone");
element = GST_ELEMENT_CAST(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
if (GST_ELEMENT_CAST(message->src) == element) {
if (code == GST_RESOURCE_ERROR_FAILED) {
- _mmcam_dbg_err("Encoder [Resource error]");
+ MMCAM_LOG_ERROR("Encoder [Resource error]");
return MM_ERROR_CAMCORDER_ENCODER_BUFFER;
} else {
- _mmcam_dbg_err("Encoder [General(%d)]", code);
+ MMCAM_LOG_ERROR("Encoder [General(%d)]", code);
return MM_ERROR_CAMCORDER_ENCODER;
}
}
/* General */
switch (code) {
case GST_RESOURCE_ERROR_WRITE:
- _mmcam_dbg_err("File write error");
+ MMCAM_LOG_ERROR("File write error");
return MM_ERROR_FILE_WRITE;
case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
- _mmcam_dbg_err("No left space");
+ MMCAM_LOG_ERROR("No left space");
return MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
case GST_RESOURCE_ERROR_OPEN_WRITE:
- _mmcam_dbg_err("Out of storage");
+ MMCAM_LOG_ERROR("Out of storage");
return MM_ERROR_OUT_OF_STORAGE;
case GST_RESOURCE_ERROR_SEEK:
- _mmcam_dbg_err("File read(seek)");
+ MMCAM_LOG_ERROR("File read(seek)");
return MM_ERROR_FILE_READ;
case GST_RESOURCE_ERROR_NOT_FOUND:
case GST_RESOURCE_ERROR_FAILED:
case GST_RESOURCE_ERROR_SYNC:
case GST_RESOURCE_ERROR_SETTINGS:
default:
- _mmcam_dbg_err("Resource error(%d)", code);
+ MMCAM_LOG_ERROR("Resource error(%d)", code);
return MM_ERROR_CAMCORDER_GST_RESOURCE;
}
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Specific plugin */
/* video encoder */
if (GST_ELEMENT_CAST(message->src) == element) {
switch (code) {
case GST_STREAM_ERROR_WRONG_TYPE:
- _mmcam_dbg_err("Video encoder [wrong stream type]");
+ MMCAM_LOG_ERROR("Video encoder [wrong stream type]");
return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
case GST_STREAM_ERROR_ENCODE:
- _mmcam_dbg_err("Video encoder [encode error]");
+ MMCAM_LOG_ERROR("Video encoder [encode error]");
return MM_ERROR_CAMCORDER_ENCODER_WORKING;
case GST_STREAM_ERROR_FAILED:
- _mmcam_dbg_err("Video encoder [stream failed]");
+ MMCAM_LOG_ERROR("Video encoder [stream failed]");
return MM_ERROR_CAMCORDER_ENCODER_WORKING;
default:
- _mmcam_dbg_err("Video encoder [General(%d)]", code);
+ MMCAM_LOG_ERROR("Video encoder [General(%d)]", code);
return MM_ERROR_CAMCORDER_ENCODER;
}
}
/* General plugin */
switch (code) {
case GST_STREAM_ERROR_FORMAT:
- _mmcam_dbg_err("General [negotiation error(%d)]", code);
+ MMCAM_LOG_ERROR("General [negotiation error(%d)]", code);
return MM_ERROR_CAMCORDER_GST_NEGOTIATION;
case GST_STREAM_ERROR_FAILED:
- _mmcam_dbg_err("General [flow error(%d)]", code);
+ MMCAM_LOG_ERROR("General [flow error(%d)]", code);
return MM_ERROR_CAMCORDER_GST_FLOW_ERROR;
case GST_STREAM_ERROR_TYPE_NOT_FOUND:
case GST_STREAM_ERROR_DECODE:
case GST_STREAM_ERROR_DECRYPT_NOKEY:
case GST_STREAM_ERROR_WRONG_TYPE:
default:
- _mmcam_dbg_err("General [error(%d)]", code);
+ MMCAM_LOG_ERROR("General [error(%d)]", code);
return MM_ERROR_CAMCORDER_GST_STREAM;
}
}
gchar *debug = NULL;
GError *err = NULL;
- return_val_if_fail(hcamcorder, FALSE);
- return_val_if_fail(error, FALSE);
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+ mmf_return_val_if_fail(error, FALSE);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
gst_message_parse_warning(message, &err, &debug);
if (error->domain == GST_CORE_ERROR) {
- _mmcam_dbg_warn("GST warning: GST_CORE domain");
+ MMCAM_LOG_WARNING("GST warning: GST_CORE domain");
} else if (error->domain == GST_LIBRARY_ERROR) {
- _mmcam_dbg_warn("GST warning: GST_LIBRARY domain");
+ MMCAM_LOG_WARNING("GST warning: GST_LIBRARY domain");
} else if (error->domain == GST_RESOURCE_ERROR) {
- _mmcam_dbg_warn("GST warning: GST_RESOURCE domain");
+ MMCAM_LOG_WARNING("GST warning: GST_RESOURCE domain");
__mmcamcorder_gst_handle_resource_warning(handle, message, error);
} else if (error->domain == GST_STREAM_ERROR) {
- _mmcam_dbg_warn("GST warning: GST_STREAM domain");
+ MMCAM_LOG_WARNING("GST warning: GST_STREAM domain");
} else {
- _mmcam_dbg_warn("This error domain(%d) is not defined.", error->domain);
+ MMCAM_LOG_WARNING("This error domain(%d) is not defined.", error->domain);
}
if (err != NULL) {
err = NULL;
}
if (debug != NULL) {
- _mmcam_dbg_err("Debug: %s", debug);
+ MMCAM_LOG_ERROR("Debug: %s", debug);
g_free(debug);
debug = NULL;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Special message handling */
/* video source */
if (GST_ELEMENT_CAST(message->src) == element) {
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]",
+ MMCAM_LOG_WARNING("-Msg src:[%s] Domain:[%s] Error:[%s]",
msg_src_element, g_quark_to_string(error->domain), error->message);
return MM_ERROR_NONE;
}
case GST_RESOURCE_ERROR_SYNC:
case GST_RESOURCE_ERROR_SETTINGS:
default:
- _mmcam_dbg_warn("General GST warning(%d)", error->code);
+ MMCAM_LOG_WARNING("General GST warning(%d)", error->code);
break;
}
mmf_return_if_fail(hcamcorder && object_name && interface_name && signal_name);
- _mmcam_dbg_log("object %s, interface %s, signal %s, value %d",
+ MMCAM_LOG_INFO("object %s, interface %s, signal %s, value %d",
object_name, interface_name, signal_name, value);
_mmcamcorder_emit_dbus_signal(hcamcorder->gdbus_conn, object_name, interface_name, signal_name, value);
}
-#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)
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
+ mm_resource_manager_res_h res, void *user_data)
+{
+ mmf_camcorder_t *hcamcorder = (mmf_camcorder_t *) user_data;
+
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+
+ MMCAM_LOG_WARNING("enter");
+
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ /* set flag for resource release callback */
+ hcamcorder->is_release_cb_calling = TRUE;
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
+ _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
+
+ if (res == hcamcorder->video_encoder_resource) {
+ /* Stop video recording */
+ if (_mmcamcorder_commit((MMHandleType)hcamcorder) != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("commit failed, cancel it");
+ _mmcamcorder_cancel((MMHandleType)hcamcorder);
+ }
+ } else {
+ /* Stop camera */
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
+ }
+
+ _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
+
+ _MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
+
+ if (res == hcamcorder->camera_resource)
+ hcamcorder->camera_resource = NULL;
+ else if (res == hcamcorder->video_overlay_resource)
+ hcamcorder->video_overlay_resource = NULL;
+ else if (res == hcamcorder->video_encoder_resource)
+ hcamcorder->video_encoder_resource = NULL;
+
+ /* restore flag for resource release callback */
+ hcamcorder->is_release_cb_calling = FALSE;
+
+ _MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
+
+ MMCAM_LOG_WARNING("leave");
+
+ return TRUE;
+}
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
+int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
+ int ret = MM_ERROR_NONE;
int current_state = MM_CAMCORDER_STATE_NONE;
- rm_cb_result cb_res = RM_CB_RESULT_OK;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderMsgItem msg;
- mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
- current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (current_state <= MM_CAMCORDER_STATE_NONE || current_state >= MM_CAMCORDER_STATE_NUM) {
- _mmcam_dbg_err("Abnormal state. Or null handle. (%p, %d)", hcamcorder, current_state);
+ MMCAM_LOG_WARNING("storage state %d", storage_state);
+
+ /* check storage state */
+ if (storage_state != STORAGE_STATE_UNMOUNTABLE &&
+ storage_state != STORAGE_STATE_REMOVED) {
+ MMCAM_LOG_WARNING("nothing to do");
+ return MM_ERROR_NONE;
}
- _MMCAMCORDER_LOCK_ASM(hcamcorder);
+ _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
- /* set value to inform a status is changed by RM */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_BY_RM;
+ /* check recording state */
+ current_state = _mmcamcorder_get_state(handle);
- /* set RM event code for sending it to application */
- hcamcorder->interrupt_code = event_src;
+ MMCAM_LOG_WARNING("current_state %d", current_state);
- _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
- switch (event_src) {
- case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
- case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
- __mmcamcorder_force_stop(hcamcorder);
- break;
- default:
- break;
+ if (current_state < MM_CAMCORDER_STATE_RECORDING) {
+ MMCAM_LOG_WARNING("no recording now");
+ goto _MANAGE_DONE;
}
- /* restore value */
- hcamcorder->state_change_by_system = _MMCAMCORDER_STATE_CHANGE_NORMAL;
+ /* check storage type */
+ if (hcamcorder->storage_info.type != STORAGE_TYPE_EXTERNAL) {
+ MMCAM_LOG_WARNING("external storage is not used");
+ goto _MANAGE_DONE;
+ }
+
+ /* cancel recording */
+ ret = _mmcamcorder_cancel(handle);
+
+ /* send error message */
+ msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+ msg.param.code = MM_ERROR_OUT_OF_STORAGE;
- _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+ _mmcamcorder_send_message(handle, &msg);
- return cb_res;
+_MANAGE_DONE:
+ _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
+
+ MMCAM_LOG_WARNING("done - ret 0x%x", ret);
+
+ return ret;
}
-#endif /* _MMCAMCORDER_RM_SUPPORT */