Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.13
+Version: 0.10.14
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
*/
#define MMCAM_PID_FOR_SOUND_FOCUS "pid-for-sound-focus"
+/**
+ * Root directory of application
+ */
+#define MMCAM_ROOT_DIRECTORY "root-directory"
+
/*=======================================================================================
| ENUM DEFINITIONS |
MM_CAM_RECORDER_TAG_ENABLE,
MM_CAM_DISPLAY_SHM_SOCKET_PATH,
MM_CAM_PID_FOR_SOUND_FOCUS,
+ MM_CAM_ROOT_DIRECTORY,
MM_CAM_ATTRIBUTE_NUM
}MMCamcorderAttrsID;
*/
int mm_camcorder_client_set_shm_socket_path(MMHandleType handle, const char *path);
+/**
+ * This function get root directory of current process.
+ *
+ * @param root_directory [out] Root directory.
+ * @return This function returns zero on success, or negative value with error code.
+ */
+int mm_camcorder_client_get_root_directory(char **root_directory);
+
#ifdef __cplusplus
}
#endif
int _mmcamcorder_get_freespace(const gchar *path, const gchar *root_directory, guint64 *free_space);
int _mmcamcorder_get_file_size(const char *filename, guint64 *size);
int _mmcamcorder_get_file_system_type(const gchar *path, int *file_system_type);
-int _mmcamcorder_get_root_directory(char **root_directory);
/* Task */
void *_mmcamcorder_util_task_thread_func(void *data);
{.int_min = 0},
{.int_max = _MMCAMCORDER_MAX_INT},
_mmcamcorder_commit_pid_for_sound_focus,
+ },
+ {
+ MM_CAM_ROOT_DIRECTORY,
+ "root-directory",
+ MMF_VALUE_TYPE_STRING,
+ MM_ATTRS_FLAG_RW,
+ {(void*)NULL},
+ MM_ATTRS_VALID_TYPE_NONE,
+ {0},
+ {0},
+ NULL,
}
};
int cmd = command;
int ret = MM_ERROR_NONE;
int err = 0;
- int size=0;
guint64 free_space = 0;
- char *dir_name = NULL;
char *err_attr_name = NULL;
GstElement *pipeline = NULL;
guint imax_size = 0;
guint imax_time = 0;
char *temp_filename = NULL;
+ char *dir_name = NULL;
int file_system_type = 0;
+ int filename_length = 0;
+ int root_directory_length = 0;
if(sc->pipeline_time) {
gst_element_set_start_time(pipeline, sc->pipeline_time);
MMCAM_TARGET_MAX_SIZE, &imax_size,
MMCAM_TARGET_TIME_LIMIT, &imax_time,
MMCAM_FILE_FORMAT, &(info->fileformat),
- MMCAM_TARGET_FILENAME, &temp_filename, &size,
+ MMCAM_TARGET_FILENAME, &temp_filename, &filename_length,
+ MMCAM_ROOT_DIRECTORY, &hcamcorder->root_directory, &root_directory_length,
NULL);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("failed to get attribute. (%s:%x)", err_attr_name, ret);
#include "mm_camcorder_internal.h"
#include <sched.h>
+#include <storage.h>
+
+
+static int _storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+{
+ char **root_directory = (char **)user_data;
+
+ if (root_directory == NULL) {
+ _mmcam_dbg_warn("user data is NULL");
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("storage id %d, type %d, state %d, path %s",
+ storage_id, type, state, path ? path : "NULL");
+
+ if (type == STORAGE_TYPE_INTERNAL && path) {
+ if (*root_directory) {
+ free(*root_directory);
+ *root_directory = NULL;
+ }
+
+ *root_directory = strdup(path);
+ if (*root_directory) {
+ _mmcam_dbg_log("get root directory %s", *root_directory);
+ return FALSE;
+ } else {
+ _mmcam_dbg_warn("strdup %s failed");
+ }
+ }
+
+ return TRUE;
+}
+
bool _mmcamcorder_client_commit_display_handle(MMHandleType handle, int attr_idx, const mmf_value_t *value)
{
int current_state = MM_CAMCORDER_STATE_NONE;
ret = _mm_camcorder_client_set_shm_socket_path(handle, path);
return ret;
}
+
+int mm_camcorder_client_get_root_directory(char **root_directory)
+{
+ int ret = STORAGE_ERROR_NONE;
+
+ if (root_directory == NULL) {
+ _mmcam_dbg_warn("user data is NULL");
+ return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ }
+
+ ret = storage_foreach_device_supported((storage_device_supported_cb)_storage_device_supported_cb, root_directory);
+ if (ret != STORAGE_ERROR_NONE) {
+ _mmcam_dbg_err("storage_foreach_device_supported failed 0x%x", ret);
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+
+ return MM_ERROR_NONE;
+}
/* create task thread */
pthread_create(&(hcamcorder->task_thread), NULL, _mmcamcorder_util_task_thread_func, (void *)hcamcorder);
- /* get root directory */
- ret = _mmcamcorder_get_root_directory(&hcamcorder->root_directory);
- if (ret != MM_ERROR_NONE) {
- goto _ERR_DEFAULT_VALUE_INIT;
- }
-
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.");
pthread_mutex_destroy(&(hcamcorder->task_thread_lock));
pthread_cond_destroy(&(hcamcorder->task_thread_cond));
- if (hcamcorder->root_directory) {
- free(hcamcorder->root_directory);
- hcamcorder->root_directory = NULL;
- }
-
/* Release handle */
memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
free(hcamcorder);
pthread_mutex_destroy(&(hcamcorder->task_thread_lock));
pthread_cond_destroy(&(hcamcorder->task_thread_cond));
- /* Release internal root directory string */
- if (hcamcorder->root_directory) {
- free(hcamcorder->root_directory);
- hcamcorder->root_directory = NULL;
- }
-
/* Release handle */
memset(hcamcorder, 0x00, sizeof(mmf_camcorder_t));
free(hcamcorder);
}
-static int __storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
-{
- char **root_directory = (char **)user_data;
-
- if (root_directory == NULL) {
- _mmcam_dbg_warn("user data is NULL");
- return FALSE;
- }
-
- _mmcam_dbg_log("storage id %d, type %d, state %d, path %s",
- storage_id, type, state, path ? path : "NULL");
-
- if (type == STORAGE_TYPE_INTERNAL && path) {
- if (*root_directory) {
- free(*root_directory);
- *root_directory = NULL;
- }
-
- *root_directory = strdup(path);
- if (*root_directory) {
- _mmcam_dbg_log("get root directory %s", *root_directory);
- return FALSE;
- } else {
- _mmcam_dbg_warn("strdup %s failed");
- }
- }
-
- return TRUE;
-}
-
-
gint32 _mmcamcorder_double_to_fix(gdouble d_number)
{
return (gint32) (d_number * 65536.0);
int ret = 0;
struct statvfs vfs;
- /*
- * TEMPORARILY disabled (The internal / external storage distinguisher codes)
- * : Since the camera / recorder module is working through the Muse Daemon Process,
- * There is an user's root path issue by the different process from the client's.
- */
-#if 0
- int is_internal = 0;
+ int is_internal = TRUE;
struct stat stat_path;
struct stat stat_root;
- if (path == NULL || root_directory == NULL || free_space == NULL) {
- _mmcam_dbg_err("invalid parameter %p, %p, %p", path, root_directory, free_space);
+ if (path == NULL || free_space == NULL) {
+ _mmcam_dbg_err("invalid parameter %p, %p", path, free_space);
return -1;
}
- if (stat(path, &stat_path) != 0) {
- *free_space = 0;
- _mmcam_dbg_err("failed to stat for [%s][errno %d]", path, errno);
- return -1;
- }
+ if (root_directory && strlen(root_directory) > 0) {
+ if (stat(path, &stat_path) != 0) {
+ *free_space = 0;
+ _mmcam_dbg_err("failed to stat for [%s][errno %d]", path, errno);
+ return -1;
+ }
- if (stat(root_directory, &stat_root) != 0) {
- *free_space = 0;
- _mmcam_dbg_err("failed to stat for [%s][errno %d]", path, errno);
- return -1;
- }
+ if (stat(root_directory, &stat_root) != 0) {
+ *free_space = 0;
+ _mmcam_dbg_err("failed to stat for [%s][errno %d]", path, errno);
+ return -1;
+ }
- if (stat_path.st_dev == stat_root.st_dev) {
- is_internal = TRUE;
+ if (stat_path.st_dev != stat_root.st_dev) {
+ is_internal = FALSE;
+ }
} else {
- is_internal = FALSE;
+ _mmcam_dbg_warn("root_directory is NULL, assume that it's internal storage.");
}
if (is_internal) {
} else {
ret = storage_get_external_memory_size(&vfs);
}
-#else
- ret = storage_get_internal_memory_size(&vfs);
-#endif
if (ret < 0) {
*free_space = 0;
return TRUE;
}
-
-
-int _mmcamcorder_get_root_directory(char **root_directory)
-{
- int ret = STORAGE_ERROR_NONE;
-
- if (root_directory == NULL) {
- _mmcam_dbg_warn("user data is NULL");
- return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
- }
-
- ret = storage_foreach_device_supported((storage_device_supported_cb)__storage_device_supported_cb, root_directory);
- if (ret != STORAGE_ERROR_NONE) {
- _mmcam_dbg_err("storage_foreach_device_supported failed 0x%x", ret);
- return MM_ERROR_CAMCORDER_INTERNAL;
- }
-
- return MM_ERROR_NONE;
-}
-
char *dir_name = NULL;
guint64 free_space = 0;
int file_system_type = 0;
+ int root_directory_length = 0;
/* Recording */
_mmcam_dbg_log("Record Start - dual stream %d", info->support_dual_stream);
MMCAM_TARGET_TIME_LIMIT, &imax_time,
MMCAM_FILE_FORMAT, &(info->fileformat),
MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ MMCAM_ROOT_DIRECTORY, &hcamcorder->root_directory, &root_directory_length,
NULL);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, ret);