Release version 0.10.14 89/49889/1 accepted/tizen/mobile/20151022.230112 accepted/tizen/tv/20151022.230125 accepted/tizen/wearable/20151022.230138 submit/tizen/20151022.102935
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Oct 2015 07:40:05 +0000 (16:40 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Oct 2015 07:40:34 +0000 (16:40 +0900)
1. update code for root directory check

Change-Id: I4351c2152fcc0dd969612239b4b6113c0f300aa5
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/include/mm_camcorder_attribute.h
src/include/mm_camcorder_client.h
src/include/mm_camcorder_util.h
src/mm_camcorder_attribute.c
src/mm_camcorder_audiorec.c
src/mm_camcorder_client.c
src/mm_camcorder_internal.c
src/mm_camcorder_util.c
src/mm_camcorder_videorec.c

index 279a85f..8b57e14 100644 (file)
@@ -2,7 +2,7 @@
 
 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
index cb2a4b2..bf7af90 100644 (file)
@@ -1237,6 +1237,11 @@ extern "C" {
  */
 #define MMCAM_PID_FOR_SOUND_FOCUS               "pid-for-sound-focus"
 
+/**
+ * Root directory of application
+ */
+#define MMCAM_ROOT_DIRECTORY                    "root-directory"
+
 
 /*=======================================================================================
 | ENUM DEFINITIONS                                                                     |
index b25db49..43bf852 100644 (file)
@@ -174,6 +174,7 @@ typedef enum
        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;
 
index 2350cb6..8451c5a 100644 (file)
@@ -144,6 +144,14 @@ int mm_camcorder_client_get_video_caps(MMHandleType handle, char **caps);
  */
 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
index f29b465..62a5821 100644 (file)
@@ -271,7 +271,6 @@ gboolean _mmcamcorder_update_composition_matrix(FILE *f, int orientation);
 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);
index bfd00ae..51914ee 100644 (file)
@@ -1443,6 +1443,17 @@ _mmcamcorder_alloc_attribute( MMHandleType handle, MMCamPreset *info )
                        {.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,
                }
        };
 
index c94acf6..c005178 100644 (file)
@@ -349,9 +349,7 @@ _mmcamcorder_audio_command(MMHandleType handle, int command)
        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;
@@ -381,7 +379,10 @@ _mmcamcorder_audio_command(MMHandleType handle, int command)
                        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);
@@ -392,7 +393,8 @@ _mmcamcorder_audio_command(MMHandleType handle, int command)
                                                          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);
index 1600e6d..bde0d82 100644 (file)
 #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;
@@ -1562,3 +1595,21 @@ int mm_camcorder_client_set_shm_socket_path(MMHandleType handle, const char *pat
        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;
+}
index 57d4583..513cd44 100644 (file)
@@ -250,12 +250,6 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info)
        /* 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.");
@@ -600,11 +594,6 @@ _ERR_DEFAULT_VALUE_INIT:
        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);
@@ -780,12 +769,6 @@ int _mmcamcorder_destroy(MMHandleType handle)
        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);
index 7527691..5409586 100644 (file)
@@ -146,37 +146,6 @@ static int __gdbus_method_call_sync(const char* bus_name, const char* object, co
 }
 
 
-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);
@@ -638,37 +607,33 @@ int _mmcamcorder_get_freespace(const gchar *path, const gchar *root_directory, g
        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) {
@@ -676,9 +641,6 @@ int _mmcamcorder_get_freespace(const gchar *path, const gchar *root_directory, g
        } else {
                ret = storage_get_external_memory_size(&vfs);
        }
-#else
-       ret = storage_get_internal_memory_size(&vfs);
-#endif
 
        if (ret < 0) {
                *free_space = 0;
@@ -2157,23 +2119,3 @@ static gboolean _mmcamcorder_convert_NV12_to_I420(unsigned char *src, guint widt
 
        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;
-}
-
index e0b09b4..d17c89d 100644 (file)
@@ -506,6 +506,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                        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);
@@ -525,6 +526,7 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
                                                          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);