{0},
{0},
NULL,
+ },
+ {
+ MM_CAM_PID_FOR_SOUND_FOCUS,
+ "pid-for-sound-focus",
+ MMF_VALUE_TYPE_INT,
+ MM_ATTRS_FLAG_RW,
+ {(void*)0},
+ MM_ATTRS_VALID_TYPE_INT_RANGE,
+ {.int_min = 0},
+ {.int_max = _MMCAMCORDER_MAX_INT},
+ _mmcamcorder_commit_pid_for_sound_focus,
}
};
}
+bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, const mmf_value_t *value)
+{
+ bool bret = FALSE;
+ int pid_current = 0;
+ int pid_new = 0;
+ int current_state = MM_CAMCORDER_STATE_NONE;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ if (hcamcorder == NULL) {
+ _mmcam_dbg_warn("handle is NULL");
+ return FALSE;
+ }
+
+ /* state check */
+ current_state = _mmcamcorder_get_state( handle);
+ if (current_state > MM_CAMCORDER_STATE_NULL) {
+ _mmcam_dbg_log("invalid state %d", current_state);
+ return FALSE;
+ }
+
+ pid_new = value->value.i_val;
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_PID_FOR_SOUND_FOCUS, &pid_current,
+ NULL);
+
+ _mmcam_dbg_log("Commit : pid_for_sound_focus - pid new %dm current %d", pid_new, pid_current);
+
+ /* unregister sound focus before set new one */
+ if (pid_current > 0) {
+ if (hcamcorder->sound_focus_register) {
+ if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) {
+ _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id);
+ } else {
+ _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id);
+ }
+ } else {
+ _mmcam_dbg_log("no need to unregister sound focus");
+ }
+ }
+
+ /* register sound focus */
+ if (MM_ERROR_NONE == _mm_session_util_read_information(-1, &hcamcorder->session_type, &hcamcorder->session_flags)) {
+ _mmcam_dbg_log("use sound focus function.");
+ hcamcorder->sound_focus_register = TRUE;
+ } else {
+ _mmcam_dbg_log("_mm_session_util_read_information failed. skip sound focus function.");
+ hcamcorder->sound_focus_register = FALSE;
+ }
+
+ if (hcamcorder->sound_focus_register) {
+ 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;
+ }
+
+ if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id,
+ pid_new,
+ "media",
+ _mmcamcorder_sound_focus_cb,
+ hcamcorder)) {
+ _mmcam_dbg_err("mm_sound_register_focus failed");
+ 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;
+}
+
+
static bool
__mmcamcorder_attrs_is_supported(MMHandleType handle, int idx)
{
#include <system_info.h>
#include <mm_session.h>
#include <mm_session_private.h>
-#include <mm_sound_focus.h>
#include <cynara-client.h>
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);
-/* sound focus related function */
-static void __mmcamcorder_force_stop(mmf_camcorder_t *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);
-void _mmcamcorder_sound_focus_watch_cb(mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
- const char *reason_for_change, const char *additional_info, void *user_data);
-
-
#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
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;
+#if 0
int resource_fd = -1;
+#endif
char *err_attr_name = NULL;
const char *ConfCtrlFile = NULL;
mmf_camcorder_t *hcamcorder = NULL;
}
#endif
- /* Check session */
- if (MM_ERROR_NONE == _mm_session_util_read_information(-1, &hcamcorder->session_type, &hcamcorder->session_flags)) {
- _mmcam_dbg_log("use sound focus function.");
- hcamcorder->sound_focus_register = TRUE;
- } else {
- _mmcam_dbg_log("_mm_session_util_read_information failed. skip sound focus function.");
- hcamcorder->sound_focus_register = FALSE;
- }
-
- /* register sound focus */
- if (hcamcorder->sound_focus_register) {
- if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) {
- _mmcam_dbg_err("mm_sound_focus_get_uniq failed");
- ret = MM_ERROR_POLICY_BLOCKED;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
- if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id, "media", _mmcamcorder_sound_focus_cb, hcamcorder)) {
- _mmcam_dbg_err("mm_sound_register_focus failed");
- ret = MM_ERROR_POLICY_BLOCKED;
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
- _mmcam_dbg_log("mm_sound_register_focus done - id %d, session type %d, flags 0x%x",
- hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags);
- }
-
/* Get Camera Configure information from Camcorder INI file */
_mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main);
_mmcam_dbg_err( "Failed to get configure(main) info." );
ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
hcamcorder->attributes = _mmcamcorder_alloc_attribute((MMHandleType)hcamcorder, info);
_mmcam_dbg_err("_mmcamcorder_create::alloc attribute error.");
ret = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
default:
_mmcam_dbg_err( "Not supported camera type." );
ret = MM_ERROR_CAMCORDER_NOT_SUPPORTED;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("videodev_type : [%d], ConfCtrlPath : [%s]", info->videodev_type, ConfCtrlFile);
if (!(hcamcorder->conf_ctrl)) {
_mmcam_dbg_err( "Failed to get configure(control) info." );
ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
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_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, info->videodev_type);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("converting table initialize error!!");
ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get device info, recommend preview fmt and display rotation from INI */
free(err_attr_name);
err_attr_name = NULL;
ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Get default value of brightness */
free(err_attr_name);
err_attr_name = NULL;
ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
_mmcam_dbg_log("Default brightness : %d", hcamcorder->brightness_default);
} else {
free(err_attr_name);
err_attr_name = NULL;
ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
ret = _mmcamcorder_init_attr_from_configure((MMHandleType)hcamcorder, info->videodev_type);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("init attribute from configure error : 0x%x", ret);
ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
}
if (!ret) {
_mmcam_dbg_err( "Failed to initialize gstreamer!!" );
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
- goto _ERR_SOUND_FOCUS_REGISTER;
+ goto _ERR_DEFAULT_VALUE_INIT;
}
/* Make some attributes as read-only type */
return MM_ERROR_NONE;
-_ERR_SOUND_FOCUS_REGISTER:
- /* unregister sound focus */
- if(hcamcorder->sound_focus_register) {
- 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);
- }
- }
-
_ERR_DEFAULT_VALUE_INIT:
/* Remove attributes */
if (hcamcorder->attributes) {
int state_FROM = MM_CAMCORDER_STATE_NULL;
int state_TO = MM_CAMCORDER_STATE_READY;
int display_surface_type = MM_DISPLAY_SURFACE_X;
+ int pid_for_sound_focus = 0;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *videosink_element_type = NULL;
const char *videosink_name = NULL;
mm_camcorder_get_attributes(handle, NULL,
MMCAM_DISPLAY_SURFACE, &display_surface_type,
MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus,
NULL);
/* set camera/recorder state to vconf key */
_mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
} else {
/* set sound focus watch callback */
- _mmcam_dbg_log("ETC - set sound focus watch callback");
+ if (pid_for_sound_focus == 0) {
+ _mmcam_dbg_warn("pid for sound focus is not set, so call getpid");
+ pid_for_sound_focus = getpid();
+ }
+
+ _mmcam_dbg_log("ETC - set sound focus watch callback - pid %d", pid_for_sound_focus);
- ret_sound = mm_sound_set_focus_watch_callback(FOCUS_FOR_BOTH,
- (mm_sound_focus_changed_watch_cb)_mmcamcorder_sound_focus_watch_cb,
- hcamcorder,
- &hcamcorder->sound_focus_watch_id);
+ 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);
}
-static void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder)
+void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder)
{
int i = 0;
int loop = 0;