/* init for sound thread */
g_mutex_init(&hcamcorder->task_thread_lock);
g_cond_init(&hcamcorder->task_thread_cond);
- hcamcorder->task_thread_state = _MMCAMCORDER_SOUND_STATE_NONE;
+ hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_NONE;
+
+ if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
+ /* init for gdbus */
+ g_mutex_init(&hcamcorder->gdbus_info_sound.sync_mutex);
+ g_cond_init(&hcamcorder->gdbus_info_sound.sync_cond);
+ g_mutex_init(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
+ g_cond_init(&hcamcorder->gdbus_info_solo_sound.sync_cond);
+ }
/* create task thread */
hcamcorder->task_thread = g_thread_try_new("MMCAM_TASK_THREAD",
goto _ERR_DEFAULT_VALUE_INIT;
}
+ /* init for gdbus */
+ hcamcorder->gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ if (hcamcorder->gdbus_conn == NULL) {
+ _mmcam_dbg_err("failed to get gdbus");
+ ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
/* get DPM handle for camera/microphone restriction */
hcamcorder->dpm_handle = dpm_manager_create();
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);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_NULL;
#ifdef _MMCAMCORDER_RM_SUPPORT
int iret = RM_OK;
#endif /* _MMCAMCORDER_RM_SUPPORT */
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_NULL) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
g_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);
+ }
+
+ g_object_unref(hcamcorder->gdbus_conn);
+ hcamcorder->gdbus_conn = NULL;
+
/* Release handle */
memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
free(hcamcorder);
int ret = MM_ERROR_NONE;
int ret_sound = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_NULL;
- int state_TO = MM_CAMCORDER_STATE_READY;
int display_surface_type = MM_DISPLAY_SURFACE_OVERLAY;
int pid_for_sound_focus = 0;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *socket_path = NULL;
int socket_path_len;
#ifdef _MMCAMCORDER_RM_SUPPORT
- int iret = RM_OK;
+ int iret = RM_OK;
#endif /* _MMCAMCORDER_RM_SUPPORT */
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_NULL) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
/* acquire sound focus */
_mmcam_dbg_log("PAUSE_OTHERS - acquire sound focus");
- ret_sound = mm_sound_acquire_focus(0, FOCUS_FOR_BOTH, NULL);
+ ret_sound = mm_sound_acquire_focus(hcamcorder->sound_focus_id, FOCUS_FOR_BOTH, NULL);
if (ret_sound != MM_ERROR_NONE) {
_mmcam_dbg_err("mm_sound_acquire_focus failed [0x%x]", ret_sound);
#ifdef _MMCAMCORDER_RM_SUPPORT
int preview_format = MM_PIXEL_FORMAT_NV12;
int qret = RM_OK;
- int qret_avail = RM_OK;
+ int qret_avail = 0; /* 0: not available, 1: available */
rm_consumer_info rci;
int app_pid = 0;
int resource_count = 0;
qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
- if (qret != RM_OK || qret_avail != RM_OK) {
+ if (qret != RM_OK || qret_avail != 1) {
_mmcam_dbg_log("Resource manager main device request fail");
resource_count = 0;
goto _ERR_CAMCORDER_CMD;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
}
if (hcamcorder->acquired_focus > 0) {
- mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL);
+ 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;
}
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_READY;
- int state_TO = MM_CAMCORDER_STATE_NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_READY) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
if (hcamcorder->acquired_focus > 0) {
- mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL);
+ 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);
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_NULL);
return MM_ERROR_NONE;
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_READY;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_READY) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
hcamcorder->error_code = MM_ERROR_NONE;
/* set attributes related sensor */
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- /* init for gdbus */
- hcamcorder->gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
- if (hcamcorder->gdbus_conn == NULL) {
- _mmcam_dbg_err("failed to get gdbus");
- ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- g_mutex_init(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_init(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_init(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_init(&hcamcorder->gdbus_info_solo_sound.sync_cond);
-
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO)
_mmcamcorder_set_attribute_to_camsensor(handle);
- }
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_PREVIEW_START);
if (ret != MM_ERROR_NONE) {
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_PREPARE;
- int state_TO = MM_CAMCORDER_STATE_READY;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_PREPARE) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_READY);
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ /* unsubscribe remained unsubscribed signal */
g_mutex_lock(&hcamcorder->gdbus_info_sound.sync_mutex);
if (hcamcorder->gdbus_info_sound.subscribe_id > 0) {
_mmcam_dbg_warn("subscribe_id[%u] is remained. remove it.", hcamcorder->gdbus_info_sound.subscribe_id);
g_dbus_connection_signal_unsubscribe(hcamcorder->gdbus_conn, hcamcorder->gdbus_info_solo_sound.subscribe_id);
}
g_mutex_unlock(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
-
- g_object_unref(hcamcorder->gdbus_conn);
- hcamcorder->gdbus_conn = NULL;
-
- g_mutex_clear(&hcamcorder->gdbus_info_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_sound.sync_cond);
- g_mutex_clear(&hcamcorder->gdbus_info_solo_sound.sync_mutex);
- g_cond_clear(&hcamcorder->gdbus_info_solo_sound.sync_cond);
}
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
int state_FROM_0 = MM_CAMCORDER_STATE_PREPARE;
int state_FROM_1 = MM_CAMCORDER_STATE_RECORDING;
int state_FROM_2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_CAPTURING;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
/* Do not change state when recording snapshot capture */
if (state == state_FROM_0)
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_CAPTURING);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_CAPTURING;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_mmcam_dbg_log("");
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_CAPTURING) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_PREPARE;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_RECORDING;
int dpm_mic_state = DPM_ALLOWED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_PREPARE && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_RECORDING);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM = MM_CAMCORDER_STATE_RECORDING;
- int state_TO = MM_CAMCORDER_STATE_PAUSED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM) {
+ if (state != MM_CAMCORDER_STATE_RECORDING) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PAUSED);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_RECORDING;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
- _mmcamcorder_set_state(handle, state_TO);
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_NONE;
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
- int state_FROM1 = MM_CAMCORDER_STATE_RECORDING;
- int state_FROM2 = MM_CAMCORDER_STATE_PAUSED;
- int state_TO = MM_CAMCORDER_STATE_PREPARE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
}
state = _mmcamcorder_get_state(handle);
- if (state != state_FROM1 && state != state_FROM2) {
+ if (state != MM_CAMCORDER_STATE_RECORDING && state != MM_CAMCORDER_STATE_PAUSED) {
_mmcam_dbg_err("Wrong state(%d)", state);
ret = MM_ERROR_CAMCORDER_INVALID_STATE;
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
if (ret != MM_ERROR_NONE)
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- _mmcamcorder_set_state(handle, state_TO);
+ _mmcamcorder_set_state(handle, MM_CAMCORDER_STATE_PREPARE);
_MMCAMCORDER_UNLOCK_CMD(hcamcorder);
void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
mm_sound_focus_state_e focus_state, const char *reason_for_change,
- const char *additional_info, void *user_data)
+ int option, const char *additional_info, void *user_data)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(user_data);
int current_state = MM_CAMCORDER_STATE_NONE;
return MM_ERROR_NONE;
}
-int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps)
+
+void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
+ const char *interface_name, const char *signal_name, int value)
{
- GstPad *pad = NULL;
- GstCaps *sink_caps = NULL;
- _MMCamcorderSubContext *sc = NULL;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- _mmcam_dbg_warn("Entered ");
- pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "sink");
- if (!pad) {
- _mmcam_dbg_err("static pad is NULL");
- return MM_ERROR_CAMCORDER_INVALID_STATE;
- }
+ mmf_return_if_fail(hcamcorder && object_name && interface_name && signal_name);
- sink_caps = gst_pad_get_current_caps(pad);
- gst_object_unref(pad);
- if (!sink_caps) {
- _mmcam_dbg_err("fail to get caps");
- return MM_ERROR_CAMCORDER_INVALID_STATE;
- }
+ _mmcam_dbg_log("object %s, interface %s, signal %s, value %d",
+ object_name, interface_name, signal_name, value);
- *caps = gst_caps_to_string(sink_caps);
- _mmcam_dbg_err("video caps : %s", *caps);
- gst_caps_unref(sink_caps);
+ _mmcamcorder_emit_dbus_signal(hcamcorder->gdbus_conn, object_name, interface_name, signal_name, value);
- return MM_ERROR_NONE;
+ return;
}
+
+
#ifdef _MMCAMCORDER_RM_SUPPORT
rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
rm_device_request_s *info, void* cb_data)