X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmm_camcorder_attribute.c;h=41b288e5bdf9c27c97e70e1bc7df865056b368dd;hb=48a734a49365f9cdc7ae77cdc9e666973be3766c;hp=e67998576d4f4a4b9b716d17bc3f17b43c757fa1;hpb=58b89b47284e82422eb4b49e13311bf25444f5f6;p=platform%2Fcore%2Fmultimedia%2Flibmm-camcorder.git diff --git a/src/mm_camcorder_attribute.c b/src/mm_camcorder_attribute.c index e679985..41b288e 100644 --- a/src/mm_camcorder_attribute.c +++ b/src/mm_camcorder_attribute.c @@ -29,7 +29,6 @@ #include #include #include -#include /*----------------------------------------------------------------------- | MACRO DEFINITIONS: | @@ -1534,17 +1533,6 @@ _mmcamcorder_alloc_attribute(MMHandleType handle, MMCamPreset *info) NULL, }, { - MM_CAM_SOUND_STREAM_TYPE, - "sound-stream-type", - MMF_VALUE_TYPE_STRING, - MM_ATTRS_FLAG_RW, - {(void*)NULL}, - MM_ATTRS_VALID_TYPE_NONE, - {0}, - {0}, - NULL, - }, - { MM_CAM_SOUND_STREAM_INDEX, "sound-stream-index", MMF_VALUE_TYPE_INT, @@ -1553,6 +1541,17 @@ _mmcamcorder_alloc_attribute(MMHandleType handle, MMCamPreset *info) MM_ATTRS_VALID_TYPE_INT_RANGE, {.int_min = -1}, {.int_max = _MMCAMCORDER_MAX_INT}, + NULL, + }, + { + MM_CAM_SOUND_STREAM_TYPE, + "sound-stream-type", + MMF_VALUE_TYPE_STRING, + MM_ATTRS_FLAG_RW, + {(void*)NULL}, + MM_ATTRS_VALID_TYPE_NONE, + {0}, + {0}, _mmcamcorder_commit_sound_stream_info, }, { @@ -1576,6 +1575,17 @@ _mmcamcorder_alloc_attribute(MMHandleType handle, MMCamPreset *info) {0}, {0}, NULL, + }, + { + MM_CAM_GDBUS_CONNECTION, + "gdbus-connection", + MMF_VALUE_TYPE_DATA, + MM_ATTRS_FLAG_RW, + {(void*)NULL}, + MM_ATTRS_VALID_TYPE_NONE, + {0}, + {0}, + NULL, } }; @@ -1720,6 +1730,7 @@ _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const cha MMHandleType attrs = 0; int ret = MM_ERROR_NONE; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + va_list var_args_copy; mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT); /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/ @@ -1729,6 +1740,9 @@ _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const cha return MM_ERROR_CAMCORDER_CMD_IS_RUNNING; } + /* copy var_args to keep original var_args */ + va_copy(var_args_copy, var_args); + attrs = MMF_CAMCORDER_ATTRS(handle); if (attrs) { ret = __mmcamcorder_check_valid_pair(handle, err_attr_name, attribute_name, var_args); @@ -1739,9 +1753,12 @@ _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const cha if (ret == MM_ERROR_NONE) { hcamcorder->error_code = MM_ERROR_NONE; - ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args); + /* In 64bit environment, unexpected result is returned if var_args is used again. */ + ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args_copy); } + va_end(var_args_copy); + _MMCAMCORDER_UNLOCK_CMD(handle); if (ret != MM_ERROR_NONE) { @@ -3783,11 +3800,11 @@ bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const m if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) { _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val); - return TRUE; } else { - _mmcam_dbg_warn("Commit : This element [%s] does not support display mode", videosink_name); - return FALSE; + _mmcam_dbg_warn("[%s] does not support display mode, but no error", videosink_name); } + + return TRUE; } @@ -3877,11 +3894,11 @@ bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, cons !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) { MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val); _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val); - return TRUE; } else { - _mmcam_dbg_warn("videosink[%s] does not support VISIBLE.", videosink_name); - return FALSE; + _mmcam_dbg_warn("[%s] does not support VISIBLE, but no error", videosink_name); } + + return TRUE; } @@ -3922,11 +3939,11 @@ bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_i !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) { method = value->value.i_val; MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method); - return TRUE; } else { - _mmcam_dbg_warn("videosink[%s] does not support geometry method.", videosink_name); - return FALSE; + _mmcam_dbg_warn("[%s] does not support geometry method, but no error", videosink_name); } + + return TRUE; } @@ -4522,41 +4539,64 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, new_pid = value->value.i_val; - _mmcam_dbg_log("Commit : pid %d, current sound_focus_register %d, sound_focus_id %d", - new_pid, hcamcorder->sound_focus_register, hcamcorder->sound_focus_id); + _mmcam_dbg_log("Commit : pid %d, current focus id %d, subscribe id %u", + new_pid, hcamcorder->sound_focus_id, hcamcorder->sound_focus_subscribe_id); + + /* unregister sound focus and unsubscribe sound signal before set new one */ + 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; + } - /* unregister sound focus before set new one */ - if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) { - if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) { - _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id); + ret = _mm_session_util_read_information(new_pid, &hcamcorder->session_type, &hcamcorder->session_flags); + if (ret == MM_ERROR_NONE) { + if (hcamcorder->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM) { + hcamcorder->sound_focus_register = FALSE; + _mmcam_dbg_warn("no need to use sound focus internally"); } else { - _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id); + ret = mm_sound_focus_get_id(&hcamcorder->sound_focus_id); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_focus_get_id failed"); + hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED; + return FALSE; + } + + ret = mm_sound_register_focus_for_session(hcamcorder->sound_focus_id, + new_pid, "media", _mmcamcorder_sound_focus_cb, hcamcorder); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_register_focus_for_session failed 0x%x", ret); + hcamcorder->sound_focus_id = 0; + hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED; + return FALSE; + } + + hcamcorder->sound_focus_register = TRUE; + + _mmcam_dbg_log("mm_sound_register_focus_for_session done - id %d, session type %d, flags 0x%x", + hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags); } } else { - _mmcam_dbg_log("no need to unregister sound focus"); - } + hcamcorder->session_type = 0; + hcamcorder->session_flags = 0; + hcamcorder->sound_focus_register = TRUE; - /* register sound focus */ - if (hcamcorder->sound_focus_register) { - hcamcorder->sound_focus_id = 0; - if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) { - _mmcam_dbg_err("mm_sound_focus_get_uniq failed"); - hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED; - return FALSE; - } + _mmcam_dbg_warn("read session info failed. sound focus watch cb will be set."); - ret = mm_sound_register_focus_for_session(hcamcorder->sound_focus_id, - new_pid, "media", _mmcamcorder_sound_focus_cb, hcamcorder); + ret = mm_sound_subscribe_signal_for_daemon(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, + new_pid, &hcamcorder->sound_focus_subscribe_id, + (mm_sound_signal_callback)_mmcamcorder_sound_signal_callback, (void*)hcamcorder); if (ret != MM_ERROR_NONE) { - _mmcam_dbg_err("mm_sound_register_focus failed"); + _mmcam_dbg_err("subscribe sound signal failed [0x%x]", ret); hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED; return FALSE; } - - _mmcam_dbg_log("mm_sound_register_focus done - id %d, session type %d, flags 0x%x", - hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags); - } else { - _mmcam_dbg_log("no need to register sound focus"); } return TRUE; @@ -4565,12 +4605,18 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value) { + int stream_index = 0; char *stream_type = NULL; - int stream_type_len = 0; _MMCamcorderSubContext *sc = NULL; mmf_return_val_if_fail(handle && value, FALSE); + stream_type = value->value.s_val; + if (!stream_type) { + _mmcam_dbg_err("NULL string"); + return FALSE; + } + sc = MMF_CAMCORDER_SUBCONTEXT(handle); if (!sc || !sc->encode_element || !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) { @@ -4579,17 +4625,16 @@ bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, co } mm_camcorder_get_attributes(handle, NULL, - MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len, + MMCAM_SOUND_STREAM_INDEX, &stream_index, NULL); - - if (stream_type == NULL) { - _mmcam_dbg_err("stream type is not set"); + if (stream_index < 0) { + _mmcam_dbg_err("invalid stream index %d", stream_index); return FALSE; } - _mmcam_dbg_log("Commit : sound stream info - type %s", stream_type); + _mmcam_dbg_log("Commit : sound stream info - type %s, index %d", stream_type, stream_index); - return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, value->value.i_val); + return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index); }