3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #include "MmsPluginAvCodec.h"
34 AvCodecType AvGetFileCodecType(const char *szFileName)
36 char szFileExt[FILEEXT_MAX] = {0, };
41 iStrLen = strlen(szFileName);
48 if (szFileName[iPos] == '.')
50 if (szFileName[iPos] == '/') {
60 if (FILEEXT_MAX > (iStrLen - iPos - 1)) {
61 strncpy(szFileExt, szFileName + iPos + 1, (iStrLen - iPos - 1));
62 szFileExt[iStrLen - iPos - 1] = '\0';
66 if (strcasecmp(szFileExt, "mp3") == 0 || strcasecmp(szFileExt, "MP3") == 0)
67 return AV_DEC_AUDIO_MP3;
69 if (strcasecmp(szFileExt, "pvx") == 0 || strcasecmp(szFileExt, "PVX") == 0)
70 return AV_DEC_VIDEO_PVX;
71 else if (strcasecmp(szFileExt, "wav") == 0 || strcasecmp(szFileExt, "WAV") == 0) {
74 if (__AvValidWAVE(szFileName) == true)
75 return AV_DEC_AUDIO_WAVE;
80 return AV_DEC_AUDIO_WAVE;
81 } else if (strcasecmp(szFileExt, "aac") == 0 || strcasecmp(szFileExt, "AAC") == 0)
82 return AV_DEC_AUDIO_AAC;
84 else if (strcasecmp(szFileExt, "wma") == 0 || strcasecmp(szFileExt, "WMA") == 0)
85 return AvWMFFGetFileType(szFileName);
86 else if (strcasecmp(szFileExt, "wmv") == 0 || strcasecmp(szFileExt, "WMV") == 0)
87 return AvWMFFGetFileType(szFileName);
88 else if (strcasecmp(szFileExt, "asf") == 0 || strcasecmp(szFileExt, "ASF") == 0)
89 return AvWMFFGetFileType(szFileName);
91 else if (strcasecmp(szFileExt, "amr") == 0 || strcasecmp(szFileExt, "AMR") == 0 ||
92 strcasecmp(szFileExt, "x-amr") == 0 || strcasecmp(szFileExt, "X-AMR") == 0) {
95 if (__AvValidAMR(szFileName) == true)
96 return AV_DEC_AUDIO_AMR;
101 return AV_DEC_AUDIO_AMR;
102 } else if (strcasecmp(szFileExt, "g7231") == 0 || strcasecmp(szFileExt, "G7231") == 0)
103 return AV_DEC_AUDIO_G723_1;
104 else if ((strcasecmp(szFileExt, "mid") == 0 || strcasecmp(szFileExt, "MID") == 0) ||
105 (strcasecmp(szFileExt, "midi") == 0 || strcasecmp(szFileExt, "MIDI") == 0)) {
108 if (__AvValidMIDI(szFileName) == true)
109 return AV_DEC_AUDIO_MIDI;
111 return AV_CODEC_NONE;
114 return AV_DEC_AUDIO_MIDI;
115 } else if (strcasecmp(szFileExt, "mmf") == 0 || strcasecmp(szFileExt, "MMF") == 0 || strcasecmp(szFileExt, "x-mmf") == 0) {
118 if (__AvValidMMF(szFileName) == true)
119 return AV_DEC_AUDIO_MMF;
121 return AV_CODEC_NONE;
124 return AV_DEC_AUDIO_MMF;
125 } else if (strcasecmp(szFileExt, "pmd") == 0 || strcasecmp(szFileExt, "PMD") == 0) {
126 return AV_DEC_AUDIO_MIDI;
127 } else if (strcasecmp(szFileExt, "xmf") == 0 || strcasecmp(szFileExt, "XMF") == 0 ||
128 strcasecmp(szFileExt, "mxmf") == 0 || strcasecmp(szFileExt, "MXMF") == 0) {
129 return AV_DEC_AUDIO_XMF;
130 } else if (strcasecmp(szFileExt, "smp") == 0 || strcasecmp(szFileExt, "SMP") == 0) {
133 if (__AvValidSMP(szFileName) == true)
134 return AV_DEC_AUDIO_ADPCM;
136 return AV_CODEC_NONE;
139 return AV_DEC_AUDIO_ADPCM;
140 } else if (strcasecmp(szFileExt, "spm") == 0 || strcasecmp(szFileExt, "SPM") == 0) {
143 if (__AvValidMIDI(szFileName) == true)
144 return AV_DEC_AUDIO_SPM;
146 return AV_CODEC_NONE;
149 return AV_DEC_AUDIO_SPM;
150 } else if (strcasecmp(szFileExt, "spf") == 0 || strcasecmp(szFileExt, "SPF") == 0) {
153 if (__AvValidMMF(szFileName) == true)
154 return AV_DEC_AUDIO_MMF_PHRASE_L1;
156 return AV_CODEC_NONE;
159 return AV_DEC_AUDIO_MMF_PHRASE_L1;
160 } else if (strcasecmp(szFileExt, "imy") == 0 || strcasecmp(szFileExt, "IMY") == 0 ||
161 strcasecmp(szFileExt, "iMelody") == 0 || strcasecmp(szFileExt, "x-iMelody") == 0 ||
162 strcasecmp(szFileExt, "Melody") == 0) {
165 if (__AvValidIMELODY(szFileName) == true)
166 return AV_DEC_AUDIO_IMELODY;
168 return AV_CODEC_NONE;
171 return AV_DEC_AUDIO_IMELODY;
172 } else if (strcasecmp(szFileExt, "dtmf") == 0)
173 return AV_DEC_AUDIO_DTMF_TONE;
174 else if (strcasecmp(szFileExt, "h263") == 0 || strcasecmp(szFileExt, "H263") == 0)
175 return AV_DEC_VIDEO_H263;
176 else if (strcasecmp(szFileExt, "mp4") == 0 || strcasecmp(szFileExt, "MP4") == 0 ||
177 strcasecmp(szFileExt, "mpeg4") == 0 || strcasecmp(szFileExt, "MPEG4") == 0 ||
178 strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) {
181 AvCodecType avCodecType = AV_CODEC_NONE;
182 FmFileAttribute fileAttrib;
186 if (!DrmGetFileAttributes(szFileName, &fileAttrib)) {
187 return AV_CODEC_NONE;
189 dateTime = TmDateTimeToSeconds(&fileAttrib.dt);
190 strLen = strlen(szFileName);
191 if ((strnicmp(lastAccessFileInfo.szFileName, szFileName, strLen) == 0) &&
192 (lastAccessFileInfo.fileSize == fileAttrib.fileSize) &&
193 (lastAccessFileInfo.dateTime == dateTime)) {
194 return lastAccessFileInfo.codecType;
196 avCodecType = AvMP4FFGetFileType(szFileName);
198 if (strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 ||
199 strcasecmp(szFileExt, "m4a") == 0 || strcasecmp(szFileExt, "M4A") == 0) {
200 if (avCodecType | AV_DEC_AUDIO_MPEG4)
201 avCodecType = AV_DEC_AUDIO_MPEG4;
204 if (avCodecType != AV_CODEC_NONE) {
205 strncpy(lastAccessFileInfo.szFileName, szFileName, strLen);
206 lastAccessFileInfo.szFileName[strLen] = '\0';
207 lastAccessFileInfo.fileSize = fileAttrib.fileSize;
208 lastAccessFileInfo.dateTime = dateTime;
209 lastAccessFileInfo.codecType = avCodecType;
216 return AV_DEC_VIDEO_MPEG4;
217 } else if (strcasecmp(szFileExt, "3gp") == 0 || strcasecmp(szFileExt, "3GP") == 0 ||
218 strcasecmp(szFileExt, "3ga") == 0 || strcasecmp(szFileExt, "3GA") == 0 ||
219 strcasecmp(szFileExt, "3gpp") == 0 || strcasecmp(szFileExt, "3GPP") == 0) {
220 return AV_CODEC_NONE;
221 } else if (strcasecmp(szFileExt, "sdp") == 0 || strcasecmp(szFileExt, "SDP") == 0)
222 return AV_DEC_VIDEO_MPEG4;
224 return AV_CODEC_NONE;