return true;
}
-static bool __AvGetLastID3v2Offset(MMFileIOHandle *fp, int *offset)
-{
- unsigned char tagHeader[MP3_TAGv2_HEADER_LEN] = {0, };
- int total_taglen = 0;
- int read = 0;
- AvTagVer2AdditionalData tagInfo = { 0, };
-
- /*init offset*/
- *offset = 0;
-
- mmfile_seek(fp, 0, MMFILE_SEEK_SET);
-
-_START_TAG_SEARCH:
-
- read = mmfile_read(fp, tagHeader, MP3_TAGv2_HEADER_LEN);
- if (read != MP3_TAGv2_HEADER_LEN) {
- debug_error(DEBUG, "mmfile_read failed");
- return false;
- }
-
- if (!__AvGetID3v2Header(tagHeader, MP3_TAGv2_HEADER_LEN, &tagInfo)) {
- debug_msg(RELEASE, "Invalid ID3 header");
- goto search_end;
- }
-
- /**@note unfortunately, some contents has many id3 tag.*/
- total_taglen += tagInfo.tagLen;
- debug_msg(RELEASE, "tag size: %u, offset: %u", tagInfo.tagLen, total_taglen);
-
- mmfile_seek(fp, total_taglen, MMFILE_SEEK_SET);
- *offset = total_taglen;
- goto _START_TAG_SEARCH;
-
-search_end:
- return true;
-}
-
/*
* This fuction retrieves the start position of header.
* Param _pFile [in] Specifies the file pointer of mp3 file.
static bool __get_stream_info(char *filename, AvFileContentInfo *pInfo)
{
MMFileIOHandle *hFile;
- unsigned char header[256] = {0, };
unsigned long frameSamples = 0;
+ AvTagVer2AdditionalData tagInfo = { 0, };
+ unsigned char header[256] = {0, };
unsigned char *buf = NULL;
unsigned long bufLen = 0;
goto EXCEPTION;
}
- /* get total length from the beginning of first ID3v2 to the end of last ID3v2
- to get the offset of MP3 data */
- __AvGetLastID3v2Offset(hFile, &pInfo->tagV2Info.tagLen);
- debug_msg(RELEASE, "ID3 tag end offset: %u", pInfo->tagV2Info.tagLen);
+ /* Find the end of ID3v2 */
+ while (pInfo->tagV2Info.tagLen < pInfo->fileLen - MP3_TAGv2_HEADER_LEN) {
+ mmfile_seek(hFile, pInfo->tagV2Info.tagLen, SEEK_SET);
- debug_msg(RELEASE, "pInfo->fileLen(%lld)", pInfo->fileLen);
+ if (mmfile_read(hFile, header, MP3_TAGv2_HEADER_LEN) != MP3_TAGv2_HEADER_LEN)
+ goto EXCEPTION;
+
+ if (!__AvGetID3v2Header(header, MP3_TAGv2_HEADER_LEN, &tagInfo))
+ break;
+
+ /* Some contents may have multiple id3 tags */
+ pInfo->tagV2Info.tagLen += tagInfo.tagLen;
+ debug_msg(RELEASE, "ID3 size[%u] Total size[%u]", tagInfo.tagLen, pInfo->tagV2Info.tagLen);
+ }
+
+ debug_msg(RELEASE, "ID3 Len[%u] File Len[%lld]", pInfo->tagV2Info.tagLen, pInfo->fileLen);
/* read file to find MP3 header */
if (pInfo->fileLen - (long long)pInfo->tagV2Info.tagLen > (long long)_AV_MP3_HEADER_POSITION_MAX) {