Support TPOS (Part of a Set) 64/200664/6
authorhj kim <backto.kim@samsung.com>
Thu, 28 Feb 2019 01:32:12 +0000 (10:32 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 28 Feb 2019 01:59:19 +0000 (10:59 +0900)
The ‘Part of a set’ frame is a numeric string that describes which part of a set the audio came from.
This frame is used if the source described in the “TALB” frame is divided into several mediums,
e.g. a double CD. The value MAY be extended with a “/” character and a numeric string containing the total number of parts in the set. E.g. “1/2”.

Change-Id: Ic0613adda4b54834892e7592df34598b9d14be9b

formats/ffmpeg/include/mm_file_format_id3tag.h
formats/ffmpeg/mm_file_format_mp3.c
formats/ffmpeg/mm_file_formats.c
include/mm_file.h
include/mm_file_formats.h
mm_file.c [changed mode: 0644->0755]
packaging/libmm-fileinfo.spec
tests/mm_file_test.c
utils/include/mm_file_utils.h
utils/mm_file_util_print.c
utils/mm_file_util_tag.c

index 3387558..2ba1551 100755 (executable)
@@ -140,6 +140,7 @@ typedef struct {
        bool    bComposerMarked;
        bool    bImageMarked;
        bool    bRecDateMarked;
+       bool    bPartOfASetMarked;
        bool    bContentGroupMarked;
 
        bool    bGenreUTF16;
@@ -160,6 +161,7 @@ typedef struct {
        int             genreLen;
        int             tracknumLen;
        int             recdateLen;
+       int             partofsetLen;
 
 /* for PC Studio Podcast */
        int             contentGroupLen;
@@ -181,17 +183,17 @@ typedef struct {
        unsigned long   duration;
 
 /* for mp3 Info */
-       char                    *pToc;                  /* VBR�϶� SeekPosition�� ���ϱ� ���� TOC ���̺��� ������ ��� �ִ� char �迭, 100 ����Ʈ ���� */
+       char                    *pToc;                  /* VBR SeekPosition */
        unsigned int    mpegVersion;    /* 1 : mpeg 1,    2 : mpeg 2, 3 : mpeg2.5 */
        unsigned int    layer;                  /* 1 : layer1, 2 : layer2, 3 : layer3 */
        unsigned int    channelIndex;   /* 0 : stereo, 1 : joint_stereo, 2 : dual_channel, 3 : mono */
        unsigned int    objectType;
        unsigned int    headerType;
-       long                    fileLen;                /* mp3 ������ ��ü ���� */
-       long                    headerPos;              /* mp3 ����� ó������ ��Ÿ���� ��ġ */
-       long                    datafileLen;    /* ID3Tag���� �����ϰ� ���� mp3 frame���� ����,  VBR�϶� XHEADDATA �� bytes �� �ش��Ѵ� */
-       int                             frameSize;              /* mp3 frame �� ���� ũ�� */
-       int                             frameNum;               /* mp3 ���Ͽ� �������� � ����ִ°�? */
+       long                    fileLen;                /* mp3 file length */
+       long                    headerPos;      /* mp3 header position */
+       long                    datafileLen;    /* mp3 data length */
+       int                     frameSize;      /* mp3 frame size */
+       int                     frameNum;       /* mp3 frame number */
        bool                    bVbr;                   /* VBR mp3? */
        bool                    bPadding;               /* Padding? */
        bool                    bV1tagFound;
@@ -209,6 +211,7 @@ typedef struct {
        char                    *pGenre;
        char                    *pTrackNum;             /*Track number/Position in set */
        char                    *pRecDate;              /*Recording dates */
+       char                    *pPartOfASet;   /*Part of a set */
 
 /* for PC Studio Podcast */
        char                    *pContentGroup;
@@ -250,6 +253,7 @@ inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo)
                mmfile_free(pInfo->pGenre);
                mmfile_free(pInfo->pTrackNum);
                mmfile_free(pInfo->pRecDate);
+               mmfile_free (pInfo->pPartOfASet);
                mmfile_free(pInfo->pContentGroup);
                mmfile_free(pInfo->pEncBy);
                mmfile_free(pInfo->pURL);
index 97e98d3..0dc8f91 100755 (executable)
@@ -210,6 +210,7 @@ int mmfile_format_read_tag_mp3(MMFileFormatContext *formatContext)
        if (privateData->pSyncLyrics)           formatContext->syncLyrics = privateData->pSyncLyrics;
        if (privateData->syncLyricsNum)         formatContext->syncLyricsNum = privateData->syncLyricsNum;
        if (privateData->pRecDate)                      formatContext->recDate = mmfile_strdup(privateData->pRecDate);
+       if (privateData->pPartOfASet)           formatContext->part_of_set = mmfile_strdup(privateData->pPartOfASet);
 
        if (privateData->imageInfo.imageLen > 0) {
                formatContext->artwork = mmfile_malloc(privateData->imageInfo.imageLen);
@@ -1285,6 +1286,7 @@ static int mmf_file_mp3_get_infomation(char *filename, AvFileContentInfo *pInfo)
        debug_msg(RELEASE, "Comment : %s\n", pInfo->pComment);
        debug_msg(RELEASE, "Rating      : %s\n", pInfo->pRating);
        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);
index 0da0866..2278098 100755 (executable)
@@ -137,6 +137,7 @@ static int _CleanupFrameContext(MMFileFormatContext *formatContext, bool clean_a
                mmfile_free(formatContext->classification);
                mmfile_free(formatContext->year);
                mmfile_free(formatContext->recDate);
+               mmfile_free(formatContext->part_of_set);
                mmfile_free(formatContext->tagTrackNum);
                mmfile_free(formatContext->rating);
                mmfile_free(formatContext->artworkMime);
index 4c0963e..3be22af 100755 (executable)
@@ -146,6 +146,7 @@ typedef enum {
 #define        MM_FILE_TAG_UNSYNCLYRICS    "tag-unsynclyrics"  /**< Unsynchronized Lyrics Information*/
 #define        MM_FILE_TAG_SYNCLYRICS_NUM  "tag-synclyrics-num"        /**< Synchronized Lyrics Information*/
 #define        MM_FILE_TAG_RECDATE                     "tag-recdate"                   /**< Recoding date */
+#define        MM_FILE_TAG_POS                 "tag-part-of-set"                       /**< Part of a set */
 #define        MM_FILE_TAG_ROTATE                      "tag-rotate"                    /**< Rotate(Orientation) Information*/
 #define        MM_FILE_TAG_CDIS                        "tag-cdis"                              /**< CDIS in User Data Information*/
 #define        MM_FILE_TAG_SMTA                        "tag-smta"                              /**< SMTA in User Data Information*/
index 3ba2a6f..169733b 100755 (executable)
@@ -135,6 +135,7 @@ struct _MMFileFormatContext {
        char *classification;
        char *year;
        char *recDate;
+       char *part_of_set;
        char *tagTrackNum;
        char *rating;
        int artworkSize;
old mode 100644 (file)
new mode 100755 (executable)
index e4eadb5..7625b3d
--- a/mm_file.c
+++ b/mm_file.c
@@ -119,6 +119,7 @@ static MMAttrsConstructInfo g_tag_attrs[] = {
        {(char *)"tag-synclyrics-num",  MM_ATTRS_TYPE_INT,              MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"tag-synclyrics",              MM_ATTRS_TYPE_DATA,     MM_ATTRS_FLAG_RW, (void *)NULL},
        {(char *)"tag-recdate",         MM_ATTRS_TYPE_STRING,   MM_ATTRS_FLAG_RW, (void *)NULL},
+       {(char *)"tag-part-of-set",             MM_ATTRS_TYPE_STRING,   MM_ATTRS_FLAG_RW, (void *)NULL},
        {(char *)"tag-rotate",                  MM_ATTRS_TYPE_STRING,   MM_ATTRS_FLAG_RW, (void *)NULL},
        {(char *)"tag-cdis",                    MM_ATTRS_TYPE_INT,              MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"tag-smta",                    MM_ATTRS_TYPE_INT,              MM_ATTRS_FLAG_RW, (void *)0},
@@ -332,6 +333,8 @@ _info_set_attr_media(MMHandleType attrs, MMFileFormatContext *formatContext)
                if (formatContext->rating)                              mm_attrs_set_string_by_name(attrs, MM_FILE_TAG_RATING, formatContext->rating);
                if (formatContext->conductor)                   mm_attrs_set_string_by_name(attrs, MM_FILE_TAG_CONDUCTOR, formatContext->conductor);
                if (formatContext->recDate)                     mm_attrs_set_string_by_name(attrs, MM_FILE_TAG_RECDATE, formatContext->recDate);
+               if (formatContext->part_of_set)                 mm_attrs_set_string_by_name(attrs, MM_FILE_TAG_POS, formatContext->part_of_set);
+
                if (formatContext->rotate)                              mm_attrs_set_string_by_name(attrs, MM_FILE_TAG_ROTATE, formatContext->rotate);
                mm_attrs_set_double_by_name(attrs, MM_FILE_TAG_LONGITUDE, formatContext->longitude);
                mm_attrs_set_double_by_name(attrs, MM_FILE_TAG_LATIDUE, formatContext->latitude);
index e0397ef..e86d547 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    0.6.75
+Version:    0.6.76
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
index befb058..5f1b722 100755 (executable)
@@ -66,6 +66,7 @@ typedef struct _TagContext {
        mmfile_value_t copyright;
        mmfile_value_t date;                    /*string */
        mmfile_value_t recdate;                 /*string */
+       mmfile_value_t part_of_set;                     /*string */
        mmfile_value_t description;
        mmfile_value_t comment;
        mmfile_value_t artwork;         /*data */
@@ -368,6 +369,7 @@ static int mmfile_get_file_infomation(void *data, void *user_data, bool file_tes
                                                MM_FILE_TAG_COPYRIGHT, &ctag.copyright.value.s_val, &ctag.copyright.len,
                                                MM_FILE_TAG_DATE, &ctag.date.value.s_val, &ctag.date.len,
                                                MM_FILE_TAG_RECDATE, &ctag.recdate.value.s_val, &ctag.recdate.len,
+                                               MM_FILE_TAG_POS, &ctag.part_of_set.value.s_val, &ctag.part_of_set.len,
                                                MM_FILE_TAG_DESCRIPTION, &ctag.description.value.s_val, &ctag.description.len,
                                                MM_FILE_TAG_COMMENT, &ctag.comment.value.s_val, &ctag.comment.len,
                                                MM_FILE_TAG_ARTWORK, &ctag.artwork.value.p_val, &ctag.artwork.len,
@@ -440,6 +442,7 @@ static int mmfile_get_file_infomation(void *data, void *user_data, bool file_tes
                printf("# copyright: [%s]\n", ctag.copyright.value.s_val);
                printf("# year: [%s]\n", ctag.date.value.s_val);
                printf("# recdate: [%s]\n", ctag.recdate.value.s_val);
+               printf("# part of a set: [%s]\n", ctag.part_of_set.value.s_val);
                printf("# description: [%s]\n", ctag.description.value.s_val);
                printf("# comment: [%s]\n", ctag.comment.value.s_val);
                printf("# artwork: [%p]\n", ctag.artwork.value.p_val);
index fae4468..44215ba 100755 (executable)
@@ -403,6 +403,7 @@ typedef struct {
        bool    bComposerMarked;
        bool    bImageMarked;
        bool    bRecDateMarked;
+       bool    bPartOfASetMarked;
        bool    bContentGroupMarked;
        bool    bUnsyncLyricsMarked;
        bool    bSyncLyricsMarked;
@@ -427,6 +428,7 @@ typedef struct {
        int             genreLen;
        int             tracknumLen;
        int             recdateLen;
+       int             partofsetLen;
        int             conductorLen;
        int             album_artistLen;
 
@@ -480,6 +482,7 @@ typedef struct {
        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*/
 
@@ -533,6 +536,7 @@ inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo)
                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);
index abfb0ac..60f318d 100755 (executable)
@@ -74,6 +74,7 @@ void mmfile_format_print_tags(MMFileFormatContext *in)
                if (in->genre)                  debug_msg(DEBUG, "genre = %s\n", in->genre);
                if (in->year)                           debug_msg(DEBUG, "year = %s\n", in->year);
                if (in->recDate)                        debug_msg(DEBUG, "recDate = %s\n", in->recDate);
+               if (in->part_of_set)            debug_msg(DEBUG, "part_of_set = %s\n", in->part_of_set);
                if (in->tagTrackNum)            debug_msg(DEBUG, "tagTrackNum = %s\n", in->tagTrackNum);
                if (in->artworkMime)            debug_msg(DEBUG, "artworkMime = %s\n", in->artworkMime);
                debug_msg(DEBUG, "artworksize = %d\n", in->artworkSize);
index 62e8ece..cc3de64 100755 (executable)
@@ -1586,7 +1586,7 @@ static int GetTagFromMetaBox(MMFileFormatContext *formatContext, MMFileIOHandle
                                        formatContext->artworkMime = mmfile_strdup("image/jpeg");
                                } else if (cover_type == _ITUNES_COVER_TYPE_PNG) {
                                        formatContext->artworkMime = mmfile_strdup("image/png");
-                                       /*} else if(cover_type == _ITUNES_COVER_TYPE_TIF) {
+                                       /*} else if (cover_type == _ITUNES_COVER_TYPE_TIF) {
                                                formatContext->artworkMime = mmfile_strdup("image/tif");*/
                                } else {
                                        debug_warning(DEBUG, "Not proper cover image type, but set to jpeg. cover_type[%d]", cover_type);
@@ -3384,6 +3384,10 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                                        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, "TPOS", 4) == 0 && pInfo->tagV2Info.bPartOfASetMarked == false) {
+                                                       pInfo->pPartOfASet = mmfile_string_convert((const char*)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], 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", charset_array[textEncodingType], NULL, (unsigned int *)&pInfo->encbyLen);
                                                        debug_msg(RELEASE, "pInfo->pEncBy returned = (%s), pInfo->encbyLen(%d)\n", pInfo->pEncBy, pInfo->encbyLen);
@@ -4062,6 +4066,22 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
 
                                                        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) {
+                                                       if (textEncodingType == AV_ID3V2_UTF8) {
+                                                               pInfo->pPartOfASet = mmfile_malloc(realCpyFrameNum+2); /*Ignore NULL char for UTF16 */
+                                                               if (pInfo->pPartOfASet != NULL) {
+                                                                       memcpy(pInfo->pPartOfASet, pExtContent, realCpyFrameNum);
+                                                                       pInfo->pPartOfASet[realCpyFrameNum] = '\0';
+                                                                       /*string copy with '\0'*/
+                                                                       pInfo->partofsetLen = realCpyFrameNum;
+                                                                       _STRNCPY_EX(pInfo->pPartOfASet, pExtContent, pInfo->partofsetLen);
+                                                               }
+                                                       } else {
+                                                               pInfo->pPartOfASet = mmfile_string_convert((const char*)pExtContent, realCpyFrameNum, "UTF-8", charset_array[textEncodingType], 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) {
                                                        if (textEncodingType == AV_ID3V2_UTF8) {
                                                                pInfo->pEncBy = mmfile_malloc(realCpyFrameNum + 2); /*Ignore NULL char for UTF16 */