#define MEDIA_ROOT_PATH_SENIOR_MODE "/opt/familytv"
#endif
+#define MEDIA_ROOT_PATH_DISC "/mnt/cdrom"
+
#define MEDIA_DB_SIZE_LIMIT_2 20000000.0
#define MEDIA_DB_SIZE_LIMIT_1 10000000.0
#define MEDIA_DB_SPACE_LIMIT 20971520.0
ret = true;
} else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
ret = true;
+ } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
+ ret = true;
}
#ifdef _USE_SENIOR_MODE
else if (strncmp(path, MEDIA_ROOT_PATH_SENIOR_MODE, strlen(MEDIA_ROOT_PATH_SENIOR_MODE)) == 0) {
Name: media-server
Summary: A server for media content management
-Version: 0.3.14
+Version: 0.3.15
Release: 0
Group: Multimedia/Service
License: Apache-2.0
#define MS_SERVER_STATUS "memory/private/mediaserver/server_status"
#define MS_DB_LIMIT "file/private/mediaserver/db_limit"
#define MS_DB_RESET "file/private/mediaserver/db_reset"
+#define MS_DISC_STATE "db/disc/mount/state"
+#define MS_DISC_PATH "memory/disc/info/mount_path"
+#define MS_DISC_TYPE "memory/disc/info/logical_type"
/*Use for Poweroff sequence*/
#define POWEROFF -1 /*This number uses for stopping Scannig thread*/
ret = MS_STORAGE_EXTERNAL;
} else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
ret = MS_STORAGE_EXTERNAL_USB;
+ } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
+ ret = MS_STORAGE_EXTERNAL;
} else {
MS_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
ret = MS_MEDIA_ERR_INVALID_PATH;
break;
else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(dir_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
break;
+ else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(dir_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
+ break;
leaf_path = strrchr(dir_path, '/');
if (leaf_path != NULL) {
ret = true;
else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
ret = true;
+ else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
+ ret = true;
else
ret = false;
continue;
}
+ if (d->d_type == DT_UNKNOWN) {
+ struct stat st;
+ if (stat(path, &st) == 0) {
+ if (S_ISREG(st.st_mode)) {
+ d->d_type = DT_REG;
+ } else if (S_ISDIR(st.st_mode)) {
+ d->d_type = DT_DIR;
+ }
+ }
+ }
+
if (d->d_type == DT_REG) {
ms_get_media_type(handle, path, &media_type);
if (media_type == MS_MEDIA_TYPE_OTHER) {
MS_DBG_ERR("failed to update db : %d\n", scan_type);
if (ret == MS_MEDIA_ERR_FILE_IO) {
MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
- }
+ }
bpos += d->d_reclen;
continue;
} else {
continue;
}
+ if (d->d_type == DT_UNKNOWN) {
+ struct stat st;
+ if (stat(path, &st) == 0) {
+ if (S_ISREG(st.st_mode)) {
+ d->d_type = DT_REG;
+ } else if (S_ISDIR(st.st_mode)) {
+ d->d_type = DT_DIR;
+ }
+ }
+ }
+
if (d->d_type == DT_REG) {
/* check media type */
ms_get_media_type(handle, path, &media_type);
}
}
- /*remove invalid folder in folder table.*/
- if (ms_storage_mount_status(new_start_path)) {
- if ((g_directory_scan_processing2 != DIR_SCAN_NON_SCAN)
- && (__msc_dir_and_storage_scan_same_path(new_start_path) == MS_MEDIA_ERR_NONE)) {
- __msc_set_dir_scan_cb(__msc_dir_scan_cb);
- MS_DBG_ERR("storage scan pause...\n");
- __msc_pause_scan();
+ if (strstr(new_start_path, MEDIA_ROOT_PATH_USB) != NULL) {
+ if (!ms_storage_mount_status(new_start_path)) {
+ MS_DBG_ERR("start path is unmounted");
+ goto EXIT;
+ }
+ }
- MS_DBG_ERR("wait folder scan callback");
+ if ((g_directory_scan_processing2 != DIR_SCAN_NON_SCAN)
+ && (__msc_dir_and_storage_scan_same_path(new_start_path) == MS_MEDIA_ERR_NONE)) {
+ __msc_set_dir_scan_cb(__msc_dir_scan_cb);
+ MS_DBG_ERR("storage scan pause...\n");
+ __msc_pause_scan();
- __msc_remove_dir_scan_cb();
- }
- if (ms_delete_invalid_folder(handle, storage_id, storage_type, uid) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("delete invalid folder failed");
- ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
- }
- } else {
- MS_DBG_ERR("start path is unmounted");
+ MS_DBG_ERR("wait folder scan callback");
+
+ __msc_remove_dir_scan_cb();
+ }
+
+ /*remove invalid folder in folder table.*/
+ if (ms_delete_invalid_folder(handle, storage_id, storage_type, uid) != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("delete invalid folder failed");
+ ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
}
goto EXIT;
return;
}
+
+void _ms_datadisc_vconf_cb(void *data)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ int disc_state = 0;
+ char *disc_type = NULL;
+ char *disc_path = NULL;
+ char *valid_type = "data";
+ ms_dir_scan_type_t scan_type = MS_SCAN_PART;
+ uid_t uid = MEDIA_DEFAULT_UID;
+ char start_path[11] = {0,};
+ void **handle = NULL;
+
+ ms_config_get_int(MS_DISC_STATE, &disc_state);
+
+ ret = ms_load_functions();
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_load_functions failed [%d]", ret);
+ return ret;
+ }
+
+ /* request scanning */
+ ms_sys_get_uid(&uid);
+
+ ms_connect_db(&handle, uid);
+
+ if (disc_state == 1) {
+ /*check disc type */
+ if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
+ MS_DBG_ERR("Get MS_DISC_TYPE failed.");
+ goto END;
+ }
+
+ MS_DBG_ERR("[DISC INSERTED][%s]",disc_type);
+
+ if (strcmp(disc_type, valid_type) == 0) {
+ /* check mount path */
+ if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
+ MS_DBG_ERR("Get MS_DISC_PATH failed.");
+ goto END;
+ }
+
+ memset(start_path, 0x0, sizeof(start_path));
+ strncpy(start_path, disc_path, sizeof(start_path)-1);
+ MS_DBG_ERR("MOUNT PATH [%s]", start_path);
+
+
+ ret = ms_insert_storage(handle, MMC_STORAGE_ID, NULL, start_path, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_insert_storage failed");
+ }
+
+ ms_send_storage_scan_request(start_path, MMC_STORAGE_ID, scan_type, uid);
+ }
+ } else {
+ MS_DBG_ERR("[DISC REMOVED]");
+ ms_set_storage_validity(handle, MMC_STORAGE_ID, 0, uid);
+ }
+
+END:
+ MS_SAFE_FREE(disc_type);
+ MS_SAFE_FREE(disc_path);
+
+ ms_disconnect_db(&handle);
+
+ ms_unload_functions();
+
+ return;
+}
#endif
int ms_write_media_server_status(void)
{
err = vconf_notify_key_changed(SMARTHUB_RESET_VCONF, (vconf_callback_fn) _ms_smarthub_vconf_cb, NULL);
if (err == -1)
MS_DBG_ERR("add call back function for event %s fails", SMARTHUB_RESET_VCONF);
+
+ err = vconf_notify_key_changed(MS_DISC_STATE, (vconf_callback_fn) _ms_datadisc_vconf_cb, NULL);
+ if (err == -1)
+ MS_DBG_ERR("add call back function for event %s fails", MS_DISC_STATE);
#endif
/*set power off callback function*/
ms_sys_set_poweroff_cb(_power_off_cb, channel);