From 3a797526b01b5d7c2bdb6d5391038c2040a0baf9 Mon Sep 17 00:00:00 2001 From: hj kim Date: Tue, 4 Feb 2020 18:10:17 +0900 Subject: [PATCH] define enum for ID3tag to make codes simple Change-Id: If2ebbfd36565d8878ad0f11da1e18742db4373d6 --- formats/ffmpeg/mm_file_format_aac.c | 26 +- formats/ffmpeg/mm_file_format_mp3.c | 71 +++-- packaging/libmm-fileinfo.spec | 2 +- utils/include/mm_file_utils.h | 148 +++------- utils/mm_file_util_tag.c | 573 +++++++++++++++++------------------- 5 files changed, 361 insertions(+), 459 deletions(-) diff --git a/formats/ffmpeg/mm_file_format_aac.c b/formats/ffmpeg/mm_file_format_aac.c index c2dd2c5..aabd77d 100644 --- a/formats/ffmpeg/mm_file_format_aac.c +++ b/formats/ffmpeg/mm_file_format_aac.c @@ -244,19 +244,19 @@ int _parse_id3_tag(tMMFILE_AAC_HANDLE *pData) mm_file_id3tag_restore_content_info(hTag); - pData->tagInfo.title = hTag->pTitle; - pData->tagInfo.artist = hTag->pArtist; - pData->tagInfo.album = hTag->pAlbum; - pData->tagInfo.album_artist = hTag->pAlbum_Artist; - pData->tagInfo.year = hTag->pYear; - pData->tagInfo.copyright = hTag->pCopyright; - pData->tagInfo.comment = hTag->pComment; - pData->tagInfo.genre = hTag->pGenre; - pData->tagInfo.tracknum = hTag->pTrackNum; - pData->tagInfo.composer = hTag->pComposer; - pData->tagInfo.classification = hTag->pContentGroup; - pData->tagInfo.recordDate = hTag->pRecDate; - pData->tagInfo.conductor = hTag->pConductor; + pData->tagInfo.title = hTag->tagInfo[AV_ID3TAG_TITLE].value; + pData->tagInfo.artist = hTag->tagInfo[AV_ID3TAG_ARTIST].value; + pData->tagInfo.album = hTag->tagInfo[AV_ID3TAG_ALBUM].value; + pData->tagInfo.album_artist = hTag->tagInfo[AV_ID3TAG_ALBUM_ARTIST].value; + pData->tagInfo.year = hTag->tagInfo[AV_ID3TAG_YEAR].value; + pData->tagInfo.copyright = hTag->tagInfo[AV_ID3TAG_COPYRIGHT].value; + pData->tagInfo.comment = hTag->tagInfo[AV_ID3TAG_COMMENT].value; + pData->tagInfo.genre = hTag->tagInfo[AV_ID3TAG_GENRE].value; + pData->tagInfo.tracknum = hTag->tagInfo[AV_ID3TAG_TRACKNUM].value; + pData->tagInfo.composer = hTag->tagInfo[AV_ID3TAG_COMPOSER].value; + pData->tagInfo.classification = hTag->tagInfo[AV_ID3TAG_CONTENT_GROUP].value; + pData->tagInfo.recordDate = hTag->tagInfo[AV_ID3TAG_RECDATE].value; + pData->tagInfo.conductor = hTag->tagInfo[AV_ID3TAG_CONDUCTOR].value; pData->tagInfo.artworkMime = hTag->imageInfo.imageMIMEType; pData->tagInfo.artworkSize = hTag->imageInfo.imageLen; pData->tagInfo.artwork = hTag->imageInfo.pImageBuf; diff --git a/formats/ffmpeg/mm_file_format_mp3.c b/formats/ffmpeg/mm_file_format_mp3.c index db1408b..7d2dc4e 100644 --- a/formats/ffmpeg/mm_file_format_mp3.c +++ b/formats/ffmpeg/mm_file_format_mp3.c @@ -192,23 +192,23 @@ int mmfile_format_read_tag_mp3(MMFileFormatContext *formatContext) privateData = formatContext->privateFormatData; - formatContext->title = mmfile_strdup(privateData->pTitle); - formatContext->artist = mmfile_strdup(privateData->pArtist); - formatContext->copyright = mmfile_strdup(privateData->pCopyright); - formatContext->comment = mmfile_strdup(privateData->pComment); - formatContext->album = mmfile_strdup(privateData->pAlbum); - formatContext->album_artist = mmfile_strdup(privateData->pAlbum_Artist); - formatContext->year = mmfile_strdup(privateData->pYear); - formatContext->genre = mmfile_strdup(privateData->pGenre); - formatContext->tagTrackNum = mmfile_strdup(privateData->pTrackNum); - formatContext->composer = mmfile_strdup(privateData->pComposer); - formatContext->classification = mmfile_strdup(privateData->pContentGroup); - formatContext->conductor = mmfile_strdup(privateData->pConductor); - formatContext->unsyncLyrics = mmfile_strdup(privateData->pUnsyncLyrics); + formatContext->title = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_TITLE].value); + formatContext->artist = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_ARTIST].value); + formatContext->copyright = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_COPYRIGHT].value); + formatContext->comment = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_COMMENT].value); + formatContext->album = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_ALBUM].value); + formatContext->album_artist = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_ALBUM_ARTIST].value); + formatContext->year = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_YEAR].value); + formatContext->genre = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_GENRE].value); + formatContext->tagTrackNum = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_TRACKNUM].value); + formatContext->composer = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_COMPOSER].value); + formatContext->classification = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_CONTENT_GROUP].value); + formatContext->conductor = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_CONDUCTOR].value); + formatContext->unsyncLyrics = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_UNSYNCLYRICS].value); formatContext->syncLyrics = privateData->pSyncLyrics; - formatContext->syncLyricsNum = privateData->syncLyricsNum; - formatContext->recDate = mmfile_strdup(privateData->pRecDate); - formatContext->part_of_set = mmfile_strdup(privateData->pPartOfASet); + formatContext->syncLyricsNum = privateData->tagInfo[AV_ID3TAG_SYNCLYRICS].length; + formatContext->recDate = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_RECDATE].value); + formatContext->part_of_set = mmfile_strdup(privateData->tagInfo[AV_ID3TAG_PART_OF_SET].value); if (privateData->imageInfo.imageLen > 0) { formatContext->artwork = mmfile_malloc(privateData->imageInfo.imageLen); @@ -1108,28 +1108,25 @@ static int mmf_file_mp3_get_tag_info(char *filename, AvFileContentInfo *pInfo) mmfile_close(hFile); /*debug print*/ - debug_msg(RELEASE, "**** Info #1 ****\n"); - debug_msg(RELEASE, "Title : %s\n", pInfo->pTitle); - debug_msg(RELEASE, "Artist : %s\n", pInfo->pArtist); - debug_msg(RELEASE, "Album : %s\n", pInfo->pAlbum); - debug_msg(RELEASE, "Album_Artist: %s\n", pInfo->pAlbum_Artist); - debug_msg(RELEASE, "Year : %s\n", pInfo->pYear); - debug_msg(RELEASE, "Comment : %s\n", pInfo->pComment); - debug_msg(RELEASE, "TrackNum : %s\n", pInfo->pTrackNum); - debug_msg(RELEASE, "Genre : %s\n", pInfo->pGenre); - debug_msg(RELEASE, "**** Info #2 ****\n"); - debug_msg(RELEASE, "Copyright : %s\n", pInfo->pCopyright); - debug_msg(RELEASE, "Comment : %s\n", pInfo->pComment); - debug_msg(RELEASE, "RecDate : %s\n", pInfo->pRecDate); - debug_msg(RELEASE, "PartOfASet : %s\n", pInfo->pPartOfASet); - debug_msg(RELEASE, "Encoded by : %s\n", pInfo->pEncBy); - debug_msg(RELEASE, "URL : %s\n", pInfo->pURL); - debug_msg(RELEASE, "Ori. Artist : %s\n", pInfo->pOriginArtist); - debug_msg(RELEASE, "Composer : %s\n", pInfo->pComposer); - debug_msg(RELEASE, "Conductor : %s\n", pInfo->pConductor); + debug_msg(RELEASE, "Title : %s\n", pInfo->tagInfo[AV_ID3TAG_TITLE].value); + debug_msg(RELEASE, "Artist : %s\n", pInfo->tagInfo[AV_ID3TAG_ARTIST].value); + debug_msg(RELEASE, "Album : %s\n", pInfo->tagInfo[AV_ID3TAG_ALBUM].value); + debug_msg(RELEASE, "Album_Artist: %s\n", pInfo->tagInfo[AV_ID3TAG_ALBUM_ARTIST].value); + debug_msg(RELEASE, "Year : %s\n", pInfo->tagInfo[AV_ID3TAG_YEAR].value); + debug_msg(RELEASE, "Comment : %s\n", pInfo->tagInfo[AV_ID3TAG_COMMENT].value); + debug_msg(RELEASE, "TrackNum : %s\n", pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value); + debug_msg(RELEASE, "Genre : %s\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value); + debug_msg(RELEASE, "Copyright : %s\n", pInfo->tagInfo[AV_ID3TAG_COPYRIGHT].value); + debug_msg(RELEASE, "RecDate : %s\n", pInfo->tagInfo[AV_ID3TAG_RECDATE].value); + debug_msg(RELEASE, "PartOfASet : %s\n", pInfo->tagInfo[AV_ID3TAG_PART_OF_SET].value); + debug_msg(RELEASE, "Encoded by : %s\n", pInfo->tagInfo[AV_ID3TAG_ENCBY].value); + debug_msg(RELEASE, "URL : %s\n", pInfo->tagInfo[AV_ID3TAG_URL].value); + debug_msg(RELEASE, "Ori. Artist : %s\n", pInfo->tagInfo[AV_ID3TAG_ORIGIN_ARTIST].value); + debug_msg(RELEASE, "Composer : %s\n", pInfo->tagInfo[AV_ID3TAG_COMPOSER].value); + debug_msg(RELEASE, "Conductor : %s\n", pInfo->tagInfo[AV_ID3TAG_CONDUCTOR].value); debug_msg(RELEASE, "Artwork : mime(%s) addr(%p) size(%d)\n", pInfo->imageInfo.imageMIMEType, pInfo->imageInfo.pImageBuf, pInfo->imageInfo.imageLen); - debug_msg(RELEASE, "UnsyncLyrics : %s\n", pInfo->pUnsyncLyrics); - debug_msg(RELEASE, "SyncLyrics size : %d\n", pInfo->syncLyricsNum); + debug_msg(RELEASE, "UnsyncLyrics : %s\n", pInfo->tagInfo[AV_ID3TAG_UNSYNCLYRICS].value); + debug_msg(RELEASE, "SyncLyrics size : %d\n", pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length); return 0; diff --git a/packaging/libmm-fileinfo.spec b/packaging/libmm-fileinfo.spec index b54a9fd..1eef915 100644 --- a/packaging/libmm-fileinfo.spec +++ b/packaging/libmm-fileinfo.spec @@ -1,6 +1,6 @@ Name: libmm-fileinfo Summary: Media Fileinfo -Version: 0.6.85 +Version: 0.6.86 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/utils/include/mm_file_utils.h b/utils/include/mm_file_utils.h index 364d080..5fb6f43 100755 --- a/utils/include/mm_file_utils.h +++ b/utils/include/mm_file_utils.h @@ -361,62 +361,42 @@ typedef struct { } AvTagVer2ImageInfo; +typedef enum { + AV_ID3TAG_TITLE = 0, /*Title/songname/ */ + AV_ID3TAG_ARTIST, /*Lead performer(s)/Soloist(s), */ + AV_ID3TAG_ALBUM, + AV_ID3TAG_GENRE, + AV_ID3TAG_TRACKNUM, /*Track number/Position in set */ + AV_ID3TAG_COMPOSER, + AV_ID3TAG_COPYRIGHT, + AV_ID3TAG_ALBUM_ARTIST, + AV_ID3TAG_CONDUCTOR, /*[#TPE3 Conductor/performer refinement], ADDED: 2010-01-xx*/ + AV_ID3TAG_YEAR, + AV_ID3TAG_COMMENT, + AV_ID3TAG_ENCBY, /*Encoded by */ + AV_ID3TAG_URL, /*User defined URL link frame for ID3V2 Tag */ + AV_ID3TAG_ORIGIN_ARTIST, /*Original artist(s)/performer(s) */ + AV_ID3TAG_RECDATE, /*Recording dates */ + AV_ID3TAG_PART_OF_SET, + AV_ID3TAG_UNSYNCLYRICS, /*Unsychronised lyrics/text transcription */ + AV_ID3TAG_CONTENT_GROUP, /* for PC Studio Podcast */ + AV_ID3TAG_PICTURE, + AV_ID3TAG_SYNCLYRICS, /*Sychronised lyrics/text */ + AV_ID3TAG_MAX, +} AvID3TagList; + typedef struct { int tagLen; char tagVersion; - - bool bTitleMarked; - bool bArtistMarked; - bool bAlbumMarked; - bool bAlbum_ArtistMarked; - bool bYearMarked; - bool bDescriptionMarked; - bool bGenreMarked; - - bool bTrackNumMarked; - bool bEncByMarked; - bool bURLMarked; - bool bCopyRightMarked; - bool bOriginArtistMarked; - bool bComposerMarked; - bool bImageMarked; - bool bRecDateMarked; - bool bPartOfASetMarked; - bool bContentGroupMarked; - bool bUnsyncLyricsMarked; - bool bSyncLyricsMarked; - - bool bConductorMarked; } AvTagVer2AdditionalData; - typedef struct { - int titleLen; - int artistLen; - int authorLen; - int copyrightLen; - int commentLen; - int ratingLen; - int albumLen; - int yearLen; - int genreLen; - int tracknumLen; - int recdateLen; - int partofsetLen; - int conductorLen; - int album_artistLen; - -/* for PC Studio Podcast */ - int contentGroupLen; - -/* for ID3V2 Tag */ - int encbyLen; - int urlLen; - int originartistLen; - int composerLen; - int unsynclyricsLen; - int syncLyricsNum; + int length; + char *value; + bool marked; +} AvID3TagInfo; +typedef struct { /* To send resolution info to appl from OEM */ int width; int height; @@ -442,30 +422,8 @@ typedef struct { bool bPadding; /* Padding? */ bool bV1tagFound; - char *pTitle; /*Title/songname/ */ - char *pArtist; /*Lead performer(s)/Soloist(s), */ - char *pCopyright; - char *pComment; - char *pAlbum; /*Album/Movie/ */ - char *pAlbum_Artist; - char *pYear; - char *pGenre; - char *pTrackNum; /*Track number/Position in set */ - char *pRecDate; /*Recording dates */ - char *pPartOfASet; // Part of a set - - char *pConductor; /*[#TPE3 Conductor/performer refinement], ADDED: 2010-01-xx*/ - -/* for PC Studio Podcast */ - char *pContentGroup; - -/* for ID3V2 Tag */ - char *pEncBy; /*Encoded by */ - char *pURL; /*User defined URL link frame for ID3V2 Tag */ - char *pOriginArtist; /*Original artist(s)/performer(s) */ - char *pComposer; /*Composer */ - char *pUnsyncLyrics; /*Unsychronised lyrics/text transcription */ - GList *pSyncLyrics; /*Sychronised lyrics/text */ + AvID3TagInfo tagInfo[AV_ID3TAG_MAX]; + GList *pSyncLyrics; AvTagVer2ImageInfo imageInfo; /*Album art attached feature */ AvTagVer2AdditionalData tagV2Info; /*Needed data for ID3 tag parsing */ @@ -491,31 +449,19 @@ void mm_file_free_synclyrics_list(GList *synclyrics_list); inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo) { - if (pInfo) { - mmfile_free(pInfo->pToc); - mmfile_free(pInfo->pTitle); - mmfile_free(pInfo->pArtist); - mmfile_free(pInfo->pCopyright); - mmfile_free(pInfo->pComment); - mmfile_free(pInfo->pAlbum); - mmfile_free(pInfo->pAlbum_Artist); - mmfile_free(pInfo->pYear); - mmfile_free(pInfo->pGenre); - mmfile_free(pInfo->pTrackNum); - mmfile_free(pInfo->pRecDate); - mmfile_free(pInfo->pPartOfASet); - mmfile_free(pInfo->pConductor); - mmfile_free(pInfo->pContentGroup); - mmfile_free(pInfo->pEncBy); - mmfile_free(pInfo->pURL); - mmfile_free(pInfo->pOriginArtist); - mmfile_free(pInfo->pComposer); - mmfile_free(pInfo->pUnsyncLyrics); - mmfile_free(pInfo->imageInfo.pImageBuf); - mmfile_free(pInfo->imageInfo.imageDescription); - if (strlen(pInfo->imageInfo.imageMIMEType) > 0) - memset(pInfo->imageInfo.imageMIMEType, 0, MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH); - } + int i = 0; + + if (!pInfo) + return; + + for (i = 0; i < AV_ID3TAG_MAX; i++) + mmfile_free(pInfo->tagInfo[i].value); + + mmfile_free(pInfo->pToc); + mmfile_free(pInfo->imageInfo.pImageBuf); + mmfile_free(pInfo->imageInfo.imageDescription); + if (strlen(pInfo->imageInfo.imageMIMEType) > 0) + memset(pInfo->imageInfo.imageMIMEType, 0, MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH); } @@ -524,9 +470,9 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer); bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer); bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer); void mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo); -int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext); -int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext); -int ParseSpatialVideoMetadataFromXMLString(const char *xmlStr, MMFileFormatContext *formatContext); +int MMFileUtilGetMetaDataFromMKV(MMFileFormatContext *formatContext); +int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext); +int ParseSpatialVideoMetadataFromXMLString(const char *xmlStr, MMFileFormatContext *formatContext); #ifdef __cplusplus diff --git a/utils/mm_file_util_tag.c b/utils/mm_file_util_tag.c index bda00bc..901c8ec 100644 --- a/utils/mm_file_util_tag.c +++ b/utils/mm_file_util_tag.c @@ -240,6 +240,58 @@ static const char * const MpegAudio_Genre[GENRE_COUNT] = {"Blues", "Classic Rock static unsigned char gTagJPEGHeader[] = {0xff, 0xd8, 0xff }; static unsigned char gTagPNGHeader[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a }; +typedef struct _mmfileid3taginfo { + char name[4]; + unsigned int int_name; + AvID3TagList tag; +} MMFILE_ID3TAG_INFO; + +#define ID3TAG_NUM_V22 16 +#define ID3TAG_NUM_V23 21 + +MMFILE_ID3TAG_INFO tag_info_v22[ID3TAG_NUM_V22] = { + {"TT2", 21170, AV_ID3TAG_TITLE}, + {"TP1", 21041, AV_ID3TAG_ARTIST}, + {"TP2", 21042, AV_ID3TAG_ALBUM_ARTIST}, + {"TP3", 21043, AV_ID3TAG_CONDUCTOR}, + {"TAL", 20588, AV_ID3TAG_ALBUM}, + {"TYE", 21349, AV_ID3TAG_YEAR}, + {"COM", 3629, AV_ID3TAG_COMMENT}, + {"TCO", 20655, AV_ID3TAG_GENRE}, + {"TRK", 21131, AV_ID3TAG_TRACKNUM}, + {"PIC", 16739, AV_ID3TAG_PICTURE}, + {"TEN", 20718, AV_ID3TAG_ENCBY}, + {"WXX", 24408, AV_ID3TAG_URL}, + {"TCR", 20658, AV_ID3TAG_COPYRIGHT}, + {"TOA", 21025, AV_ID3TAG_ORIGIN_ARTIST}, + {"TCM", 20653, AV_ID3TAG_COMPOSER}, + {"TRD", 21124, AV_ID3TAG_RECDATE}, +}; + +MMFILE_ID3TAG_INFO tag_info_v23[ID3TAG_NUM_V23] = { + {"TIT2", 665266, AV_ID3TAG_TITLE}, + {"TPE1", 671953, AV_ID3TAG_ARTIST}, + {"TPE2", 671954, AV_ID3TAG_ALBUM_ARTIST}, + {"TPE3", 671955, AV_ID3TAG_CONDUCTOR}, + {"TALB", 656834, AV_ID3TAG_ALBUM}, + {"TYER", 681202, AV_ID3TAG_YEAR}, + {"COMM", 114157, AV_ID3TAG_COMMENT}, + {"TCON", 658990, AV_ID3TAG_GENRE}, + {"TRCK", 673963, AV_ID3TAG_TRACKNUM}, + {"APIC", 49507, AV_ID3TAG_PICTURE}, + {"TENC", 660995, AV_ID3TAG_ENCBY}, + {"WXXX", 779096, AV_ID3TAG_URL}, + {"TCOP", 658992, AV_ID3TAG_COPYRIGHT}, + {"TOPE", 671301, AV_ID3TAG_ORIGIN_ARTIST}, + {"TCOM", 658989, AV_ID3TAG_COMPOSER}, + {"TDRA", 660097, AV_ID3TAG_RECDATE}, /*Recdate for 2.3*/ + {"USLT", 708052, AV_ID3TAG_UNSYNCLYRICS}, + {"SYLT", 648660, AV_ID3TAG_SYNCLYRICS}, + {"TPOS", 672307, AV_ID3TAG_PART_OF_SET}, + {"TIT1", 665265, AV_ID3TAG_CONTENT_GROUP}, /*Content Group for 2.4*/ + {"TDRC", 660099, AV_ID3TAG_RECDATE}, /*Recdate for 2.4*/ +}; + static int GetJunkCounterLimit(void); static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOHandle *fp, MMFILE_MP4_BASIC_BOX_HEADER *basic_header, eMMFILE_3GP_TEXT_TAG eTag) @@ -1720,18 +1772,18 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle goto exception; } - formatContext->title = mmfile_strdup((const char *)tagInfo.pTitle); - formatContext->artist = mmfile_strdup((const char *)tagInfo.pArtist); - formatContext->copyright = mmfile_strdup((const char *)tagInfo.pCopyright); - formatContext->comment = mmfile_strdup((const char *)tagInfo.pComment); - formatContext->album = mmfile_strdup((const char *)tagInfo.pAlbum); - formatContext->album_artist = mmfile_strdup((const char *)tagInfo.pAlbum_Artist); - formatContext->year = mmfile_strdup((const char *)tagInfo.pYear); - formatContext->genre = mmfile_strdup((const char *)tagInfo.pGenre); - formatContext->tagTrackNum = mmfile_strdup((const char *)tagInfo.pTrackNum); - formatContext->composer = mmfile_strdup((const char *)tagInfo.pComposer); - formatContext->classification = mmfile_strdup((const char *)tagInfo.pContentGroup); - formatContext->conductor = mmfile_strdup((const char *)tagInfo.pConductor); + formatContext->title = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_TITLE].value); + formatContext->artist = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_ARTIST].value); + formatContext->copyright = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_COPYRIGHT].value); + formatContext->comment = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_COMMENT].value); + formatContext->album = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_ALBUM].value); + formatContext->album_artist = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_ALBUM_ARTIST].value); + formatContext->year = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_YEAR].value); + formatContext->genre = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_GENRE].value); + formatContext->tagTrackNum = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_TRACKNUM].value); + formatContext->composer = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_COMPOSER].value); + formatContext->classification = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_CONTENT_GROUP].value); + formatContext->conductor = mmfile_strdup((const char *)tagInfo.tagInfo[AV_ID3TAG_CONDUCTOR].value); formatContext->artwork = mmfile_malloc(tagInfo.imageInfo.imageLen); if ((tagInfo.imageInfo.imageLen > 0) && formatContext->artwork) { @@ -2497,27 +2549,13 @@ static bool release_characterset_array(char **charset_array) static void init_content_info(AvFileContentInfo *pInfo) { - pInfo->tagV2Info.bTitleMarked = false; - pInfo->tagV2Info.bArtistMarked = false; - pInfo->tagV2Info.bAlbumMarked = false; - pInfo->tagV2Info.bAlbum_ArtistMarked = false; - pInfo->tagV2Info.bYearMarked = false; - pInfo->tagV2Info.bDescriptionMarked = false; - pInfo->tagV2Info.bGenreMarked = false; - pInfo->tagV2Info.bTrackNumMarked = false; - pInfo->tagV2Info.bEncByMarked = false; - pInfo->tagV2Info.bURLMarked = false; - pInfo->tagV2Info.bCopyRightMarked = false; - pInfo->tagV2Info.bOriginArtistMarked = false; - pInfo->tagV2Info.bComposerMarked = false; - pInfo->tagV2Info.bImageMarked = false; - - pInfo->tagV2Info.bRecDateMarked = false; - pInfo->tagV2Info.bContentGroupMarked = false; - - pInfo->tagV2Info.bUnsyncLyricsMarked = false; - pInfo->tagV2Info.bSyncLyricsMarked = false; - pInfo->tagV2Info.bConductorMarked = false; + int i=0; + + for(i = 0; i < AV_ID3TAG_MAX; i++) { + pInfo->tagInfo[i].length = 0; + pInfo->tagInfo[i].value = NULL; + pInfo->tagInfo[i].marked = false; + } pInfo->imageInfo.bURLInfo = false; pInfo->imageInfo.pImageBuf = NULL; @@ -2647,7 +2685,7 @@ static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal if (nTagLen < MMFILE_SYNC_LYRIC_INFO_MIN_LEN) { debug_msg(RELEASE, "failed to get Synchronised lyrics Info realCpyFramNum(%d)\n", nTagLen); - pInfo->syncLyricsNum = 0; + pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length = 0; return; } @@ -2683,7 +2721,7 @@ static void __id3tag_parse_SYLT(AvFileContentInfo *pInfo, unsigned char *pTagVal } pInfo->pSyncLyrics = synclyrics_info_list; - pInfo->syncLyricsNum = g_list_length(pInfo->pSyncLyrics); + pInfo->tagInfo[AV_ID3TAG_SYNCLYRICS].length = g_list_length(pInfo->pSyncLyrics); } static bool __id3tag_parse_PIC_format(AvFileContentInfo *pInfo, unsigned char *pTagVal, int *offset) @@ -2847,21 +2885,25 @@ static void __id3tag_parse_APIC_picture(AvFileContentInfo *pInfo, unsigned char pInfo->imageInfo.bURLInfo = true; } -static void _mm_file_id3tag_parse_PIC(AvFileContentInfo *pInfo, unsigned char *pTagVal, int nTagLen, const char *pCharSet) +static bool _mm_file_id3tag_parse_PIC(AvFileContentInfo *pInfo, unsigned char *pTagVal, int nTagLen, const char *pCharSet) { /* current position to read pTagVal */ int offset = 0; debug_fenter(RELEASE); - if (!__id3tag_parse_PIC_format(pInfo, pTagVal, &offset)) + if (!__id3tag_parse_PIC_format(pInfo, pTagVal, &offset)) { debug_msg(RELEASE, "PIC is not valid\n"); + return false; + } __id3tag_parse_APIC_pictype(pInfo, pTagVal, &offset); __id3tag_parse_APIC_desc(pInfo, pTagVal, nTagLen, pCharSet, &offset); __id3tag_parse_APIC_picture(pInfo, pTagVal, nTagLen, &offset); debug_fleave(RELEASE); + + return true; } static bool _mm_file_id3tag_parse_APIC(AvFileContentInfo *pInfo, unsigned char *pTagVal, int nTagLen, const char *pCharSet) @@ -2892,70 +2934,70 @@ bool mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo, unsigned char *buffer) debug_msg(RELEASE, "ID3tag v110--------------------------------------------------------------\n"); - if (pInfo->tagV2Info.bTitleMarked == false) { - pFullStr = mmfile_string_convert((const char *)&buffer[3], MP3_ID3_TITLE_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->titleLen); + if (pInfo->tagInfo[AV_ID3TAG_TITLE].marked == false) { + pFullStr = mmfile_string_convert((const char *)&buffer[3], MP3_ID3_TITLE_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_TITLE].length); if (pFullStr != NULL) { - pInfo->pTitle = rtrimN(pFullStr); + pInfo->tagInfo[AV_ID3TAG_TITLE].value = rtrimN(pFullStr); free(pFullStr); } - debug_msg(RELEASE, "pInfo->pTitle returned =(%s), pInfo->titleLen(%d)\n", pInfo->pTitle, pInfo->titleLen); + debug_msg(RELEASE, "pInfo->pTitle returned =(%s), pInfo->titleLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_TITLE].value, pInfo->tagInfo[AV_ID3TAG_TITLE].length); } - if (pInfo->tagV2Info.bArtistMarked == false) { - pFullStr = mmfile_string_convert((const char *)&buffer[33], MP3_ID3_ARTIST_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->artistLen); + if (pInfo->tagInfo[AV_ID3TAG_ARTIST].marked == false) { + pFullStr = mmfile_string_convert((const char *)&buffer[33], MP3_ID3_ARTIST_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_ARTIST].length); if (pFullStr != NULL) { - pInfo->pArtist = rtrimN(pFullStr); + pInfo->tagInfo[AV_ID3TAG_ARTIST].value = rtrimN(pFullStr); free(pFullStr); } - debug_msg(RELEASE, "pInfo->pArtist returned =(%s), pInfo->artistLen(%d)\n", pInfo->pArtist, pInfo->artistLen); + debug_msg(RELEASE, "pInfo->pArtist returned =(%s), pInfo->artistLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_ARTIST].value, pInfo->tagInfo[AV_ID3TAG_ARTIST].length); } - if (pInfo->tagV2Info.bAlbumMarked == false) { - pFullStr = mmfile_string_convert((const char *)&buffer[63], MP3_ID3_ALBUM_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->albumLen); + if (pInfo->tagInfo[AV_ID3TAG_ALBUM].marked == false) { + pFullStr = mmfile_string_convert((const char *)&buffer[63], MP3_ID3_ALBUM_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_ALBUM].length); if (pFullStr != NULL) { - pInfo->pAlbum = rtrimN(pFullStr); + pInfo->tagInfo[AV_ID3TAG_ALBUM].value = rtrimN(pFullStr); free(pFullStr); } - debug_msg(RELEASE, "pInfo->pAlbum returned =(%s), pInfo->albumLen(%d)\n", pInfo->pAlbum, pInfo->albumLen); + debug_msg(RELEASE, "pInfo->pAlbum returned =(%s), pInfo->albumLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_ALBUM].value, pInfo->tagInfo[AV_ID3TAG_ALBUM].length); } - if (pInfo->tagV2Info.bYearMarked == false) { + if (pInfo->tagInfo[AV_ID3TAG_YEAR].marked == false) { - pInfo->pYear = mmfile_string_convert((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->yearLen); + pInfo->tagInfo[AV_ID3TAG_YEAR].value = mmfile_string_convert((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_YEAR].length); - debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->pYear, pInfo->yearLen); + debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_YEAR].value, pInfo->tagInfo[AV_ID3TAG_YEAR].length); - if (pInfo->pYear == NULL) { /*Use same logic with ffmpeg*/ - pInfo->pYear = get_string((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, (int *)&pInfo->yearLen); - debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->pYear, pInfo->yearLen); + if (pInfo->tagInfo[AV_ID3TAG_YEAR].value == NULL) { /*Use same logic with ffmpeg*/ + pInfo->tagInfo[AV_ID3TAG_YEAR].value = get_string((const char *)&buffer[93], MP3_ID3_YEAR_LENGTH, (int *)&pInfo->tagInfo[AV_ID3TAG_YEAR].length); + debug_msg(RELEASE, "pInfo->pYear returned =(%s), pInfo->yearLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_YEAR].value, pInfo->tagInfo[AV_ID3TAG_YEAR].length); } } - if (pInfo->tagV2Info.bDescriptionMarked == false) { - pInfo->pComment = mmfile_string_convert((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->commentLen); - debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen); + if (pInfo->tagInfo[AV_ID3TAG_COMMENT].marked == false) { + pInfo->tagInfo[AV_ID3TAG_COMMENT].value = mmfile_string_convert((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, "UTF-8", locale, NULL, (unsigned int *)&pInfo->tagInfo[AV_ID3TAG_COMMENT].length); + debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_COMMENT].value, pInfo->tagInfo[AV_ID3TAG_COMMENT].length); - if (pInfo->pComment == NULL) { /*Use same logic with ffmpeg*/ - pInfo->pComment = get_string((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, (int *)&pInfo->commentLen); - debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen); + if (pInfo->tagInfo[AV_ID3TAG_COMMENT].value == NULL) { /*Use same logic with ffmpeg*/ + pInfo->tagInfo[AV_ID3TAG_COMMENT].value = get_string((const char *)&buffer[97], MP3_ID3_DESCRIPTION_LENGTH, (int *)&pInfo->tagInfo[AV_ID3TAG_COMMENT]); + debug_msg(RELEASE, "pInfo->pComment returned =(%s), pInfo->commentLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_COMMENT].value, pInfo->tagInfo[AV_ID3TAG_COMMENT].length); } } - if (pInfo->tagV2Info.bTrackNumMarked == false) { - pInfo->pTrackNum = mmfile_malloc(ID3TAG_V110_TRACK_NUM_DIGIT); - if (pInfo->pTrackNum != NULL) { - pInfo->pTrackNum[ID3TAG_V110_TRACK_NUM_DIGIT - 1] = 0; - snprintf(pInfo->pTrackNum, ID3TAG_V110_TRACK_NUM_DIGIT, "%04d", (int)buffer[126]); - pInfo->tracknumLen = strlen(pInfo->pTrackNum); + if (pInfo->tagInfo[AV_ID3TAG_TRACKNUM].marked == false) { + pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value = mmfile_malloc(ID3TAG_V110_TRACK_NUM_DIGIT); + if (pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value != NULL) { + pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value[ID3TAG_V110_TRACK_NUM_DIGIT - 1] = 0; + snprintf(pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value, ID3TAG_V110_TRACK_NUM_DIGIT, "%04d", (int)buffer[126]); + pInfo->tagInfo[AV_ID3TAG_TRACKNUM].length = strlen(pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value); - debug_msg(RELEASE, "pInfo->pTrackNum returned =(%s), pInfo->tracknumLen(%d)\n", pInfo->pTrackNum, pInfo->tracknumLen); + debug_msg(RELEASE, "pInfo->pTrackNum returned =(%s), pInfo->tracknumLen(%d)\n", pInfo->tagInfo[AV_ID3TAG_TRACKNUM].value, pInfo->tagInfo[AV_ID3TAG_TRACKNUM].length); } } - if (pInfo->tagV2Info.bGenreMarked == false) { + if (pInfo->tagInfo[AV_ID3TAG_GENRE].marked == false) { pInfo->genre = buffer[127]; debug_msg(RELEASE, "pInfo->genre returned genre number (%d)\n", pInfo->genre); } @@ -2963,6 +3005,50 @@ bool mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo, unsigned char *buffer) return true; } +static AvID3TagList __get_tag_info_v222(const char *tag) +{ + unsigned int n = 0; + int i = 0; + + while (i < 2) { + n += tag[i++] - 'A' + 1; + n <<= 5; + } + n += tag[2]; //num, char mixted + + for (i = 0; i < ID3TAG_NUM_V22; i++) { + if (n == tag_info_v22[i].int_name) { + return tag_info_v22[i].tag; + } + } + + debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!\n", tag); + + return AV_ID3TAG_MAX; +} + +static AvID3TagList __get_tag_info_v223(const char *tag) +{ + unsigned int n = 0; + int i = 0; + + while (i < 3) { + n += tag[i++] - 'A' + 1; + n <<= 5; + } + n += tag[3]; //num, char mixted + + for (i = 0; i < ID3TAG_NUM_V23; i++) { + if (n == tag_info_v23[i].int_name) { + return tag_info_v23[i].tag; + } + } + + debug_msg(RELEASE, "(%s) This Frame ID currently not Supports!!\n", tag); + + return AV_ID3TAG_MAX; +} + EXPORT_API bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) { @@ -2975,10 +3061,9 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) unsigned long purelyFramelen = 0; unsigned int encodingOffSet = 0; int realCpyFrameNum = 0, tmp = 0; - int textEncodingType = 0; - char **charset_array = NULL; + AvID3TagList tag_id = AV_ID3TAG_MAX; make_characterset_array(&charset_array); @@ -3008,7 +3093,8 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) purelyFramelen = oneFrameLen - MP3_TAGv2_22_TXT_HEADER_LEN; curPos += oneFrameLen; - if (purelyFramelen > 0) { + tag_id = __get_tag_info_v222(CompTmp); + if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) { if (buffer[curPos - purelyFramelen] == 0x00) { encodingOffSet = 1; textEncodingType = AV_ID3V2_ISO_8859; @@ -3036,31 +3122,8 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) memcpy(pExtContent, &buffer[curPos - purelyFramelen + encodingOffSet], purelyFramelen - encodingOffSet); if (realCpyFrameNum > 0) { - if (strncmp((char *)CompTmp, "TT2", 3) == 0 && pInfo->tagV2Info.bTitleMarked == false) { - pInfo->pTitle = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->titleLen); - debug_msg(RELEASE, "pInfo->pTitle returned = (%s), pInfo->titleLen(%d)\n", pInfo->pTitle, pInfo->titleLen); - pInfo->tagV2Info.bTitleMarked = true; - } else if (strncmp((char *)CompTmp, "TP1", 3) == 0 && pInfo->tagV2Info.bArtistMarked == false) { - pInfo->pArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->artistLen); - debug_msg(RELEASE, "pInfo->pArtist returned = (%s), pInfo->artistLen(%d)\n", pInfo->pArtist, pInfo->artistLen); - pInfo->tagV2Info.bArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TP2", 3) == 0 && pInfo->tagV2Info.bAlbum_ArtistMarked == false) { - pInfo->pAlbum_Artist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->album_artistLen); - debug_msg(RELEASE, "pInfo->pAlbum_Artist returned = (%s), pInfo->album_artistLen(%d)\n", pInfo->pAlbum_Artist, pInfo->album_artistLen); - pInfo->tagV2Info.bAlbum_ArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TP3", 3) == 0 && pInfo->tagV2Info.bConductorMarked == false) { - pInfo->pConductor = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->conductorLen); - debug_msg(RELEASE, "pInfo->pConductor returned = (%s), pInfo->conductorLen(%d)\n", pInfo->pConductor, pInfo->conductorLen); - pInfo->tagV2Info.bConductorMarked = true; - } else if (strncmp((char *)CompTmp, "TAL", 3) == 0 && pInfo->tagV2Info.bAlbumMarked == false) { - pInfo->pAlbum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->albumLen); - debug_msg(RELEASE, "pInfo->pAlbum returned = (%s), pInfo->albumLen(%d)\n", pInfo->pAlbum, pInfo->albumLen); - pInfo->tagV2Info.bAlbumMarked = true; - } else if (strncmp((char *)CompTmp, "TYE", 3) == 0 && pInfo->tagV2Info.bYearMarked == false) { - pInfo->pYear = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->yearLen); - debug_msg(RELEASE, "pInfo->pYear returned = (%s), pInfo->yearLen(%d)\n", pInfo->pYear, pInfo->yearLen); - pInfo->tagV2Info.bYearMarked = true; - } else if (strncmp((char *)CompTmp, "COM", 3) == 0 && pInfo->tagV2Info.bDescriptionMarked == false) { + switch (tag_id) { + case AV_ID3TAG_COMMENT: /*skip language data! */ if (realCpyFrameNum > 4) { realCpyFrameNum -= 4; @@ -3069,32 +3132,17 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) /*pExtContent[tmp+1] value should't have encoding value */ if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) { textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp); - - pInfo->pComment = mmfile_string_convert((char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen); - debug_msg(RELEASE, "pInfo->pComment returned = (%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen); - pInfo->tagV2Info.bDescriptionMarked = true; + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked = true; } else { debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get Comment Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet); } } else { debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); } - tmp = 0; - - } else if (strncmp((char *)CompTmp, "TCO", 3) == 0 && pInfo->tagV2Info.bGenreMarked == false) { - pInfo->pGenre = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->genreLen); - debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen); - _mm_file_id3tag_add_bracket_at_genre(&pInfo->pGenre, pInfo->genreLen); - pInfo->tagV2Info.bGenreMarked = true; - } else if (strncmp((char *)CompTmp, "TRK", 3) == 0 && pInfo->tagV2Info.bTrackNumMarked == false) { - pInfo->pTrackNum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tracknumLen); - debug_msg(RELEASE, "pInfo->pTrackNum returned = (%s), pInfo->tracknumLen(%d)\n", pInfo->pTrackNum, pInfo->tracknumLen); - pInfo->tagV2Info.bTrackNumMarked = true; - } else if (strncmp((char *)CompTmp, "TEN", 3) == 0 && pInfo->tagV2Info.bEncByMarked == false) { - pInfo->pEncBy = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->encbyLen); - debug_msg(RELEASE, "pInfo->pEncBy returned = (%s), pInfo->encbyLen(%d)\n", pInfo->pEncBy, pInfo->encbyLen); - pInfo->tagV2Info.bEncByMarked = true; - } else if (strncmp((char *)CompTmp, "WXX", 3) == 0 && pInfo->tagV2Info.bURLMarked == false) { + break; + + case AV_ID3TAG_URL: if (realCpyFrameNum > 4) { /*skip language data! */ realCpyFrameNum -= 4; @@ -3104,37 +3152,33 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) if (pExtContent[tmp] > 0x20 && (pExtContent[tmp - 1] == 0x00 || pExtContent[tmp - 1] == 0x01)) { textEncodingType = __id3tag_get_text_encoding_v222(pExtContent, tmp); - pInfo->pURL = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->urlLen); - debug_msg(RELEASE, "pInfo->pURL returned = (%s), pInfo->urlLen(%d)\n", pInfo->pURL, pInfo->urlLen); - pInfo->tagV2Info.bURLMarked = true; + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked = true; } else { debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: failed to get URL Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet); } } else { debug_msg(RELEASE, "mmf_file_id3tag_parse_v222: URL info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); } - tmp = 0; - } else if (strncmp((char *)CompTmp, "TCR", 3) == 0 && pInfo->tagV2Info.bCopyRightMarked == false) { - pInfo->pCopyright = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->copyrightLen); - debug_msg(RELEASE, "pInfo->pCopyright returned = (%s), pInfo->copyrightLen(%d)\n", pInfo->pCopyright, pInfo->copyrightLen); - pInfo->tagV2Info.bCopyRightMarked = true; - } else if (strncmp((char *)CompTmp, "TOA", 3) == 0 && pInfo->tagV2Info.bOriginArtistMarked == false) { - pInfo->pOriginArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->originartistLen); - debug_msg(RELEASE, "pInfo->pOriginArtist returned = (%s), pInfo->originartistLen(%d)\n", pInfo->pOriginArtist, pInfo->originartistLen); - pInfo->tagV2Info.bOriginArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TCM", 3) == 0 && pInfo->tagV2Info.bComposerMarked == false) { - pInfo->pComposer = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->composerLen); - debug_msg(RELEASE, "pInfo->pComposer returned = (%s), pInfo->originartistLen(%d)\n", pInfo->pComposer, pInfo->composerLen); - pInfo->tagV2Info.bComposerMarked = true; - } else if (strncmp((char *)CompTmp, "TRD", 3) == 0 && pInfo->tagV2Info.bRecDateMarked == false) { - pInfo->pRecDate = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->recdateLen); - debug_msg(RELEASE, "pInfo->pRecDate returned = (%s), pInfo->recdateLen(%d)\n", pInfo->pRecDate, pInfo->recdateLen); - pInfo->tagV2Info.bRecDateMarked = true; - } else if (strncmp((char *)CompTmp, "PIC", 3) == 0 && pInfo->tagV2Info.bImageMarked == false && realCpyFrameNum <= 2000000) { - debug_msg(DEBUG, "text encoding %d \n", textEncodingType); - _mm_file_id3tag_parse_PIC(pInfo, pExtContent, realCpyFrameNum, (const char*)charset_array[textEncodingType]); - pInfo->tagV2Info.bImageMarked = true; + break; + + + case AV_ID3TAG_PICTURE: + if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_PIC(pInfo, pExtContent, realCpyFrameNum, (const char*)charset_array[textEncodingType])) + pInfo->tagInfo[tag_id].marked = true; + break; + + default: + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked = true; + + if (tag_id == AV_ID3TAG_GENRE) + _mm_file_id3tag_add_bracket_at_genre(&pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length); + break; } + + if (pInfo->tagInfo[tag_id].value) + debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length); } } @@ -3165,104 +3209,6 @@ bool mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer) } } -static void __parse_tag_info(AvFileContentInfo *pInfo, const char *CompTmp, const char *pExtContent, unsigned int realCpyFrameNum, const char *from_codeset) -{ - if (!pInfo) { - debug_error(DEBUG, "Invalid pInfo"); - return; - } - - if (!CompTmp) { - debug_error(DEBUG, "Invalid tag info"); - return; - } - - if (!from_codeset) { - debug_error(DEBUG, "Invalid from_codeset"); - return; - } - - debug_msg(DEBUG, "text encoding %s \n", from_codeset); - - if (strncmp((char *)CompTmp, "TIT2", 4) == 0 && pInfo->tagV2Info.bTitleMarked == false) { - pInfo->pTitle = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->titleLen); - debug_msg(RELEASE, "pInfo->pTitle returned = (%s), pInfo->titleLen(%d)\n", pInfo->pTitle, pInfo->titleLen); - pInfo->tagV2Info.bTitleMarked = true; - } else if (strncmp((char *)CompTmp, "TPE1", 4) == 0 && pInfo->tagV2Info.bArtistMarked == false) { - pInfo->pArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->artistLen); - debug_msg(RELEASE, "pInfo->pArtist returned = (%s), pInfo->artistLen(%d)\n", pInfo->pArtist, pInfo->artistLen); - pInfo->tagV2Info.bArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TPE2", 4) == 0 && pInfo->tagV2Info.bAlbum_ArtistMarked == false) { - pInfo->pAlbum_Artist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->album_artistLen); - debug_msg(RELEASE, "pInfo->pAlbum_Artist returned = (%s), pInfo->album_artistLen(%d)\n", pInfo->pAlbum_Artist, pInfo->album_artistLen); - pInfo->tagV2Info.bAlbum_ArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TPE3", 4) == 0 && pInfo->tagV2Info.bConductorMarked == false) { - pInfo->pConductor = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->conductorLen); - debug_msg(RELEASE, "pInfo->pConductor returned = (%s), pInfo->conductorLen(%d)\n", pInfo->pConductor, pInfo->conductorLen); - pInfo->tagV2Info.bConductorMarked = true; - } else if (strncmp((char *)CompTmp, "TALB", 4) == 0 && pInfo->tagV2Info.bAlbumMarked == false) { - pInfo->pAlbum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->albumLen); - debug_msg(RELEASE, "pInfo->pAlbum returned = (%s), pInfo->albumLen(%d)\n", pInfo->pAlbum, pInfo->albumLen); - pInfo->tagV2Info.bAlbumMarked = true; - } else if (strncmp((char *)CompTmp, "TYER", 4) == 0 && pInfo->tagV2Info.bYearMarked == false) { - pInfo->pYear = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->yearLen); - debug_msg(RELEASE, "pInfo->pYear returned = (%s), pInfo->yearLen(%d)\n", pInfo->pYear, pInfo->yearLen); - pInfo->tagV2Info.bYearMarked = true; - } else if (strncmp((char *)CompTmp, "TCON", 4) == 0 && pInfo->tagV2Info.bGenreMarked == false) { - pInfo->pGenre = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->genreLen); - debug_msg(RELEASE, "pInfo->pGenre returned = (%s), pInfo->genreLen(%d)\n", pInfo->pGenre, pInfo->genreLen); - _mm_file_id3tag_add_bracket_at_genre(&pInfo->pGenre, pInfo->genreLen); - pInfo->tagV2Info.bGenreMarked = true; - } else if (strncmp((char *)CompTmp, "TRCK", 4) == 0 && pInfo->tagV2Info.bTrackNumMarked == false) { - pInfo->pTrackNum = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->tracknumLen); - debug_msg(RELEASE, "pInfo->pTrackNum returned = (%s), pInfo->tracknumLen(%d)\n", pInfo->pTrackNum, pInfo->tracknumLen); - pInfo->tagV2Info.bTrackNumMarked = true; - } else if (strncmp((char *)CompTmp, "TPOS", 4) == 0 && pInfo->tagV2Info.bPartOfASetMarked == false) { - pInfo->pPartOfASet = mmfile_string_convert((const char*)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int*)&pInfo->partofsetLen); - debug_msg(RELEASE, "pInfo->pPartOfASet returned = (%s), pInfo->partofsetLen(%d)\n", pInfo->pPartOfASet, pInfo->partofsetLen); - pInfo->tagV2Info.bPartOfASetMarked = true; - } else if (strncmp((char *)CompTmp, "TENC", 4) == 0 && pInfo->tagV2Info.bEncByMarked == false) { - pInfo->pEncBy = mmfile_string_convert((char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->encbyLen); - debug_msg(RELEASE, "pInfo->pEncBy returned = (%s), pInfo->encbyLen(%d)\n", pInfo->pEncBy, pInfo->encbyLen); - pInfo->tagV2Info.bEncByMarked = true; - } else if (strncmp((char *)CompTmp, "WXXX", 4) == 0 && pInfo->tagV2Info.bURLMarked == false) { - pInfo->pURL = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->urlLen); - debug_msg(RELEASE, "pInfo->pURL returned = (%s), pInfo->urlLen(%d)\n", pInfo->pURL, pInfo->urlLen); - pInfo->tagV2Info.bURLMarked = true; - } else if (strncmp((char *)CompTmp, "TCOP", 4) == 0 && pInfo->tagV2Info.bCopyRightMarked == false) { - pInfo->pCopyright = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->copyrightLen); - debug_msg(RELEASE, "pInfo->pCopyright returned = (%s), pInfo->copyrightLen(%d)\n", pInfo->pCopyright, pInfo->copyrightLen); - pInfo->tagV2Info.bCopyRightMarked = true; - } else if (strncmp((char *)CompTmp, "TOPE", 4) == 0 && pInfo->tagV2Info.bOriginArtistMarked == false) { - pInfo->pOriginArtist = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->originartistLen); - debug_msg(RELEASE, "pInfo->pOriginArtist returned = (%s), pInfo->originartistLen(%d)\n", pInfo->pOriginArtist, pInfo->originartistLen); - pInfo->tagV2Info.bOriginArtistMarked = true; - } else if (strncmp((char *)CompTmp, "TCOM", 4) == 0 && pInfo->tagV2Info.bComposerMarked == false) { - pInfo->pComposer = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->composerLen); - debug_msg(RELEASE, "pInfo->pComposer returned = (%s), pInfo->composerLen(%d)\n", pInfo->pComposer, pInfo->composerLen); - pInfo->tagV2Info.bComposerMarked = true; - } else if (strncmp((char *)CompTmp, "TRDA", 4) == 0 && pInfo->tagV2Info.bRecDateMarked == false) { - pInfo->pRecDate = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->recdateLen); - debug_msg(RELEASE, "pInfo->pRecDate returned = (%s), pInfo->recdateLen(%d)\n", pInfo->pRecDate, pInfo->recdateLen); - pInfo->tagV2Info.bRecDateMarked = true; - } else if (strncmp((char *)CompTmp, "APIC", 4) == 0 && pInfo->tagV2Info.bImageMarked == false && realCpyFrameNum <= 2000000) { - if (_mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, from_codeset)) - pInfo->tagV2Info.bImageMarked = true; - } - /*TDRC and TIT1 is for 2.4*/ - else if (strncmp((char *)CompTmp, "TDRC", 4) == 0 && pInfo->tagV2Info.bRecDateMarked == false) { /*TYER(year) and TRDA are replaced by the TDRC */ - pInfo->pRecDate = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->recdateLen); - debug_msg(RELEASE, "pInfo->pRecDate returned = (%s), pInfo->recdateLen(%d)\n", pInfo->pRecDate, pInfo->recdateLen); - pInfo->tagV2Info.bRecDateMarked = true; - } else if (strncmp((char *)CompTmp, "TIT1", 4) == 0 && pInfo->tagV2Info.bContentGroupMarked == false) { - pInfo->pContentGroup = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", from_codeset, NULL, (unsigned int *)&pInfo->contentGroupLen); - debug_msg(RELEASE, "pInfo->pContentGroup returned = (%s), pInfo->contentGroupLen(%d)\n", pInfo->pContentGroup, pInfo->contentGroupLen); - pInfo->tagV2Info.bContentGroupMarked = true; - } else { - debug_msg(RELEASE, "CompTmp(%s) This Frame ID currently not Supports!!\n", CompTmp); - } -} - EXPORT_API bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) { @@ -3277,6 +3223,8 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) int realCpyFrameNum = 0, tmp = 0; unsigned int textEncodingType = 0; char **charset_array = NULL; + AvID3TagList tag_id = AV_ID3TAG_MAX; + char *lang_info = NULL; make_characterset_array(&charset_array); @@ -3323,7 +3271,8 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) purelyFramelen = oneFrameLen - MP3_TAGv2_23_TXT_HEADER_LEN; curPos += oneFrameLen; - if (purelyFramelen > 0) { + tag_id = __get_tag_info_v223(CompTmp); + if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) { if (IS_ENCODEDBY_UTF16(buffer + (curPos - purelyFramelen))) { encodingOffSet = 2; debug_msg(RELEASE, "this text string(%s) encoded by UTF16 encodingOffSet(%d)\n", CompTmp, encodingOffSet); @@ -3381,7 +3330,8 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) memcpy(pExtContent, &buffer[curPos - purelyFramelen + encodingOffSet], purelyFramelen - encodingOffSet); if (realCpyFrameNum > 0) { - if (strncmp((char *)CompTmp, "COMM", 4) == 0 && pInfo->tagV2Info.bDescriptionMarked == false) { + switch (tag_id) { + case AV_ID3TAG_COMMENT: if (realCpyFrameNum > 3) { realCpyFrameNum -= 3; tmp = 3; @@ -3391,20 +3341,17 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) textEncodingType = __id3tag_get_text_encoding_v223(pExtContent, &realCpyFrameNum, textEncodingType, &tmp); debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum); - pInfo->pComment = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen); + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "failed to get Comment Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet); - pInfo->commentLen = 0; } } else { debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); - pInfo->commentLen = 0; } - tmp = 0; + break; - debug_msg(RELEASE, "pInfo->pComment returned = (%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen); - pInfo->tagV2Info.bDescriptionMarked = true; - } else if (strncmp((char *)CompTmp, "SYLT", 4) == 0 && pInfo->tagV2Info.bSyncLyricsMarked == false) { + case AV_ID3TAG_SYNCLYRICS: if (realCpyFrameNum > 5) { realCpyFrameNum -= 5; tmp = 5; @@ -3416,21 +3363,17 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum); __id3tag_parse_SYLT(pInfo, pExtContent, realCpyFrameNum, charset_array[textEncodingType], textEncodingType, tmp); + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "failed to get Synchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet); - pInfo->syncLyricsNum = 0; } } else { debug_msg(RELEASE, "Synchronised lyrics too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); - pInfo->syncLyricsNum = 0; } - tmp = 0; + break; - //debug_msg(RELEASE, "pInfo->pSyncLyrics returned = (%s), pInfo->syncLyricsNum(%d)\n", pInfo->pSyncLyrics, pInfo->syncLyricsNum); - debug_msg(RELEASE, "pInfo->syncLyricsNum(%d)\n", pInfo->syncLyricsNum); - pInfo->tagV2Info.bSyncLyricsMarked = true; - } else if (strncmp((char *)CompTmp, "USLT", 4) == 0 && pInfo->tagV2Info.bUnsyncLyricsMarked == false) { - char *lang_info = strndup((char *)pExtContent, 3); + case AV_ID3TAG_UNSYNCLYRICS: + lang_info = strndup((char *)pExtContent, 3); if (realCpyFrameNum > 3) { realCpyFrameNum -= 3; @@ -3470,27 +3413,34 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer) } if (char_set == NULL) { - pInfo->pUnsyncLyrics = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->unsynclyricsLen); + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); } else { - pInfo->pUnsyncLyrics = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", char_set, NULL, (unsigned int *)&pInfo->unsynclyricsLen); + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", char_set, NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); mmfile_free(char_set); } + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "failed to get Unsynchronised lyrics Info tmp(%d), purelyFramelen - encodingOffSet(%lu)\n", tmp, purelyFramelen - encodingOffSet); - pInfo->unsynclyricsLen = 0; } } else { debug_msg(RELEASE, "Unsynchronised lyrics too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); - pInfo->unsynclyricsLen = 0; } - tmp = 0; - - debug_msg(RELEASE, "pInfo->pUnsyncLyrics returned = (%s), pInfo->unsynclyricsLen(%d)\n", pInfo->pUnsyncLyrics, pInfo->unsynclyricsLen); - pInfo->tagV2Info.bUnsyncLyricsMarked = true; mmfile_free(lang_info); - } else { - __parse_tag_info(pInfo, CompTmp, (const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]); + break; + + case AV_ID3TAG_PICTURE: + if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType])) + pInfo->tagInfo[tag_id].marked= true; + break; + + default: + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked= true; + break; } + + if (pInfo->tagInfo[tag_id].value) + debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length); } } else { @@ -3537,6 +3487,7 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) int realCpyFrameNum = 0, tmp = 0; unsigned int textEncodingType = 0; char **charset_array = NULL; + AvID3TagList tag_id = AV_ID3TAG_MAX; make_characterset_array(&charset_array); @@ -3581,7 +3532,8 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) debug_msg(RELEASE, "-----------------------------------------------------------------------------------\n"); - if (purelyFramelen > 0) { + tag_id = __get_tag_info_v223(CompTmp); + if (tag_id != AV_ID3TAG_MAX && !pInfo->tagInfo[tag_id].marked && purelyFramelen > 0) { /*in case of UTF 16 encoding */ /*buffer+(curPos-purelyFramelen) data should '0x01' but in order to expansion, we don't accurately check the value. */ if (IS_ENCODEDBY_UTF16(buffer + (curPos - purelyFramelen))) { @@ -3649,7 +3601,8 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) memcpy(pExtContent, &buffer[curPos - purelyFramelen + encodingOffSet], purelyFramelen - encodingOffSet); if (realCpyFrameNum > 0) { - if (strncmp((char *)CompTmp, "COMM", 4) == 0 && pInfo->tagV2Info.bDescriptionMarked == false) { + switch (tag_id) { + case AV_ID3TAG_COMMENT: if (realCpyFrameNum > 3) { realCpyFrameNum -= 3; tmp = 3; @@ -3657,16 +3610,14 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp); debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum); - pInfo->pComment = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->commentLen); + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); } + break; - tmp = 0; - - debug_msg(RELEASE, "pInfo->pComment returned = (%s), pInfo->commentLen(%d)\n", pInfo->pComment, pInfo->commentLen); - pInfo->tagV2Info.bDescriptionMarked = true; - } else if (strncmp((char *)CompTmp, "SYLT", 4) == 0 && pInfo->tagV2Info.bSyncLyricsMarked == false) { + case AV_ID3TAG_SYNCLYRICS: if (realCpyFrameNum > 5) { realCpyFrameNum -= 5; tmp = 5; @@ -3675,13 +3626,13 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum); __id3tag_parse_SYLT(pInfo, pExtContent, realCpyFrameNum, charset_array[textEncodingType], textEncodingType, tmp); + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "SyncLyrics info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); } + break; - tmp = 0; - pInfo->tagV2Info.bSyncLyricsMarked = true; - } else if (strncmp((char *)CompTmp, "USLT", 4) == 0 && pInfo->tagV2Info.bUnsyncLyricsMarked == false) { + case AV_ID3TAG_UNSYNCLYRICS: if (realCpyFrameNum > 3) { realCpyFrameNum -= 3; tmp = 3; @@ -3689,18 +3640,26 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer) textEncodingType = __id3tag_get_text_encoding_v224(pExtContent, &realCpyFrameNum, textEncodingType, &tmp); debug_msg(RELEASE, "tmp(%d) textEncodingType(%d), realCpyFrameNum(%d)\n", tmp, textEncodingType, realCpyFrameNum); - pInfo->pUnsyncLyrics = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->unsynclyricsLen); + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)&pExtContent[tmp], realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked= true; } else { debug_msg(RELEASE, "Description info too small to parse realCpyFrameNum(%d)\n", realCpyFrameNum); } + break; - tmp = 0; + case AV_ID3TAG_PICTURE: + if ((realCpyFrameNum <= 2000000) && _mm_file_id3tag_parse_APIC(pInfo, (unsigned char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType])) + pInfo->tagInfo[tag_id].marked= true; + break; - debug_msg(RELEASE, "pInfo->pUnsyncLyrics returned = (%s), pInfo->unsynclyricsLen(%d)\n", pInfo->pUnsyncLyrics, pInfo->unsynclyricsLen); - pInfo->tagV2Info.bDescriptionMarked = true; - } else { - __parse_tag_info(pInfo, CompTmp, (const char *)pExtContent, realCpyFrameNum, charset_array[textEncodingType]); + default: + pInfo->tagInfo[tag_id].value = mmfile_string_convert((const char *)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->tagInfo[tag_id].length); + pInfo->tagInfo[tag_id].marked= true; + break; } + + if (pInfo->tagInfo[tag_id].value) + debug_msg(RELEASE, "[%d] returned = (%s), len = (%d)\n", tag_id, pInfo->tagInfo[tag_id].value, pInfo->tagInfo[tag_id].length); } } else { @@ -3742,30 +3701,30 @@ void mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo) int mpegAudioFileLen = 0, idv2IntGenre = GENRE_COUNT - 1/*, tmpinx = 0, tmpinx2=0*/; /* for Genre Info */ - if (pInfo->tagV2Info.bGenreMarked == false) { + if (pInfo->tagInfo[AV_ID3TAG_GENRE].marked == false) { if (pInfo->bV1tagFound == true) { debug_msg(RELEASE, "Genre: %d\n", pInfo->genre); if (pInfo->genre > GENRE_COUNT - 1) pInfo->genre = GENRE_COUNT - 1; - pInfo->pGenre = mmfile_strdup(MpegAudio_Genre[pInfo->genre]); - if (pInfo->pGenre) - pInfo->genreLen = strlen(pInfo->pGenre); + pInfo->tagInfo[AV_ID3TAG_GENRE].value = mmfile_strdup(MpegAudio_Genre[pInfo->genre]); + if (pInfo->tagInfo[AV_ID3TAG_GENRE].value) + pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value); else debug_error(RELEASE, "Genre: memory allocation failed.\n"); } else { debug_msg(RELEASE, "Genre was not Found.\n"); } - } else if (pInfo->tagV2Info.bGenreMarked == true) { - debug_msg(RELEASE, "pInfo->genreLen size is Zero Or not UTF16 code! genreLen[%d] genre[%s]\n", pInfo->genreLen, pInfo->pGenre); + } else { + debug_msg(RELEASE, "genre size is Zero Or not UTF16 code! genreLen[%d] genre[%s]\n", pInfo->tagInfo[AV_ID3TAG_GENRE].length, pInfo->tagInfo[AV_ID3TAG_GENRE].value); - if (pInfo->pGenre) - mpegAudioGenre = mmfile_strdup(pInfo->pGenre); + if (pInfo->tagInfo[AV_ID3TAG_GENRE].value) + mpegAudioGenre = mmfile_strdup(pInfo->tagInfo[AV_ID3TAG_GENRE].value); else - pInfo->genreLen = 0; + pInfo->tagInfo[AV_ID3TAG_GENRE].length = 0; - mmfile_free(pInfo->pGenre); + mmfile_free(pInfo->tagInfo[AV_ID3TAG_GENRE].value); /*tmpinx = 0;*/ if (!mpegAudioGenre) @@ -3775,11 +3734,11 @@ void mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo) *Genre number * (XXX) XXX is 0 - 148 */ - pInfo->genreLen = strlen(mpegAudioGenre); - if (pInfo->genreLen >= 3 && - mpegAudioGenre[0] == '(' && mpegAudioGenre[pInfo->genreLen - 1] == ')') { + pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(mpegAudioGenre); + if (pInfo->tagInfo[AV_ID3TAG_GENRE].length >= 3 && + mpegAudioGenre[0] == '(' && mpegAudioGenre[pInfo->tagInfo[AV_ID3TAG_GENRE].length - 1] == ')') { bAdditionGenre = true; - for (mpegAudioFileLen = 1; mpegAudioFileLen <= pInfo->genreLen - 2; mpegAudioFileLen++) { + for (mpegAudioFileLen = 1; mpegAudioFileLen <= pInfo->tagInfo[AV_ID3TAG_GENRE].length - 2; mpegAudioFileLen++) { if (mpegAudioGenre[mpegAudioFileLen] < '0' || mpegAudioGenre[mpegAudioFileLen] > '9') { bAdditionGenre = false; break; @@ -3793,28 +3752,28 @@ void mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo) if (idv2IntGenre > GENRE_COUNT - 1 || idv2IntGenre < 0) idv2IntGenre = GENRE_COUNT - 1; - pInfo->pGenre = mmfile_strdup(MpegAudio_Genre[idv2IntGenre]); - if (pInfo->pGenre) - pInfo->genreLen = strlen(pInfo->pGenre); + pInfo->tagInfo[AV_ID3TAG_GENRE].value = mmfile_strdup(MpegAudio_Genre[idv2IntGenre]); + if (pInfo->tagInfo[AV_ID3TAG_GENRE].value) + pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value); else debug_error(RELEASE, "Genre: memory allocation failed.\n"); - debug_msg(RELEASE, "pInfo->pGenre = %s\n", pInfo->pGenre); - } else if (bAdditionGenre == false && pInfo->genreLen > 0) { + debug_msg(RELEASE, "pInfo->tagInfo[AV_ID3TAG_GENRE].value = %s\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value); + } else if (bAdditionGenre == false && pInfo->tagInfo[AV_ID3TAG_GENRE].length > 0) { /** * Genre string. */ /* Give space for NULL character. Hence added "+1" */ - pInfo->pGenre = mmfile_strdup(mpegAudioGenre); - if (pInfo->pGenre) - pInfo->genreLen = strlen(pInfo->pGenre); + pInfo->tagInfo[AV_ID3TAG_GENRE].value = mmfile_strdup(mpegAudioGenre); + if (pInfo->tagInfo[AV_ID3TAG_GENRE].value) + pInfo->tagInfo[AV_ID3TAG_GENRE].length = strlen(pInfo->tagInfo[AV_ID3TAG_GENRE].value); else debug_error(RELEASE, "Genre: memory allocation failed.\n"); - debug_msg(RELEASE, "pInfo->pGenre = %s, pInfo->genreLen = %d\n", pInfo->pGenre, pInfo->genreLen); + debug_msg(RELEASE, "pInfo->tagInfo[AV_ID3TAG_GENRE].value = %s, pInfo->tagInfo[AV_ID3TAG_GENRE].length = %d\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value, pInfo->tagInfo[AV_ID3TAG_GENRE].length); } else { - debug_msg(RELEASE, "Failed to \"(...)\" value to genre = %s\n", pInfo->pGenre); + debug_msg(RELEASE, "Failed to \"(...)\" value to genre = %s\n", pInfo->tagInfo[AV_ID3TAG_GENRE].value); } mmfile_free(mpegAudioGenre); } -- 2.7.4