+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _MMFILE_ID3_TAG_H_
-#define _MMFILE_ID3_TAG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mm_file_utils.h"
-#include "mm_file_format_tags.h"
-
-#define MMFILE_ID3TAG_FAIL 0
-#define MMFILE_ID3TAG_SUCCESS 1
-
-typedef void *MMFileID3TagHandle;
-
-typedef enum mmfileId3TagInfoVersion {
- MMFILE_ID3TAG_V1_0 = 0,
- MMFILE_ID3TAG_V1_1,
- MMFILE_ID3TAG_V2_0,
- MMFILE_ID3TAG_V2_2,
- MMFILE_ID3TAG_V2_3,
- MMFILE_ID3TAG_V2_4,
- MMFILE_ID3TAG_VMAX,
-} eMMFileID3TagVersion;
-
-int MMFileID3V1TagFind(MMFileIOHandle *fp, unsigned char bAppended, unsigned int startOffset, unsigned int endOffset, tMMFileTags *out);
-int MMFileID3V2TagFind(MMFileIOHandle *fp, unsigned char bAppended, unsigned int startOffset, unsigned int endOffset, tMMFileTags *out);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_MMFILE_ID3_TAG_H_ */
-
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _MMFILE_TAGS_H_
-#define _MMFILE_TAGS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *MMFileTagsHandle;
-
-#define MMFILE_TAGS_SUCCESS 1
-#define MMFILE_TAGS_FAIL 0
-
-typedef enum mmfiletagstype {
- MMFILE_TAG_ID3V1 = 0,
- MMFILE_TAG_ID3V2,
- MMFILE_TAG_MUSICAL_MATCH,
- MMFILE_TAG_LYRICS3,
- MMFILE_TAG_APE,
- MMFILE_TAG_MAX,
-} eMMFileTagsType;
-
-typedef struct mmfileTags {
- eMMFileTagsType typeOfTag;
- unsigned char bAppendedTag;
- unsigned int version;
- unsigned int startOffset;
- unsigned int tagSize;
- unsigned int endOffset;
-} tMMFileTags;
-
-int MMFileOpenTags(MMFileTagsHandle *tagsHandle, const char *uriName);
-int MMFileGetFirstTag(MMFileTagsHandle tagsHandle, tMMFileTags *out);
-int MMFileGetNextTag(MMFileTagsHandle tagsHandle, tMMFileTags *out);
-int MMFileTagsClose(MMFileTagsHandle tagsHandle);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _MMFILE_TAGS_H_ */
-
#include "mm_file_format_audio.h"
#include "mm_file_format_mp3.h"
-
#define __MMFILE_NEW_FRAME_FUNC
-#ifdef __MMFILE_NEW_TAGLIBS__
-#include "mm_file_format_tags.h"
-#endif
-
-
#define AV_MP3_FIND_SYNC_LEN 1024*30
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
read = mmfile_read(fp, tagHeader, MP3_TAGv2_HEADER_LEN);
if (read != MP3_TAGv2_HEADER_LEN) {
- debug_error(DEBUG, "read error occured.\n");
+ debug_error(DEBUG, "mmfile_read failed\n");
return 0;
}
}
mmfile_free(pHeader);
} else {
- debug_warning(RELEASE, "Mp3 file frist byte is 0xff, but not header sync\n");
+ debug_warning(RELEASE, "Mp3 file first byte is 0xff, but not header sync\n");
}
}
buf++;
bufLen = pInfo->fileLen - (long long)pInfo->tagV2Info.tagLen;
} else {
- /* if taglen is invlaid, check whole file to get MP3 info */
+ /* if taglen is invalid, check whole file to get MP3 info */
if (mmfile_seek(hFile, 0L, SEEK_SET) < 0)
goto EXCEPTION;
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include "mm_file_debug.h"
-#include "mm_file_format_tag_id3.h"
-
-#define MMFILE_ID3V1TAG_SIZE 128
-#define MMFILE_ID3V2TAG_HEADER_SIZE 10
-
-static unsigned int GetSynchsafeInteger(unsigned int value);
-
-
-int MMFileID3V1TagFind(MMFileIOHandle *fp, unsigned char bAppended, unsigned int startOffset, unsigned int endOffset, tMMFileTags *out)
-{
- int ret = 0;
-
- if (!fp || !out) {
- debug_error(DEBUG, "Invalid input\n");
- return MMFILE_ID3TAG_FAIL;
- }
-
- if (bAppended) {
- unsigned char tagSymbol[3] = {0, };
-
- unsigned int offset = endOffset - MMFILE_ID3V1TAG_SIZE;
-
- mmfile_seek(fp, offset, MMFILE_SEEK_SET);
-
- ret = mmfile_read(fp, tagSymbol, 3);
- if (MMFILE_UTIL_FAIL == ret) {
- debug_error(DEBUG, "read error\n");
- return MMFILE_ID3TAG_FAIL;
- }
-
- if (memcmp("TAG", tagSymbol, 3) == 0) {
- unsigned char versionBuf[2] = {0, };
-
- out->typeOfTag = MMFILE_TAG_ID3V1;
- out->startOffset = offset;
- out->endOffset = endOffset;
- out->bAppendedTag = 1;
- out->tagSize = MMFILE_ID3V1TAG_SIZE;
-
- offset += 125; /* byte delimiter offset: ID3V1.1 spec. */
- mmfile_seek(fp, offset, MMFILE_SEEK_SET);
-
- ret = mmfile_read(fp, versionBuf, 2);
- if (MMFILE_UTIL_FAIL == ret) {
- debug_error(DEBUG, "read error\n");
- return MMFILE_ID3TAG_FAIL;
- }
-
- if (versionBuf[0] == '\0' && versionBuf[1] != '\0') {
- out->version = MMFILE_ID3TAG_V1_1;
- } else {
- out->version = MMFILE_ID3TAG_V1_0;
- }
-
- debug_msg(RELEASE, "typeOfTag = %d\n", out->typeOfTag);
- debug_msg(RELEASE, "startOffset = %d\n", out->startOffset);
- debug_msg(RELEASE, "endOffset = %d\n", out->endOffset);
- debug_msg(RELEASE, "bAppendedTag = %d\n", out->bAppendedTag);
- debug_msg(RELEASE, "tagSize = %d\n", out->tagSize);
- debug_msg(RELEASE, "version = %d\n", out->version);
-
- return MMFILE_ID3TAG_SUCCESS;
- }
- }
-
- return MMFILE_ID3TAG_FAIL;
-}
-
-
-
-int MMFileID3V2TagFind(MMFileIOHandle *fp, unsigned char bAppended, unsigned int startOffset, unsigned int endOffset, tMMFileTags *out)
-{
- unsigned char *id3v2ID = NULL;
- unsigned char header[MMFILE_ID3V2TAG_HEADER_SIZE] = {0, };
- unsigned int offset = 0;
- unsigned int index = 0;
- int ret = 0;
-
- if (!fp || !out) {
- debug_error(DEBUG, "Invalid input\n");
- return MMFILE_ID3TAG_FAIL;
- }
-
- if (bAppended) {
- id3v2ID = "3DI";
- offset = endOffset - MMFILE_ID3V2TAG_HEADER_SIZE;
- } else {
- id3v2ID = "ID3";
- offset = startOffset;
- }
-
- mmfile_seek(fp, offset, MMFILE_SEEK_SET);
-
- ret = mmfile_read(fp, header, MMFILE_ID3V2TAG_HEADER_SIZE);
- if (MMFILE_UTIL_FAIL == ret) {
- debug_error(DEBUG, "read error\n");
- return MMFILE_ID3TAG_FAIL;
- }
-
- if (memcmp(id3v2ID, header, 3) == 0) {
- index += 3;
- out->typeOfTag = MMFILE_TAG_ID3V2;
- out->bAppendedTag = bAppended;
- out->startOffset = offset;
-
- /*version check */
- switch (header[index]) {
- case 0:
- out->version = MMFILE_ID3TAG_V2_0;
- break;
- case 2:
- out->version = MMFILE_ID3TAG_V2_2;
- break;
- case 3:
- out->version = MMFILE_ID3TAG_V2_3;
- break;
- case 4:
- out->version = MMFILE_ID3TAG_V2_4;
- break;
- default:
- debug_warning(DEBUG, "unknown version of id3v2\n");
- break;
- }
-
- index += 2;
- /*check footer */
- unsigned char footer = (header[index] & 0x10) ? 1 : 0;
-
- index += 1;
- /*out->tagSize = GetSynchsafeInteger() + (footer ? 20 : 10) */
-
- if (bAppended) {
-/* out->endOffset */
- }
- out->endOffset = endOffset;
- }
-
-
- return MMFILE_ID3TAG_FAIL;
-}
-
-
-static unsigned int GetSynchsafeInteger(unsigned int value)
-{
- int i = 0;
- const unsigned int mask = 0x7F000000;
- unsigned int ret = 0;
-
- for (i = 0; i < sizeof(unsigned int); i++) {
- ret = (ret << 7) | ((value & mask) >> 24);
- value <<= 8;
- }
- return ret;
-}
-
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include "mm_file_debug.h"
-#include "mm_file_utils.h"
-#include "mm_file_format_tag_id3.h"
-#include "mm_file_format_tags.h"
-
-#define MMFILE_TAGS_NUMBER_OF_ELEMENTS(X) (sizeof X / sizeof X[0])
-
-typedef int (*MMFileFindTagFunc)(MMFileIOHandle *fp, unsigned char bAppended, unsigned int startOffset, unsigned int endOffset, tMMFileTags *out);
-
-
-typedef struct mmfiletagsdata {
- MMFileIOHandle *fp;
- unsigned int filesize;
- unsigned int startOffset;
- unsigned int endOffset;
- MMFileList tagList;
-} tMMFileTagsData;
-
-
-MMFileFindTagFunc gFindPreprendTagFuncs[] = {
- MMFileID3V2TagFind,
-};
-
-MMFileFindTagFunc gFindAppendTagFuncs[] = {
- MMFileID3V1TagFind,
- MMFileID3V2TagFind,
-};
-
-
-int _MMFileFindTags(tMMFileTagsData *privateData, MMFileFindTagFunc FindTag, unsigned char bAppended);
-int _MMFileFindPrependTags(tMMFileTagsData *privateData);
-int _MMFileFindAppendTags(tMMFileTagsData *privateData);
-
-
-
-
-int MMFileOpenTags(MMFileTagsHandle *tagsHandle, const char *uriName)
-{
- tMMFileTagsData *privateData = NULL;
- int ret = 0;
-
- privateData = g_new0(tMMFileTagsData, 1);
-
- *tagsHandle = privateData;
-
- ret = mmfile_open(&privateData->fp, uriName, MMFILE_RDONLY);
- if (MMFILE_UTIL_FAIL == ret) {
- debug_error(DEBUG, "mmfile_open\n");
- ret = MMFILE_TAGS_FAIL;
- goto exception;
- }
-
- privateData->filesize = mmfile_get_size(privateData->fp);
- if (privateData->filesize <= 0) {
- debug_error(DEBUG, "mmfile_get_size: too small\n");
- ret = MMFILE_TAGS_FAIL;
- goto exception;
- }
- privateData->startOffset = 0;
- privateData->endOffset = privateData->filesize;
-
- /* Find all of tags */
- while (MMFILE_TAGS_SUCCESS == _MMFileFindPrependTags(privateData)) ;
- while (MMFILE_TAGS_SUCCESS == _MMFileFindAppendTags(privateData)) ;
-
- if (!privateData->tagList) {
- debug_error(DEBUG, "there is no tags\n");
- ret = MMFILE_TAGS_FAIL;
- goto exception;
- }
-
- return MMFILE_TAGS_SUCCESS;
-
-exception:
- if (*tagsHandle) {
- MMFileTagsClose(*tagsHandle);
- *tagsHandle = NULL;
- }
-
- return ret;
-}
-
-
-int MMFileTagsClose(MMFileTagsHandle tagsHandle)
-{
- tMMFileTagsData *privateData = tagsHandle;
-
- if (privateData) {
- mmfile_close(privateData->fp);
- mmfile_free(privateData->tagList);
- mmfile_free(privateData);
- }
-
- return MMFILE_TAGS_SUCCESS;
-}
-
-
-
-
-int MMFileGetFirstTag(MMFileTagsHandle tagsHandle, tMMFileTags *out)
-{
-
-}
-
-
-int MMFileGetNextTag(MMFileTagsHandle tagsHandle, tMMFileTags *out)
-{
-}
-
-int _MMFileFindPrependTags(tMMFileTagsData *privateData)
-{
- int i = 0;
- int res = 0;
-
- if (!privateData || !privateData->fp) {
- debug_error(DEBUG, "Invalid argument\n");
- return MMFILE_TAGS_FAIL;
- }
-
- for (i = 0; i < MMFILE_TAGS_NUMBER_OF_ELEMENTS(gFindPreprendTagFuncs); i++) {
- if (gFindPreprendTagFuncs[i]) {
- if (MMFILE_TAGS_SUCCESS == _MMFileFindTags(privateData, gFindPreprendTagFuncs[i], 0)) {
- return MMFILE_TAGS_SUCCESS;
- }
- }
- }
-
- return MMFILE_TAGS_FAIL;
-}
-
-int _MMFileFindAppendTags(tMMFileTagsData *privateData)
-{
- int i = 0;
- int res = 0;
-
- if (!privateData || !privateData->fp) {
- debug_error(DEBUG, "Invalid argument\n");
- return MMFILE_TAGS_FAIL;
- }
-
- for (i = 0; i < MMFILE_TAGS_NUMBER_OF_ELEMENTS(gFindAppendTagFuncs); i++) {
- if (gFindAppendTagFuncs[i]) {
- if (MMFILE_TAGS_SUCCESS == _MMFileFindTags(privateData, gFindAppendTagFuncs[i], 1)) {
- return MMFILE_TAGS_SUCCESS;
- }
- }
- }
-
- return MMFILE_TAGS_FAIL;
-}
-
-int _MMFileFindTags(tMMFileTagsData *privateData, MMFileFindTagFunc FindTag, unsigned char bAppended)
-{
- tMMFileTags *tagData = NULL;
- int ret = 0;
-
- mm_file_retvm_if_fails(DEBUG, privateData, MMFILE_TAGS_FAIL);
- mm_file_retvm_if_fails(DEBUG, privateData->fp, MMFILE_TAGS_FAIL);
-
- tagData = g_new0(tMMFileTags, 1);
-
- ret = FindTag(privateData->fp, bAppended, privateData->startOffset, privateData->endOffset, tagData);
- if (ret) {
- if (bAppended) {
- privateData->endOffset = tagData->startOffset;
- } else {
- privateData->startOffset = tagData->endOffset;
- }
-
- ret = MMFILE_TAGS_SUCCESS;
- }
-
- mmfile_free(tagData);
-
- return ret;
-}
-