4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: 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.
24 #include "mm_file_debug.h"
25 #include "mm_file_utils.h"
27 typedef struct _mmfileavmimetype {
28 char mimetype[MMFILE_MIMETYPE_MAX_LEN];
29 char ffmpegFormat[MMFILE_FILE_FMT_MAX_LEN];
30 char extension[MMFILE_FILE_EXT_MAX_LEN];
33 const MMFileAVMimeType MMFILE_FFMPEG_MIME_TABLE[] = {
34 {"audio/mpeg", "mp3", "mp3"},
35 {"audio/mp3", "mp3", "mp3"},
36 {"audio/mpg3", "mp3", "mp3"},
37 {"audio/mpeg3", "mp3", "mp3"},
38 {"audio/mpg", "mp3", "mp3"},
39 {"audio/x-mpeg", "mp3", "mp3"},
40 {"audio/x-mp3", "mp3", "mp3"},
41 {"audio/x-mpeg3", "mp3", "mp3"},
42 {"audio/x-mpg", "mp3", "mp3"},
43 {"audio/x-mpegaudio", "mp3", "mp3"}, /*10 */
45 {"video/3gpp", "mov,mp4,m4a,3gp,3g2,mj2", "3gp"},
46 {"video/h263", "mov,mp4,m4a,3gp,3g2,mj2", "3gp"},
47 {"video/3gp", "mov,mp4,m4a,3gp,3g2,mj2", "3gp"},
48 {"video/3gpp", "mov,mp4,m4a,3gp,3g2,mj2", "3gp"},
49 {"video/mp4v-es", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
50 {"video/dvd", "mov,mp4,m4a,3gp,3g2,mj2", "mpeg"},
51 {"audio/3gpp", "mov,mp4,m4a,3gp,3g2,mj2", "3gp"}, /*17 */
53 {"video/mpeg4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
54 {"video/mp4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
55 {"video/x-mp4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
56 {"video/x-pv-mp4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
57 {"audio/mp4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
58 {"audio/MP4A-LATM", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
59 {"audio/mpeg4", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
60 {"audio/m4a", "mov,mp4,m4a,3gp,3g2,mj2", "mp4"}, /*25 */
62 {"video/avi", "avi", "avi"},
63 {"video/divx", "divx", "divx"},
65 {"audio/x-ms-asf", "asf", "asf"},
66 {"video/x-ms-asf", "asf", "asf"},
67 {"video/x-ms-asf", "asf", "asf"},
69 {"video/x-ms-wmv", "asf", "wmv"},
70 {"audio/wma", "asf", "wma"},
71 {"audio/x-ms-wma", "asf", "wma"},
73 {"audio/wave", "wav", "wav"}, /* Not Sure */
74 {"audio/wav", "wav", "wav"}, /* Not Sure */
75 {"audio/x-wave", "wav", "wav"}, /* Not Sure */
76 {"audio/x-wav", "wav", "wav"}, /* Not Sure */
78 {"audio/aac", "aac", "aac"}, /* Not Sure */
79 {"audio/g72", "aac", "aac"}, /* Not Sure */ /*39 */
81 {"audio/AMR", "amr", "amr"}, /* Not Sure */
82 {"audio/amr-wb", "amr", "amr"}, /* Not Sure */
83 {"audio/x-amr", "amr", "amr"}, /* Not Sure */
85 {"audio/x-mid", "mid", "mid"}, /* Not Sure */
86 {"audio/x-midi", "mid", "mid"}, /* Not Sure */
87 {"audio/mid", "mid", "mid"}, /* Not Sure */
88 {"audio/midi", "mid", "mid"}, /* Not Sure */
89 {"audio/mid", "mid", "mid"}, /* Not Sure */ /*47 */
91 {"audio/iMelody", "imy", "imy"}, /* Not Sure */
92 {"audio/imelody", "imy", "imy"}, /* Not Sure */
93 {"audio/melody", "imy", "imy"}, /* Not Sure */
94 {"audio/imy", "imy", "imy"}, /* Not Sure */
95 {"audio/x-iMelody", "imy", "imy"}, /* Not Sure */
97 {"audio/basic", "snd", ""}, /* Not Sure */
98 {"audio/pmd", "pmd", ""}, /* Not Sure */
99 {"audio/sp-midi", "smp", ""}, /* Not Sure */ /*55 */
101 {"audio/mmf", "mmf", "mmf"}, /* Not Sure */
102 {"audio/smaf", "mmf", "mmf"}, /* Not Sure */
103 {"audio/x-mmf", "mmf", "mmf"}, /* Not Sure */
104 {"audio/x-smaf", "mmf", "mmf"}, /* Not Sure */
106 {"audio/xmf", "xmf", "xmf"}, /* Not Sure */
107 {"audio/mobile-xmf", "xmf", "xmf"}, /* Not Sure */
108 {"audio/x-xmf", "xmf", "xmf"}, /* Not Sure */ /*62 */
110 {"audio/vnd.rn-realaudio", "rm", ""}, /* Not Sure */
111 {"audio/x-pn-multirate-realaudio", "rm", ""}, /* Not Sure */
112 {"audio/x-pn-multirate-realaudio-live", "rm", ""}, /* Not Sure */
113 {"video/vnd.rn-realvideo", "rm", ""}, /* Not Sure */
114 {"video/vnd.rn-realmedia", "rm", ""}, /* Not Sure */
115 {"video/x-pn-multirate-realvideo", "rm", ""}, /* Not Sure */ /*68 */
117 {"video/ogg", "ogg", "ogg"},
118 {"video/theora", "ogg", "ogg"},
119 {"audio/ogg", "ogg", "ogg"},
120 {"audio/x-ogg", "ogg", "ogg"},
121 {"audio/vorbis", "ogg", "ogg"}, /*73 */
123 {"audio/x-flac", "flac", "flac"}, /*74 */
124 {"video/x-flv", "flv", "flv"}, /*75 */
125 {"video/MP2T", "mpegts", "ts"},
126 {"video/MP2P", "mpeg", "mpg"},
127 {"video/mpeg", "mpegvideo", "mpeg"}, /*mpeg 1 video */
132 int mmfile_util_get_ffmpeg_format(const char *mime, char *ffmpegFormat)
135 int table_size = sizeof(MMFILE_FFMPEG_MIME_TABLE) / sizeof(MMFileAVMimeType);
137 if (NULL == mime || NULL == ffmpegFormat) {
138 debug_error(DEBUG, "error: mmfile_util_get_format\n");
139 return MMFILE_UTIL_FAIL;
142 for (i = 0; i < table_size; i++) {
143 if (!strcasecmp(MMFILE_FFMPEG_MIME_TABLE[i].mimetype, mime)) {
148 if (i == table_size) {
149 debug_error(DEBUG, "error: not found[%s]\n", mime);
150 return MMFILE_UTIL_FAIL;
153 memcpy(ffmpegFormat, MMFILE_FFMPEG_MIME_TABLE[i].ffmpegFormat, strlen(MMFILE_FFMPEG_MIME_TABLE[i].ffmpegFormat));
155 return MMFILE_UTIL_SUCCESS;
160 int mmfile_util_get_file_ext(const char *mime, char *ext)
163 int table_size = sizeof(MMFILE_FFMPEG_MIME_TABLE) / sizeof(MMFileAVMimeType);
165 if (NULL == mime || NULL == ext) {
166 debug_error(DEBUG, "error: mmfile_util_get_file_ext\n");
167 return MMFILE_UTIL_FAIL;
170 for (i = 0; i < table_size; i++) {
171 if (!strcasecmp(MMFILE_FFMPEG_MIME_TABLE[i].mimetype, mime)) {
176 if (i == table_size) {
177 debug_error(DEBUG, "error: not found[%s]\n", mime);
178 return MMFILE_UTIL_FAIL;
181 memcpy(ext, MMFILE_FFMPEG_MIME_TABLE[i].extension, strlen(MMFILE_FFMPEG_MIME_TABLE[i].extension));
183 return MMFILE_UTIL_SUCCESS;