#include <unistd.h>
#include <stdlib.h>
+#ifndef __USE_XOPEN
+#define DEF_XOPEN
+#define __USE_XOPEN /* needed for strptime */
+#endif
#include <time.h>
+#ifdef DEF_XOPEN
+#undef __USE_XOPEN
+#endif
#include <string.h>
+#include <system_info.h>
#include <sys/vfs.h>
#include <glib/gstdio.h>
#include <sys/stat.h>
-#include <string.h>
#include <dirent.h>
#include <ctype.h>
-#include <errno.h>
#include <aul/aul.h>
#include <mm_file.h>
-#include <mm_error.h>
#include <libexif/exif-data.h>
-#include <media-thumbnail.h>
#include <media-util.h>
-#include <grp.h>
-#include <pwd.h>
-#include "uuid.h"
+#include <uuid/uuid.h>
+#include <mm_util_magick.h>
+#include "media-util-err.h"
#include "media-svc-util.h"
-#include "media-svc-error.h"
+#include "media-svc-db-utils.h"
#include "media-svc-debug.h"
#include "media-svc-env.h"
#include "media-svc-hash.h"
#include "media-svc-album.h"
#include "media-svc-localize_ch.h"
-#define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/
-#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO
-
-typedef enum {
- MEDIA_SVC_EXTRACTED_FIELD_NONE = 0x00000001,
- MEDIA_SVC_EXTRACTED_FIELD_TITLE = MEDIA_SVC_EXTRACTED_FIELD_NONE << 1,
- MEDIA_SVC_EXTRACTED_FIELD_DESC = MEDIA_SVC_EXTRACTED_FIELD_NONE << 2,
- MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT = MEDIA_SVC_EXTRACTED_FIELD_NONE << 3,
- MEDIA_SVC_EXTRACTED_FIELD_AUTHOR = MEDIA_SVC_EXTRACTED_FIELD_NONE << 4,
- MEDIA_SVC_EXTRACTED_FIELD_ARTIST = MEDIA_SVC_EXTRACTED_FIELD_NONE << 5,
- MEDIA_SVC_EXTRACTED_FIELD_GENRE = MEDIA_SVC_EXTRACTED_FIELD_NONE << 6,
- MEDIA_SVC_EXTRACTED_FIELD_ALBUM = MEDIA_SVC_EXTRACTED_FIELD_NONE << 7,
- MEDIA_SVC_EXTRACTED_FIELD_TRACKNUM = MEDIA_SVC_EXTRACTED_FIELD_NONE << 8,
- MEDIA_SVC_EXTRACTED_FIELD_YEAR = MEDIA_SVC_EXTRACTED_FIELD_NONE << 9,
- MEDIA_SVC_EXTRACTED_FIELD_CATEGORY = MEDIA_SVC_EXTRACTED_FIELD_NONE << 10,
-} media_svc_extracted_field_e;
-
-#if 0
-static char *__year_2_str(int year);
-
-static char *__year_2_str(int year)
-{
- static char ret[MEDIA_SVC_METADATA_LEN_MAX];
-
- if (year == -1 || year == 0) {
- _strncpy_safe(ret, MEDIA_SVC_TAG_UNKNOWN, MEDIA_SVC_METADATA_LEN_MAX);
- } else {
- snprintf(ret, MEDIA_SVC_METADATA_LEN_MAX - 1, "%d", year);
- }
- return ret;
-}
-#endif
+#define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/
+
+/* Define data structures for media type and mime type */
+#define MEDIA_SVC_CATEGORY_UNKNOWN 0x00000000 /**< Default */
+#define MEDIA_SVC_CATEGORY_ETC 0x00000001 /**< ETC category */
+#define MEDIA_SVC_CATEGORY_IMAGE 0x00000002 /**< Image category */
+#define MEDIA_SVC_CATEGORY_VIDEO 0x00000004 /**< Video category */
+#define MEDIA_SVC_CATEGORY_MUSIC 0x00000008 /**< Music category */
+#define MEDIA_SVC_CATEGORY_SOUND 0x00000010 /**< Sound category */
+#define MEDIA_SVC_CATEGORY_PVR 0x00000020 /**< PVR category */
+#define MEDIA_SVC_CATEGORY_UHD 0x00000040 /**< UHD category */
+#define MEDIA_SVC_CATEGORY_SCSA 0x00000080 /**< SCSA category */
+
+#define CONTENT_TYPE_NUM 5
+#define MUSIC_MIME_NUM 29
+#define SOUND_MIME_NUM 1
+#define MIME_TYPE_LENGTH 255
+#define MIME_LENGTH 50
+#define _3GP_FILE ".3gp"
+#define _MP4_FILE ".mp4"
+#define _ASF_FILE ".asf"
+#define MEDIA_SVC_ARTWORK_SIZE 2000
+#define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
+
+
+static int media_svc_pinyin_support = -1;
+
+typedef struct {
+ char content_type[15];
+ int category_by_mime;
+} _media_svc_content_table_s;
+
+static const _media_svc_content_table_s content_category[CONTENT_TYPE_NUM] = {
+ {"audio", MEDIA_SVC_CATEGORY_SOUND},
+ {"image", MEDIA_SVC_CATEGORY_IMAGE},
+ {"video", MEDIA_SVC_CATEGORY_VIDEO},
+ {"application", MEDIA_SVC_CATEGORY_ETC},
+ {"text", MEDIA_SVC_CATEGORY_ETC},
+};
+
+static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
+ /*known mime types of normal files*/
+ "mpeg",
+ "ogg",
+ "x-ms-wma",
+ "x-flac",
+ "mp4",
+ /* known mime types of drm files*/
+ "mp3",
+ "x-mp3", /*alias of audio/mpeg*/
+ "x-mpeg", /*alias of audio/mpeg*/
+ "3gpp",
+ "x-ogg", /*alias of audio/ogg*/
+ "vnd.ms-playready.media.pya:*.pya", /*playready*/
+ "wma",
+ "aac",
+ "x-m4a", /*alias of audio/mp4*/
+ /* below mimes are rare*/
+ "x-vorbis+ogg",
+ "x-flac+ogg",
+ "x-matroska",
+ "ac3",
+ "mp2",
+ "x-ape",
+ "x-ms-asx",
+ "vnd.rn-realaudio",
+
+ "x-vorbis", /*alias of audio/x-vorbis+ogg*/
+ "vorbis", /*alias of audio/x-vorbis+ogg*/
+ "x-oggflac",
+ "x-mp2", /*alias of audio/mp2*/
+ "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
+ "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
+ "x-wav",
+};
+
+static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
+ "x-smaf",
+};
char *_media_info_generate_uuid(void)
{
uuid_t uuid_value;
- static char uuid_unparsed[50];
+ static char uuid_unparsed[37];
+RETRY_GEN:
uuid_generate(uuid_value);
uuid_unparse(uuid_value, uuid_unparsed);
- //media_svc_debug("UUID : %s", uuid_unparsed);
- return uuid_unparsed;
-}
-
-void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
-{
- if (!x_src || strlen(x_src) == 0) {
- media_svc_error("x_src is NULL");
- return;
- }
-
- if (max_len < 1) {
- media_svc_error("length is Wrong");
- return;
+ if (strlen(uuid_unparsed) < 36) {
+ media_svc_debug("INVALID UUID : %s. RETRY GENERATE.", uuid_unparsed);
+ goto RETRY_GEN;
}
- strncpy(x_dst, x_src, max_len-1);
- x_dst[max_len-1] = '\0';
+ return uuid_unparsed;
}
-int __media_svc_malloc_and_strncpy(char **dst, const char *src)
+static int __media_svc_split_to_double(char *input, double *arr)
{
- int len = 0;
-
- if (!STRING_VALID(src)) {
- media_svc_error("invalid src");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
-
- SAFE_FREE(*dst);
+ char tmp_arr[255] = {0, };
+ int len = 0, idx = 0, arr_idx = 0, str_idx = 0;
- len = strlen(src) + 1;
- *dst = malloc(len);
-
- if (*dst == NULL) {
- media_svc_error("malloc failed");
- return MEDIA_INFO_ERROR_INTERNAL;
+ if (!STRING_VALID(input)) {
+ media_svc_error("Invalid parameter");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
+ memset(tmp_arr, 0x0, sizeof(tmp_arr));
- strncpy(*dst, src, len);
- char *p = *dst;
- p[len - 1] = '\0';
+ /*media_svc_debug("input: [%s]", input); */
- return MEDIA_INFO_ERROR_NONE;
-}
+ len = strlen(input);
-static void __media_svc_split_to_double(char *input, double *arr, int *num)
-{
- char tmp_arr[255] = { 0, };
- int len = strlen(input);
- int i = 0, idx = 0, tmp_idx = 0;
- int is_prev_space = 0;
-
- for (;;) {
- if (input[len - 1] == ' ') {
- len--;
+ for (idx = 0; idx < (len + 1); idx++) {
+ if (input[idx] == ' ') {
+ continue;
+ } else if ((input[idx] == ',') || (idx == len)) {
+ arr[arr_idx] = atof(tmp_arr);
+ arr_idx++;
+ str_idx = 0;
+ /*media_svc_debug("idx=[%d] arr_idx=[%d] tmp_attr[%s] atof(tmp_arr)=[%f]", idx, arr_idx, tmp_arr, atof(tmp_arr)); */
+ memset(tmp_arr, 0x0, sizeof(tmp_arr));
} else {
- break;
+ tmp_arr[str_idx] = input[idx];
+ str_idx++;
}
}
- for (i = 0; i < len; i++) {
- if (idx > 2) {
- break;
- }
-
- if (input[i] == ' ') {
- if (is_prev_space == 1) {
- continue;
- }
- if (idx <= 2) {
- arr[idx++] = atof(tmp_arr);
- }
- tmp_idx = 0;
- is_prev_space = 1;
- continue;
- }
-
- tmp_arr[tmp_idx] = input[i];
- tmp_arr[++tmp_idx] = '\0';
- is_prev_space = 0;
+ if (arr_idx != 3) {
+ media_svc_debug("Error when parsing GPS [%d]", arr_idx);
+ return MS_MEDIA_ERR_INTERNAL;
}
- if (i == len) {
- if (idx <= 2) {
- arr[idx++] = atof(tmp_arr);
- }
- *num = idx;
- return;
- } else {
- *num = idx--;
- return;
- }
+ return MS_MEDIA_ERR_NONE;
}
-static int __media_svc_get_exif_info(ExifData *ed,
- char *buf,
- int *i_value,
- double *d_value,
- int ifdtype,
- long tagtype)
+static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, double *d_value, long tagtype)
{
ExifEntry *entry;
- ExifIfd ifd;
ExifTag tag;
- if (ed == NULL) {
- //media_svc_debug("ExifData is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
+ if (ed == NULL)
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
- ifd = ifdtype;
tag = tagtype;
entry = exif_data_get_entry(ed, tag);
if (entry) {
/* Get the contents of the tag in human-readable form */
if (tag == EXIF_TAG_ORIENTATION ||
- tag == EXIF_TAG_PIXEL_X_DIMENSION ||
- tag == EXIF_TAG_PIXEL_Y_DIMENSION) {
+ tag == EXIF_TAG_PIXEL_X_DIMENSION ||
+ tag == EXIF_TAG_PIXEL_Y_DIMENSION ||
+ tag == EXIF_TAG_ISO_SPEED_RATINGS) {
if (i_value == NULL) {
- media_svc_error("i_value is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ media_svc_debug("i_value is NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
short exif_value = exif_get_short(entry->data, mByteOrder);
- //media_svc_debug("%s : %d", exif_tag_get_name_in_ifd(tag,ifd), exif_value);
*i_value = (int)exif_value;
} else if (tag == EXIF_TAG_GPS_LATITUDE || tag == EXIF_TAG_GPS_LONGITUDE || tag == EXIF_TAG_GPS_ALTITUDE) {
if (d_value == NULL) {
- media_svc_error("d_value is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ media_svc_debug("d_value is NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* Get the contents of the tag in human-readable form */
- char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
+ char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = {0, };
exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
gps_buf[strlen(gps_buf)] = '\0';
-
- //media_svc_debug("%s: %s\n", exif_tag_get_name_in_ifd(tag, ifd), gps_buf);
+ int ret = MS_MEDIA_ERR_NONE;
double tmp_arr[3] = { 0.0, 0.0, 0.0 };
- int count = 0;
- __media_svc_split_to_double(gps_buf, tmp_arr, &count);
- if (count != 3) {
- media_svc_error("Value is invalid");
- return MEDIA_INFO_ERROR_INTERNAL;
- }
+ ret = __media_svc_split_to_double(gps_buf, tmp_arr);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
*d_value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
- //media_svc_debug("GPS value is %f", *d_value);
+ } else if (tag == EXIF_TAG_EXPOSURE_TIME) {
+
+ if (buf == NULL) {
+ media_svc_debug("buf is NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
+ ExifRational mRational = exif_get_rational(entry->data, mByteOrder);
+ long numerator = mRational.numerator;
+ long denominator = mRational.denominator;
+ snprintf(buf, MEDIA_SVC_METADATA_LEN_MAX, "%ld/%ld", numerator, denominator);
+
+ } else if (tag == EXIF_TAG_FNUMBER) {
+
+ if (d_value == NULL) {
+ media_svc_debug("d_value is NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
+ ExifRational mRational = exif_get_rational(entry->data, mByteOrder);
+ long numerator = mRational.numerator;
+ long denominator = mRational.denominator;
+
+ *d_value = ((numerator*1.0)/(denominator*1.0));
+
} else {
if (buf == NULL) {
- media_svc_error("buf is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ media_svc_debug("buf is NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX);
buf[strlen(buf)] = '\0';
-
- if (*buf) {
- media_svc_debug("%s: %s\n", exif_tag_get_name_in_ifd(tag, ifd), buf);
- }
}
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-unsigned int _media_svc_get_current_time(void)
+time_t __media_svc_get_timeline_from_str(const char *timstr)
{
- struct timeval t;
- unsigned int tval = 0;
- gettimeofday(&t, NULL);
+ struct tm t;
+ time_t modified_t = 0;
+ time_t rawtime;
+ struct tm timeinfo;
+
+ if (!STRING_VALID(timstr)) {
+ media_svc_error("Invalid Parameter");
+ return 0;
+ }
+
+ /*Exif Format : %Y:%m:%d %H:%M:%S
+ Videoc Content Creation_time format of FFMpeg : %Y-%m-%d %H:%M:%S*/
+ memset(&t, 0x00, sizeof(struct tm));
+
+ tzset();
+ time(&rawtime);
+ localtime_r(&rawtime, &timeinfo);
+
+ if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) {
+ t.tm_isdst = timeinfo.tm_isdst;
+ if (t.tm_isdst != 0)
+ media_svc_debug("DST %d", t.tm_isdst);
+
+ /* If time string has timezone */
+ if (strptime(timstr, "%Y:%m:%d %H:%M:%S %z", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S %z", &t)) {
+ GTimeVal timeval;
+ char tim_tmp_str[255] = { 0, };
+
+ /* ISO8601 Time string format */
+ strftime(tim_tmp_str, 255, "%Y-%m-%dT%H:%M:%S%z", &t);
+ g_time_val_from_iso8601(tim_tmp_str, &timeval);
+ modified_t = timeval.tv_sec;
+ media_svc_debug("Calibrated timeval : [%d][%s]", modified_t, tim_tmp_str);
+ } else {
+ /* Just localtime */
+ modified_t = mktime(&t);
+ }
- tval = t.tv_sec*1000000L + t.tv_usec;
+ if (modified_t > 0)
+ return modified_t;
+ else
+ media_svc_debug("Failed to get timeline : [%s] [%d:%d:%d: %d:%d:%d]", timstr, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
+ } else {
+ media_svc_error("Failed to get timeline : [%s]", timstr);
+ }
- return tval/1000;
+ return 0;
}
-int _media_svc_check_escape_char(char ch)
+static int __media_svc_get_content_type_from_mime(const char *path, const char *mimetype, int *category)
{
- int i;
- char escape_char[3] = {'%', '_' ,'#'};
+ int idx = 0;
- for (i = 0; i < 3; i++) {
- if (ch == escape_char[i]) {
- return 1;
+ *category = MEDIA_SVC_CATEGORY_UNKNOWN;
+
+ /*categorize from mimetype */
+ for (idx = 0; idx < CONTENT_TYPE_NUM; idx++) {
+ if (strstr(mimetype, content_category[idx].content_type) != NULL) {
+ *category = (*category | content_category[idx].category_by_mime);
+ break;
}
}
- return 0;
-}
+ /*in application type, exitst sound file ex) x-smafs, asf */
+ if (*category & MEDIA_SVC_CATEGORY_ETC) {
+ int prefix_len = strlen(content_category[0].content_type);
+ char *ext = NULL;
-char *_media_svc_escape_str(char *input, int len)
-{
- int i = 0;
- int j = 0;
- char *result = NULL;
+ for (idx = 0; idx < SOUND_MIME_NUM; idx++) {
+ if (strstr(mimetype + prefix_len, sound_mime_table[idx]) != NULL) {
+ *category ^= MEDIA_SVC_CATEGORY_ETC;
+ *category |= MEDIA_SVC_CATEGORY_SOUND;
+ break;
+ }
+ }
- result = (char*)malloc(len * 2 * sizeof(char) + 1);
- if (result == NULL) {
- return NULL;
- }
+ if (strncasecmp(mimetype, "text/x-iMelody", strlen("text/x-iMelody")) == 0) {
+ *category ^= MEDIA_SVC_CATEGORY_ETC;
+ *category |= MEDIA_SVC_CATEGORY_SOUND;
+ }
- for (i = 0; i < len; i++, j++) {
- if (input[i] == '\0') break;
+ /*"asf" must check video stream and then categorize in directly. */
+ ext = strrchr(path, '.');
+ if (ext != NULL) {
+ if (strncasecmp(ext, _ASF_FILE, 5) == 0) {
+ int audio = 0;
+ int video = 0;
+ int err = 0;
- if (_media_svc_check_escape_char(input[i])) {
- result[j] = '#';
- result[++j] = input[i];
- } else {
- result[j] = input[i];
+ err = mm_file_get_stream_info(path, &audio, &video);
+ if (err == 0) {
+ if (audio > 0 && video == 0) {
+ *category ^= MEDIA_SVC_CATEGORY_ETC;
+ *category |= MEDIA_SVC_CATEGORY_MUSIC;
+ } else {
+ *category ^= MEDIA_SVC_CATEGORY_ETC;
+ *category |= MEDIA_SVC_CATEGORY_VIDEO;
+ }
+ }
+ }
}
}
- result[j] = '\0';
+ /*check music file in sound files. */
+ if (*category & MEDIA_SVC_CATEGORY_SOUND) {
+ int prefix_len = strlen(content_category[0].content_type) + 1;
- return result;
-}
+ for (idx = 0; idx < MUSIC_MIME_NUM; idx++) {
+ if (strcmp(mimetype + prefix_len, music_mime_table[idx]) == 0) {
+ *category ^= MEDIA_SVC_CATEGORY_SOUND;
+ *category |= MEDIA_SVC_CATEGORY_MUSIC;
+ break;
+ }
+ }
-int _media_svc_rename_file( const char *old_name, const char *new_name)
-{
- if((old_name == NULL) || (new_name == NULL))
- {
- media_svc_error("invalid file name");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
+ /*m3u file is playlist but mime type is "audio/x-mpegurl". but It has to be classified into MS_CATEGORY_ETC since playlist is not a sound track*/
+ if (strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) {
+ *category ^= MEDIA_SVC_CATEGORY_SOUND;
+ *category |= MEDIA_SVC_CATEGORY_ETC;
+ }
+ } else if (*category & MEDIA_SVC_CATEGORY_VIDEO) {
+ /*some video files don't have video stream. in this case it is categorize as music. */
+ char *ext = NULL;
+ /*"3gp" and "mp4" must check video stream and then categorize in directly. */
+ ext = strrchr(path, '.');
+ if (ext != NULL) {
+ if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
+ int audio = 0;
+ int video = 0;
+ int err = 0;
- if (rename(old_name, new_name) < 0) {
- media_svc_error("Old : [%s] New : [%s] errno : [%s]", old_name, new_name, strerror(errno));
- return MEDIA_INFO_ERROR_INTERNAL;
+ err = mm_file_get_stream_info(path, &audio, &video);
+ if (err == 0) {
+ if (audio > 0 && video == 0) {
+ *category ^= MEDIA_SVC_CATEGORY_VIDEO;
+ *category |= MEDIA_SVC_CATEGORY_MUSIC;
+ }
+ }
+ /*even though error occued in mm_file_get_stream_info return MS_MEDIA_ERR_NONE. fail means invalid media content. */
+ }
+ }
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-bool _media_svc_remove_file(const char *path)
+static int __media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
{
- int result = -1;
-
- result = remove(path);
- if (result == 0) {
- media_svc_debug("success to remove file");
- return TRUE;
- } else {
- media_svc_error("fail to remove file result errno = %s", strerror(errno));
- return FALSE;
- }
-}
+ int ret = MS_MEDIA_ERR_NONE;
+ int category = 0;
-int _media_svc_remove_all_files_in_dir(const char *dir_path)
-{
- struct dirent *entry = NULL;
- struct stat st;
- char filename[MEDIA_SVC_PATHNAME_SIZE] = {0};
- DIR *dir = NULL;
+ media_svc_media_type_e type;
- dir = opendir(dir_path);
- if (dir == NULL) {
- media_svc_error("%s is not exist", dir_path);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
+ ret = __media_svc_get_content_type_from_mime(path, mime_type, &category);
+ if (ret != MS_MEDIA_ERR_NONE)
+ media_svc_error("__media_svc_get_content_type_from_mime failed : %d", ret);
- while ((entry = readdir(dir)) != NULL) {
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
- continue;
- }
- snprintf(filename, sizeof(filename), "%s/%s", dir_path, entry->d_name);
+ if (category & MEDIA_SVC_CATEGORY_SOUND) type = MEDIA_SVC_MEDIA_TYPE_SOUND;
+ else if (category & MEDIA_SVC_CATEGORY_MUSIC) type = MEDIA_SVC_MEDIA_TYPE_MUSIC;
+ else if (category & MEDIA_SVC_CATEGORY_IMAGE) type = MEDIA_SVC_MEDIA_TYPE_IMAGE;
+ else if (category & MEDIA_SVC_CATEGORY_VIDEO) type = MEDIA_SVC_MEDIA_TYPE_VIDEO;
+ else type = MEDIA_SVC_MEDIA_TYPE_OTHER;
- if (stat(filename, &st) != 0) {
- continue;
- }
- if (S_ISDIR(st.st_mode)) {
- continue;
- }
- if (unlink(filename) != 0) {
- media_svc_error("failed to remove : %s", filename);
- closedir(dir);
- return MEDIA_INFO_ERROR_INTERNAL;
- }
- }
+ *media_type = type;
- closedir(dir);
- return MEDIA_INFO_ERROR_NONE;
+ return ret;
}
-char *_media_svc_get_title_from_filepath (const char *path)
+/*
+drm_contentifo is not NULL, if the file is OMA DRM.
+If the file is not OMA DRM, drm_contentinfo must be NULL.
+*/
+static int __media_svc_get_mime_type(const char *path, char *mimetype)
{
- char *filename = NULL;
- char *title = NULL;
- char *ext = NULL;
- int filename_len = -1;
- int new_title_len = -1;
+ if (path == NULL)
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
- if (!path) {
- media_svc_error("path is NULL");
- return NULL;
+ /*in case of normal files or failure to get mime in drm */
+ if (aul_get_mime_from_file(path, mimetype, 255) < 0) {
+ media_svc_error("aul_get_mime_from_file fail");
+ return MS_MEDIA_ERR_INTERNAL;
}
- filename = g_path_get_basename(path);
- if (!STRING_VALID(filename)) {
- media_svc_error("wrong file name");
- SAFE_FREE(filename);
- return NULL;
- }
+ return MS_MEDIA_ERR_NONE;
+}
- filename_len = strlen(filename);
+static bool __media_svc_get_file_ext(const char *file_path, char *file_ext)
+{
+ int i = 0;
- ext = g_strrstr(filename, ".");
- if (!ext) {
- media_svc_error("there is no file extention");
- return filename;
- }
+ for (i = strlen(file_path); i >= 0; i--) {
+ if (file_path[i] == '.') {
+ SAFE_STRLCPY(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
+ return true;
+ }
- new_title_len = filename_len - strlen(ext);
- if (new_title_len < 1) {
- media_svc_error("title length is zero");
- SAFE_FREE(filename);
- return NULL;
+ if (file_path[i] == '/')
+ return false;
}
+ return false;
+}
- title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE-1);
+static int __media_svc_get_location_value(MMHandleType tag, double *longitude, double *latitude, double *altitude)
+{
+ char *err_attr_name = NULL;
+ double gps_value = 0.0;
+ int mmf_error = FILEINFO_ERROR_NONE;
- SAFE_FREE(filename);
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LONGITUDE, &gps_value, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE) {
+ if (longitude != NULL)
+ *longitude = (gps_value == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : gps_value;
+ } else {
+ SAFE_FREE(err_attr_name);
+ }
- media_svc_debug("extract title is [%s]", title);
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LATIDUE, &gps_value, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE) {
+ if (latitude != NULL)
+ *latitude = (gps_value == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : gps_value;
+ } else {
+ SAFE_FREE(err_attr_name);
+ }
- return title;
-}
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALTIDUE, &gps_value, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE) {
+ if (altitude != NULL)
+ *altitude = (gps_value == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : gps_value;
+ } else {
+ SAFE_FREE(err_attr_name);
+ }
-static int _mkdir(const char *dir, mode_t mode) {
- char tmp[256];
- char *p = NULL;
- size_t len;
-
- snprintf(tmp, sizeof(tmp),"%s",dir);
- len = strlen(tmp);
- if(tmp[len - 1] == '/')
- tmp[len - 1] = 0;
- for(p = tmp + 1; *p; p++)
- if(*p == '/') {
- *p = 0;
- mkdir(tmp, mode);
- *p = '/';
- }
- return mkdir(tmp, mode);
+ return MS_MEDIA_ERR_NONE;
}
-static char* _media_svc_get_thumb_path(uid_t uid)
+static int __media_svc_resize_artwork(const char *path, const char *img_format)
{
- char *result_psswd = NULL;
- struct group *grpinfo = NULL;
- if(uid == getuid())
- {
- result_psswd = strdup(MEDIA_SVC_THUMB_PATH_PREFIX);
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- }
- else
- {
- struct passwd *userinfo = getpwuid(uid);
- if(userinfo == NULL) {
- media_svc_error("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- media_svc_error("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result_psswd, "%s/data/file-manager-service/.thumb", userinfo->pw_dir);
- }
+ int ret = MS_MEDIA_ERR_NONE;
+ unsigned int width = 0;
+ unsigned int height = 0;
+ unsigned int resized_width = 0;
+ unsigned int resized_height = 0;
+ mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
- _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO);
+ if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
+ media_svc_debug("type [jpeg]");
- return result_psswd;
-}
+ mm_util_extract_image_info(path, &img_type, &width, &height);
-char* _media_svc_get_thumb_internal_path(uid_t uid)
-{
- char *result_psswd = NULL;
- struct group *grpinfo = NULL;
- if(uid == getuid())
- {
- result_psswd = strdup(MEDIA_SVC_THUMB_INTERNAL_PATH);
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- }
- else
- {
- struct passwd *userinfo = getpwuid(uid);
- if(userinfo == NULL) {
- media_svc_error("getpwuid(%d) returns NULL !", uid);
- return NULL;
+ if (width <= MEDIA_SVC_ARTWORK_SIZE || height <= MEDIA_SVC_ARTWORK_SIZE) {
+ media_svc_debug("No need resizing");
+ return MS_MEDIA_ERR_NONE;
}
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- media_svc_error("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
+
+ /* resizing */
+ if (width > height) {
+ resized_height = MEDIA_SVC_ARTWORK_SIZE;
+ resized_width = width * MEDIA_SVC_ARTWORK_SIZE / height;
+ } else {
+ resized_width = MEDIA_SVC_ARTWORK_SIZE;
+ resized_height = height * MEDIA_SVC_ARTWORK_SIZE / width;
}
- asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/phone", userinfo->pw_dir);
- }
- _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO);
+ ret = mm_util_resize_P_P(path, resized_width, resized_height, path);
+
+ } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
+ media_svc_debug("type [png]");
+ } else {
+ media_svc_debug("Not proper img format");
+ }
- return result_psswd;
+ return ret;
}
-char* _media_svc_get_thumb_external_path(uid_t uid)
+static int __media_svc_safe_atoi(char *buffer, int *si)
{
- char *result_psswd = NULL;
- struct group *grpinfo = NULL;
- if(uid == getuid())
- {
- result_psswd = strdup(MEDIA_SVC_THUMB_EXTERNAL_PATH);
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- }
- else
- {
- struct passwd *userinfo = getpwuid(uid);
- if(userinfo == NULL) {
- media_svc_error("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if(grpinfo == NULL) {
- media_svc_error("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- media_svc_error("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/mmc", userinfo->pw_dir);
- }
+ char *end = NULL;
+ errno = 0;
+ media_svc_retvm_if(buffer == NULL || si == NULL, MS_MEDIA_ERR_INTERNAL, "invalid parameter");
+
+ const long sl = strtol(buffer, &end, 10);
- _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO);
+ media_svc_retvm_if(end == buffer, MS_MEDIA_ERR_INTERNAL, "not a decimal number");
+ media_svc_retvm_if('\0' != *end, MS_MEDIA_ERR_INTERNAL, "extra characters at end of input: %s", end);
+ media_svc_retvm_if((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno), MS_MEDIA_ERR_INTERNAL, "out of range of type long");
+ media_svc_retvm_if(sl > INT_MAX, MS_MEDIA_ERR_INTERNAL, "greater than INT_MAX");
+ media_svc_retvm_if(sl < INT_MIN, MS_MEDIA_ERR_INTERNAL, "less than INT_MIN");
- return result_psswd;
+ *si = (int)sl;
+
+ return MS_MEDIA_ERR_NONE;
}
-int _media_svc_save_image(void *image, int size, char *image_path, uid_t uid)
+static int __media_svc_save_image(unsigned char *image, unsigned int size, char *image_path, uid_t uid)
{
+ int ret = MS_MEDIA_ERR_NONE;
+
media_svc_debug("start save image, path [%s] image size [%d]", image_path, size);
if (!image) {
media_svc_error("invalid image..");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
struct statfs fs;
- if (-1 == statfs(_media_svc_get_thumb_path(uid), &fs)) {
+ char *thumb_path = NULL;
+ ret = ms_user_get_root_thumb_store_path(uid, &thumb_path);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_root_thumb_store_path fail");
+
+ if (-1 == statfs(thumb_path, &fs)) {
media_svc_error("error in statfs");
- return MEDIA_INFO_ERROR_INTERNAL;
+ SAFE_FREE(thumb_path);
+ return MS_MEDIA_ERR_INTERNAL;
}
+ SAFE_FREE(thumb_path);
+
long bsize_kbytes = fs.f_bsize >> 10;
if ((bsize_kbytes * fs.f_bavail) < 1024) {
media_svc_error("not enought space...");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;
}
FILE *fp = NULL;
if (fp == NULL) {
media_svc_error("failed to open file");
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
nwrite = fwrite(image, 1, size, fp);
if (nwrite != size) {
media_svc_error("failed to write thumbnail");
fclose(fp);
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_INTERNAL;
}
fclose(fp);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-
-bool _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
+static char *__media_svc_get_title_from_filepath(const char *path)
{
- char savename[MEDIA_SVC_PATHNAME_SIZE] = {0};
- char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0};
- char *thumb_dir = NULL;
- char hash[255 + 1];
- char *thumbfile_ext = NULL;
-
- thumb_dir = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? _media_svc_get_thumb_internal_path(uid) : _media_svc_get_thumb_external_path(uid);
+ char *filename = NULL;
+ char *title = NULL;
+ char *ext = NULL;
+ int filename_len = -1;
+ int new_title_len = -1;
- memset(file_ext, 0, sizeof(file_ext));
- if (!_media_svc_get_file_ext(pathname, file_ext)) {
- media_svc_error("get file ext fail");
+ if (!path) {
+ media_svc_error("path is NULL");
+ return NULL;
}
- int err = -1;
- err = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
- if (err < 0) {
- media_svc_error("mb_svc_generate_hash_code failed : %d", err);
- return FALSE;
+ filename = g_path_get_basename(path);
+ if (!STRING_VALID(filename)) {
+ media_svc_error("wrong file name");
+ SAFE_FREE(filename);
+ return NULL;
}
- //media_svc_debug("img format is [%s]", img_format);
+ filename_len = strlen(filename);
- if((strstr(img_format, "jpeg") != NULL) ||(strstr(img_format, "jpg") != NULL) ||(strstr(img_format, "JPG") != NULL)) {
- thumbfile_ext = "jpg";
- } else if((strstr(img_format, "png") != NULL) ||(strstr(img_format, "PNG") != NULL)) {
- thumbfile_ext = "png";
- } else if((strstr(img_format, "gif") != NULL) ||(strstr(img_format, "GIF") != NULL)) {
- thumbfile_ext = "gif";
- } else if((strstr(img_format, "bmp") != NULL) ||(strstr(img_format, "BMP") != NULL)) {
- thumbfile_ext = "bmp";
- } else {
- media_svc_error("Not proper img format");
- return FALSE;
+ ext = g_strrstr(filename, ".");
+ if (!ext) {
+ media_svc_error("there is no file extention");
+ return filename;
+ }
+
+ new_title_len = filename_len - strlen(ext);
+ if (new_title_len < 1) {
+ media_svc_error("title length is zero");
+ SAFE_FREE(filename);
+ return NULL;
}
- snprintf(savename, sizeof(savename), "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
- _strncpy_safe(thumb_path, savename, MEDIA_SVC_PATHNAME_SIZE);
- //media_svc_debug("thumb_path is [%s]", thumb_path);
+ title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE - 1);
+
+ SAFE_FREE(filename);
+
+ media_svc_debug("extract title is [%s]", title);
- return TRUE;
+ return title;
}
-bool _media_svc_get_file_ext(const char *file_path, char *file_ext)
+bool __media_svc_check_support_pinyin()
{
- int i = 0;
+ int ret = SYSTEM_INFO_ERROR_NONE;
+ bool is_supported = false;
- for (i = strlen(file_path); i >= 0; i--) {
- if (file_path[i] == '.') {
- _strncpy_safe(file_ext, &file_path[i+1], MEDIA_SVC_FILE_EXT_LEN_MAX);
- return true;
+ if (media_svc_pinyin_support == -1) {
+ ret = system_info_get_platform_bool("http://tizen.org/feature/content.filter.pinyin", &is_supported);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ media_svc_debug("SYSTEM_INFO_ERROR: content.filter.pinyin [%d]", ret);
+ return false;
}
- if (file_path[i] == '/') {
- return false;
+ media_svc_pinyin_support = is_supported;
+ }
+
+ return media_svc_pinyin_support;
+}
+int _media_svc_rename_file(const char *old_name, const char *new_name)
+{
+ if ((old_name == NULL) || (new_name == NULL)) {
+ media_svc_error("invalid file name");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ if (rename(old_name, new_name) < 0) {
+ media_svc_stderror(" ");
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_remove_file(const char *path)
+{
+ int result = -1;
+
+ result = remove(path);
+ if (result == 0) {
+ media_svc_debug("success to remove file");
+ return MS_MEDIA_ERR_NONE;
+ } else {
+ media_svc_stderror("fail to remove file result");
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+}
+
+int _media_svc_remove_all_files_in_dir(const char *dir_path)
+{
+ char filename[MEDIA_SVC_PATHNAME_SIZE] = {0, };
+ GDir *dir = NULL;
+ GError *error = NULL;
+ const char *name;
+
+ dir = g_dir_open(dir_path, 0, &error);
+ if (dir != NULL && error == NULL) {
+ while ((name = g_dir_read_name(dir))) {
+ memset(filename, 0, sizeof(filename));
+ snprintf(filename, sizeof(filename), "%s/%s", dir_path, name);
+
+ if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ if (unlink(filename) != 0)
+ media_svc_stderror("failed to remove");
+ }
}
+ } else {
+ media_svc_error("%s is not exist", dir_path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- return false;
+
+ g_dir_close(dir);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, };
+ char hash[255 + 1] = {0, };
+ char *thumb_dir = NULL;
+ char *thumbfile_ext = NULL;
+
+ ret = ms_user_get_thumb_store_path(uid, storage_type, &thumb_dir);
+ if (!STRING_VALID(thumb_dir)) {
+ media_svc_error("ms_user_get_thumb_store_path failed");
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ if (!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR)) {
+ media_svc_error("Wrong path[%s]", thumb_dir);
+ SAFE_FREE(thumb_dir);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ memset(file_ext, 0, sizeof(file_ext));
+ if (!__media_svc_get_file_ext(pathname, file_ext))
+ media_svc_error("get file ext fail");
+
+ ret = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("mb_svc_generate_hash_code failed : %d", ret);
+ SAFE_FREE(thumb_dir);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ if (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) {
+ if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
+ thumbfile_ext = (char *)"jpg";
+ } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
+ thumbfile_ext = (char *)"png";
+ } else if ((strstr(img_format, "gif") != NULL) || (strstr(img_format, "GIF") != NULL)) {
+ thumbfile_ext = (char *)"gif";
+ } else if ((strstr(img_format, "bmp") != NULL) || (strstr(img_format, "BMP") != NULL)) {
+ thumbfile_ext = (char *)"bmp";
+ } else {
+ media_svc_error("Not proper img format");
+ SAFE_FREE(thumb_dir);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
+ } else {
+ if (strcasecmp(file_ext, "PNG") == 0)
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.png", thumb_dir, file_ext, hash);
+ else
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.jpg", thumb_dir, file_ext, hash);
+ }
+
+ SAFE_FREE(thumb_dir);
+
+ return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_file_time(const char *full_path)
memset(&statbuf, 0, sizeof(struct stat));
fd = stat(full_path, &statbuf);
if (fd == -1) {
- media_svc_error("stat(%s) fails.", full_path);
- return MEDIA_INFO_ERROR_INTERNAL;
- }
+ media_svc_error("stat(%s) fails.", full_path);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
- return statbuf.st_mtime;
+ return statbuf.st_mtime;
}
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, media_svc_storage_type_e storage_type,
- const char *path, media_svc_media_type_e *media_type, bool refresh, drm_content_info_s **drm_contentInfo)
+int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh)
{
- int ret = MEDIA_INFO_ERROR_NONE;
- char * media_uuid = NULL;
- char * file_name = NULL;
- struct stat st;
- drm_bool_type_e drm_type = DRM_FALSE;
- char mime_type[256] = {0};
-
- ret = __media_svc_malloc_and_strncpy(&content_info->path, path);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
-
- memset(&st, 0, sizeof(struct stat));
- if (stat(path, &st) == 0) {
- content_info->modified_time = st.st_mtime;
- content_info->timeline = content_info->modified_time;
- content_info->size = st.st_size;
- //media_svc_debug("Modified time : [%d] Size : [%lld]", content_info->modified_time, content_info->size);
- } else {
- media_svc_error("stat failed : %s", strerror(errno));
- }
-
/* Set default GPS value before extracting meta information */
content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
/* Set filename to title for all media */
char *title = NULL;
- title = _media_svc_get_title_from_filepath(content_info->path);
+ title = __media_svc_get_title_from_filepath(content_info->path);
if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(title);
SAFE_FREE(title);
+ media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
} else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ media_svc_error("Can't extract title");
+ content_info->media_meta.title = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
}
/* Set default value before extracting meta information */
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.description == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
+
+ content_info->media_meta.copyright = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.copyright == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
+
+ content_info->media_meta.track_num = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.track_num == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.album = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.album == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.artist == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.album_artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.album_artist == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.genre = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.genre == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album_artist, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.composer = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.composer == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_meta.year = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ media_svc_retv_del_if(content_info->media_meta.year == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ if (refresh) {
+ media_svc_debug("refresh");
+ return MS_MEDIA_ERR_NONE;
+ }
+
+ content_info->played_count = 0;
+ content_info->last_played_time = 0;
+ content_info->last_played_position = 0;
+ content_info->favourate = 0;
+ content_info->media_meta.rating = 0;
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type,
+ const char *path, media_svc_media_type_e *media_type, bool refresh)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ char * media_uuid = NULL;
+ bool drm_type = false;
+ char mime_type[256] = {0, };
+
+ content_info->path = g_strdup(path);
+ media_svc_retv_del_if(content_info->path == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
+
+ struct stat st;
+ memset(&st, 0, sizeof(struct stat));
+ if (stat(path, &st) == 0) {
+ content_info->modified_time = st.st_mtime;
+ content_info->timeline = content_info->modified_time;
+ content_info->size = st.st_size;
+ } else {
+ media_svc_stderror("stat failed");
+ }
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, MEDIA_SVC_TAG_UNKNOWN);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ _media_svc_set_default_value(content_info, refresh);
/* refresh is TRUE when file modified. so only modified_time and size are changed*/
- if(refresh) {
+ if (refresh) {
media_svc_debug("refresh");
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
+ content_info->storage_uuid = g_strdup(storage_id);
+ media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
+
content_info->storage_type = storage_type;
time(&content_info->added_time);
media_uuid = _media_info_generate_uuid();
- media_svc_retvm_if(media_uuid == NULL, MEDIA_INFO_ERROR_INTERNAL, "Invalid UUID");
+ if (media_uuid == NULL) {
+ _media_svc_destroy_content_info(content_info);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
- ret = __media_svc_malloc_and_strncpy(&content_info->media_uuid, media_uuid);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->media_uuid = g_strdup(media_uuid);
+ media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- file_name = g_path_get_basename(path);
- ret = __media_svc_malloc_and_strncpy(&content_info->file_name, file_name);
- SAFE_FREE(file_name);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->file_name = g_path_get_basename(path);
+ media_svc_retv_del_if(content_info->file_name == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
/* if the file is DRM file, drm_type value is DRM_TRUE(1).
if drm_contentinfo is not NULL, the file is OMA DRM.*/
- ret = _media_svc_get_mime_type(path, mime_type, &drm_type, drm_contentInfo);
- if (ret < 0) {
- media_svc_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
- return MEDIA_INFO_ERROR_INVALID_PATH;
- }
+ ret = __media_svc_get_mime_type(path, mime_type);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
- media_svc_error("mime [%s]", mime_type);
+ media_svc_debug("mime [%s]", mime_type);
content_info->is_drm = drm_type;
- ret = _media_svc_get_media_type(path, mime_type, media_type);
- media_svc_retv_if(ret != MEDIA_INFO_ERROR_NONE, ret);
+ ret = __media_svc_get_media_type(path, mime_type, media_type);
+ media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
if ((*media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (*media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
media_svc_error("invalid media_type condition[%d]", *media_type);
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- ret = __media_svc_malloc_and_strncpy(&content_info->mime_type, mime_type);
- media_svc_retv_del_if(ret != MEDIA_INFO_ERROR_NONE, ret, content_info);
+ content_info->mime_type = g_strdup(mime_type);
+ media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- media_svc_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
+ media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
content_info->media_type = *media_type;
- content_info->played_count = 0;
- content_info->last_played_time= 0;
- content_info->last_played_position= 0;
- content_info->favourate= 0;
- content_info->media_meta.rating = 0;
-
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
+int image_360_check(char *path)
{
- if (content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE) {
- media_svc_error("content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
+ FILE *fp = NULL;
+ long app1_size = 0;
+ int size = 1;
+ unsigned char exif_header[4] = {0, };
+ unsigned char exif_app1[2] = {0, };
+ unsigned char exif_app1_xmp[2] = {0, };
+ long exif_app1_xmp_size = 0;
+ unsigned char exif_app1_xmp_t[2] = {0, };
+ char *xmp_data = NULL;
+ int size1 = 0;
+ int size2 = 0;
+ int fdata = 0;
+ int temp = 0;
+
+ memset(exif_header, 0x00, sizeof(exif_header));
+ memset(exif_app1, 0x00, sizeof(exif_app1));
+ memset(exif_app1_xmp, 0x00, sizeof(exif_app1_xmp));
+ memset(exif_app1_xmp_t, 0x00, sizeof(exif_app1_xmp_t));
+
+ fp = fopen(path, "rb");
+ if (fp == NULL)
+ goto ERROR;
+
+ size = fread(exif_header, 1, sizeof(exif_header), fp);
+ if (size <= 0)
+ goto ERROR;
+
+ if ((exif_header[0] == 0xff) && (exif_header[1] == 0xd8) && (exif_header[2] == 0xff) && (exif_header[3] == 0xe1)) {
+ size = fread(exif_app1, 1, sizeof(exif_app1), fp);
+ if (size <= 0)
+ goto ERROR;
+
+ size1 = exif_app1[0];
+ size2 = exif_app1[1];
+
+ app1_size = size1 * 256 + size2 - 2;
+
+ if (fseek(fp, app1_size, SEEK_CUR) != 0)
+ goto ERROR;
+
+ size = fread(exif_app1_xmp, 1, sizeof(exif_app1_xmp), fp);
+ if (size <= 0)
+ goto ERROR;
+
+ if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
+ int result = 0;
+ char *ptr = NULL;
+ size = fread(exif_app1_xmp_t, 1, sizeof(exif_app1_xmp_t), fp);
+ if (size <= 0)
+ goto ERROR;
+
+ size1 = exif_app1_xmp_t[0];
+ size2 = exif_app1_xmp_t[1];
+
+ exif_app1_xmp_size = size1 * 256 + size2 - 2;
+
+ if (exif_app1_xmp_size > 0) {
+ xmp_data = (char *)malloc(exif_app1_xmp_size);
+ memset(xmp_data, 0x0, exif_app1_xmp_size);
+
+ ptr = xmp_data;
+
+ while (exif_app1_xmp_size >= 0) {
+ exif_app1_xmp_size--;
+ fdata = fgetc(fp);
+ if (fdata == EOF)
+ continue;
+ if (fdata == '\0')
+ continue;
+ *ptr = (char)fdata;
+ ptr++;
+ temp++;
+ }
+ ptr = ptr - temp;
- char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
- char description_buf[MEDIA_SVC_METADATA_DESCRIPTION_MAX + 1] = { '\0' };
- memset(buf, 0x00, sizeof(buf));
- memset(description_buf, 0x00, sizeof(description_buf));
+ if (strstr(ptr, "UsePanoramaViewer")
+ && strstr(ptr, "True")
+ && strstr(ptr, "ProjectionType")
+ && strstr(ptr, "equirectangular"))
+ result = 1;
+
+ SAFE_FREE(xmp_data);
+ } else {
+ media_svc_error("invalid exif_app1_xmp_size [%ld]", exif_app1_xmp_size);
+ }
+
+ if (fp) {
+ fclose(fp);
+ fp = NULL;
+ }
+ return result;
+ } else {
+ goto ERROR;
+ }
+ } else {
+ goto ERROR;
+ }
+ERROR:
+ if (fp) {
+ fclose(fp);
+ fp = NULL;
+ }
+ return 0;
+}
- int ret = MEDIA_INFO_ERROR_NONE;
+int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info)
+{
double value = 0.0;
int orient_value = 0;
int exif_width = 0;
int exif_height = 0;
ExifData *ed = NULL;
+ int has_datetaken = FALSE;
+ double fnumber = 0.0;
+ int iso = 0;
+ char *path = NULL;
- char *path = content_info->path;
- if (path == NULL) {
- media_svc_error("path is NULL");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (content_info == NULL || content_info->media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+ media_svc_error("content_info == NULL || media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ path = content_info->path;
+ if (!STRING_VALID(path)) {
+ media_svc_error("Invalid Path");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
/* Load an ExifData object from an EXIF file */
ed = exif_data_new_from_file(path);
if (!ed) {
- media_svc_debug("There is no exif data in [ %s ]", path);
+ media_svc_sec_debug("There is no exif data in [ %s ]", path);
+ goto GET_WIDTH_HEIGHT;
}
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LATITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
- if (strlen(buf) != 0) {
- if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE) == MEDIA_INFO_ERROR_NONE) {
+ content_info->media_meta.is_360 = image_360_check(path);
- if (strcmp(buf, "S") == 0) {
+ if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0) {
+ if (strcmp(buf, "S") == 0)
value = -1 * value;
- }
-
- content_info->media_meta.latitude = value;
- } else {
- content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
}
+ content_info->media_meta.latitude = value;
} else {
content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
}
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_GPS_LONGITUDE_REF) == MEDIA_INFO_ERROR_NONE) {
- if (strlen(buf) != 0) {
- if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE) == MEDIA_INFO_ERROR_NONE) {
- if (strcmp(buf, "W") == 0) {
+ if (__media_svc_get_exif_info(ed, NULL, NULL, &value, EXIF_TAG_GPS_LONGITUDE) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_GPS_LONGITUDE_REF) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0) {
+ if (strcmp(buf, "W") == 0)
value = -1 * value;
- }
- content_info->media_meta.longitude = value;
- } else {
- content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
}
+ content_info->media_meta.longitude = value;
} else {
content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
}
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, description_buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION) == MEDIA_INFO_ERROR_NONE) {
- if (strlen(description_buf) == 0) {
- //media_svc_debug("Use 'No description'");
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- } else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, description_buf);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- }
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) == 0)
+ content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
+ else
+ content_info->media_meta.description = g_strdup(buf);
} else {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, MEDIA_SVC_TAG_UNKNOWN);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
}
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_IFD_0, EXIF_TAG_DATE_TIME) == MEDIA_INFO_ERROR_NONE) {
- if (strlen(buf) == 0) {
- //media_svc_debug("time is NULL");
- } else {
- //media_svc_debug("time is %s", buf);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, buf);
- if(ret != MEDIA_INFO_ERROR_NONE) {
- media_svc_error("strcpy error");
- } else {
- /* This is same as recorded_date */
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- }
+ if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0) {
+ has_datetaken = TRUE;
+ content_info->media_meta.datetaken = g_strdup(buf);
+
+ /* This is same as recorded_date */
+ content_info->media_meta.recorded_date = g_strdup(buf);
+ }
+ }
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0) {
+ has_datetaken = TRUE;
+ content_info->media_meta.datetaken = g_strdup(buf);
+
+ /* This is same as recorded_date */
+ content_info->media_meta.recorded_date = g_strdup(buf);
}
}
+ if (has_datetaken) {
+ content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
+ if (content_info->timeline == 0)
+ content_info->timeline = content_info->modified_time;
+ else
+ media_svc_debug("Timeline : %ld", content_info->timeline);
+ }
+
+ memset(buf, 0x00, sizeof(buf));
+
+ /* Get exposure_time value from exif. */
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0)
+ content_info->media_meta.exposure_time = g_strdup(buf);
+ }
+
+ /* Get fnumber value from exif. */
+ if (__media_svc_get_exif_info(ed, NULL, NULL, &fnumber, EXIF_TAG_FNUMBER) == MS_MEDIA_ERR_NONE) {
+ if (fnumber > 0.0)
+ content_info->media_meta.fnumber = fnumber;
+ else
+ content_info->media_meta.fnumber = 0.0;
+ } else {
+ content_info->media_meta.fnumber = 0.0;
+ }
+
+ /* Get iso value from exif. */
+ if (__media_svc_get_exif_info(ed, NULL, &iso, NULL, EXIF_TAG_ISO_SPEED_RATINGS) == MS_MEDIA_ERR_NONE) {
+ if (iso > 0)
+ content_info->media_meta.iso = iso;
+ else
+ content_info->media_meta.iso = 0;
+ } else {
+ content_info->media_meta.iso = 0;
+ }
+
+ memset(buf, 0x00, sizeof(buf));
+
+ /* Get model value from exif. */
+ if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
+ if (strlen(buf) > 0)
+ content_info->media_meta.model = g_strdup(buf);
+ }
+
/* Get orientation value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_IFD_0, EXIF_TAG_ORIENTATION) == MEDIA_INFO_ERROR_NONE) {
- if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270) {
+ if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
+ if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270)
content_info->media_meta.orientation = orient_value;
- } else {
+ else
content_info->media_meta.orientation = 0;
- }
} else {
content_info->media_meta.orientation = 0;
}
/* Get width value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_X_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
- if (exif_width > 0) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
+ if (exif_width > 0)
content_info->media_meta.width = exif_width;
- } else {
+ else
content_info->media_meta.width = 0;
- }
} else {
content_info->media_meta.width = 0;
}
/* Get height value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_IFD_EXIF, EXIF_TAG_PIXEL_Y_DIMENSION) == MEDIA_INFO_ERROR_NONE) {
- if (exif_height > 0) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
+ if (exif_height > 0)
content_info->media_meta.height = exif_height;
- } else {
+ else
content_info->media_meta.height = 0;
- }
} else {
content_info->media_meta.height = 0;
}
- content_info->media_meta.weather = NULL;
-
if (ed != NULL) exif_data_unref(ed);
- /* Set filename to title for image media */
- char *title = NULL;
- title = _media_svc_get_title_from_filepath(content_info->path);
- if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- SAFE_FREE(title);
- } else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
- }
-
-#if 0
- /* Extracting thumbnail */
- char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
- int width = 0;
- int height = 0;
+GET_WIDTH_HEIGHT:
- ret = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
- if (ret < 0) {
- media_svc_error("thumbnail_request_from_db failed: %d", ret);
- } else {
- //media_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
- }
+ if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) {
+ /*Get image width, height*/
+ unsigned int img_width = 0;
+ unsigned int img_height = 0;
+ mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
- content_info->media_meta.width = width;
- content_info->media_meta.height = height;
+ mm_util_extract_image_info(path, &img_type, &img_width, &img_height);
+ if (content_info->media_meta.width == 0)
+ content_info->media_meta.width = img_width;
- if (STRING_VALID(thumb_path))
- ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- else
- content_info->thumbnail_path = NULL;
+ if (content_info->media_meta.height == 0)
+ content_info->media_meta.height = img_height;
+ }
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
-#endif
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
-int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type, drm_content_info_s *drm_contentInfo, uid_t uid)
+int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
{
- MMHandleType content = 0;
MMHandleType tag = 0;
char *p = NULL;
- void *image = NULL;
int size = -1;
- int extracted_field = MEDIA_SVC_EXTRACTED_FIELD_NONE;
- int mmf_error = MM_ERROR_NONE;
- bool thumb_extracted_from_drm = FALSE;
+ int mmf_error = FILEINFO_ERROR_NONE;
char *err_attr_name = NULL;
- char *title = NULL;
- bool extract_thumbnail = FALSE;
- bool append_album = FALSE;
int album_id = 0;
- double gps_value = 0.0;
- int ret = MEDIA_INFO_ERROR_NONE;
- char *path = content_info->path;
-
-#ifdef __SUPPORT_DRM
- /*To do - code for DRM content*/
- if (content_info->is_drm) {
- drm_file_type_e drm_file_type;
-
- ret = drm_get_file_type(path, &drm_file_type);
- if (ret < 0) {
- media_svc_error("drm_get_file_type falied : %d", ret);
- drm_file_type = DRM_TYPE_UNDEFINED;
- }
-
- /* if drm_contentinfo is not NULL, the file is OMA DRM.*/
- if (drm_contentInfo != NULL) {
- if (drm_file_type == DRM_TYPE_OMA_V1) {
- if (strlen(drm_contentInfo->title) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
- }
- if (strlen(drm_contentInfo->description) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
- }
- } else if (drm_file_type == DRM_TYPE_OMA_V2) {
- if (strlen(drm_contentInfo->title) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, drm_contentInfo->title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
- }
+ /*Get Content Tag attribute ===========*/
+ mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
- if (strlen(drm_contentInfo->description) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, drm_contentInfo->description);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_DESC;
- }
+ if (mmf_error == FILEINFO_ERROR_NONE) {
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.album = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- if (strlen(drm_contentInfo->copyright) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, drm_contentInfo->copyright);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT;
- }
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.artist = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- if (strlen(drm_contentInfo->author) > 0) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, drm_contentInfo->author);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, drm_contentInfo->author);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.album_artist = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_ARTIST;
- }
- }
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ content_info->media_meta.genre = g_strdup(p);
- if (!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) {
- title = _media_svc_get_title_from_filepath(path);
- if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- SAFE_FREE(title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- } else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
- }
+ /* If genre is Ringtone, it's categorized as sound. But this logic is commented */
+ /*
+ if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
+ content_info->media_type = MEDIA_SVC_MEDIA_TYPE_SOUND;
}
-
- return MEDIA_INFO_ERROR_NONE;
+ */
} else {
- media_svc_debug("Some Not OMA Content's metadata is not incrypted so fileinfo can extracted metadata");
- }
- }
-#endif
-
- /*Get Content attribute ===========*/
- mmf_error = mm_file_create_content_attrs(&content, content_info->path);
-
- if (mmf_error == MM_ERROR_NONE) {
- /*Common attribute*/
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration, NULL);
- if (mmf_error != MM_ERROR_NONE) {
SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get duration attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("duration : %d", content_info->media_meta.duration);
}
- /*Sound/Music attribute*/
- if((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (!isspace(*p)) {
+ content_info->media_meta.title = g_strdup(p);
+ } else {
+ int idx = 0;
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("bit rate : %d", content_info->media_meta.bitrate);
- }
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get sample rate attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("sample rate : %d", content_info->media_meta.samplerate);
- }
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get audio channels attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("channel : %d", content_info->media_meta.channel);
- }
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get audio bit per sample attr - err(%x)", mmf_error);
- } else {
- media_svc_debug("bitpersample : %d", content_info->media_meta.bitpersample);
- }
- }else if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { /*Video attribute*/
- int audio_bitrate = 0;
- int video_bitrate = 0;
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &audio_bitrate, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("audio bit rate : %d", audio_bitrate);
- }
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_BITRATE, &video_bitrate, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("video bit rate : %d", video_bitrate);
+ for (idx = 0; idx < size; idx++) {
+ if (isspace(*p)) {
+ media_svc_debug("SPACE [%s]", p);
+ p++;
+ continue;
+ } else {
+ media_svc_debug("Not SPACE [%s]", p);
+ content_info->media_meta.title = g_strdup(p);
+ break;
+ }
+ }
}
+ }
- content_info->media_meta.bitrate = audio_bitrate + video_bitrate;
-
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get video width attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("width : %d", content_info->media_meta.width);
- }
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.description = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- SAFE_FREE(err_attr_name);
- media_svc_debug("fail to get video height attr - err(%x)", mmf_error);
- } else {
- //media_svc_debug("height : %d", content_info->media_meta.height);
- }
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.composer = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- } else {
- media_svc_error("Not support type");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
- }
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.copyright = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
- mmf_error = mm_file_destroy_content_attrs(content);
- if (mmf_error != MM_ERROR_NONE) {
- media_svc_error("fail to free content attr - err(%x)", mmf_error);
- }
+ mmf_error = mm_file_destroy_tag_attrs(tag);
+ if (mmf_error != FILEINFO_ERROR_NONE)
+ media_svc_error("fail to free tag attr - err(%x)", mmf_error);
} else {
- media_svc_error("error in mm_file_create_content_attrs [%d]", mmf_error);
+ content_info->album_id = album_id;
}
+ return MS_MEDIA_ERR_NONE;
+}
+
+int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid)
+{
+ MMHandleType content = 0;
+ MMHandleType tag = 0;
+ char *p = NULL;
+ unsigned char *image = NULL;
+ unsigned int size = 0;
+ int mmf_error = FILEINFO_ERROR_NONE;
+ char *err_attr_name = NULL;
+ int album_id = 0;
+ int ret = MS_MEDIA_ERR_NONE;
+ int cdis_value = 0;
+
/*Get Content Tag attribute ===========*/
mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
- if (mmf_error == MM_ERROR_NONE) {
+ if (mmf_error == FILEINFO_ERROR_NONE) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ALBUM)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.album, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
-
- //media_svc_debug("album[%d] : %s", size, content_info->media_meta.album);
- } else {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.album = g_strdup(p);
+ else
SAFE_FREE(err_attr_name);
- //media_svc_debug("album - unknown");
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_ARTIST)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.artist, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- //media_svc_debug("artist[%d] : %s", size, content_info->media_meta.artist);
- } else {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.artist = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.album_artist = g_strdup(p);
+ else
SAFE_FREE(err_attr_name);
- //media_svc_debug("artist - unknown");
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_GENRE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.genre, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ content_info->media_meta.genre = g_strdup(p);
- //media_svc_debug("genre : %s", content_info->media_meta.genre);
/* If genre is Ringtone, it's categorized as sound. But this logic is commented */
/*
if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
*/
} else {
SAFE_FREE(err_attr_name);
- //media_svc_debug("genre - unknown");
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_TITLE)) && (mmf_error == MM_ERROR_NONE) && (size > 0)/* && (!isspace(*p))*/) {
- if(!isspace(*p)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
-
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_TITLE;
- //media_svc_debug("extract title from content : %s", content_info->media_meta.title);
- //media_svc_debug("^^^^^^^^^^^^^^^ path = %s, title = %s, size = %d ^^^^^^^^^^^^^^", content_info->path, content_info->media_meta.title, size);
- }
- else {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (!isspace(*p)) {
+ content_info->media_meta.title = g_strdup(p);
+ } else {
int idx = 0;
- for(idx = 0; idx < size; idx++) {
- if(isspace(*p)) {
+ for (idx = 0; idx < size; idx++) {
+ if (isspace(*p)) {
media_svc_debug("SPACE [%s]", p);
p++;
continue;
} else {
media_svc_debug("Not SPACE [%s]", p);
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ content_info->media_meta.title = g_strdup(p);
break;
}
}
-
- if(idx == size)
- {
- media_svc_debug("Can't extract title. All string is space");
- title = _media_svc_get_title_from_filepath(content_info->path);
- if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- SAFE_FREE(title);
- } else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
- }
- }
- }
- } else {
- SAFE_FREE(err_attr_name);
- title = _media_svc_get_title_from_filepath(content_info->path);
- if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- SAFE_FREE(title);
- } else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
}
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.description, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- //media_svc_debug("desc : %s", content_info->media_meta.description);
- } else {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.description = g_strdup(p);
+ else
+ SAFE_FREE(err_attr_name);
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE)
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RECDATE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_DESC)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, p);
- if(ret != MEDIA_INFO_ERROR_NONE) {
- media_svc_error("strcpy error");
+ if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
+ char mime_type[255] = {0, };
+ ret = __media_svc_get_mime_type(content_info->path, mime_type);
+ /*if 3gp that audio only, media_type is music */
+ if ((ret == MS_MEDIA_ERR_NONE) &&
+ ((content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/mp4") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/3gpp") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "video/3gpp") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "audio/mp4") == 0))) {
+ /*Creation time format is 2013-01-01 00:00:00. change it to 2013:01:01 00:00:00 like exif time format*/
+ char *time_info = g_strdup_printf("0000:00:00 00:00:00 +0000");
+ char *p_value = p;
+ char *time_value = time_info;
+ if (time_info != NULL) {
+ while (*p_value != '\0') {
+ if (*p_value == '-')
+ *time_value = ':';
+ else
+ *time_value = *p_value;
+ time_value++;
+ p_value++;
+ }
+ content_info->media_meta.recorded_date = g_strdup(time_info);
+ SAFE_FREE(time_info);
+ } else {
+ media_svc_error("memory allocation error");
+ }
} else {
+ content_info->media_meta.recorded_date = g_strdup(p);
+ }
+
+ if (STRING_VALID(content_info->media_meta.recorded_date)) {
+ content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date);
+ if (content_info->timeline == 0)
+ content_info->timeline = content_info->modified_time;
+ else
+ media_svc_debug("Timeline : %ld", content_info->timeline);
+
/* This is same as datetaken */
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ /* Remove compensation string */
+ if (strlen(content_info->media_meta.recorded_date) > MEDIA_SVC_DEFAULT_FORMAT_LEN) {
+ content_info->media_meta.datetaken = g_strndup(content_info->media_meta.recorded_date, MEDIA_SVC_DEFAULT_FORMAT_LEN);
+ G_SAFE_FREE(content_info->media_meta.recorded_date);
+ content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.datetaken);
+ } else {
+ content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
+ }
}
- //media_svc_debug("Recorded date : %s", content_info->media_meta.recorded_date);
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_AUTHOR)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.composer, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- //media_svc_debug("extract composer from content : %s", content_info->media_meta.composer);
- } else {
- //media_svc_debug("composer - unknown");
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.composer = g_strdup(p);
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_COPYRIGHT)) && (mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.copyright, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- extracted_field |= MEDIA_SVC_EXTRACTED_FIELD_AUTHOR;
- //media_svc_debug("extract copyright from content : %s", content_info->media_meta.copyright);
- } else {
- //media_svc_debug("copyright - unknown");
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.copyright = g_strdup(p);
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
- if ((mmf_error == MM_ERROR_NONE) && (size > 0)) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.track_num, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- } else {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+ content_info->media_meta.track_num = g_strdup(p);
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DATE, &p, &size, NULL);
- if ((!(extracted_field & MEDIA_SVC_EXTRACTED_FIELD_YEAR)) && (mmf_error == MM_ERROR_NONE) && (size == 4)) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size == 4) {
int year = 0;
- if((p != NULL) && (sscanf( p, "%d", &year))) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.year, p);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- } else {
+ if ((p != NULL) && (__media_svc_safe_atoi(p, &year) == MS_MEDIA_ERR_NONE))
+ content_info->media_meta.year = g_strdup(p);
+ else
media_svc_debug("Wrong Year Information [%s]", p);
- }
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RATING, &p, &size, NULL);
- if ((mmf_error == MM_ERROR_NONE) && (size > 0)) {
- content_info->media_meta.rating = atoi(p);
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ int rate = 0;
+ if ((p != NULL) && (__media_svc_safe_atoi(p, &rate) == MS_MEDIA_ERR_NONE))
+ content_info->media_meta.rating = rate;
} else {
SAFE_FREE(err_attr_name);
content_info->media_meta.rating = 0;
}
- if((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
- /*Initialize album_id to 0. below code will set the album_id*/
- content_info->album_id = album_id;
- ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
-
- if (ret != MEDIA_INFO_ERROR_NONE) {
- if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
- media_svc_debug("album does not exist. So start to make album art");
- extract_thumbnail = TRUE;
- append_album = TRUE;
- } else {
- extract_thumbnail = FALSE;
- append_album = FALSE;
- }
+ /*Do not extract artwork for the USB Storage content*/
+ if (content_info->storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
+ SAFE_FREE(err_attr_name);
} else {
- content_info->album_id = album_id;
- append_album = FALSE;
-
- if((!strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) ||
- (!strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN)))) {
-
- media_svc_debug("Unknown album or artist already exists. Extract thumbnail for Unknown.");
- extract_thumbnail = TRUE;
- } else {
-
- media_svc_debug("album already exists. don't need to make album art");
- ret = _media_svc_get_album_art_by_album_id(handle, album_id, &content_info->thumbnail_path);
- media_svc_retv_del_if((ret != MEDIA_INFO_ERROR_NONE) && (ret != MEDIA_INFO_ERROR_DATABASE_NO_RECORD), ret, content_info);
- extract_thumbnail = FALSE;
- }
+ /*media_svc_debug("artwork size1 [%d]", size); */
}
-
- if ((!thumb_extracted_from_drm) && (extract_thumbnail == TRUE)) {
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
- SAFE_FREE(err_attr_name);
- } else {
- //media_svc_debug("artwork size1 [%d]", size);
- }
-
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_SIZE, &size, NULL);
- if (mmf_error != MM_ERROR_NONE) {
- media_svc_error("fail to get artwork size - err(%x)", mmf_error);
- SAFE_FREE(err_attr_name);
- } else {
- //media_svc_debug("artwork size2 [%d]", size);
- }
- if (image != NULL && size > 0) {
- bool result = FALSE;
- int ret = MEDIA_INFO_ERROR_NONE;
- char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
- int artwork_mime_size = -1;
-
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
- if ((mmf_error == MM_ERROR_NONE) && (artwork_mime_size > 0)) {
- result = _media_svc_get_thumbnail_path(content_info->storage_type, thumb_path, content_info->path, p, uid);
- if (result == FALSE) {
- media_svc_error("Fail to Get Thumbnail Path");
- }
- } else {
- SAFE_FREE(err_attr_name);
- }
-
- if(strlen(thumb_path) > 0)
- {
- ret = _media_svc_save_image(image, size, thumb_path, uid);
- if (ret != MEDIA_INFO_ERROR_NONE) {
- media_svc_error("Fail to Save Thumbnail Image");
- }
- else {
- ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_SIZE, &size, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ media_svc_error("fail to get artwork size - err(%x)", mmf_error);
+ SAFE_FREE(err_attr_name);
+ } else {
+ /*media_svc_debug("artwork size2 [%d]", size); */
+ }
+
+ if (image != NULL && size > 0) {
+ char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
+ int artwork_mime_size = -1;
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
+ if ((mmf_error == FILEINFO_ERROR_NONE) && (artwork_mime_size > 0)) {
+ ret = _media_svc_get_thumbnail_path(content_info->storage_type, content_info->media_type, thumb_path, content_info->path, p, uid);
+ if (ret != MS_MEDIA_ERR_NONE)
+ media_svc_error("Fail to Get Thumbnail Path");
+
+ if (strlen(thumb_path) > 0) {
+ ret = __media_svc_save_image(image, size, thumb_path, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("Fail to Save Image");
+ } else {
+ /* albumart resizing */
+ ret = __media_svc_resize_artwork(thumb_path, p);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("Fail to Make Thumbnail Image");
+ _media_svc_remove_file(thumb_path);
+
+ } else {
+ content_info->thumbnail_path = g_strdup(thumb_path);
+ }
}
}
+ } else {
+ SAFE_FREE(err_attr_name);
}
}
-
- if(append_album == TRUE) {
-
- if((strncmp(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))) &&
- (strncmp(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN, strlen(MEDIA_SVC_TAG_UNKNOWN))))
+ }
+
+ /*Initialize album_id to 0. below code will set the album_id*/
+ content_info->album_id = album_id;
+ ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ media_svc_debug("album does not exist. So start to make album art");
+ if ((g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
+ (g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
else
ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
-
+
content_info->album_id = album_id;
}
- } else if(media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LONGITUDE, &gps_value, NULL);
- if (mmf_error == MM_ERROR_NONE) {
- if (gps_value == 0.0)
- content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- else
- content_info->media_meta.longitude = gps_value;
+ } else {
+ content_info->album_id = album_id;
+ }
+
+ if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+ double longitude = 0.0;
+ double latitude = 0.0;
+ double altitude = 0.0;
+
+ __media_svc_get_location_value(tag, &longitude, &latitude, &altitude);
+ content_info->media_meta.longitude = longitude;
+ content_info->media_meta.latitude = latitude;
+ content_info->media_meta.altitude = altitude;
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_CDIS, &cdis_value, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ cdis_value = 0;
+ SAFE_FREE(err_attr_name);
+ }
+
+ media_svc_debug("CDIS : %d", cdis_value);
+
+ mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ROTATE, &p, &size, NULL);
+ if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
+ content_info->media_meta.orientation = atoi(p);
} else {
SAFE_FREE(err_attr_name);
+ content_info->media_meta.orientation = 0;
+ media_svc_debug("fail to get video orientation attr - err(%x)", mmf_error);
}
+ }
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_LATIDUE, &gps_value, NULL);
- if (mmf_error == MM_ERROR_NONE) {
- if (gps_value == 0.0)
- content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- else
- content_info->media_meta.latitude = gps_value;
+ mmf_error = mm_file_destroy_tag_attrs(tag);
+ if (mmf_error != FILEINFO_ERROR_NONE)
+ media_svc_error("fail to free tag attr - err(%x)", mmf_error);
+ } else {
+ content_info->album_id = album_id;
+ }
+
+ /*Get Content attribute ===========*/
+ if (cdis_value == 1)
+ mmf_error = mm_file_create_content_attrs_safe(&content, content_info->path);
+ else
+ mmf_error = mm_file_create_content_attrs_simple(&content, content_info->path);
+
+ if (mmf_error == FILEINFO_ERROR_NONE) {
+ /*Common attribute*/
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get duration attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("duration : %d", content_info->media_meta.duration); */
+ }
+
+ /*Sound/Music attribute*/
+ if ((content_info->media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) || (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
+
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
} else {
+ /*media_svc_debug("bit rate : %d", content_info->media_meta.bitrate); */
+ }
+
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get sample rate attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("sample rate : %d", content_info->media_meta.samplerate); */
}
- mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALTIDUE, &gps_value, NULL);
- if (mmf_error == MM_ERROR_NONE) {
- if (gps_value == 0.0)
- content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- else
- content_info->media_meta.altitude = gps_value;
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get audio channels attr - err(%x)", mmf_error);
} else {
+ /*media_svc_debug("channel : %d", content_info->media_meta.channel); */
+ }
+
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get audio bit per sample attr - err(%x)", mmf_error);
+ } else {
+ media_svc_debug("bitpersample : %d", content_info->media_meta.bitpersample);
}
-#if 0
- //if ((!thumb_extracted_from_drm) && (extract_thumbnail == TRUE))
- {
- /* Extracting thumbnail */
- char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
- int width = 0;
- int height = 0;
-
- ret = thumbnail_request_from_db_with_size(content_info->path, thumb_path, sizeof(thumb_path), &width, &height);
- if (ret < 0) {
- media_svc_error("thumbnail_request_from_db failed: %d", ret);
- } else {
- //media_svc_debug("thumbnail_request_from_db success: %s", thumb_path);
- }
+ } else if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) { /*Video attribute*/
+ int audio_bitrate = 0;
+ int video_bitrate = 0;
- ret = __media_svc_malloc_and_strncpy(&content_info->thumbnail_path, thumb_path);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &audio_bitrate, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("audio bit rate : %d", audio_bitrate); */
+ }
- if (content_info->media_meta.width <= 0) content_info->media_meta.width = width;
- if (content_info->media_meta.height <= 0) content_info->media_meta.height = height;
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_BITRATE, &video_bitrate, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get audio bitrate attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("video bit rate : %d", video_bitrate); */
}
-#endif
- }
- mmf_error = mm_file_destroy_tag_attrs(tag);
- if (mmf_error != MM_ERROR_NONE) {
- media_svc_error("fail to free tag attr - err(%x)", mmf_error);
- }
- } else {
- /* in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
- char *title = NULL;
- media_svc_error("no tag information");
-
- title = _media_svc_get_title_from_filepath(content_info->path);
- if (title) {
- ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.title, title);
- if(ret != MEDIA_INFO_ERROR_NONE)
- media_svc_error("strcpy error");
- SAFE_FREE(title);
+ content_info->media_meta.bitrate = audio_bitrate + video_bitrate;
+
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get video width attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("width : %d", content_info->media_meta.width); */
+ }
+
+ mmf_error = mm_file_get_attrs(content, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height, NULL);
+ if (mmf_error != FILEINFO_ERROR_NONE) {
+ SAFE_FREE(err_attr_name);
+ media_svc_debug("fail to get video height attr - err(%x)", mmf_error);
+ } else {
+ /*media_svc_debug("height : %d", content_info->media_meta.height); */
+ }
} else {
- media_svc_error("Can't extract title from filepath [%s]", content_info->path);
+ media_svc_error("Not support type");
+ mmf_error = mm_file_destroy_content_attrs(content);
+ if (mmf_error != FILEINFO_ERROR_NONE)
+ media_svc_error("fail to free content attr - err(%x)", mmf_error);
+
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- content_info->album_id = album_id;
+ mmf_error = mm_file_destroy_content_attrs(content);
+ if (mmf_error != FILEINFO_ERROR_NONE)
+ media_svc_error("fail to free content attr - err(%x)", mmf_error);
+ } else {
+ media_svc_error("error in mm_file_create_content_attrs [%d]", mmf_error);
}
- return MEDIA_INFO_ERROR_NONE;
+ return MS_MEDIA_ERR_NONE;
}
void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
SAFE_FREE(content_info->mime_type);
SAFE_FREE(content_info->folder_uuid);
SAFE_FREE(content_info->thumbnail_path);
+ SAFE_FREE(content_info->storage_uuid);
/* Delete media_svc_content_meta_s */
SAFE_FREE(content_info->media_meta.title);
SAFE_FREE(content_info->media_meta.track_num);
SAFE_FREE(content_info->media_meta.description);
SAFE_FREE(content_info->media_meta.datetaken);
+ SAFE_FREE(content_info->media_meta.exposure_time);
+ SAFE_FREE(content_info->media_meta.model);
SAFE_FREE(content_info->media_meta.weather);
+ SAFE_FREE(content_info->media_meta.category);
+ SAFE_FREE(content_info->media_meta.keyword);
+ SAFE_FREE(content_info->media_meta.location_tag);
+ SAFE_FREE(content_info->media_meta.content_name);
+ SAFE_FREE(content_info->media_meta.age_rating);
+ SAFE_FREE(content_info->media_meta.author);
+ SAFE_FREE(content_info->media_meta.provider);
SAFE_FREE(content_info->media_meta.title_pinyin);
SAFE_FREE(content_info->media_meta.album_pinyin);
return;
}
-int _media_svc_get_store_type_by_path(const char *path, media_svc_storage_type_e *storage_type)
+int __media_svc_get_proper_thumb_size(unsigned int orig_w, unsigned int orig_h, unsigned int *thumb_w, unsigned int *thumb_h)
{
- if(STRING_VALID(path))
- {
- if(strncmp(path, MEDIA_SVC_PATH_PHONE, strlen(MEDIA_SVC_PATH_PHONE)) == 0)
- {
- *storage_type = MEDIA_SVC_STORAGE_INTERNAL;
- }
- else if(strncmp (path, MEDIA_SVC_PATH_MMC, strlen(MEDIA_SVC_PATH_MMC)) == 0)
- {
- *storage_type = MEDIA_SVC_STORAGE_EXTERNAL;
- }
- }
- else
- {
- media_svc_error("INVALID parameter");
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ bool portrait = false;
+ double ratio;
+
+ if (orig_w < orig_h)
+ portrait = true;
+
+ /* Set smaller length to default size */
+ if (portrait) {
+ if (orig_w < *thumb_w)
+ *thumb_w = orig_w;
+ ratio = (double)orig_h / (double)orig_w;
+ *thumb_h = *thumb_w * ratio;
+ } else {
+ if (orig_h < *thumb_h)
+ *thumb_h = orig_h;
+ ratio = (double)orig_w / (double)orig_h;
+ *thumb_w = *thumb_h * ratio;
}
- return MEDIA_INFO_ERROR_NONE;
-}
-
-char *_media_svc_replace_path(char *s, const char *olds, const char *news)
-{
- char *result, *sr;
- size_t i, count = 0;
- size_t oldlen = strlen(olds); if (oldlen < 1) return s;
- size_t newlen = strlen(news);
-
- if (newlen != oldlen) {
- for (i = 0; s[i] != '\0';) {
- if (memcmp(&s[i], olds, oldlen) == 0) count++, i += oldlen;
- else i++;
- }
- } else i = strlen(s);
-
-
- result = (char *) calloc(1, i + 1 + count * (newlen - oldlen));
- if (result == NULL) return NULL;
-
- sr = result;
- while (*s) {
- if (memcmp(s, olds, oldlen) == 0) {
- memcpy(sr, news, newlen);
- sr += newlen;
- s += oldlen;
- } else *sr++ = *s++;
- }
-
- *sr = '\0';
-
- return result;
-}
+ media_svc_debug("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
-int _media_svc_error_convert(int error)
-{
- media_svc_debug("error : [%d]", error);
-
- if(error == MS_MEDIA_ERR_NONE) /*Error None*/
- return MEDIA_INFO_ERROR_NONE;
- else if(error == MS_MEDIA_ERR_DB_CONNECT_FAIL) /*DB Connect Fail*/
- return MEDIA_INFO_ERROR_DATABASE_CONNECT;
- else if(error == MS_MEDIA_ERR_DB_DISCONNECT_FAIL) /*DB Disconnect Fail*/
- return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
- else if(error == MS_MEDIA_ERR_SOCKET_CONN) /*Socket Connect Fail*/
- return MEDIA_INFO_ERROR_SOCKET_CONN;
- else if(error == MS_MEDIA_ERR_INVALID_PARAMETER || error == MS_MEDIA_ERR_INVALID_PATH)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
-
- return MEDIA_INFO_ERROR_INTERNAL;
+ return MS_MEDIA_ERR_NONE;
}
-
-bool _media_svc_is_drm_file(const char *path)
+int _media_svc_create_thumbnail(const char *path, char *thumb_path, int max_length, media_svc_media_type_e media_type, uid_t uid)
{
-#ifdef __SUPPORT_DRM
- int ret;
- drm_bool_type_e is_drm_file = DRM_UNKNOWN;
+ int ret = MS_MEDIA_ERR_NONE;
+ unsigned int origin_w = 0;
+ unsigned int origin_h = 0;
+ unsigned int thumb_w = THUMB_WIDTH;
+ unsigned int thumb_h = THUMB_HEIGHT;
+ mm_util_img_codec_type image_type = IMG_CODEC_UNKNOWN_TYPE;
- ret = drm_is_drm_file(path,&is_drm_file);
- if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file)
- return TRUE;
-#endif
- return FALSE;
-}
+ if (path == NULL || thumb_path == NULL) {
+ media_svc_error("Invalid parameter");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
-int _media_svc_get_mime_in_drm_info(const char *path, char *mime, drm_content_info_s **drm_contentInfo)
-{
-#ifdef __SUPPORT_DRM
- int ret = MEDIA_INFO_ERROR_NONE;
- drm_file_type_e file_type = DRM_TYPE_UNDEFINED;
+ if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ media_svc_error("Original path(%s) doesn't exist.", path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
- if (path == NULL || mime == NULL)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
+ if (max_length <= 0) {
+ media_svc_error("Length is invalid");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
- ret = drm_get_file_type(path, &file_type);
- if (ret != DRM_RETURN_SUCCESS) {
- media_svc_error("drm_get_file_type() failed : %d", ret);
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
- } else {
- if (file_type == DRM_TYPE_OMA_V1
- || file_type == DRM_TYPE_OMA_V2
- || file_type == DRM_TYPE_OMA_PD) {
- *drm_contentInfo = malloc(sizeof(drm_content_info_s));
- memset(*drm_contentInfo,0x0,sizeof(drm_content_info_s));
- ret = drm_get_content_info(path, *drm_contentInfo);
- if (ret != DRM_RETURN_SUCCESS) {
- media_svc_error("drm_svc_get_content_info() fails :%d ", ret);
- free(*drm_contentInfo);
- *drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
- }
+ ms_user_storage_type_e store_type = -1;
+ ret = ms_user_get_storage_type(uid, path, &store_type);
- if (STRING_VALID((*drm_contentInfo)->mime_type)) {
- strncpy(mime,(*drm_contentInfo)->mime_type, MEDIA_SVC_METADATA_LEN_MAX);
- media_svc_debug("DRM contentType : %s",(*drm_contentInfo)->mime_type);
- } else {
- free(*drm_contentInfo);
- *drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
- }
- } else {
- media_svc_error("THIS IS DRM BUT YOU SHOULD USE API OF AUL LIBRARY");
- *drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
- }
+ if ((ret != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) {
+ media_svc_sec_error("origin path(%s) is invalid. err : [%d] store_type [%d]", path, ret, store_type);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- return MEDIA_INFO_ERROR_NONE;
-#else
- *drm_contentInfo = NULL;
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
-#endif
-}
+ media_svc_sec_debug("Path[%s] Type[%d]", path, media_type);
-int _media_svc_get_content_type_from_mime(const char * path, const char * mimetype, int * category)
-{
- int i = 0;
- int err = 0;
-
- *category = MEDIA_SVC_CATEGORY_UNKNOWN;
+ //1. make hash path
+ ret = _media_svc_get_thumbnail_path(store_type, media_type, thumb_path, path, THUMB_EXT, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
+ SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
+ return ret;
+ }
- //media_svc_debug("mime type : %s", mimetype);
+ //2. save thumbnail
+ if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+ ret = mm_util_extract_image_info(path, &image_type, &origin_w, &origin_h);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("Getting image info is failed err: %d", ret);
+ SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
- /*categorize from mimetype */
- for (i = 0; i < CONTENT_TYPE_NUM; i++) {
- if (strstr(mimetype, content_category[i].content_type) != NULL) {
- *category = (*category | content_category[i].category_by_mime);
- break;
+ if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM)) {
+ media_svc_error("This original image is too big");
+ SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
+ return MS_MEDIA_ERR_THUMB_TOO_BIG;
}
- }
- /*in application type, exitst sound file ex) x-smafs */
- if (*category & MEDIA_SVC_CATEGORY_ETC) {
- int prefix_len = strlen(content_category[0].content_type);
+ __media_svc_get_proper_thumb_size(origin_w, origin_h, &thumb_w, &thumb_h);
+ ret = mm_util_resize_P_P(path, thumb_w, thumb_h, thumb_path);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ media_svc_error("mm_util_resize_P_P err: %d", ret);
+ SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ } else {
+ MMHandleType content = (MMHandleType) NULL;
+ MMHandleType tag = (MMHandleType) NULL;
+
+ char *p = NULL;
+ int cdis_value = 0;
+ void *frame = NULL;
+ int video_track_num = 0;
+ char *err_msg = NULL;
+ int size = 0;
+ mm_util_image_h img = NULL;
+ mm_util_image_h resize_img = NULL;
+
+ /* Get Content Tag attribute for orientation */
+ ret = mm_file_create_tag_attrs(&tag, path);
+ mm_util_magick_rotate_type rot_type = MM_UTIL_ROTATE_NUM;
+
+ if (ret == FILEINFO_ERROR_NONE) {
+ ret = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_ROTATE, &p, &size, NULL);
+ if (ret == FILEINFO_ERROR_NONE && size >= 0) {
+ if (p == NULL) {
+ rot_type = MM_UTIL_ROTATE_0;
+ } else {
+ if (strncmp(p, "90", size) == 0)
+ rot_type = MM_UTIL_ROTATE_90;
+ else if (strncmp(p, "180", size) == 0)
+ rot_type = MM_UTIL_ROTATE_180;
+ else if (strncmp(p, "270", size) == 0)
+ rot_type = MM_UTIL_ROTATE_270;
+ else
+ rot_type = MM_UTIL_ROTATE_0;
+ }
+ media_svc_debug("There is tag rotate : %d", rot_type);
+ } else {
+ media_svc_debug("There is NOT tag rotate");
+ rot_type = MM_UTIL_ROTATE_0;
+ SAFE_FREE(err_msg);
+ }
- for (i = 0; i < SOUND_MIME_NUM; i++) {
- if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
- *category ^= MEDIA_SVC_CATEGORY_ETC;
- *category |= MEDIA_SVC_CATEGORY_SOUND;
- break;
+ ret = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_CDIS, &cdis_value, NULL);
+ if (ret != FILEINFO_ERROR_NONE) {
+ cdis_value = 0;
+ SAFE_FREE(err_msg);
}
+ } else {
+ rot_type = MM_UTIL_ROTATE_0;
+ cdis_value = 0;
}
- }
- /*check music file in soun files. */
- if (*category & MEDIA_SVC_CATEGORY_SOUND) {
- int prefix_len = strlen(content_category[0].content_type) + 1;
+ ret = mm_file_destroy_tag_attrs(tag);
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("fail to free tag attr - err(%x)", ret);
+ }
- //media_svc_error("mime_type : %s", mimetype + prefix_len);
+ if (cdis_value == 1) {
+ media_svc_debug("This is CDIS vlaue 1");
+ ret = mm_file_create_content_attrs_safe(&content, path);
+ } else {
+ ret = mm_file_create_content_attrs(&content, path);
+ }
- for (i = 0; i < MUSIC_MIME_NUM; i++) {
- if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
- *category ^= MEDIA_SVC_CATEGORY_SOUND;
- *category |= MEDIA_SVC_CATEGORY_MUSIC;
- break;
- }
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_create_content_attrs fails : %d", ret);
+ return MS_MEDIA_ERR_INTERNAL;
}
- /*m3u file is playlist but mime type is "audio/x-mpegurl". but It has to be classified into MS_CATEGORY_ETC since playlist is not a sound track*/
- if(strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) {
- *category ^= MEDIA_SVC_CATEGORY_SOUND;
- *category |= MEDIA_SVC_CATEGORY_ETC;
+ ret = mm_file_get_attrs(content, &err_msg, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &video_track_num, NULL);
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_get_attrs fails : %s", err_msg);
+ SAFE_FREE(err_msg);
+ goto ERROR;
}
- } else if (*category & MEDIA_SVC_CATEGORY_VIDEO) {
- /*some video files don't have video stream. in this case it is categorize as music. */
- char *ext;
- /*"3gp" and "mp4" must check video stream and then categorize in directly. */
- ext = strrchr(path, '.');
- if (ext != NULL) {
- if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
- int audio = 0;
- int video = 0;
- err = mm_file_get_stream_info(path, &audio, &video);
- if (err == 0) {
- if (audio > 0 && video == 0) {
- *category ^= MEDIA_SVC_CATEGORY_VIDEO;
- *category |= MEDIA_SVC_CATEGORY_MUSIC;
- }
- }
+ if (video_track_num > 0) {
+ ret = mm_file_get_attrs(content, &err_msg,
+ MM_FILE_CONTENT_VIDEO_WIDTH,
+ &origin_w,
+ MM_FILE_CONTENT_VIDEO_HEIGHT,
+ &origin_h,
+ MM_FILE_CONTENT_VIDEO_THUMBNAIL, &frame, /* raw image is RGB888 format */
+ &size, NULL);
+
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_get_attrs fails : %s", err_msg);
+ SAFE_FREE(err_msg);
+ goto ERROR;
}
- }
- }
- //media_svc_debug("category_from_ext : %d", *category);
+ media_svc_debug("W[%d] H[%d] Size[%d] Frame[%p] Rotate[%d]", origin_w, origin_h, size, frame, rot_type);
+ if (frame == NULL || origin_w == 0 || origin_h == 0) {
+ media_svc_error("Failed to get frame data");
+ goto ERROR;
+ }
- return err;
-}
+ ret = __media_svc_get_proper_thumb_size(origin_w, origin_h, &thumb_w, &thumb_h);
+ if (thumb_w <= 0 || thumb_h <= 0) {
+ media_svc_error("Failed to get thumb size");
+ goto ERROR;
+ }
-/*
-drm_contentifo is not NULL, if the file is OMA DRM.
-If the file is not OMA DRM, drm_contentinfo must be NULL.
-*/
-int _media_svc_get_mime_type(const char *path, char *mimetype, drm_bool_type_e *is_drm, drm_content_info_s **drm_contentInfo)
-{
- int ret = MEDIA_INFO_ERROR_NONE;
+ media_svc_debug("Origin:W[%d] H[%d] Proper:W[%d] H[%d]", origin_w, origin_h, thumb_w, thumb_h);
- if (path == NULL)
- return MEDIA_INFO_ERROR_INVALID_PARAMETER;
-
-#ifdef __SUPPORT_DRM
- /* In case of drm file. */
- if (_media_svc_is_drm_file(path)) {
- *is_drm = DRM_TRUE;
- ret = _media_svc_get_mime_in_drm_info(path, mimetype, drm_contentInfo);
- if (ret == MEDIA_INFO_ERROR_NONE) {
- return ret;
+ ret = mm_util_create_handle(&img, (unsigned char *)frame, origin_w, origin_h, size, MM_UTIL_COLOR_RGB24);
+ if (origin_w > thumb_w || origin_h > thumb_h) {
+ if (rot_type != MM_UTIL_ROTATE_0) {
+ ret = mm_util_resize_B_B(img, thumb_w, thumb_h, &resize_img);
+ if (ret != MM_UTIL_ERROR_NONE)
+ goto ERROR;
+ ret = mm_util_rotate_B_P(resize_img, rot_type, thumb_path);
+ } else {
+ ret = mm_util_resize_B_P(img, thumb_w, thumb_h, thumb_path);
+ }
+ } else {
+ if (rot_type != MM_UTIL_ROTATE_0)
+ ret = mm_util_rotate_B_P(img, rot_type, thumb_path);
+ else
+ ret = mm_util_resize_B_P(img, origin_w, origin_h, thumb_path);
+ }
}
- }
-#else
- *is_drm = DRM_FALSE;
- *drm_contentInfo = NULL;
-#endif
-
- /*in case of normal files or failure to get mime in drm */
- if (aul_get_mime_from_file(path, mimetype, 255) < 0) {
- media_svc_error("aul_get_mime_from_file fail");
- return MEDIA_INFO_ERROR_INVALID_MEDIA;
- }
-
- return MEDIA_INFO_ERROR_NONE;
-}
-int _media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
-{
- int ret = MEDIA_INFO_ERROR_NONE;
- int category = 0;
+ ERROR:
+ mm_util_destroy_handle(img);
+ mm_util_destroy_handle(resize_img);
+ mm_file_destroy_content_attrs(content);
- media_svc_media_type_e type;
+ if (ret != MS_MEDIA_ERR_NONE)
+ return MS_MEDIA_ERR_INTERNAL;
- ret = _media_svc_get_content_type_from_mime(path, mime_type, &category);
- if (ret < 0) {
- media_svc_error("_media_svc_get_content_type_from_mime failed : %d", ret);
+ return MS_MEDIA_ERR_NONE;
}
- if (category & MEDIA_SVC_CATEGORY_SOUND) type = MEDIA_SVC_MEDIA_TYPE_SOUND;
- else if (category & MEDIA_SVC_CATEGORY_MUSIC) type = MEDIA_SVC_MEDIA_TYPE_MUSIC;
- else if (category & MEDIA_SVC_CATEGORY_IMAGE) type = MEDIA_SVC_MEDIA_TYPE_IMAGE;
- else if (category & MEDIA_SVC_CATEGORY_VIDEO) type = MEDIA_SVC_MEDIA_TYPE_VIDEO;
- else type = MEDIA_SVC_MEDIA_TYPE_OTHER;
-
- *media_type = type;
-
return ret;
}
int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str)
{
- int ret = MEDIA_INFO_ERROR_NONE;
+ int ret = MS_MEDIA_ERR_NONE;
int size = 0;
pinyin_name_s *pinyinname = NULL;
+
*pinyin_str = NULL;
- if(!STRING_VALID(src_str))
- {
+ if (!STRING_VALID(src_str)) {
media_svc_debug("String is invalid");
return ret;
}
ret = _media_svc_convert_chinese_to_pinyin(src_str, &pinyinname, &size);
- if (ret == MEDIA_INFO_ERROR_NONE)
- {
- if(STRING_VALID(pinyinname[0].pinyin_name))
+ if (ret == MS_MEDIA_ERR_NONE) {
+ if (size > 0 && STRING_VALID(pinyinname[0].pinyin_name))
*pinyin_str = strdup(pinyinname[0].pinyin_name);
else
- *pinyin_str = strdup(src_str); //Return Original Non China Character
+ *pinyin_str = strdup(src_str); /* Return Original Non China Character */
}
_media_svc_pinyin_free(pinyinname, size);
bool _media_svc_check_pinyin_support(void)
{
- /*Check CSC*/
- return TRUE;
+ /* Check CSC : TODO : need to check CSC */
+
+ /* Check content.filter.pinyin feature */
+ return __media_svc_check_support_pinyin();
}
+
+int _media_svc_get_media_type(const char *path, int *mediatype)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ char mime_type[256] = {0};
+ media_svc_media_type_e media_type = MEDIA_SVC_MEDIA_TYPE_OTHER;
+
+ ret = __media_svc_get_mime_type(path, mime_type);
+ if (ret == MS_MEDIA_ERR_NONE)
+ __media_svc_get_media_type(path, mime_type, &media_type);
+ else
+ media_svc_error("__media_svc_get_mime_type failed");
+
+ *mediatype = media_type;
+
+ return ret;
+}
+