From: jiyong.min Date: Wed, 5 Dec 2018 04:38:44 +0000 (+0900) Subject: Fix wrong category of the media from mime X-Git-Tag: accepted/tizen/unified/20190111.055201~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F194568%2F5;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Fix wrong category of the media from mime Change-Id: Ia6f99d5a61a43a895fbc50183623144c9f72a3ed --- diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index a2744b2..17badfe 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -330,11 +330,15 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char * { int idx = 0; + media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is null"); + media_svc_retvm_if(mimetype == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "mimetype is null"); + media_svc_retvm_if(category == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "category is null"); + *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) { + if (strncmp(mimetype, content_category[idx].content_type, strlen(content_category[idx].content_type)) == 0) { *category = (*category | content_category[idx].category_by_mime); break; } @@ -342,7 +346,7 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char * /*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); + int prefix_len = strlen(content_category[MEDIA_SVC_CATEGORY_ETC].content_type) + 1; char *ext = NULL; for (idx = 0; idx < SOUND_MIME_NUM; idx++) { @@ -382,7 +386,7 @@ static int __media_svc_get_content_type_from_mime(const char *path, const char * /*check music file in sound files. */ if (*category & MEDIA_SVC_CATEGORY_SOUND) { - int prefix_len = strlen(content_category[0].content_type) + 1; + int prefix_len = strlen(content_category[MEDIA_SVC_CATEGORY_SOUND].content_type) + 1; for (idx = 0; idx < MUSIC_MIME_NUM; idx++) { if (strcmp(mimetype + prefix_len, music_mime_table[idx]) == 0) {