4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 #define __USE_XOPEN /* needed for strptime */
33 #include <system_info.h>
35 #include <glib/gstdio.h>
41 #include <libexif/exif-data.h>
42 #include <media-util.h>
43 #include <uuid/uuid.h>
44 #include <mm_util_magick.h>
45 #include "media-util-err.h"
46 #include "media-svc-util.h"
47 #include "media-svc-db-utils.h"
48 #include "media-svc-debug.h"
49 #include "media-svc-env.h"
50 #include "media-svc-hash.h"
51 #include "media-svc-album.h"
52 #include "media-svc-localize_ch.h"
54 #define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/
56 /* Define data structures for media type and mime type */
57 #define MEDIA_SVC_CATEGORY_UNKNOWN 0x00000000 /**< Default */
58 #define MEDIA_SVC_CATEGORY_ETC 0x00000001 /**< ETC category */
59 #define MEDIA_SVC_CATEGORY_IMAGE 0x00000002 /**< Image category */
60 #define MEDIA_SVC_CATEGORY_VIDEO 0x00000004 /**< Video category */
61 #define MEDIA_SVC_CATEGORY_MUSIC 0x00000008 /**< Music category */
62 #define MEDIA_SVC_CATEGORY_SOUND 0x00000010 /**< Sound category */
63 #define MEDIA_SVC_CATEGORY_PVR 0x00000020 /**< PVR category */
64 #define MEDIA_SVC_CATEGORY_UHD 0x00000040 /**< UHD category */
65 #define MEDIA_SVC_CATEGORY_SCSA 0x00000080 /**< SCSA category */
67 #define CONTENT_TYPE_NUM 5
68 #define MUSIC_MIME_NUM 29
69 #define SOUND_MIME_NUM 1
70 #define MIME_TYPE_LENGTH 255
71 #define MIME_LENGTH 50
72 #define _3GP_FILE ".3gp"
73 #define _MP4_FILE ".mp4"
74 #define _ASF_FILE ".asf"
75 #define MEDIA_SVC_ARTWORK_SIZE 2000
76 #define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
78 #define MEDIA_SVC_DEFAULT_GPS_VALUE -200 /**< Default GPS Value*/
80 static int media_svc_pinyin_support = -1;
83 char content_type[15];
85 } _media_svc_content_table_s;
87 static const _media_svc_content_table_s content_category[CONTENT_TYPE_NUM] = {
88 {"audio", MEDIA_SVC_CATEGORY_SOUND},
89 {"image", MEDIA_SVC_CATEGORY_IMAGE},
90 {"video", MEDIA_SVC_CATEGORY_VIDEO},
91 {"application", MEDIA_SVC_CATEGORY_ETC},
92 {"text", MEDIA_SVC_CATEGORY_ETC},
95 static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
96 /*known mime types of normal files*/
102 /* known mime types of drm files*/
104 "x-mp3", /*alias of audio/mpeg*/
105 "x-mpeg", /*alias of audio/mpeg*/
107 "x-ogg", /*alias of audio/ogg*/
108 "vnd.ms-playready.media.pya:*.pya", /*playready*/
111 "x-m4a", /*alias of audio/mp4*/
112 /* below mimes are rare*/
122 "x-vorbis", /*alias of audio/x-vorbis+ogg*/
123 "vorbis", /*alias of audio/x-vorbis+ogg*/
125 "x-mp2", /*alias of audio/mp2*/
126 "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
127 "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
131 static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
135 char *_media_info_generate_uuid(void)
138 static char uuid_unparsed[37];
141 uuid_generate(uuid_value);
142 uuid_unparse(uuid_value, uuid_unparsed);
144 if (strlen(uuid_unparsed) < 36) {
145 media_svc_debug("INVALID UUID : %s. RETRY GENERATE.", uuid_unparsed);
149 return uuid_unparsed;
152 static int __media_svc_split_to_double(char *input, double *arr)
154 char tmp_arr[255] = {0, };
155 int len = 0, idx = 0, arr_idx = 0, str_idx = 0;
157 if (!STRING_VALID(input)) {
158 media_svc_error("Invalid parameter");
159 return MS_MEDIA_ERR_INVALID_PARAMETER;
161 memset(tmp_arr, 0x0, sizeof(tmp_arr));
163 /*media_svc_debug("input: [%s]", input); */
167 for (idx = 0; idx < (len + 1); idx++) {
168 if (input[idx] == ' ') {
170 } else if ((input[idx] == ',') || (idx == len)) {
171 arr[arr_idx] = atof(tmp_arr);
174 /*media_svc_debug("idx=[%d] arr_idx=[%d] tmp_attr[%s] atof(tmp_arr)=[%f]", idx, arr_idx, tmp_arr, atof(tmp_arr)); */
175 memset(tmp_arr, 0x0, sizeof(tmp_arr));
177 tmp_arr[str_idx] = input[idx];
183 media_svc_debug("Error when parsing GPS [%d]", arr_idx);
184 return MS_MEDIA_ERR_INTERNAL;
187 return MS_MEDIA_ERR_NONE;
190 /* GPS information is not ExifTag member */
191 static int __media_svc_get_exif_gps_double(ExifData *ed, double *value, long tagtype)
193 int ret = MS_MEDIA_ERR_NONE;
195 char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = {0, };
196 double tmp_arr[3] = { 0.0, 0.0, 0.0 };
198 media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
199 media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
201 entry = exif_data_get_entry(ed, tagtype);
203 exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
204 gps_buf[strlen(gps_buf)] = '\0';
206 ret = __media_svc_split_to_double(gps_buf, tmp_arr);
207 media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
209 *value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
212 return MS_MEDIA_ERR_NONE;
215 static int __media_svc_get_exif_gps_str(ExifData *ed, char *value, long tagtype)
219 media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
220 media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
222 entry = exif_data_get_entry(ed, tagtype);
224 exif_entry_get_value(entry, value, MEDIA_SVC_METADATA_LEN_MAX);
225 value[strlen(value)] = '\0';
228 return MS_MEDIA_ERR_NONE;
231 static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, double *d_value, ExifTag tagtype)
234 ExifByteOrder mByteOrder;
235 ExifRational mRational;
236 long numerator, denominator;
238 media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
240 entry = exif_data_get_entry(ed, tagtype);
241 media_svc_retv_if(!entry, MS_MEDIA_ERR_NONE);
244 case EXIF_TAG_ORIENTATION:
245 case EXIF_TAG_PIXEL_X_DIMENSION:
246 case EXIF_TAG_PIXEL_Y_DIMENSION:
247 case EXIF_TAG_ISO_SPEED_RATINGS:
248 media_svc_retvm_if(!i_value, MS_MEDIA_ERR_INVALID_PARAMETER, "i_value is NULL");
250 mByteOrder = exif_data_get_byte_order(ed);
251 short exif_value = exif_get_short(entry->data, mByteOrder);
252 *i_value = (int)exif_value;
254 case EXIF_TAG_EXPOSURE_TIME:
255 media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
257 mByteOrder = exif_data_get_byte_order(ed);
258 mRational = exif_get_rational(entry->data, mByteOrder);
259 numerator = mRational.numerator;
260 denominator = mRational.denominator;
261 snprintf(buf, MEDIA_SVC_METADATA_LEN_MAX, "%ld/%ld", numerator, denominator);
263 case EXIF_TAG_FNUMBER:
264 media_svc_retvm_if(!d_value, MS_MEDIA_ERR_INVALID_PARAMETER, "d_value is NULL");
266 mByteOrder = exif_data_get_byte_order(ed);
267 mRational = exif_get_rational(entry->data, mByteOrder);
268 numerator = mRational.numerator;
269 denominator = mRational.denominator;
271 *d_value = ((numerator*1.0)/(denominator*1.0));
274 media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
276 exif_entry_get_value(entry, buf, MEDIA_SVC_METADATA_LEN_MAX);
277 buf[strlen(buf)] = '\0';
280 return MS_MEDIA_ERR_NONE;
283 time_t __media_svc_get_timeline_from_str(const char *timstr)
286 time_t modified_t = 0;
290 if (!STRING_VALID(timstr)) {
291 media_svc_error("Invalid Parameter");
295 /*Exif Format : %Y:%m:%d %H:%M:%S
296 Videoc Content Creation_time format of FFMpeg : %Y-%m-%d %H:%M:%S*/
297 memset(&t, 0x00, sizeof(struct tm));
301 localtime_r(&rawtime, &timeinfo);
303 if (strptime(timstr, "%Y:%m:%d %H:%M:%S", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S", &t)) {
304 t.tm_isdst = timeinfo.tm_isdst;
306 media_svc_debug("DST %d", t.tm_isdst);
308 /* If time string has timezone */
309 if (strptime(timstr, "%Y:%m:%d %H:%M:%S %z", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S %z", &t)) {
311 char tim_tmp_str[255] = { 0, };
313 /* ISO8601 Time string format */
314 strftime(tim_tmp_str, 255, "%Y-%m-%dT%H:%M:%S%z", &t);
315 g_time_val_from_iso8601(tim_tmp_str, &timeval);
316 modified_t = timeval.tv_sec;
317 media_svc_debug("Calibrated timeval : [%lu][%s]", modified_t, tim_tmp_str);
320 modified_t = mktime(&t);
326 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);
328 media_svc_error("Failed to get timeline : [%s]", timstr);
334 static int __media_svc_get_content_type_from_mime(const char *path, const char *mimetype, int *category)
338 media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is null");
339 media_svc_retvm_if(mimetype == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "mimetype is null");
340 media_svc_retvm_if(category == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "category is null");
342 *category = MEDIA_SVC_CATEGORY_UNKNOWN;
344 /*categorize from mimetype */
345 for (idx = 0; idx < CONTENT_TYPE_NUM; idx++) {
346 if (strncmp(mimetype, content_category[idx].content_type, strlen(content_category[idx].content_type)) == 0) {
347 *category = (*category | content_category[idx].category_by_mime);
352 /*in application type, exitst sound file ex) x-smafs, asf */
353 if (*category & MEDIA_SVC_CATEGORY_ETC) {
354 int prefix_len = strlen(content_category[3].content_type) + 1;
357 for (idx = 0; idx < SOUND_MIME_NUM; idx++) {
358 if (strstr(mimetype + prefix_len, sound_mime_table[idx]) != NULL) {
359 *category ^= MEDIA_SVC_CATEGORY_ETC;
360 *category |= MEDIA_SVC_CATEGORY_SOUND;
365 if (strncasecmp(mimetype, "text/x-iMelody", strlen("text/x-iMelody")) == 0) {
366 *category ^= MEDIA_SVC_CATEGORY_ETC;
367 *category |= MEDIA_SVC_CATEGORY_SOUND;
370 /*"asf" must check video stream and then categorize in directly. */
371 ext = strrchr(path, '.');
373 if (strncasecmp(ext, _ASF_FILE, 5) == 0) {
378 err = mm_file_get_stream_info(path, &audio, &video);
380 if (audio > 0 && video == 0) {
381 *category ^= MEDIA_SVC_CATEGORY_ETC;
382 *category |= MEDIA_SVC_CATEGORY_MUSIC;
384 *category ^= MEDIA_SVC_CATEGORY_ETC;
385 *category |= MEDIA_SVC_CATEGORY_VIDEO;
392 /*check music file in sound files. */
393 if (*category & MEDIA_SVC_CATEGORY_SOUND) {
394 int prefix_len = strlen(content_category[0].content_type) + 1;
396 for (idx = 0; idx < MUSIC_MIME_NUM; idx++) {
397 if (strcmp(mimetype + prefix_len, music_mime_table[idx]) == 0) {
398 *category ^= MEDIA_SVC_CATEGORY_SOUND;
399 *category |= MEDIA_SVC_CATEGORY_MUSIC;
404 /*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*/
405 if (strncasecmp(mimetype, "audio/x-mpegurl", strlen("audio/x-mpegurl")) == 0) {
406 *category ^= MEDIA_SVC_CATEGORY_SOUND;
407 *category |= MEDIA_SVC_CATEGORY_ETC;
409 } else if (*category & MEDIA_SVC_CATEGORY_VIDEO) {
410 /*some video files don't have video stream. in this case it is categorize as music. */
412 /*"3gp" and "mp4" must check video stream and then categorize in directly. */
413 ext = strrchr(path, '.');
415 if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
420 err = mm_file_get_stream_info(path, &audio, &video);
422 if (audio > 0 && video == 0) {
423 *category ^= MEDIA_SVC_CATEGORY_VIDEO;
424 *category |= MEDIA_SVC_CATEGORY_MUSIC;
427 /*even though error occued in mm_file_get_stream_info return MS_MEDIA_ERR_NONE. fail means invalid media content. */
432 return MS_MEDIA_ERR_NONE;
435 static int __media_svc_get_media_type(const char *path, const char *mime_type, media_svc_media_type_e *media_type)
437 int ret = MS_MEDIA_ERR_NONE;
440 media_svc_media_type_e type;
442 ret = __media_svc_get_content_type_from_mime(path, mime_type, &category);
443 if (ret != MS_MEDIA_ERR_NONE)
444 media_svc_error("__media_svc_get_content_type_from_mime failed : %d", ret);
446 if (category & MEDIA_SVC_CATEGORY_SOUND) type = MEDIA_SVC_MEDIA_TYPE_SOUND;
447 else if (category & MEDIA_SVC_CATEGORY_MUSIC) type = MEDIA_SVC_MEDIA_TYPE_MUSIC;
448 else if (category & MEDIA_SVC_CATEGORY_IMAGE) type = MEDIA_SVC_MEDIA_TYPE_IMAGE;
449 else if (category & MEDIA_SVC_CATEGORY_VIDEO) type = MEDIA_SVC_MEDIA_TYPE_VIDEO;
450 else type = MEDIA_SVC_MEDIA_TYPE_OTHER;
458 drm_contentifo is not NULL, if the file is OMA DRM.
459 If the file is not OMA DRM, drm_contentinfo must be NULL.
461 static int __media_svc_get_mime_type(const char *path, char *mimetype)
463 media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
465 /*in case of normal files or failure to get mime in drm */
466 if (aul_get_mime_from_file(path, mimetype, 255) < 0) {
467 media_svc_error("aul_get_mime_from_file fail");
468 return MS_MEDIA_ERR_INTERNAL;
471 return MS_MEDIA_ERR_NONE;
474 static bool __media_svc_get_file_ext(const char *file_path, char *file_ext)
478 for (i = strlen(file_path); i >= 0; i--) {
479 if (file_path[i] == '.') {
480 SAFE_STRLCPY(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
484 if (file_path[i] == '/')
490 static int __media_svc_resize_artwork(const char *path, const char *img_format)
492 int ret = MS_MEDIA_ERR_NONE;
493 unsigned int width = 0;
494 unsigned int height = 0;
495 unsigned int resized_width = 0;
496 unsigned int resized_height = 0;
497 mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
499 if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
500 media_svc_debug("type [jpeg]");
502 mm_util_extract_image_info(path, &img_type, &width, &height);
504 if (width <= MEDIA_SVC_ARTWORK_SIZE || height <= MEDIA_SVC_ARTWORK_SIZE) {
505 media_svc_debug("No need resizing");
506 return MS_MEDIA_ERR_NONE;
510 if (width > height) {
511 resized_height = MEDIA_SVC_ARTWORK_SIZE;
512 resized_width = width * MEDIA_SVC_ARTWORK_SIZE / height;
514 resized_width = MEDIA_SVC_ARTWORK_SIZE;
515 resized_height = height * MEDIA_SVC_ARTWORK_SIZE / width;
518 ret = mm_util_resize_P_P(path, resized_width, resized_height, path);
520 } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
521 media_svc_debug("type [png]");
523 media_svc_debug("Not proper img format");
529 static int __media_svc_safe_atoi(char *buffer, int *si)
533 media_svc_retvm_if(buffer == NULL || si == NULL, MS_MEDIA_ERR_INTERNAL, "invalid parameter");
535 const long sl = strtol(buffer, &end, 10);
537 media_svc_retvm_if(end == buffer, MS_MEDIA_ERR_INTERNAL, "not a decimal number");
538 media_svc_retvm_if('\0' != *end, MS_MEDIA_ERR_INTERNAL, "extra characters at end of input: %s", end);
539 media_svc_retvm_if((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno), MS_MEDIA_ERR_INTERNAL, "out of range of type long");
540 media_svc_retvm_if(sl > INT_MAX, MS_MEDIA_ERR_INTERNAL, "greater than INT_MAX");
541 media_svc_retvm_if(sl < INT_MIN, MS_MEDIA_ERR_INTERNAL, "less than INT_MIN");
545 return MS_MEDIA_ERR_NONE;
548 static int __media_svc_save_image(unsigned char *image, unsigned int size, char *image_path, uid_t uid)
550 int ret = MS_MEDIA_ERR_NONE;
552 media_svc_sec_debug("start save image, path [%s] image size [%d]", image_path, size);
555 media_svc_error("invalid image..");
556 return MS_MEDIA_ERR_INVALID_PARAMETER;
560 char *thumb_path = NULL;
561 ret = ms_user_get_root_thumb_store_path(uid, &thumb_path);
562 media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_root_thumb_store_path fail");
564 if (-1 == statfs(thumb_path, &fs)) {
565 media_svc_error("error in statfs");
566 SAFE_FREE(thumb_path);
567 return MS_MEDIA_ERR_INTERNAL;
570 SAFE_FREE(thumb_path);
572 long bsize_kbytes = fs.f_bsize >> 10;
574 if ((bsize_kbytes * fs.f_bavail) < 1024) {
575 media_svc_error("not enought space...");
576 return MS_MEDIA_ERR_NOT_ENOUGH_SPACE;
581 if (image != NULL && size > 0) {
582 fp = fopen(image_path, "w");
585 media_svc_error("failed to open file");
586 return MS_MEDIA_ERR_INTERNAL;
589 nwrite = fwrite(image, 1, size, fp);
590 if (nwrite != size) {
591 media_svc_error("failed to write thumbnail");
593 return MS_MEDIA_ERR_INTERNAL;
598 return MS_MEDIA_ERR_NONE;
601 static char *__media_svc_get_title_from_filepath(const char *path)
603 char *filename = NULL;
606 int filename_len = -1;
607 int new_title_len = -1;
610 media_svc_error("path is NULL");
614 filename = g_path_get_basename(path);
615 if (!STRING_VALID(filename)) {
616 media_svc_error("wrong file name");
621 filename_len = strlen(filename);
623 ext = g_strrstr(filename, ".");
625 media_svc_error("there is no file extention");
629 new_title_len = filename_len - strlen(ext);
630 if (new_title_len < 1) {
631 media_svc_error("title length is zero");
636 title = g_strndup(filename, new_title_len < MEDIA_SVC_PATHNAME_SIZE ? new_title_len : MEDIA_SVC_PATHNAME_SIZE - 1);
640 media_svc_debug("extract title is [%s]", title);
645 void _media_svc_remove_file(const char *path)
647 if (!STRING_VALID(path))
650 if (remove(path) != 0)
651 media_svc_stderror("fail to remove file result");
654 int _media_svc_get_thumbnail_path(media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
656 int ret = MS_MEDIA_ERR_NONE;
657 char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, };
658 char hash[255 + 1] = {0, };
659 char *thumb_dir = NULL;
660 char *thumbfile_ext = NULL;
662 ret = ms_user_get_root_thumb_store_path(uid, &thumb_dir);
663 if (!STRING_VALID(thumb_dir)) {
664 media_svc_error("ms_user_get_root_thumb_store_path failed");
665 return MS_MEDIA_ERR_INTERNAL;
668 if (!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR)) {
669 media_svc_error("Wrong path[%s]", thumb_dir);
670 SAFE_FREE(thumb_dir);
671 return MS_MEDIA_ERR_INTERNAL;
674 memset(file_ext, 0, sizeof(file_ext));
675 if (!__media_svc_get_file_ext(pathname, file_ext))
676 media_svc_error("get file ext fail");
678 ret = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
679 if (ret != MS_MEDIA_ERR_NONE) {
680 media_svc_error("mb_svc_generate_hash_code failed : %d", ret);
681 SAFE_FREE(thumb_dir);
682 return MS_MEDIA_ERR_INTERNAL;
685 if (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) {
686 if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
687 thumbfile_ext = (char *)"jpg";
688 } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
689 thumbfile_ext = (char *)"png";
690 } else if ((strstr(img_format, "gif") != NULL) || (strstr(img_format, "GIF") != NULL)) {
691 thumbfile_ext = (char *)"gif";
692 } else if ((strstr(img_format, "bmp") != NULL) || (strstr(img_format, "BMP") != NULL)) {
693 thumbfile_ext = (char *)"bmp";
695 media_svc_error("Not proper img format");
696 SAFE_FREE(thumb_dir);
697 return MS_MEDIA_ERR_INTERNAL;
700 snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
702 if (strcasecmp(file_ext, "PNG") == 0)
703 snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.png", thumb_dir, file_ext, hash);
705 snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.jpg", thumb_dir, file_ext, hash);
708 SAFE_FREE(thumb_dir);
710 return MS_MEDIA_ERR_NONE;
713 int _media_svc_get_file_time(const char *full_path)
718 memset(&statbuf, 0, sizeof(struct stat));
719 fd = stat(full_path, &statbuf);
721 media_svc_sec_error("stat(%s) fails.", full_path);
722 return MS_MEDIA_ERR_INTERNAL;
725 return statbuf.st_mtime;
728 int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh)
730 /* Set default GPS value before extracting meta information */
731 content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
732 content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
733 content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
735 /* Set filename to title for all media */
737 title = __media_svc_get_title_from_filepath(content_info->path);
739 content_info->media_meta.title = g_strdup(title);
741 media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
743 media_svc_error("Can't extract title");
744 content_info->media_meta.title = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
745 media_svc_retv_del_if(content_info->media_meta.title == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
748 /* Set default value before extracting meta information */
749 content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
750 media_svc_retv_del_if(content_info->media_meta.description == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
752 content_info->media_meta.copyright = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
753 media_svc_retv_del_if(content_info->media_meta.copyright == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
755 content_info->media_meta.track_num = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
756 media_svc_retv_del_if(content_info->media_meta.track_num == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
758 content_info->media_meta.album = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
759 media_svc_retv_del_if(content_info->media_meta.album == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
761 content_info->media_meta.artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
762 media_svc_retv_del_if(content_info->media_meta.artist == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
764 content_info->media_meta.album_artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
765 media_svc_retv_del_if(content_info->media_meta.album_artist == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
767 content_info->media_meta.genre = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
768 media_svc_retv_del_if(content_info->media_meta.genre == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
770 content_info->media_meta.composer = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
771 media_svc_retv_del_if(content_info->media_meta.composer == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
773 content_info->media_meta.year = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
774 media_svc_retv_del_if(content_info->media_meta.year == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
777 media_svc_debug("refresh");
778 return MS_MEDIA_ERR_NONE;
781 content_info->favourate = 0;
782 content_info->media_meta.rating = 0;
784 return MS_MEDIA_ERR_NONE;
787 int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh)
789 int ret = MS_MEDIA_ERR_NONE;
790 char * media_uuid = NULL;
791 bool drm_type = false;
792 char mime_type[256] = {0, };
793 media_svc_media_type_e media_type;
795 media_svc_retvm_if(!_media_svc_is_valid_storage_type(storage_type), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
796 media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
798 content_info->path = g_strdup(path);
799 media_svc_retv_del_if(content_info->path == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
802 memset(&st, 0, sizeof(struct stat));
803 if (stat(path, &st) == 0) {
804 content_info->modified_time = st.st_mtime;
805 content_info->timeline = content_info->modified_time;
806 content_info->size = st.st_size;
808 media_svc_stderror("stat failed");
811 _media_svc_set_default_value(content_info, refresh);
813 /* refresh is TRUE when file modified. so only modified_time and size are changed*/
815 media_svc_debug("refresh");
816 return MS_MEDIA_ERR_NONE;
819 content_info->storage_uuid = g_strdup(storage_id);
820 media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
822 content_info->storage_type = storage_type;
823 time(&content_info->added_time);
825 media_uuid = _media_info_generate_uuid();
826 if (media_uuid == NULL) {
827 _media_svc_destroy_content_info(content_info);
828 return MS_MEDIA_ERR_INTERNAL;
831 content_info->media_uuid = g_strdup(media_uuid);
832 media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
834 content_info->file_name = g_path_get_basename(path);
835 media_svc_retv_del_if(content_info->file_name == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
837 /* if the file is DRM file, drm_type value is DRM_TRUE(1).
838 if drm_contentinfo is not NULL, the file is OMA DRM.*/
839 ret = __media_svc_get_mime_type(path, mime_type);
840 media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
842 media_svc_debug("mime [%s]", mime_type);
843 content_info->is_drm = drm_type;
845 ret = __media_svc_get_media_type(path, mime_type, &media_type);
846 media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
848 content_info->mime_type = g_strdup(mime_type);
849 media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
851 media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
853 content_info->media_type = media_type;
855 return MS_MEDIA_ERR_NONE;
858 int image_360_check(char *path)
863 unsigned char exif_header[4] = {0, };
864 unsigned char exif_app1[2] = {0, };
865 unsigned char exif_app1_xmp[2] = {0, };
866 long exif_app1_xmp_size = 0;
867 unsigned char exif_app1_xmp_t[2] = {0, };
868 char *xmp_data = NULL;
874 memset(exif_header, 0x00, sizeof(exif_header));
875 memset(exif_app1, 0x00, sizeof(exif_app1));
876 memset(exif_app1_xmp, 0x00, sizeof(exif_app1_xmp));
877 memset(exif_app1_xmp_t, 0x00, sizeof(exif_app1_xmp_t));
879 fp = fopen(path, "rb");
883 size = fread(exif_header, 1, sizeof(exif_header), fp);
887 if ((exif_header[0] == 0xff) && (exif_header[1] == 0xd8) && (exif_header[2] == 0xff) && (exif_header[3] == 0xe1)) {
888 size = fread(exif_app1, 1, sizeof(exif_app1), fp);
892 size1 = exif_app1[0];
893 size2 = exif_app1[1];
895 app1_size = size1 * 256 + size2 - 2;
897 if (fseek(fp, app1_size, SEEK_CUR) != 0)
900 size = fread(exif_app1_xmp, 1, sizeof(exif_app1_xmp), fp);
904 if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
907 size = fread(exif_app1_xmp_t, 1, sizeof(exif_app1_xmp_t), fp);
911 size1 = exif_app1_xmp_t[0];
912 size2 = exif_app1_xmp_t[1];
914 exif_app1_xmp_size = size1 * 256 + size2 - 2;
916 if (exif_app1_xmp_size > 0) {
917 xmp_data = (char *)malloc(exif_app1_xmp_size);
918 memset(xmp_data, 0x0, exif_app1_xmp_size);
922 while (exif_app1_xmp_size >= 0) {
923 exif_app1_xmp_size--;
935 if (strstr(ptr, "UsePanoramaViewer")
936 && strstr(ptr, "True")
937 && strstr(ptr, "ProjectionType")
938 && strstr(ptr, "equirectangular"))
943 media_svc_error("invalid exif_app1_xmp_size [%ld]", exif_app1_xmp_size);
965 int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
968 int orient_value = 0;
972 bool has_datetaken = false;
973 double fnumber = 0.0;
977 char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
979 media_svc_retvm_if(!content_info, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid content_info");
980 media_svc_retvm_if(content_info->media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid media_type [%d]", content_info->media_type);
981 media_svc_retvm_if(!STRING_VALID(content_info->path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
983 path = content_info->path;
985 /* Load an ExifData object from an EXIF file */
986 ed = exif_data_new_from_file(path);
989 media_svc_sec_debug("There is no exif data in [ %s ]", path);
990 goto GET_WIDTH_HEIGHT;
993 content_info->media_meta.is_360 = image_360_check(path);
995 content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
996 content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
997 content_info->media_meta.description = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
998 content_info->media_meta.fnumber = 0.0;
999 content_info->media_meta.iso = 0;
1000 content_info->media_meta.orientation = 0;
1001 content_info->media_meta.width = 0;
1002 content_info->media_meta.height = 0;
1004 memset(buf, 0x00, sizeof(buf));
1005 if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
1006 if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
1007 if (!g_strcmp0(buf, "S"))
1009 content_info->media_meta.latitude = value;
1013 memset(buf, 0x00, sizeof(buf));
1014 if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LONGITUDE) == MS_MEDIA_ERR_NONE) {
1015 if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LONGITUDE_REF) == MS_MEDIA_ERR_NONE) {
1016 if (!g_strcmp0(buf, "W"))
1019 content_info->media_meta.longitude = value;
1023 memset(buf, 0x00, sizeof(buf));
1024 if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
1025 if (strlen(buf) > 0) {
1026 SAFE_FREE(content_info->media_meta.description);
1027 content_info->media_meta.description = g_strdup(buf);
1031 memset(buf, 0x00, sizeof(buf));
1032 if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
1033 if (strlen(buf) > 0) {
1034 has_datetaken = true;
1035 content_info->media_meta.datetaken = g_strdup(buf);
1037 /* This is same as recorded_date */
1038 content_info->media_meta.recorded_date = g_strdup(buf);
1042 memset(buf, 0x00, sizeof(buf));
1043 if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
1044 if (strlen(buf) > 0) {
1045 has_datetaken = true;
1046 content_info->media_meta.datetaken = g_strdup(buf);
1048 /* This is same as recorded_date */
1049 content_info->media_meta.recorded_date = g_strdup(buf);
1053 if (has_datetaken) {
1054 content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.datetaken);
1055 if (content_info->timeline == 0)
1056 content_info->timeline = content_info->modified_time;
1058 media_svc_debug("Timeline : %ld", content_info->timeline);
1061 memset(buf, 0x00, sizeof(buf));
1062 /* Get exposure_time value from exif. */
1063 if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
1064 if (strlen(buf) > 0)
1065 content_info->media_meta.exposure_time = g_strdup(buf);
1068 /* Get fnumber value from exif. */
1069 if (__media_svc_get_exif_info(ed, NULL, NULL, &fnumber, EXIF_TAG_FNUMBER) == MS_MEDIA_ERR_NONE) {
1071 content_info->media_meta.fnumber = fnumber;
1074 /* Get iso value from exif. */
1075 if (__media_svc_get_exif_info(ed, NULL, &iso, NULL, EXIF_TAG_ISO_SPEED_RATINGS) == MS_MEDIA_ERR_NONE) {
1077 content_info->media_meta.iso = iso;
1080 memset(buf, 0x00, sizeof(buf));
1081 /* Get model value from exif. */
1082 if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
1083 if (strlen(buf) > 0)
1084 content_info->media_meta.model = g_strdup(buf);
1087 /* Get orientation value from exif. */
1088 if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
1089 if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270)
1090 content_info->media_meta.orientation = orient_value;
1093 /* Get width value from exif. */
1094 if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
1096 content_info->media_meta.width = exif_width;
1099 /* Get height value from exif. */
1100 if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
1101 if (exif_height > 0)
1102 content_info->media_meta.height = exif_height;
1106 exif_data_unref(ed);
1110 if (content_info->media_meta.width == 0 || content_info->media_meta.height == 0) {
1111 /*Get image width, height*/
1112 unsigned int img_width = 0;
1113 unsigned int img_height = 0;
1114 mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
1116 mm_util_extract_image_info(path, &img_type, &img_width, &img_height);
1117 if (content_info->media_meta.width == 0)
1118 content_info->media_meta.width = img_width;
1120 if (content_info->media_meta.height == 0)
1121 content_info->media_meta.height = img_height;
1124 return MS_MEDIA_ERR_NONE;
1127 int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *storage_id, const char *path)
1129 MMHandleType tag = 0;
1132 int mmf_error = FILEINFO_ERROR_NONE;
1134 content_info->storage_uuid = g_strdup(storage_id);
1135 content_info->path = g_strdup(path);
1137 mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
1138 if (mmf_error != FILEINFO_ERROR_NONE)
1139 return MS_MEDIA_ERR_INTERNAL;
1141 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ALBUM, &p, &size, NULL);
1142 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1143 content_info->media_meta.album = g_strdup(p);
1145 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTIST, &p, &size, NULL);
1146 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1147 content_info->media_meta.artist = g_strdup(p);
1149 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
1150 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1151 content_info->media_meta.album_artist = g_strdup(p);
1153 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_GENRE, &p, &size, NULL);
1154 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1155 content_info->media_meta.genre = g_strdup(p);
1157 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_TITLE, &p, &size, NULL);
1158 if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
1160 content_info->media_meta.title = g_strdup(p);
1164 for (idx = 0; idx < size; idx++) {
1166 media_svc_debug("SPACE [%s]", p);
1170 media_svc_debug("Not SPACE [%s]", p);
1171 content_info->media_meta.title = g_strdup(p);
1178 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
1179 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1180 content_info->media_meta.description = g_strdup(p);
1182 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
1183 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1184 content_info->media_meta.composer = g_strdup(p);
1186 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
1187 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1188 content_info->media_meta.copyright = g_strdup(p);
1190 mm_file_destroy_tag_attrs(tag);
1192 return MS_MEDIA_ERR_NONE;
1195 int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid)
1197 MMHandleType content = 0;
1198 MMHandleType tag = 0;
1200 unsigned char *image = NULL;
1201 unsigned int size = 0;
1202 int mmf_error = FILEINFO_ERROR_NONE;
1204 int ret = MS_MEDIA_ERR_NONE;
1207 /*Get Content Tag attribute ===========*/
1208 mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
1210 if (mmf_error == FILEINFO_ERROR_NONE) {
1211 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ALBUM, &p, &size, NULL);
1212 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1213 content_info->media_meta.album = g_strdup(p);
1215 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTIST, &p, &size, NULL);
1216 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1217 content_info->media_meta.artist = g_strdup(p);
1219 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
1220 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1221 content_info->media_meta.album_artist = g_strdup(p);
1223 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_GENRE, &p, &size, NULL);
1224 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1225 content_info->media_meta.genre = g_strdup(p);
1227 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_TITLE, &p, &size, NULL);
1228 if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
1229 while(p && isspace(*p))
1232 content_info->media_meta.title = g_strdup(p);
1235 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
1236 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1237 content_info->media_meta.description = g_strdup(p);
1239 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
1241 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RECDATE, &p, &size, NULL);
1242 if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
1243 char mime_type[255] = {0, };
1244 ret = __media_svc_get_mime_type(content_info->path, mime_type);
1245 /*if 3gp that audio only, media_type is music */
1246 if ((ret == MS_MEDIA_ERR_NONE) &&
1247 ((content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/mp4") == 0) ||
1248 (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/3gpp") == 0) ||
1249 (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "video/3gpp") == 0) ||
1250 (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "audio/mp4") == 0))) {
1251 /*Creation time format is 2013-01-01 00:00:00 +0000. change it to 2013:01:01 00:00:00 like exif time format*/
1252 char *time_info = g_strdup_printf("0000:00:00 00:00:00 +0000");
1254 char *time_value = time_info;
1255 if (time_info != NULL) {
1256 while (*p_value != '\0') {
1257 if (*p_value == '-')
1260 *time_value = *p_value;
1264 content_info->media_meta.recorded_date = g_strdup(time_info);
1265 SAFE_FREE(time_info);
1267 media_svc_error("memory allocation error");
1270 content_info->media_meta.recorded_date = g_strdup(p);
1273 if (STRING_VALID(content_info->media_meta.recorded_date)) {
1274 content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date);
1275 if (content_info->timeline == 0)
1276 content_info->timeline = content_info->modified_time;
1278 /* This is same as datetaken */
1279 /* Remove compensation string */
1280 if (strlen(content_info->media_meta.recorded_date) > MEDIA_SVC_DEFAULT_FORMAT_LEN) {
1281 content_info->media_meta.datetaken = g_strndup(content_info->media_meta.recorded_date, MEDIA_SVC_DEFAULT_FORMAT_LEN);
1282 g_free(content_info->media_meta.recorded_date);
1283 content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.datetaken);
1285 content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
1290 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
1291 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1292 content_info->media_meta.composer = g_strdup(p);
1294 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
1295 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1296 content_info->media_meta.copyright = g_strdup(p);
1298 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
1299 if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
1300 content_info->media_meta.track_num = g_strdup(p);
1302 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_DATE, &p, &size, NULL);
1303 if (mmf_error == FILEINFO_ERROR_NONE && size == 4) {
1305 if ((p != NULL) && (__media_svc_safe_atoi(p, &year) == MS_MEDIA_ERR_NONE))
1306 content_info->media_meta.year = g_strdup(p);
1308 media_svc_debug("Wrong Year Information [%s]", p);
1311 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_RATING, &p, &size, NULL);
1312 if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
1314 if ((p != NULL) && (__media_svc_safe_atoi(p, &rate) == MS_MEDIA_ERR_NONE))
1315 content_info->media_meta.rating = rate;
1317 content_info->media_meta.rating = 0;
1320 /*Do not extract artwork for the USB Storage content*/
1321 if (content_info->storage_type != MS_USER_STORAGE_EXTERNAL_USB) {
1322 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
1323 if (mmf_error != FILEINFO_ERROR_NONE) {
1324 media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
1326 /*media_svc_debug("artwork size1 [%d]", size); */
1329 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK_SIZE, &size, NULL);
1330 if (mmf_error != FILEINFO_ERROR_NONE) {
1331 media_svc_error("fail to get artwork size - err(%x)", mmf_error);
1333 /*media_svc_debug("artwork size2 [%d]", size); */
1336 if (image != NULL && size > 0) {
1337 char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
1338 int artwork_mime_size = -1;
1340 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
1341 if ((mmf_error == FILEINFO_ERROR_NONE) && (artwork_mime_size > 0)) {
1342 ret = _media_svc_get_thumbnail_path(content_info->media_type, thumb_path, content_info->path, p, uid);
1343 if (ret != MS_MEDIA_ERR_NONE)
1344 media_svc_error("Fail to Get Thumbnail Path");
1346 if (strlen(thumb_path) > 0) {
1347 ret = __media_svc_save_image(image, size, thumb_path, uid);
1348 if (ret != MS_MEDIA_ERR_NONE) {
1349 media_svc_error("Fail to Save Image");
1351 /* albumart resizing */
1352 ret = __media_svc_resize_artwork(thumb_path, p);
1353 if (ret != MS_MEDIA_ERR_NONE) {
1354 media_svc_error("Fail to Make Thumbnail Image");
1355 _media_svc_remove_file(thumb_path);
1358 content_info->thumbnail_path = g_strdup(thumb_path);
1366 /*Initialize album_id to 0. below code will set the album_id*/
1367 content_info->album_id = album_id;
1368 ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
1369 if (ret != MS_MEDIA_ERR_NONE) {
1370 if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
1371 media_svc_debug("album does not exist. So start to make album art");
1372 if ((g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
1373 (g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
1374 ret = _media_svc_append_album(handle, is_direct, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
1376 ret = _media_svc_append_album(handle, is_direct, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
1378 content_info->album_id = album_id;
1381 content_info->album_id = album_id;
1384 if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
1385 double longitude = 0.0;
1386 double latitude = 0.0;
1387 double altitude = 0.0;
1389 mm_file_get_attrs(tag, MM_FILE_TAG_LONGITUDE, &longitude,
1390 MM_FILE_TAG_LATIDUE, &latitude,
1391 MM_FILE_TAG_ALTIDUE, &altitude,
1394 content_info->media_meta.longitude = (longitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : longitude;
1395 content_info->media_meta.latitude = (latitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : latitude;
1396 content_info->media_meta.altitude = (altitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : altitude;
1398 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_CDIS, &cdis_value, NULL);
1399 if (mmf_error != FILEINFO_ERROR_NONE)
1402 media_svc_debug("CDIS : %d", cdis_value);
1404 mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ROTATE, &p, &size, NULL);
1405 if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
1406 content_info->media_meta.orientation = atoi(p);
1408 content_info->media_meta.orientation = 0;
1409 media_svc_debug("fail to get video orientation attr - err(%x)", mmf_error);
1413 mmf_error = mm_file_destroy_tag_attrs(tag);
1414 if (mmf_error != FILEINFO_ERROR_NONE)
1415 media_svc_error("fail to free tag attr - err(%x)", mmf_error);
1417 content_info->album_id = album_id;
1420 /*Get Content attribute ===========*/
1421 if (cdis_value == 1)
1422 mmf_error = mm_file_create_content_attrs_safe(&content, content_info->path);
1424 mmf_error = mm_file_create_content_attrs_simple(&content, content_info->path);
1426 media_svc_retvm_if(mmf_error != FILEINFO_ERROR_NONE, MS_MEDIA_ERR_NONE, "mm_file_create_content_attrs failed");
1428 if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
1429 int audio_bitrate = 0;
1430 int video_bitrate = 0;
1432 mm_file_get_attrs(content, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration,
1433 MM_FILE_CONTENT_AUDIO_BITRATE, &audio_bitrate,
1434 MM_FILE_CONTENT_VIDEO_BITRATE, &video_bitrate,
1435 MM_FILE_CONTENT_VIDEO_WIDTH, &content_info->media_meta.width,
1436 MM_FILE_CONTENT_VIDEO_HEIGHT, &content_info->media_meta.height,
1439 content_info->media_meta.bitrate = audio_bitrate + video_bitrate;
1441 mm_file_get_attrs(content, MM_FILE_CONTENT_DURATION, &content_info->media_meta.duration,
1442 MM_FILE_CONTENT_AUDIO_BITRATE, &content_info->media_meta.bitrate,
1443 MM_FILE_CONTENT_AUDIO_SAMPLERATE, &content_info->media_meta.samplerate,
1444 MM_FILE_CONTENT_AUDIO_CHANNELS, &content_info->media_meta.channel,
1445 MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &content_info->media_meta.bitpersample,
1449 mm_file_destroy_content_attrs(content);
1451 return MS_MEDIA_ERR_NONE;
1454 void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
1456 media_svc_retm_if(content_info == NULL, "content info is NULL");
1458 /* Delete media_svc_content_info_s */
1459 SAFE_FREE(content_info->media_uuid);
1460 SAFE_FREE(content_info->path);
1461 SAFE_FREE(content_info->file_name);
1462 SAFE_FREE(content_info->mime_type);
1463 SAFE_FREE(content_info->folder_uuid);
1464 SAFE_FREE(content_info->thumbnail_path);
1465 SAFE_FREE(content_info->storage_uuid);
1467 /* Delete media_svc_content_meta_s */
1468 SAFE_FREE(content_info->media_meta.title);
1469 SAFE_FREE(content_info->media_meta.album);
1470 SAFE_FREE(content_info->media_meta.artist);
1471 SAFE_FREE(content_info->media_meta.album_artist);
1472 SAFE_FREE(content_info->media_meta.genre);
1473 SAFE_FREE(content_info->media_meta.composer);
1474 SAFE_FREE(content_info->media_meta.year);
1475 SAFE_FREE(content_info->media_meta.recorded_date);
1476 SAFE_FREE(content_info->media_meta.copyright);
1477 SAFE_FREE(content_info->media_meta.track_num);
1478 SAFE_FREE(content_info->media_meta.description);
1479 SAFE_FREE(content_info->media_meta.datetaken);
1480 SAFE_FREE(content_info->media_meta.exposure_time);
1481 SAFE_FREE(content_info->media_meta.model);
1483 SAFE_FREE(content_info->media_meta.title_pinyin);
1484 SAFE_FREE(content_info->media_meta.album_pinyin);
1485 SAFE_FREE(content_info->media_meta.artist_pinyin);
1486 SAFE_FREE(content_info->media_meta.album_artist_pinyin);
1487 SAFE_FREE(content_info->media_meta.genre_pinyin);
1488 SAFE_FREE(content_info->media_meta.composer_pinyin);
1489 SAFE_FREE(content_info->media_meta.copyright_pinyin);
1490 SAFE_FREE(content_info->media_meta.description_pinyin);
1493 static void __media_svc_get_proper_thumb_size(unsigned int orig_w, unsigned int orig_h, unsigned int *thumb_w, unsigned int *thumb_h)
1495 bool portrait = false;
1498 media_svc_retm_if(!orig_w, "Invalid orig_w");
1499 media_svc_retm_if(!orig_h, "Invalid orig_h");
1500 media_svc_retm_if(!thumb_w, "Invalid thumb_w");
1501 media_svc_retm_if(!thumb_h, "Invalid thumb_h");
1503 if (orig_w < orig_h)
1506 /* Set smaller length to default size */
1508 if (orig_w < *thumb_w)
1510 ratio = (double)orig_h / (double)orig_w;
1511 *thumb_h = *thumb_w * ratio;
1513 if (orig_h < *thumb_h)
1515 ratio = (double)orig_w / (double)orig_h;
1516 *thumb_w = *thumb_h * ratio;
1519 media_svc_debug("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
1524 static void __get_rotation_and_cdis(const char *origin_path, mm_util_magick_rotate_type *rot_type, int *cdis_value)
1526 int err = MS_MEDIA_ERR_NONE;
1527 MMHandleType tag = (MMHandleType) NULL;
1530 int _cdis_value = 0;
1531 mm_util_magick_rotate_type _rot_type = MM_UTIL_ROTATE_NUM;
1533 /* Get Content Tag attribute for orientation */
1534 err = mm_file_create_tag_attrs(&tag, origin_path);
1535 if (err != FILEINFO_ERROR_NONE) {
1536 *rot_type = MM_UTIL_ROTATE_0;
1541 err = mm_file_get_attrs(tag, MM_FILE_TAG_ROTATE, &p, &size, NULL);
1542 if (err == FILEINFO_ERROR_NONE && size >= 0) {
1544 _rot_type = MM_UTIL_ROTATE_0;
1546 if (strncmp(p, "90", size) == 0)
1547 _rot_type = MM_UTIL_ROTATE_90;
1548 else if (strncmp(p, "180", size) == 0)
1549 _rot_type = MM_UTIL_ROTATE_180;
1550 else if (strncmp(p, "270", size) == 0)
1551 _rot_type = MM_UTIL_ROTATE_270;
1553 _rot_type = MM_UTIL_ROTATE_0;
1555 media_svc_debug("There is tag rotate : %d", _rot_type);
1557 media_svc_debug("There is NOT tag rotate");
1558 _rot_type = MM_UTIL_ROTATE_0;
1561 err = mm_file_get_attrs(tag, MM_FILE_TAG_CDIS, &_cdis_value, NULL);
1562 if (err != FILEINFO_ERROR_NONE)
1565 *rot_type = _rot_type;
1566 *cdis_value = _cdis_value;
1568 err = mm_file_destroy_tag_attrs(tag);
1569 if (err != FILEINFO_ERROR_NONE) {
1570 media_svc_error("fail to free tag attr - err(%x)", err);
1576 static int __get_video_info(int cdis_value, const char *origin_path, int *video_track_num, unsigned int *width, unsigned int *height, void **frame, size_t *size)
1578 int err = MS_MEDIA_ERR_NONE;
1579 MMHandleType content = (MMHandleType) NULL;
1580 int _video_track_num = 0;
1584 void *_frame = NULL;
1586 if (cdis_value == 1) {
1587 media_svc_debug("This is CDIS vlaue 1");
1588 err = mm_file_create_content_attrs_safe(&content, origin_path);
1590 err = mm_file_create_content_attrs(&content, origin_path);
1593 if (err != FILEINFO_ERROR_NONE) {
1594 media_svc_error("mm_file_create_content_attrs fails : %d", err);
1595 return MS_MEDIA_ERR_INTERNAL;
1598 err = mm_file_get_attrs(content, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_num, NULL);
1599 if (err != FILEINFO_ERROR_NONE) {
1600 media_svc_error("mm_file_get_attrs fails : %d", err);
1601 mm_file_destroy_content_attrs(content);
1602 return MS_MEDIA_ERR_INTERNAL;
1605 *video_track_num = _video_track_num;
1607 if (_video_track_num == 0) {
1608 mm_file_destroy_content_attrs(content);
1609 return MS_MEDIA_ERR_NONE;
1612 err = mm_file_get_attrs(content,
1613 MM_FILE_CONTENT_VIDEO_WIDTH,
1615 MM_FILE_CONTENT_VIDEO_HEIGHT,
1617 MM_FILE_CONTENT_VIDEO_THUMBNAIL, &_frame, /* raw image is RGB888 format */
1620 if (err != FILEINFO_ERROR_NONE) {
1621 media_svc_error("mm_file_get_attrs fails : %d", err);
1622 mm_file_destroy_content_attrs(content);
1623 return MS_MEDIA_ERR_INTERNAL;
1626 media_svc_debug("W[%d] H[%d] Size[%zu] Frame[%p]", _width, _height, _size, _frame);
1627 if (!_frame || !_width || !_height) {
1628 mm_file_destroy_content_attrs(content);
1629 return MS_MEDIA_ERR_INTERNAL;
1636 *frame = calloc(1, _size);
1637 memcpy(*frame, _frame, _size);
1639 mm_file_destroy_content_attrs(content);
1641 return MS_MEDIA_ERR_NONE;
1644 static int __get_video_thumb(int width, int height, void *frame, size_t size, mm_util_magick_rotate_type rot_type, const char *thumb_path, unsigned int thumb_width, unsigned int thumb_height)
1646 int err = MS_MEDIA_ERR_NONE;
1647 mm_util_image_h img = NULL;
1648 mm_util_image_h resize_img = NULL;
1650 media_svc_retvm_if(!STRING_VALID(thumb_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid thumb_path");
1651 __media_svc_get_proper_thumb_size(width, height, &thumb_width, &thumb_height);
1652 if (thumb_width <= 0 || thumb_height <= 0) {
1653 media_svc_error("Failed to get thumb size");
1654 return MS_MEDIA_ERR_INTERNAL;
1657 media_svc_debug("Origin:W[%d] H[%d] Proper:W[%d] H[%d]", width, height, thumb_width, thumb_height);
1659 err = mm_image_create_image(width, height, MM_UTIL_COLOR_RGB24, (unsigned char *)frame, size, &img);
1660 media_svc_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to mm_image_create_image [%d]", err);
1662 if (width > thumb_width || height > thumb_height) {
1663 if (rot_type != MM_UTIL_ROTATE_0) {
1664 err = mm_util_resize_B_B(img, thumb_width, thumb_height, &resize_img);
1665 if (err != MM_UTIL_ERROR_NONE)
1668 err = mm_util_rotate_B_P(resize_img, rot_type, thumb_path);
1670 err = mm_util_resize_B_P(img, thumb_width, thumb_height, thumb_path);
1673 if (rot_type != MM_UTIL_ROTATE_0)
1674 err = mm_util_rotate_B_P(img, rot_type, thumb_path);
1676 err = mm_util_resize_B_P(img, width, height, thumb_path);
1680 mm_image_destroy_image(img);
1681 mm_image_destroy_image(resize_img);
1682 if (err != MS_MEDIA_ERR_NONE)
1683 return MS_MEDIA_ERR_INTERNAL;
1685 return MS_MEDIA_ERR_NONE;
1688 static int __create_video_thumbnail(const char *path, char *thumb_path)
1690 int ret = MS_MEDIA_ERR_NONE;
1692 unsigned int width = 0;
1693 unsigned int height = 0;
1695 int video_track_num = 0;
1697 mm_util_magick_rotate_type rot_type = MM_UTIL_ROTATE_NUM;
1699 __get_rotation_and_cdis(path, &rot_type, &cdis_value);
1700 ret = __get_video_info(cdis_value, path, &video_track_num, &width, &height, &frame, &size);
1701 media_svc_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "fail to __get_video_info [%d]", ret);
1702 media_svc_retvm_if(video_track_num == 0, MM_UTIL_ERROR_NONE, "No video track");
1704 ret = __get_video_thumb(width, height, frame, size, rot_type, thumb_path, THUMB_WIDTH, THUMB_HEIGHT);
1711 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid)
1713 int ret = MS_MEDIA_ERR_NONE;
1714 unsigned int origin_w = 0;
1715 unsigned int origin_h = 0;
1716 unsigned int thumb_w = THUMB_WIDTH;
1717 unsigned int thumb_h = THUMB_HEIGHT;
1718 mm_util_img_codec_type image_type = IMG_CODEC_UNKNOWN_TYPE;
1720 if (path == NULL || thumb_path == NULL) {
1721 media_svc_error("Invalid parameter");
1722 return MS_MEDIA_ERR_INVALID_PARAMETER;
1725 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
1726 media_svc_error("Original path(%s) doesn't exist.", path);
1727 return MS_MEDIA_ERR_INVALID_PARAMETER;
1730 ms_user_storage_type_e store_type = -1;
1731 ret = ms_user_get_storage_type(uid, path, &store_type);
1733 if ((ret != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) {
1734 media_svc_sec_error("origin path(%s) is invalid. err : [%d] store_type [%d]", path, ret, store_type);
1735 return MS_MEDIA_ERR_INVALID_PARAMETER;
1738 media_svc_sec_debug("Path[%s] Type[%d]", path, media_type);
1741 ret = _media_svc_get_thumbnail_path(media_type, thumb_path, path, THUMB_EXT, uid);
1742 if (ret != MS_MEDIA_ERR_NONE) {
1743 media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
1744 SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
1749 if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
1750 ret = mm_util_extract_image_info(path, &image_type, &origin_w, &origin_h);
1751 if (ret != MS_MEDIA_ERR_NONE) {
1752 media_svc_error("Getting image info is failed err: %d", ret);
1753 SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
1754 return MS_MEDIA_ERR_INTERNAL;
1757 if (image_type == IMG_CODEC_UNKNOWN_TYPE) {
1758 media_svc_error("Unsupported image codec");
1759 return MS_MEDIA_ERR_UNSUPPORTED_CONTENT;
1762 if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM)) {
1763 media_svc_error("This original image is too big");
1764 SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
1765 return MS_MEDIA_ERR_THUMB_TOO_BIG;
1768 __media_svc_get_proper_thumb_size(origin_w, origin_h, &thumb_w, &thumb_h);
1769 ret = mm_util_resize_P_P(path, thumb_w, thumb_h, thumb_path);
1770 if (ret != MM_UTIL_ERROR_NONE) {
1771 media_svc_error("mm_util_resize_P_P err: %d", ret);
1772 SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
1773 return MS_MEDIA_ERR_INTERNAL;
1776 return __create_video_thumbnail(path, thumb_path);
1782 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str)
1784 int ret = MS_MEDIA_ERR_NONE;
1786 pinyin_name_s *pinyinname = NULL;
1788 media_svc_retvm_if(!STRING_VALID(src_str), MS_MEDIA_ERR_INVALID_PARAMETER, "String is NULL");
1789 media_svc_retvm_if(pinyin_str == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "pinyin_str is NULL");
1793 ret = _media_svc_convert_chinese_to_pinyin(src_str, &pinyinname, &size);
1794 if (ret == MS_MEDIA_ERR_NONE) {
1795 if (size > 0 && STRING_VALID(pinyinname[0].pinyin_name))
1796 *pinyin_str = strdup(pinyinname[0].pinyin_name);
1798 *pinyin_str = strdup(src_str); /* Return Original Non China Character */
1801 _media_svc_pinyin_free(pinyinname, size);
1806 bool _media_svc_check_pinyin_support(void)
1808 int ret = SYSTEM_INFO_ERROR_NONE;
1809 bool is_supported = false;
1811 if (media_svc_pinyin_support == -1) {
1812 ret = system_info_get_platform_bool("http://tizen.org/feature/content.filter.pinyin", &is_supported);
1813 if (ret != SYSTEM_INFO_ERROR_NONE) {
1814 media_svc_debug("SYSTEM_INFO_ERROR: content.filter.pinyin [%d]", ret);
1818 media_svc_pinyin_support = is_supported;
1821 return media_svc_pinyin_support;
1824 int _media_svc_get_media_type(const char *path, int *mediatype)
1826 int ret = MS_MEDIA_ERR_NONE;
1827 char mime_type[256] = {0};
1828 media_svc_media_type_e media_type = MEDIA_SVC_MEDIA_TYPE_OTHER;
1830 media_svc_retvm_if(mediatype == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "mediatype is NULL");
1832 ret = __media_svc_get_mime_type(path, mime_type);
1833 if (ret == MS_MEDIA_ERR_NONE)
1834 __media_svc_get_media_type(path, mime_type, &media_type);
1836 media_svc_error("__media_svc_get_mime_type failed");
1838 *mediatype = media_type;
1843 bool _media_svc_is_valid_storage_type(ms_user_storage_type_e storage_type)
1845 if ((storage_type != MS_USER_STORAGE_INTERNAL)
1846 && (storage_type != MS_USER_STORAGE_EXTERNAL)
1847 && (storage_type != MS_USER_STORAGE_EXTERNAL_USB)) {
1848 media_svc_error("storage type is incorrect[%d]", storage_type);