-static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category)
-{
- int i = 0;
- int err = 0;
-
- *category = MS_CATEGORY_UNKNOWN;
-
- //MS_DBG("mime type : %s", mimetype);
-
- /*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;
- }
- }
-
- /*in application type, exitst sound file ex) x-smafs */
- if (*category & MS_CATEGORY_ETC) {
- int prefix_len = strlen(content_category[0].content_type);
-
- for (i = 0; i < SOUND_MIME_NUM; i++) {
- if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
- *category ^= MS_CATEGORY_ETC;
- *category |= MS_CATEGORY_SOUND;
- break;
- }
- }
- }
-
- /*check music file in soun files. */
- if (*category & MS_CATEGORY_SOUND) {
- int prefix_len = strlen(content_category[0].content_type) + 1;
-
- //MS_DBG("mime_type : %s", mimetype + prefix_len);
-
- for (i = 0; i < MUSIC_MIME_NUM; i++) {
- if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
- *category ^= MS_CATEGORY_SOUND;
- *category |= MS_CATEGORY_MUSIC;
- break;
- }
- }
-
- /*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 ^= MS_CATEGORY_SOUND;
- *category |= MS_CATEGORY_ETC;
- }
- } else if (*category & MS_CATEGORY_VIDEO) {
- /*some video files don't have video stream. in this case it is categorize as music. */
- /*"3gp" and "mp4" must check video stream and then categorize in directly. */
- char file_ext[10] = {0};
- memset(file_ext, 0, sizeof(file_ext));
- if((_media_svc_get_file_ext(path, file_ext)) && strlen(file_ext) > 0) {
- if ((strncasecmp(file_ext, _3GP_FILE, 4) == 0) || (strncasecmp(file_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 ^= MS_CATEGORY_VIDEO;
- *category |= MS_CATEGORY_MUSIC;
- }
- }
- }
- }
- }
-
- //MS_DBG("category_from_ext : %d", *category);
-
- return err;
-}
-
-static int __get_content_type(const char * file_path, const char * mime_type)
-{
- int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
- int category = 0;
-
- ret = __get_content_type_from_mime(file_path, mime_type, &category);
-
- if (category & MS_CATEGORY_SOUND) return MEDIA_SVC_MEDIA_TYPE_SOUND;
- else if (category & MS_CATEGORY_MUSIC) return MEDIA_SVC_MEDIA_TYPE_MUSIC;
- else if (category & MS_CATEGORY_IMAGE) return MEDIA_SVC_MEDIA_TYPE_IMAGE;
- else if (category & MS_CATEGORY_VIDEO) return MEDIA_SVC_MEDIA_TYPE_VIDEO;
- else return MEDIA_SVC_MEDIA_TYPE_OTHER;
-}
-