}
if (formatContext->pre_checked == 0) {
- res = MMFileFormatIsValidAAC (formatContext->uriFileName);
+ res = MMFileFormatIsValidAAC (NULL, formatContext->uriFileName);
if (res == 0) {
debug_error("It is not AAC file\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
}
static int __get_fileformat(const char *urifilename, int *format)
{
int index;
+ int ret = 0;
+ MMFileIOHandle *fp = NULL;
debug_error("%s\n", urifilename);
+ ret = mmfile_open (&fp, urifilename, MMFILE_RDONLY);
+
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ if(fp)
+ mmfile_close(fp);
+ return MMFILE_FORMAT_FAIL;
+ }
+
for (index = 0; index < MM_FILE_FORMAT_NUM; index++) {
debug_msg ("search index = [%d]\n", index);
switch (index) {
case MM_FILE_FORMAT_QT:
case MM_FILE_FORMAT_3GP:
case MM_FILE_FORMAT_MP4: {
- if (MMFileFormatIsValidMP4 (urifilename)) {
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
*format = MM_FILE_FORMAT_3GP;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_ASF:
case MM_FILE_FORMAT_WMA:
case MM_FILE_FORMAT_WMV: {
- if (MMFileFormatIsValidASF (urifilename)) {
+ if (MMFileFormatIsValidASF (fp, NULL)) {
*format = MM_FILE_FORMAT_ASF;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_DIVX:
case MM_FILE_FORMAT_AVI: {
- if (MMFileFormatIsValidAVI(urifilename)) {
+ if (MMFileFormatIsValidAVI(fp, NULL)) {
*format = MM_FILE_FORMAT_AVI;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_MATROSKA: {
- if (MMFileFormatIsValidMatroska (urifilename)) {
+ if (MMFileFormatIsValidMatroska (fp, NULL)) {
*format = MM_FILE_FORMAT_MATROSKA;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_FLV: {
- if (MMFileFormatIsValidFLV (urifilename)) {
+ if (MMFileFormatIsValidFLV (fp, NULL)) {
*format = MM_FILE_FORMAT_FLV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
}
*format = -1;
+
+ if(fp)
+ mmfile_close(fp);
+
return MMFILE_FORMAT_FAIL;
+
+FILE_FORMAT_SUCCESS:
+ if(fp)
+ mmfile_close(fp);
+
+ return MMFILE_FORMAT_SUCCESS;
}
static int __mmfile_get_frame(AVFormatContext *pFormatCtx, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
}
if (formatContext->pre_checked == 0) {
- ret = MMFileFormatIsValidIMY (formatContext->uriFileName);
+ ret = MMFileFormatIsValidIMY (NULL, formatContext->uriFileName);
if (ret == 0) {
debug_error("It is not imelody file\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
}
}
if (formatContext->pre_checked == 0) {
- res = MMFileFormatIsValidMID (formatContext->uriFileName);
+ res = MMFileFormatIsValidMID (NULL, formatContext->uriFileName);
if ( res == 0 ) {
debug_error("It is not MIDI file\n");
return MMFILE_FORMAT_FAIL;
EXPORT_API
int mmfile_format_open_mmf (MMFileFormatContext *formatContext)
-{
+{
int ret = 0;
if (NULL == formatContext) {
debug_error ("error: formatContext is NULL\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
if (formatContext->pre_checked == 0) {
- ret = MMFileFormatIsValidMMF (formatContext->uriFileName);
+ ret = MMFileFormatIsValidMMF (NULL, formatContext->uriFileName);
if (ret == 0) {
debug_error ("error: it is not MMF file\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
}
int ret = 0;
debug_fenter();
-
+
if (NULL == formatContext)
{
debug_error("formatContext is NULL\n");
}
if (formatContext->pre_checked == 0) {
- ret = MMFileFormatIsValidMP3 (formatContext->uriFileName,5);
+ ret = MMFileFormatIsValidMP3 (NULL, formatContext->uriFileName, 5);
if ( ret == 0 )
{
debug_error("It is not mp3 file\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
}
-
formatContext->ReadStream = mmfile_format_read_stream_mp3;
formatContext->ReadFrame = mmfile_format_read_frame_mp3;
formatContext->ReadTag = mmfile_format_read_tag_mp3;
}
if (formatContext->pre_checked == 0) {
- ret = MMFileFormatIsValidWAV (formatContext->uriFileName);
+ ret = MMFileFormatIsValidWAV (NULL, formatContext->uriFileName);
if ( ret == 0 )
{
debug_error("It is not wav file\n");
- return MMFILE_FORMAT_FAIL;
+ return MMFILE_FORMAT_FAIL;
}
}
#define _MMF_FILE_FILEEXT_MAX 128
+#define MMFILE_EXT_MP4 0x6D7034
+#define MMFILE_EXT_MPEG4 0x6D70656734
+#define MMFILE_EXT_M4A 0x6D3461
+#define MMFILE_EXT_MPG 0x6D7067
+#define MMFILE_EXT_MPG4 0x6D706734
+#define MMFILE_EXT_M4V 0x6D3476
+#define MMFILE_EXT_3GP 0x336770
+#define MMFILE_EXT_AMR 0x616D72
+#define MMFILE_EXT_AWB 0x617762
+#define MMFILE_EXT_WAV 0x776176
+#define MMFILE_EXT_MID 0x6D6964
+#define MMFILE_EXT_MIDI 0x6D696D69
+#define MMFILE_EXT_SPM 0x73706D
+#define MMFILE_EXT_MP3 0x6D7033
+#define MMFILE_EXT_AAC 0x616163
+#define MMFILE_EXT_XMF 0x786D66
+#define MMFILE_EXT_MXMF 0x6D786D66
+#define MMFILE_EXT_MMF 0x6D6D66
+#define MMFILE_EXT_MA2 0x6D6132
+#define MMFILE_EXT_IMY 0x696D79
+#define MMFILE_EXT_AVI 0x617669
+#define MMFILE_EXT_DIVX 0x64697678
+#define MMFILE_EXT_ASF 0x617366
+#define MMFILE_EXT_ASX 0x617378
+#define MMFILE_EXT_WMA 0x776D61
+#define MMFILE_EXT_WMV 0x776D76
+#define MMFILE_EXT_OGG 0x6F6767
+#define MMFILE_EXT_MKV 0x6D6B76
+#define MMFILE_EXT_MKA 0x6D6B61
+#define MMFILE_EXT_MOV 0x6D6F76
+#define MMFILE_EXT_FLAC 0x666C6163
+#define MMFILE_EXT_FLV 0x666C76
+
int (*MMFileOpenFunc[MM_FILE_FORMAT_NUM+1]) (MMFileFormatContext *fileContext) = {
mmfile_format_open_ffmpg, /* 3GP */
mmfile_format_open_ffmpg, /* ASF */
_PreprocessFile (MMFileSourceType *fileSrc, char **urifilename, int *formatEnum, int *isdrm)
{
const char *fileName = NULL;
- char extansion_name[_MMF_FILE_FILEEXT_MAX];
- int pos = 0;
int filename_len = 0;
int index = 0, skip_index = 0;
+ int ret = 0;
+ MMFileIOHandle *fp = NULL;
if (fileSrc->type == MM_FILE_SRC_TYPE_FILE) {
+ unsigned long long file_extansion = 0;
+
fileName = (const char *)(fileSrc->file.path);
filename_len = strlen (fileName);
- pos = filename_len;
-
- /**
- * Get file extension from file's name
- */
- while (pos > 0) {
- pos--;
- if (fileName[pos] == '.')
- break;
- }
-
- memset (extansion_name, 0x00, _MMF_FILE_FILEEXT_MAX);
-
- /*extract metadata for all file. ex)a , a. , a.mp3*/
- if (pos == 0) {
- /*even though there is no file extension, extracto metadata*/
- debug_msg ("no file extension");
- }
- else if (_MMF_FILE_FILEEXT_MAX > (filename_len - pos - 1)) {
- strncpy (extansion_name, fileName + pos +1 , (filename_len - pos - 1));
- extansion_name[filename_len - pos - 1] = '\0';
- } else {
- debug_error ("invalid filename. destination length: %d, source length: %d.\n", _MMF_FILE_FILEEXT_MAX, (filename_len - pos - 1));
- return MMFILE_FORMAT_FAIL; /*invalid file name*/
- }
#ifdef DRM_SUPPORT
/**
ret = drm_get_file_type(fileSrc->file.path, &file_type);
if((ret == DRM_RETURN_SUCCESS) && ((file_type == DRM_TYPE_OMA_V1) ||(file_type == DRM_TYPE_OMA_V2)))
{
+ char extansion_name[_MMF_FILE_FILEEXT_MAX];
+ int i = 0;
is_drm = TRUE;
+
+ memset(&contentInfo, 0x0, sizeof(drm_content_info_s));
+
+ if (DRM_RETURN_SUCCESS != drm_get_content_info (fileSrc->file.path, &contentInfo)) {
+ debug_error ("error: drm_get_content_info\n");
+ goto FILE_FORMAT_FAIL;
+ }
+
+ memset (extansion_name, 0x00, _MMF_FILE_FILEEXT_MAX);
+ if (MMFILE_UTIL_SUCCESS != mmfile_util_get_file_ext (contentInfo.mime_type, extansion_name)) {
+ debug_error ("error: mmfile_util_get_ffmpeg_format\n");
+ goto FILE_FORMAT_FAIL;
+ }
+
+ file_extansion = 0;
+
+ for(i=0; i<stlen(extansion_name); i++) {
+ file_extansion |= (extansion_name[i] >= 'A' && extansion_name[i] <= 'Z' ? extansion_name[i] + 0x20 : extansion_name[i]) << i * 8;
+ }
+
+ *urifilename = mmfile_malloc (MMFILE_DRM_URI_LEN + filename_len + 1);
+ if (!*urifilename) {
+ debug_error ("error: mmfile_malloc uriname\n");
+ goto FILE_FORMAT_FAIL;
+ }
+
+ memset (*urifilename, 0x00, MMFILE_DRM_URI_LEN + filename_len + 1);
+ strncpy (*urifilename, MMFILE_DRM_URI, MMFILE_DRM_URI_LEN);
+ strncat (*urifilename, fileName, filename_len);
+ (*urifilename)[MMFILE_DRM_URI_LEN + filename_len] = '\0';
}
}
{
*isdrm = MM_FILE_DRM_OMA;
debug_error ("OMA DRM detected. Not Support DRM Content\n");
- return MMFILE_FORMAT_FAIL; /*Not Support DRM Content*/
- }
- else
-#endif // DRM_SUPPORT
+ goto FILE_FORMAT_FAIL; /*Not Support DRM Content*/
+ }
+ else
+#endif // DRM_SUPPORT
{
+ int pos = filename_len;
*isdrm = MM_FILE_DRM_NONE;
#ifdef __MMFILE_MMAP_MODE__
*urifilename = mmfile_malloc (MMFILE_MMAP_URI_LEN + filename_len + 1);
if (!*urifilename) {
debug_error ("error: mmfile_malloc uriname\n");
- return MMFILE_FORMAT_FAIL;
+ goto FILE_FORMAT_FAIL;
}
memset (*urifilename, 0x00, MMFILE_MMAP_URI_LEN + filename_len + 1);
*urifilename = mmfile_malloc (MMFILE_FILE_URI_LEN + filename_len + 1);
if (!*urifilename) {
debug_error ("error: mmfile_malloc uriname\n");
- return MMFILE_FORMAT_FAIL;
+ goto FILE_FORMAT_FAIL;
}
memset (*urifilename, 0x00, MMFILE_FILE_URI_LEN + filename_len + 1);
strncat (*urifilename, fileName, filename_len);
(*urifilename)[MMFILE_FILE_URI_LEN + filename_len] = '\0';
#endif
+ /**
+ * Get file extension from file's name
+ */
+ while (pos > 0) {
+ pos--;
+ if (fileName[pos] == '.')
+ break;
+ file_extansion |= (fileName[pos] >= 'A' && fileName[pos] <= 'Z' ? fileName[pos] + 0x20 : fileName[pos]) << (filename_len - pos - 1) * 8;
+ }
+ }
+
+ ret = mmfile_open (&fp, *urifilename, MMFILE_RDONLY);
+
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto FILE_FORMAT_FAIL;
}
///////////////////////////////////////////////////////////////////////
debug_msg ("Get codec type of [%s].\n", extansion_name);
#endif
- if (strcasecmp (extansion_name, "mp4") == 0 ||
- strcasecmp (extansion_name, "mpeg4") == 0 ||
- strcasecmp (extansion_name, "m4a") == 0 ||
- strcasecmp (extansion_name, "mpg") == 0 ||
- strcasecmp (extansion_name, "mpg4") == 0 ||
- strcasecmp (extansion_name, "m4v") == 0 ) {
-
- if (MMFileFormatIsValidMP4 (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_MP4;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MP4;
- goto PROBE_PROPER_FILE_TYPE;
+ switch(file_extansion) {
+ case MMFILE_EXT_MP4:
+ case MMFILE_EXT_MPEG4:
+ case MMFILE_EXT_M4A:
+ case MMFILE_EXT_MPG:
+ case MMFILE_EXT_MPG4:
+ case MMFILE_EXT_M4V:
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_MP4;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MP4;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_3GP:
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_3GP;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_3GP;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_AMR:
+ case MMFILE_EXT_AWB:
+ if (MMFileFormatIsValidAMR (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_AMR;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_AMR;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_WAV:
+ if (MMFileFormatIsValidWAV (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_WAV;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_WAV;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_MID:
+ case MMFILE_EXT_MIDI:
+ case MMFILE_EXT_SPM:
+ if (MMFileFormatIsValidMID (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_MID;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MID;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_MP3:
+ if (MMFileFormatIsValidMP3 (fp, NULL, 5)) {
+ *formatEnum = MM_FILE_FORMAT_MP3;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MP3;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_AAC:
+ if (MMFileFormatIsValidAAC (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_AAC;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_AAC;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_XMF:
+ case MMFILE_EXT_MXMF:
+ if (MMFileFormatIsValidMID (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_MID;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MID;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_MMF:
+ case MMFILE_EXT_MA2:
+ if (MMFileFormatIsValidMMF (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_MMF;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MMF;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_IMY:
+ if (MMFileFormatIsValidIMY (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_IMELODY;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_IMELODY;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
- } else if (strcasecmp (extansion_name, "3gp") == 0) {
- if (MMFileFormatIsValidMP4 (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_3GP;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_3GP;
- goto PROBE_PROPER_FILE_TYPE;
+ case MMFILE_EXT_AVI:
+ if (MMFileFormatIsValidAVI (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_AVI;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_AVI;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_DIVX:
+ if (MMFileFormatIsValidAVI (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_DIVX;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_DIVX;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
- } else if (strcasecmp (extansion_name, "amr") == 0 ||
- strcasecmp (extansion_name, "awb") == 0) {
+ case MMFILE_EXT_ASF:
+ case MMFILE_EXT_ASX:
+ if (MMFileFormatIsValidASF (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_ASF;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_ASF;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_WMA:
+ if (MMFileFormatIsValidWMA (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_WMA;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_WMA;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_WMV:
+ if (MMFileFormatIsValidWMV (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_WMV;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_WMV;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_OGG:
+ if (MMFileFormatIsValidOGG (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_OGG;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_OGG;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
- if (MMFileFormatIsValidAMR (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_AMR;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_AMR;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "wav") == 0) {
- if (MMFileFormatIsValidWAV (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_WAV;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_WAV;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "mid") == 0 ||
- strcasecmp (extansion_name, "midi") == 0 ||
- strcasecmp (extansion_name, "spm") == 0 ) {
-
- if (MMFileFormatIsValidMID (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_MID;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MID;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "mp3") == 0) {
- if (MMFileFormatIsValidMP3 (*urifilename,5)) {
- *formatEnum = MM_FILE_FORMAT_MP3;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MP3;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "aac") == 0) {
- if (MMFileFormatIsValidAAC (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_AAC;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_AAC;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "xmf") == 0 ||
- strcasecmp (extansion_name, "mxmf") == 0) {
- if (MMFileFormatIsValidMID (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_MID;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MID;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (!strcasecmp (extansion_name, "mmf") ||
- !strcasecmp (extansion_name, "ma2")) {
- if (MMFileFormatIsValidMMF (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_MMF;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MMF;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "imy") == 0) {
- if (MMFileFormatIsValidIMY (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_IMELODY;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_IMELODY;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "avi") == 0) {
- if (MMFileFormatIsValidAVI (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_AVI;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_AVI;
- goto PROBE_PROPER_FILE_TYPE;
- } else if (strcasecmp (extansion_name, "divx") == 0) {
- if (MMFileFormatIsValidAVI (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_DIVX;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_DIVX;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "asf") == 0 ||
- strcasecmp (extansion_name, "asx") == 0 ) {
- if (MMFileFormatIsValidASF (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_ASF;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_ASF;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "wma") == 0) {
- if (MMFileFormatIsValidWMA (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_WMA;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_WMA;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "wmv") == 0) {
- if (MMFileFormatIsValidWMV (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_WMV;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_WMV;
- goto PROBE_PROPER_FILE_TYPE;
-
- } else if (strcasecmp (extansion_name, "ogg") == 0) {
- if (MMFileFormatIsValidOGG (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_OGG;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_OGG;
- goto PROBE_PROPER_FILE_TYPE;
- } else if (strcasecmp (extansion_name, "mkv") == 0 ||
- strcasecmp (extansion_name, "mka") == 0) {
- if (MMFileFormatIsValidMatroska (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_MATROSKA;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_MATROSKA;
- goto PROBE_PROPER_FILE_TYPE;
- } else if (strcasecmp (extansion_name, "mov") == 0) {
- if (MMFileFormatIsValidMP4 (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_QT;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_QT;
- goto PROBE_PROPER_FILE_TYPE;
- } else if (strcasecmp (extansion_name, "flac") == 0) {
- if (MMFileFormatIsValidFLAC (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_FLAC;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_FLAC;
- goto PROBE_PROPER_FILE_TYPE;
- } else if (strcasecmp (extansion_name, "flv") == 0) {
- if (MMFileFormatIsValidFLV (*urifilename)) {
- *formatEnum = MM_FILE_FORMAT_FLV;
- return MMFILE_FORMAT_SUCCESS;
- }
- skip_index = MM_FILE_FORMAT_FLV;
- goto PROBE_PROPER_FILE_TYPE;
- } else {
- debug_warning ("probe file type=%s\n", fileName);
- skip_index = -1;
- goto PROBE_PROPER_FILE_TYPE;
+ case MMFILE_EXT_MKV:
+ case MMFILE_EXT_MKA:
+ if (MMFileFormatIsValidMatroska (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_MATROSKA;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_MATROSKA;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_MOV:
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_QT;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_QT;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_FLAC:
+ if (MMFileFormatIsValidFLAC (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_FLAC;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_FLAC;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ case MMFILE_EXT_FLV:
+ if (MMFileFormatIsValidFLV (fp, NULL)) {
+ *formatEnum = MM_FILE_FORMAT_FLV;
+ goto FILE_FORMAT_SUCCESS;
+ }
+ skip_index = MM_FILE_FORMAT_FLV;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
+
+ default :
+ debug_warning ("probe file type=%s\n", fileName);
+ skip_index = -1;
+ goto PROBE_PROPER_FILE_TYPE;
+ break;
}
} else if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) {
char tempURIBuffer[MMFILE_URI_MAX_LEN] = {0,};
*urifilename = mmfile_strdup (tempURIBuffer);
if (!*urifilename) {
debug_error ("error: uri is NULL\n");
- return MMFILE_FORMAT_FAIL;
+ goto FILE_FORMAT_FAIL;
+ }
+
+ ret = mmfile_open (&fp, *urifilename, MMFILE_RDONLY);
+
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto FILE_FORMAT_FAIL;
}
#ifdef __MMFILE_TEST_MODE__
switch (fileSrc->memory.format) {
case MM_FILE_FORMAT_3GP: {
- if (MMFileFormatIsValidMP4 (*urifilename)) {
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_3GP;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_3GP;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_MP4: {
- if (MMFileFormatIsValidMP4 (*urifilename)) {
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MP4;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_MP4;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_AMR: {
- if (MMFileFormatIsValidAMR (*urifilename)) {
+ if (MMFileFormatIsValidAMR (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AMR;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_AMR;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_WAV: {
- if (MMFileFormatIsValidWAV (*urifilename)) {
+ if (MMFileFormatIsValidWAV (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_WAV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_WAV;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_MID: {
- if (MMFileFormatIsValidMID (*urifilename)) {
+ if (MMFileFormatIsValidMID (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MID;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_MID;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_MP3: {
- if (MMFileFormatIsValidMP3 (*urifilename,5)) {
+ if (MMFileFormatIsValidMP3 (fp, NULL, 5)) {
*formatEnum = MM_FILE_FORMAT_MP3;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_MP3;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_AAC: {
- if (MMFileFormatIsValidAAC (*urifilename)) {
+ if (MMFileFormatIsValidAAC (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AAC;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_AAC;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_MMF: {
- if (MMFileFormatIsValidMMF (*urifilename)) {
+ if (MMFileFormatIsValidMMF (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MMF;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_MMF;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_IMELODY: {
- if (MMFileFormatIsValidIMY (*urifilename)) {
+ if (MMFileFormatIsValidIMY (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_IMELODY;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_IMELODY;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_AVI: {
- if (MMFileFormatIsValidAVI (*urifilename)) {
+ if (MMFileFormatIsValidAVI (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AVI;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_AVI;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_DIVX: {
- if (MMFileFormatIsValidAVI (*urifilename)) {
+ if (MMFileFormatIsValidAVI (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_DIVX;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_DIVX;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_ASF: {
- if (MMFileFormatIsValidASF (*urifilename)) {
+ if (MMFileFormatIsValidASF (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_ASF;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_ASF;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_WMA: {
- if (MMFileFormatIsValidWMA (*urifilename)) {
+ if (MMFileFormatIsValidWMA (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_WMA;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_WMA;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_WMV: {
- if (MMFileFormatIsValidWMV (*urifilename)) {
+ if (MMFileFormatIsValidWMV (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_WMV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_WMV;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_OGG: {
- if (MMFileFormatIsValidOGG (*urifilename)) {
+ if (MMFileFormatIsValidOGG (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_OGG;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_OGG;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_MATROSKA: {
- if (MMFileFormatIsValidMatroska (*urifilename)) {
+ if (MMFileFormatIsValidMatroska (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MATROSKA;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_MATROSKA;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_QT: {
- if (MMFileFormatIsValidMP4 (*urifilename)) {
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_QT;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_QT;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_FLAC: {
- if (MMFileFormatIsValidFLAC (*urifilename)) {
+ if (MMFileFormatIsValidFLAC (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_FLAC;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_FLAC;
goto PROBE_PROPER_FILE_TYPE;
}
case MM_FILE_FORMAT_FLV: {
- if (MMFileFormatIsValidFLV (*urifilename)) {
+ if (MMFileFormatIsValidFLV (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_FLV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
skip_index = MM_FILE_FORMAT_FLV;
goto PROBE_PROPER_FILE_TYPE;
}
} else {
debug_error ("error: invaild input type[memory|file]\n");
- return MMFILE_FORMAT_FAIL;
+ goto FILE_FORMAT_FAIL;
}
PROBE_PROPER_FILE_TYPE:
case MM_FILE_FORMAT_3GP:
case MM_FILE_FORMAT_MP4: {
if (skip_index == MM_FILE_FORMAT_QT || skip_index == MM_FILE_FORMAT_3GP || skip_index == MM_FILE_FORMAT_MP4)
- break;
+ goto FILE_FORMAT_FAIL;
- if (MMFileFormatIsValidMP4 (*urifilename)) {
+ if (MMFileFormatIsValidMP4 (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_3GP;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_3GP;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_WMA:
case MM_FILE_FORMAT_WMV: {
if (skip_index == MM_FILE_FORMAT_ASF || skip_index == MM_FILE_FORMAT_WMA || skip_index == MM_FILE_FORMAT_WMV)
- break;
+ goto FILE_FORMAT_FAIL;
- if (MMFileFormatIsValidASF (*urifilename)) {
+ if (MMFileFormatIsValidASF (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_ASF;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_ASF;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_DIVX:
case MM_FILE_FORMAT_AVI: {
if (skip_index == MM_FILE_FORMAT_DIVX || skip_index == MM_FILE_FORMAT_AVI)
- break;
+ goto FILE_FORMAT_FAIL;
- if (MMFileFormatIsValidAVI(*urifilename)) {
+ if (MMFileFormatIsValidAVI(fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AVI;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_AVI;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_OGG: {
- if (MMFileFormatIsValidOGG (*urifilename)) {
+ if (MMFileFormatIsValidOGG (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_OGG;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_OGG;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_AMR: {
- if (MMFileFormatIsValidAMR (*urifilename)) {
+ if (MMFileFormatIsValidAMR (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AMR;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_AMR;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_AAC: {
- if (MMFileFormatIsValidAAC (*urifilename)) {
+ if (MMFileFormatIsValidAAC (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_AAC;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_AAC;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_MP3: {
- if (MMFileFormatIsValidMP3 (*urifilename,50)) {
+ if (MMFileFormatIsValidMP3 (fp, NULL, 50)) {
*formatEnum = MM_FILE_FORMAT_MP3;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_MP3;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_WAV: {
- if (MMFileFormatIsValidWAV (*urifilename)) {
+ if (MMFileFormatIsValidWAV (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_WAV;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_WAV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_MID: {
- if (MMFileFormatIsValidMID (*urifilename)) {
+ if (MMFileFormatIsValidMID (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MID;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_MID;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_MMF: {
- if (MMFileFormatIsValidMMF (*urifilename)) {
+ if (MMFileFormatIsValidMMF (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MMF;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_MMF;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_IMELODY: {
- if (MMFileFormatIsValidIMY (*urifilename)) {
+ if (MMFileFormatIsValidIMY (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_IMELODY;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_IMELODY;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_MATROSKA: {
- if (MMFileFormatIsValidMatroska (*urifilename)) {
+ if (MMFileFormatIsValidMatroska (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_MATROSKA;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_MATROSKA;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_FLAC: {
- if (MMFileFormatIsValidFLAC (*urifilename)) {
+ if (MMFileFormatIsValidFLAC (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_FLAC;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_FLAC;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_FLV: {
- if (MMFileFormatIsValidFLV (*urifilename)) {
+ if (MMFileFormatIsValidFLV (fp, NULL)) {
*formatEnum = MM_FILE_FORMAT_FLV;
if (fileSrc->type == MM_FILE_SRC_TYPE_MEMORY) fileSrc->memory.format = MM_FILE_FORMAT_FLV;
- return MMFILE_FORMAT_SUCCESS;
+ goto FILE_FORMAT_SUCCESS;
}
break;
}
case MM_FILE_FORMAT_AU:
case MM_FILE_FORMAT_VOB:
case MM_FILE_FORMAT_JPG:
- break;
default: {
debug_error ("error: invaild format enum[%d]\n", index);
+ goto FILE_FORMAT_FAIL;
break;
}
}
}
+FILE_FORMAT_FAIL:
if (index == MM_FILE_FORMAT_NUM)
debug_error("Can't probe file type\n");
*formatEnum = -1;
+
+ if(fp)
+ mmfile_close(fp);
+
return MMFILE_FORMAT_FAIL;
+
+FILE_FORMAT_SUCCESS:
+ if(fp)
+ mmfile_close(fp);
+
+ return MMFILE_FORMAT_SUCCESS;
}
static int _mmfile_format_close (MMFileFormatContext *formatContext, bool clean_all)
Name: libmm-fileinfo
Summary: Media Fileinfo
-Version: 0.6.3
+Version: 0.6.31
Release: 0
Group: System/Libraries
License: Apache-2.0
inline short mmfile_io_be_int16 (unsigned short value);
inline short mmfile_io_le_int16 (unsigned short value);
+typedef struct MMFileIOHandle
+{
+ struct MMFileIOFunc *iofunc;
+ int flags; /* file flags */
+ void *privateData;
+ char *fileName;
+} MMFileIOHandle;
////////////////////////////////////////////////////////////////////////
// FILE HEADER CHECK API //
////////////////////////////////////////////////////////////////////////
-int MMFileFormatIsValidMP3 (const char *mmfileuri, int frameCnt);
-int MMFileFormatIsValidAAC (const char *mmfileuri);
-int MMFileFormatIsValidASF (const char *mmfileuri);
-int MMFileFormatIsValidMP4 (const char *mmfileuri);
-int MMFileFormatIsValidAVI (const char *mmfileuri);
-int MMFileFormatIsValidAMR (const char *mmfileuri);
-int MMFileFormatIsValidWAV (const char *mmfileuri);
-int MMFileFormatIsValidMMF (const char *mmfileuri);
-int MMFileFormatIsValidMID (const char *mmfileuri);
-int MMFileFormatIsValidIMY (const char *mmfileuri);
-int MMFileFormatIsValidWMA (const char *mmfileuri);
-int MMFileFormatIsValidWMV (const char *mmfileuri);
-int MMFileFormatIsValidOGG (const char *mmfileuri);
-int MMFileFormatIsValidMatroska (const char *mmfileuri);
-int MMFileFormatIsValidQT (const char *mmfileuri);
-int MMFileFormatIsValidFLAC (const char *mmfileuri);
-int MMFileFormatIsValidFLV (const char *mmfileuri);
+int MMFileFormatIsValidMP3 (MMFileIOHandle *pFileIO, const char *mmfileuri, int frameCnt);
+int MMFileFormatIsValidAAC (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidASF (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidMP4 (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidAVI (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidAMR (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidWAV (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidMMF (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidMID (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidIMY (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidWMA (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidWMV (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidOGG (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidMatroska (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidQT (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidFLAC (MMFileIOHandle *pFileIO, const char *mmfileuri);
+int MMFileFormatIsValidFLV (MMFileIOHandle *pFileIO, const char *mmfileuri);
////////////////////////////////////////////////////////////////////////
#define MMFILE_SEEK_CUR SEEK_CUR
#define MMFILE_SEEK_END SEEK_END
-typedef struct MMFileIOHandle
-{
- struct MMFileIOFunc *iofunc;
- int flags; /* file flags */
- void *privateData;
- char *fileName;
-} MMFileIOHandle;
-
typedef struct MMFileIOFunc
{
const char *handleName;
/* MP3 Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidMP3 (const char *mmfileuri, int frameCnt)
+int MMFileFormatIsValidMP3 (MMFileIOHandle *pFileIO, const char *mmfileuri, int frameCnt)
{
#define _MMFILE_MP3_HEADER_LENGTH 4
#define _MMFILE_MP3_BUFFER_LENGTH 8200
- MMFileIOHandle *fp = NULL;
- unsigned char *buffer=NULL;
+ MMFileIOHandle *fp = pFileIO;
+ unsigned char buffer[_MMFILE_MP3_BUFFER_LENGTH] = {0,};
long long filesize = 0;
unsigned int sizeID3 = 0;
int readed = 0;
unsigned int i = 0, j = 0;
int ret = 0,frameSize,count,offset;
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if(ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if(ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
+
mmfile_seek (fp, 0L, MMFILE_SEEK_END);
filesize = mmfile_tell (fp);
mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
endoffset = startoffset + 102400;
if(endoffset > filesize - _MMFILE_MP3_HEADER_LENGTH)
endoffset = filesize - _MMFILE_MP3_HEADER_LENGTH;
-
+
/* find sync bit */
i = startoffset;
count = 0;
-
- buffer = mmfile_malloc (_MMFILE_MP3_BUFFER_LENGTH * sizeof(char));
-
- if (NULL == buffer) {
- debug_error("Error in allocating memory for MP3 buffer\n");
- goto exit;
- }
while (i < endoffset) {
mmfile_seek (fp, i, MMFILE_SEEK_SET);
debug_msg ( "Header Not Detected at: %d\n",i+j);
#endif
exit:
-
- if(buffer) {
- mmfile_free (buffer);
- }
-
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* AAC Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidAAC (const char *mmfileuri)
+int MMFileFormatIsValidAAC (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_AAC_HEADER_LENGTH 4
#define _MMFILE_AAC_BUFFER_LENGTH 8200
- MMFileIOHandle *fp = NULL;
- unsigned char *buffer=NULL;
+ MMFileIOHandle *fp = pFileIO;
+ unsigned char buffer[_MMFILE_AAC_BUFFER_LENGTH] = {0,};
unsigned int sizeID3 = 0;
long long filesize = 0;
int readed = 0;
int ret = 0;
unsigned int sync,frameSize;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
/* Initialize the members of handle */
mmfile_seek (fp, 0, MMFILE_SEEK_END);
endoffset = startoffset + 10240;
if(endoffset > filesize - _MMFILE_AAC_HEADER_LENGTH)
endoffset = filesize - _MMFILE_AAC_HEADER_LENGTH;
-
- buffer = mmfile_malloc (_MMFILE_AAC_BUFFER_LENGTH * sizeof(char));
- if (NULL == buffer) {
- debug_error("Error in allocating memory for AAC buffer\n");
- goto exit;
- }
-
i = startoffset;
while (i < endoffset) {
mmfile_seek (fp, i, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_AAC_BUFFER_LENGTH);
-
+
if (readed < _MMFILE_AAC_HEADER_LENGTH) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
#endif
exit:
- if (buffer) {
- mmfile_free (buffer);
- }
-
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* OGG Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidOGG (const char *mmfileuri)
+int MMFileFormatIsValidOGG (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_OGG_HEADER_LENGTH 4
#define _MMFILE_OGG_BUFFER_LENGTH 512
#define _MMFILE_OGG_CHECK_LIMIT (_MMFILE_OGG_HEADER_LENGTH * 1000)
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_OGG_BUFFER_LENGTH] = {0,};
unsigned int sizeID3 = 0;
long long filesize = 0;
int ret = 0;
unsigned int check_limit = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- ret = 0;
- return ret;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ ret = 0;
+ goto exit;
+ }
}
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- ret = 0;
- goto exit;
- }
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
/* Initialize the members of handle */
mmfile_seek (fp, 0, MMFILE_SEEK_END);
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* MIDI Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidMID (const char *mmfileuri)
+int MMFileFormatIsValidMID (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_MIDI_HEADER_LENGTH 4
#define _MMFILE_MIDI_BUFFER_LENGTH 512
#define _MMFILE_MIDI_CHECK_LIMIT (_MMFILE_MIDI_HEADER_LENGTH * 1024)
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_MIDI_BUFFER_LENGTH] = {0,};
long long filesize = 0;
int readed = 0;
int ret = 0;
unsigned int check_limit = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
/* Initialize the members of handle */
mmfile_seek (fp, 0, MMFILE_SEEK_END);
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* WAV Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidWAV (const char *mmfileuri)
+int MMFileFormatIsValidWAV (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_WAV_HEADER_LENGTH 15
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_WAV_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_WAV_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
-
- /* set begin and end point at the file */
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_WAV_HEADER_LENGTH);
if (_MMFILE_WAV_HEADER_LENGTH != readed) {
goto exit;
}
-
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* MP4 Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidMP4 (const char *mmfileuri)
+int MMFileFormatIsValidMP4 (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_MP4_HEADER_LENGTH 4
#define _MMFILE_MP4_CHECK_LIMIT (1024*10) /*10Kbyte*/
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_MP4_HEADER_LENGTH] = {0,};
long long filesize = 0;
int readed = 0;
int ret = 0;
unsigned int check_limit = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
/* Initialize the members of handle */
mmfile_seek (fp, 0, MMFILE_SEEK_END);
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* AVI Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidAVI (const char *mmfileuri)
+int MMFileFormatIsValidAVI (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_AVI_HEADER_LENGTH 12
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_AVI_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_AVI_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_AVI_HEADER_LENGTH);
+
if (_MMFILE_AVI_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* ASF Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidASF (const char *mmfileuri)
+int MMFileFormatIsValidASF (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_ASF_HEADER_LENGTH 16
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_ASF_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_ASF_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_ASF_HEADER_LENGTH);
+
if (_MMFILE_ASF_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* WMA Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidWMA (const char *mmfileuri)
+int MMFileFormatIsValidWMA (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_ASF_HEADER_LENGTH 16
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_ASF_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_ASF_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_ASF_HEADER_LENGTH);
+
if (_MMFILE_ASF_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* WMV Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidWMV (const char *mmfileuri)
+int MMFileFormatIsValidWMV (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_ASF_HEADER_LENGTH 16
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_ASF_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_ASF_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_ASF_HEADER_LENGTH);
+
if (_MMFILE_ASF_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* MMF Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidMMF (const char *mmfileuri)
+int MMFileFormatIsValidMMF (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_MMF_HEADER_LENGTH 18
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_MMF_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_MMF_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_MMF_HEADER_LENGTH);
+
if (_MMFILE_MMF_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* MMF Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidIMY (const char *mmfileuri)
+int MMFileFormatIsValidIMY (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_IMY_HEADER_LENGTH 13
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_IMY_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_IMY_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_IMY_HEADER_LENGTH);
+
if (_MMFILE_IMY_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* AMR Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidAMR (const char *mmfileuri)
+int MMFileFormatIsValidAMR (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_AMR_MAX_HEADER_SIZE 15
#define _MMFILE_AMR_MIN_HEADER_SIZE 6
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_AMR_MAX_HEADER_SIZE] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_AMR_MAX_HEADER_SIZE) {
- debug_error ("header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_AMR_MAX_HEADER_SIZE);
+
if (_MMFILE_AMR_MAX_HEADER_SIZE != readed) {
debug_error ("read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
}
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/***********************************************************************/
/* Matroska Header Check API */
/***********************************************************************/
-
EXPORT_API
-int MMFileFormatIsValidMatroska (const char *mmfileuri)
+int MMFileFormatIsValidMatroska (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_EBML_MARKER_LENGTH 4
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char* buffer = NULL;
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
-
int len_mask = 0x80, size = 1, n = 1, total = 0;
char probe_data[] = { 'm', 'a', 't', 'r', 'o', 's', 'k', 'a' };
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- debug_msg ( "[%s][%d]\n", __func__, __LINE__);
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- ret = 0;
-
- /* set begin and end point at the file */
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
buffer = mmfile_malloc (_MMFILE_EBML_MARKER_LENGTH * sizeof(char));
readed = mmfile_read (fp, buffer, _MMFILE_EBML_MARKER_LENGTH);
mmfile_free (buffer);
}
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
return ret;
}
/* QT Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidQT (const char *mmfileuri)
+int MMFileFormatIsValidQT (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
return 1;
}
/* Flac Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidFLAC (const char *mmfileuri)
+int MMFileFormatIsValidFLAC (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_FLAC_HEADER_LENGTH 5 /*fLaC*/
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_FLAC_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_FLAC_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
-
- /* set begin and end point at the file */
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_FLAC_HEADER_LENGTH);
+
if (_MMFILE_FLAC_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
goto exit;
}
-
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
-return ret;
+ return ret;
}
/***********************************************************************/
/* FLV(flash video) Header Check API */
/***********************************************************************/
EXPORT_API
-int MMFileFormatIsValidFLV (const char *mmfileuri)
+int MMFileFormatIsValidFLV (MMFileIOHandle *pFileIO, const char *mmfileuri)
{
#define _MMFILE_FLV_HEADER_LENGTH 4 /*FLV*/
- MMFileIOHandle *fp = NULL;
+ MMFileIOHandle *fp = pFileIO;
unsigned char buffer[_MMFILE_FLV_HEADER_LENGTH] = {0,};
- long long filesize = 0;
int readed = 0;
- unsigned int startoffset = 0;
int ret = 0;
- if (NULL == mmfileuri) {
- debug_error ("file source is NULL\n");
- return ret;
- }
-
- ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
- if (ret == MMFILE_UTIL_FAIL) {
- debug_error ("error: mmfile_open\n");
- goto exit;
- }
-
- /* Initialize the members of handle */
- mmfile_seek (fp, 0, MMFILE_SEEK_END);
- filesize = mmfile_tell(fp);
- mmfile_seek (fp, 0, MMFILE_SEEK_SET);
-
- if (filesize < _MMFILE_FLV_HEADER_LENGTH) {
- debug_error ( "header is too small.\n");
- ret = 0;
- goto exit;
+ if(fp == NULL) {
+ ret = mmfile_open (&fp, mmfileuri, MMFILE_RDONLY);
+ if (ret == MMFILE_IO_FAILED) {
+ debug_error ("error: mmfile_open\n");
+ goto exit;
+ }
}
- ret = 0;
-
- /* set begin and end point at the file */
- startoffset = 0;
-
- mmfile_seek (fp, startoffset, MMFILE_SEEK_SET);
+ mmfile_seek (fp, 0L, MMFILE_SEEK_SET);
readed = mmfile_read (fp, buffer, _MMFILE_FLV_HEADER_LENGTH);
+
if (_MMFILE_FLV_HEADER_LENGTH != readed) {
debug_error ( "read error. size = %d. Maybe end of file.\n", readed);
ret = 0;
goto exit;
}
-
exit:
- if (fp) {
- mmfile_close (fp);
- }
+ if(pFileIO == NULL && fp != NULL)
+ mmfile_close(fp);
-return ret;
+ return ret;
}
+
/***********************************************************************/
/* Implementation of Internal Functions */
/***********************************************************************/
static int _MMFileIsASFHeader (void *header)
{
- /* ID: 30 26 B2 75 8E 66 CF 11 A6 D9 00 AA 00 62 CE 6C */
+ /* ID: 30 26 B2 75 8E 66 CF 11 A6 D9 00 AA 00 62 CE 6C */
unsigned char *s = header;
if ( (*(s + 0) == 0x30) &&