381b72e2ff9d05a7ec45f2dad8d0490ce9198b02
[platform/core/multimedia/libmm-fileinfo.git] / utils / include / mm_file_utils.h
1 /*
2  * libmm-fileinfo
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Haejeong Kim <backto.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef _MM_FILE_UTILS_H_
23 #define _MM_FILE_UTILS_H_
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <string.h>
30 #include <stdio.h>
31 #include <stdbool.h>
32 #include <stdlib.h>
33
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #include <glib.h>
38
39 #include "mm_file_formats.h"
40 #include "mm_file_codecs.h"
41
42 #define MMFILE_UTIL_FAIL                -1
43 #define MMFILE_UTIL_SUCCESS     0
44
45 #define MMFILE_IO_FAILED                MMFILE_UTIL_FAIL
46 #define MMFILE_IO_SUCCESS               MMFILE_UTIL_SUCCESS
47 #define CAST_MM_HANDLE(x)                       (MMHandleType)(x)
48
49 #ifndef TRUE
50 #define TRUE    (1 == 1)
51 #endif
52 #ifndef FALSE
53 #define FALSE   (!TRUE)
54 #endif
55
56 #define MM_FILE_INI_PATH        "/etc/multimedia/mm_file_config.ini"
57
58
59 /*////////////////////////////////////////////////////////////////////// */
60 /*                     ENDIAN UTIL API                                // */
61 /*////////////////////////////////////////////////////////////////////// */
62 inline unsigned int     mmfile_io_be_uint32(unsigned int value);
63 inline unsigned int     mmfile_io_le_uint32(unsigned int value);
64 inline int              mmfile_io_be_int32(unsigned int value);
65 inline int              mmfile_io_le_int32(unsigned int value);
66 inline unsigned short   mmfile_io_be_uint16(unsigned short value);
67 inline unsigned short   mmfile_io_le_uint16(unsigned short value);
68 inline short            mmfile_io_be_int16(unsigned short value);
69 inline short            mmfile_io_le_int16(unsigned short value);
70
71 typedef struct MMFileIOHandle {
72         struct MMFileIOFunc *iofunc;
73         int     flags;         /* file flags */
74         void   *privateData;
75         char   *fileName;
76 } MMFileIOHandle;
77
78 /*////////////////////////////////////////////////////////////////////// */
79 /*                     FILE HEADER CHECK API                          // */
80 /*////////////////////////////////////////////////////////////////////// */
81 int MMFileFormatIsValidMP3(MMFileIOHandle *pFileIO, const char *mmfileuri, int frameCnt);
82 int MMFileFormatIsValidAAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
83 int MMFileFormatIsValidASF(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
84 int MMFileFormatIsValidMP4(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
85 int MMFileFormatIsValidAVI(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
86 int MMFileFormatIsValidAMR(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
87 int MMFileFormatIsValidWAV(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
88 int MMFileFormatIsValidMMF(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
89 int MMFileFormatIsValidMID(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
90 int MMFileFormatIsValidIMY(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
91 int MMFileFormatIsValidWMA(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
92 int MMFileFormatIsValidWMV(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
93 int MMFileFormatIsValidOGG(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
94 int MMFileFormatIsValidREAL(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
95 int MMFileFormatIsValidMatroska(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
96 int MMFileFormatIsValidQT(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
97 int MMFileFormatIsValidFLAC(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
98 int MMFileFormatIsValidFLV(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
99 int MMFileFormatIsValidMPEGTS(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
100 int MMFileFormatIsValidMPEGPS(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
101 int MMFileFormatIsValidMPEGVIDEO(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
102 int MMFileFormatIsValidMPEGAUDIO(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
103 int MMFileFormatIsValidAIFF(MMFileIOHandle *pFileIO, const char *mmfileuri, int dummy);
104
105
106
107 /*////////////////////////////////////////////////////////////////////// */
108 /*                       IO HANDLER API                               // */
109 /*////////////////////////////////////////////////////////////////////// */
110 #define MMFILE_URI_MAX_LEN     512
111 #define MMFILE_FILE_URI        "file://"
112 #define MMFILE_FILE_URI_LEN    7
113 #define MMFILE_MEM_URI         "mem://"
114 #define MMFILE_MEM_URI_LEN     6
115 #define MMFILE_MMAP_URI        "mmap://"
116 #define MMFILE_MMAP_URI_LEN    7
117 #define MMFILE_AVIO_BUFFER_LEN          32768
118
119 #define MMFILE_RDONLY           O_RDONLY
120 #define MMFILE_WRONLY           O_WRONLY
121 #define MMFILE_RDWR                     O_RDWR
122
123 #define MMFILE_SEEK_SET         SEEK_SET
124 #define MMFILE_SEEK_CUR         SEEK_CUR
125 #define MMFILE_SEEK_END         SEEK_END
126
127 typedef struct MMFileIOFunc {
128         const char      *handleName;
129         int     (*mmfile_open)(MMFileIOHandle *h, const char *filename, int flags);
130         int     (*mmfile_read)(MMFileIOHandle *h, unsigned char *buf, int size);
131         int     (*mmfile_write)(MMFileIOHandle *h, unsigned char *buf, int size);
132         int64_t(*mmfile_seek)(MMFileIOHandle *h, int64_t pos, int whence);
133         long long(*mmfile_tell)(MMFileIOHandle *h);
134         int     (*mmfile_close)(MMFileIOHandle *h);
135         struct MMFileIOFunc *next;
136 } MMFileIOFunc;
137
138
139 int mmfile_register_io_func(MMFileIOFunc *iofunc);
140 int mmfile_register_io_all();
141
142 int                     mmfile_open(MMFileIOHandle **h, const char *filename, int flags);
143 int                     mmfile_read(MMFileIOHandle *h, unsigned char *buf, int size);
144 int                     mmfile_write(MMFileIOHandle *h, unsigned char *buf, int size);
145 int64_t         mmfile_seek(MMFileIOHandle *h, int64_t pos, int whence);
146 long long       mmfile_tell(MMFileIOHandle *h);
147 int                     mmfile_close(MMFileIOHandle *h);
148
149
150
151 /*////////////////////////////////////////////////////////////////////// */
152 /*                            MIME  API                               // */
153 /*////////////////////////////////////////////////////////////////////// */
154 #define MMFILE_FILE_FMT_MAX_LEN 25
155 #define MMFILE_MIMETYPE_MAX_LEN 40
156 #define MMFILE_FILE_EXT_MAX_LEN 7
157
158 int mmfile_util_get_ffmpeg_format(const char *mime, char *ffmpegFormat);
159 int mmfile_util_get_file_ext(const char *mime, char *ext);
160
161
162
163 /*////////////////////////////////////////////////////////////////////// */
164 /*                            PRINT API                               // */
165 /*////////////////////////////////////////////////////////////////////// */
166 void mmfile_format_print_contents(MMFileFormatContext *in);
167 void mmfile_format_print_tags(MMFileFormatContext *in);
168 void mmfile_codec_print(MMFileCodecContext *in);
169 void mmfile_format_print_frame(MMFileFormatFrame *in);
170
171
172
173
174 /*////////////////////////////////////////////////////////////////////// */
175 /*                            STRING API                              // */
176 /*////////////////////////////////////////////////////////////////////// */
177 char **mmfile_strsplit(const char *string, const char *delimiter);
178 void mmfile_strfreev(char **str_array);
179 int  mmfile_util_wstrlen(unsigned short *wText);
180 short *mmfile_swap_2byte_string(short *mszOutput, short *mszInput, int length);
181 char *mmfile_get_charset(const char *str);
182 char *mmfile_string_convert(const char *str, unsigned int len, const char *to_codeset, const char *from_codeset, gsize *bytes_read, unsigned int *bytes_written);
183 char *mmfile_strdup(const char *str);
184
185
186
187 /*////////////////////////////////////////////////////////////////////// */
188 /*                            LOCALE API                              // */
189 /*////////////////////////////////////////////////////////////////////// */
190 char *MMFileUtilGetLocale(int *error);
191
192
193
194
195 /*////////////////////////////////////////////////////////////////////// */
196 /*                            IMAGE API                               // */
197 /*////////////////////////////////////////////////////////////////////// */
198 typedef enum {
199         MMFILE_PIXEL_FORMAT_YUV420 = 0,
200         MMFILE_PIXEL_FORMAT_YUV422 = 1,
201         MMFILE_PIXEL_FORMAT_RGB565 = 2,
202         MMFILE_PIXEL_FORMAT_RGB888 = 3,
203         MMFILE_PIXEL_FORMAT_MAX,
204 } eMMFilePixelFormat;
205
206 int mmfile_util_image_convert(unsigned char *src, eMMFilePixelFormat src_fmt, int src_width, int src_height, unsigned char *dst, eMMFilePixelFormat dst_fmt, int dst_width, int dst_height);
207
208
209
210 /*////////////////////////////////////////////////////////////////////// */
211 /*                            MEMORY API                              // */
212 /*////////////////////////////////////////////////////////////////////// */
213 void *mmfile_malloc(unsigned int size);
214 #define mmfile_free(ptr)  do { if ((ptr)) { mmfile_free_r((ptr)); (ptr) = NULL; } } while (0)
215 void  mmfile_free_r(void *ptr);
216 void *mmfile_realloc(void *ptr, unsigned int size);
217 void *mmfile_memset(void *s, int c, unsigned int n);
218 void *mmfile_memcpy(void *dest, const void *src, unsigned int n);
219
220 /*////////////////////////////////////////////////////////////////////// */
221 /*                        DATA STRUCTURE API                          // */
222 /*////////////////////////////////////////////////////////////////////// */
223 typedef void *MMFileList;
224 MMFileList mmfile_list_alloc();
225 MMFileList mmfile_list_append(MMFileList list, void *data);
226 MMFileList mmfile_list_prepend(MMFileList list, void *data);
227 MMFileList mmfile_list_find(MMFileList list, void *data);
228 MMFileList mmfile_list_first(MMFileList list);
229 MMFileList mmfile_list_last(MMFileList list);
230 MMFileList mmfile_list_nth(MMFileList list, unsigned int n);
231 MMFileList mmfile_list_next(MMFileList list);
232 MMFileList mmfile_list_previous(MMFileList list);
233 unsigned int mmfile_list_length(MMFileList list);
234 MMFileList mmfile_list_remove(MMFileList list, void *data);
235 MMFileList mmfile_list_remove_all(MMFileList list, void *data);
236 MMFileList mmfile_list_reverse(MMFileList list);
237 void mmfile_list_free(MMFileList list);
238
239
240
241 /*////////////////////////////////////////////////////////////////////// */
242 /*                            MEMORY DEBUG API                        // */
243 /*////////////////////////////////////////////////////////////////////// */
244 #ifdef __MMFILE_MEM_TRACE__
245 void *mmfile_malloc_debug(unsigned int size, const char *func, unsigned int line);
246 void *mmfile_calloc_debug(unsigned int nmemb, unsigned int size, const char *func, unsigned int line);
247 void  mmfile_free_debug(void *ptr, const char *func, unsigned int line);
248 void *mmfile_realloc_debug(void *ptr, unsigned int size, const char *func, unsigned int line);
249 void *mmfile_memset_debug(void *s, int c, unsigned int n, const char *func, unsigned int line);
250 void *mmfile_memcpy_debug(void *dest, const void *src, unsigned int n, const char *func, unsigned int line);
251 char *mmfile_string_convert_debug(const char *str, unsigned int len, const char *to_codeset, const char *from_codeset,
252                                                                 int *bytes_read,
253                                                                 int *bytes_written,
254                                                                 const char *func,
255                                                                 unsigned int line);
256 char *mmfile_strdup_debug(const char *str, const char *func, unsigned int line);
257
258 #define mmfile_malloc(size)         mmfile_malloc_debug((size), __func__, __LINE__)
259 #define mmfile_calloc(size)         mmfile_calloc_debug((size), __func__, __LINE__)
260 #define mmfile_free(ptr)            do { mmfile_free_debug((ptr), __func__, __LINE__); (ptr) = NULL; } while (0)
261 #define mmfile_realloc(ptr, size)   mmfile_realloc_debug((ptr), (size), __func__, __LINE__)
262 #define mmfile_memset(ptr, c, n)    mmfile_memset_debug((ptr), (c), (n),  __func__, __LINE__)
263 #define mmfile_memcpy(dest, src, n) mmfile_memcpy_debug((ptr), (src), (n), __func__, __LINE__)
264
265 #define mmfile_string_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written) mmfile_string_convert_debug((str), (len), (to_codeset), (from_codeset), (bytes_read), (bytes_written), __func__, __LINE__)
266 #define mmfile_strdup(x)   mmfile_strdup_debug((x), __func__, __LINE__)
267
268 #endif
269
270
271
272 /*////////////////////////////////////////////////////////////////////// */
273 /*                            TAG API                                 // */
274 /*////////////////////////////////////////////////////////////////////// */
275
276 #define MM_FILE_REVERSE_BYTE_ORDER_INT(i) ((int)((((i)&0xFF000000)>>24) | (((i)&0x00FF0000)>>8) | (((i)&0x0000FF00)<<8) | (((i)&0x000000FF)<<24)))
277 #define MM_FILE_REVERSE_BYTE_ORDER_SHORT(s) ((short)((((s)&0xFF00)>>8) | (((s)&0x00FF)<<8)))
278
279 #define _FREE_EX(ptr)               { if ((ptr)) {mmfile_free((ptr)); (ptr) = NULL; } }
280 #define _STRNCPY_EX(dst, src, size)   { if ((size > 0)) {strncpy((char*)(dst), (char*)(src), (size)); *((dst) + (size)) = '\0'; } }
281
282 inline static int __AvMemstr(unsigned char *mem, unsigned char *str, int str_len, int search_range)
283 {
284         int offset = 0;
285         unsigned char *pSrc = mem;
286
287         for (offset = 0; offset < search_range; offset++) {
288                 pSrc = mem + offset;
289                 if (memcmp(pSrc, str, str_len) == 0)
290                         return offset;
291         }
292
293         return -1;
294 }
295
296 #define IS_ID3V2_TAG(x) (((x))[0] == 0x49 && ((x))[1] == 0x44 && ((x))[2] == 0x33)
297 #define IS_INCLUDE_URL(x)       (((x))[0] == 0x2D && ((x))[1] == 0x2D && ((x))[2] == 0x3E)
298 #define IS_INCLUDE_URL_UTF16(x) (((x))[0] == 0x2D && ((x))[1] == NULL && ((x))[2] == 0x2D && ((x))[3] == NULL && ((x))[4] == 0x3E && ((x))[5] == NULL)
299 #define IS_ENCODEDBY_UTF16(x)   (((x))[0] == 0xFF && ((x))[1] == 0xFE)
300 #define IS_ENCODEDBY_UTF16_R(x) (((x))[0] == 0xFE && ((x))[1] == 0xFF)
301
302 #define NEWLINE_OF_UTF16(x)     (((x))[0] == 0xFF && ((x))[1] == 0xFE && ((x))[2] == 0x00 && ((x))[3] == 0x00)
303 #define NEWLINE_OF_UTF16_R(x)   (((x))[0] == 0xFE && ((x))[1] == 0xFF && ((x))[2] == 0x00 && ((x))[3] == 0x00)
304
305
306 #define AV_WM_LOCALCODE_SIZE_MAX                2
307 #define MP3_TAGv2_HEADER_LEN 10
308 #define MP3_TAGv2_23_TXT_HEADER_LEN 10
309 #define MP3_TAGv2_22_TXT_HEADER_LEN 6
310 #define TAGV1_SEEK_GAP 10
311
312
313 typedef enum {
314         AV_ID3V2_PICTURE_TYPE_MIN,
315         AV_ID3V2_PICTURE_TYPE_OTHER = AV_ID3V2_PICTURE_TYPE_MIN,
316         AV_ID3V2_PICTURE_TYPE_PNG_ONLY_FILEICON,
317         AV_ID3V2_PICTURE_TYPE_OTHER_FILEICON,
318         AV_ID3V2_PICTURE_TYPE_FRONT_COVER,
319         AV_ID3V2_PICTURE_TYPE_BACK_COVER,
320         AV_ID3V2_PICTURE_TYPE_LEAFLET_PAGE,
321         AV_ID3V2_PICTURE_TYPE_MEDIA_SIDEOFCD,
322         AV_ID3V2_PICTURE_TYPE_LEAD_ARTIST,
323         AV_ID3V2_PICTURE_TYPE_ARTIST_PERFORMER,
324         AV_ID3V2_PICTURE_TYPE_CONDUCTOR,
325         AV_ID3V2_PICTURE_TYPE_BAND_ORCHESTRA,
326         AV_ID3V2_PICTURE_TYPE_COMPOSER,
327         AV_ID3V2_PICTURE_TYPE_LYRICIST_TEXTWRITER,
328         AV_ID3V2_PICTURE_TYPE_RECORDING_LOCATION,
329         AV_ID3V2_PICTURE_TYPE_DURING_RECORDING,
330         AV_ID3V2_PICTURE_TYPE_DURING_PERFORMANCE,
331         AV_ID3V2_PICTURE_TYPE_MOVIE_VIDEO_SCREEN_CAPTURE,
332         AV_ID3V2_PICTURE_TYPE_BRIGHT_COLOURED_FISH,
333         AV_ID3V2_PICTURE_TYPE_ILLUSTRATION,
334         AV_ID3V2_PICTURE_TYPE_BAND_ARTIST_LOGOTYPE,
335         AV_ID3V2_PICTURE_TYPE_PUBLISHER_STUDIO_LOGOTYPE,
336
337         AV_ID3V2_PICTURE_TYPE_MAX,
338         AV_ID3V2_PICTURE_TYPE_UNKNOWN   = AV_ID3V2_PICTURE_TYPE_MAX /* Unknown picture type */
339
340 } AvID3v2PictureType;
341
342
343 #define MP3TAGINFO_SIZE                                                 128         /* file end 128 byte  */
344 #define MP3_ID3_TITLE_LENGTH                                    30
345 #define MP3_ID3_ARTIST_LENGTH                                   30
346 #define MP3_ID3_ALBUM_LENGTH                                    30
347 #define MP3_ID3_YEAR_LENGTH                                             4
348 #define MP3_ID3_DESCRIPTION_LENGTH                              30
349 #define MP3_ID3_GENRE_LENGTH                                    30
350
351 #define MP3_ID3_TRACKNUM_LENGTH                                 30
352 #define MP3_ID3_ENCBY_LENGTH                                    30
353 #define MP3_ID3_URL_LENGTH                                              100
354 #define MP3_ID3_FRAMEID_LENGTH                                  30
355 #define MP3_ID3_ORIGINARTIST_LENGTH                             30
356 #define MP3_ID3_COMPOSER_LENGTH                                 100
357 #define MP3_ID3_IMAGE_DESCRIPTION_MAX_LENGTH    65
358 #define MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH              31
359 #define MP3_ID3_IMAGE_EXT_MAX_LENGTH                    4
360 #define TCC_FM_PATH_MOUNT_MMC                                   "/Mount/Mmc"
361
362
363
364 typedef enum {
365         AV_ID3V2_ISO_8859 = 0,
366         AV_ID3V2_UTF16,
367         AV_ID3V2_UTF16_BE,
368         AV_ID3V2_UTF8,
369         AV_ID3V2_MAX
370
371 } AvID3v2EncodingType;
372
373
374 typedef struct {
375         char    *pImageBuf;
376         char    *imageDescription;
377         char    imageMIMEType[MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH];
378         char    imageExt[MP3_ID3_IMAGE_EXT_MAX_LENGTH];
379         int             pictureType;
380         int             imageLen;
381         int             imgDesLen;
382         int             imgMimetypeLen;
383         bool    bURLInfo;
384
385 } AvTagVer2ImageInfo;
386
387 typedef struct {
388         int             tagLen;
389         char    tagVersion;
390
391         bool    bTagVer2Found;
392
393         bool    bTitleMarked;
394         bool    bArtistMarked;
395         bool    bAlbumMarked;
396         bool    bAlbum_ArtistMarked;
397         bool    bYearMarked;
398         bool    bDescriptionMarked;
399         bool    bGenreMarked;
400
401         bool    bTrackNumMarked;
402         bool    bEncByMarked;
403         bool    bURLMarked;
404         bool    bCopyRightMarked;
405         bool    bOriginArtistMarked;
406         bool    bComposerMarked;
407         bool    bImageMarked;
408         bool    bRecDateMarked;
409         bool    bContentGroupMarked;
410         bool    bUnsyncLyricsMarked;
411         bool    bSyncLyricsMarked;
412
413         bool    bConductorMarked;
414
415         bool    bGenreUTF16;
416
417 } AvTagVer2AdditionalData;
418
419
420 typedef struct {
421         int             titleLen;
422         int             artistLen;
423         int             authorLen;
424         int             copyrightLen;
425         int             descriptionLen;
426         int             commentLen;
427         int             ratingLen;
428         int             albumLen;
429         int             yearLen;
430         int             genreLen;
431         int             tracknumLen;
432         int             recdateLen;
433         int             conductorLen;
434         int             album_artistLen;
435
436 /* for PC Studio Podcast */
437         int             contentGroupLen;
438
439 /* for ID3V2 Tag */
440         int             encbyLen;
441         int             urlLen;
442         int             originartistLen;
443         int             composerLen;
444         int             unsynclyricsLen;
445         int             syncLyricsNum;
446
447 /* To send resolution info to appl from OEM */
448         int     width;
449         int     height;
450
451         unsigned int    bitRate;
452         unsigned int    sampleRate;
453         unsigned int    channels;
454 /*      unsigned long   creationTime; */
455         long long               duration;
456
457 /* for mp3 Info */
458         char                    *pToc;                  /* VBR??? SeekPosition?? ????? ???? TOC ??????? ?????? ??\EF\BF???? char ?ò÷, 100 ????? ???? */
459         unsigned int    mpegVersion;    /* 1 : mpeg 1,    2 : mpeg 2, 3 : mpeg2.5 */
460         unsigned int    layer;                  /* 1 : layer1, 2 : layer2, 3 : layer3 */
461         unsigned int    channelIndex;   /* 0 : stereo, 1 : joint_stereo, 2 : dual_channel, 3 : mono */
462         unsigned int    objectType;
463         unsigned int    headerType;
464         long long               fileLen;                /* mp3 ?????? ??u ???? */
465         long                    headerPos;              /* mp3 ????\EF\BF?o?????? ??????? ??? */
466         long long               datafileLen;    /* ID3Tag???? ??????? ???? mp3 frame???? ????,  VBR??? XHEADDATA ?? bytes ?? ?????? */
467         int                             frameSize;              /* mp3 frame ?? ???? ??? */
468         int                             frameNum;               /* mp3 ????? ???????? ?? ?????¡Æ\EF\BF? */
469         bool                    bVbr;                   /* VBR mp3? */
470         bool                    bPadding;               /* Padding? */
471         bool                    bV1tagFound;
472
473         char                    *pTitle;                /*Title/songname/ */
474         char                    *pArtist;               /*Lead performer(s)/Soloist(s), */
475         char                    *pAuthor;               /*Author */
476         char                    *pCopyright;
477         char                    *pDescription;
478         char                    *pComment;
479         char                    *pRating;
480         char                    *pAlbum;                /*Album/Movie/ */
481         char                    *pAlbum_Artist;
482         char                    *pYear;
483         char                    *pGenre;
484         char                    *pTrackNum;             /*Track number/Position in set */
485         char                    *pRecDate;              /*Recording dates */
486
487         char                    *pConductor;            /*[#TPE3 Conductor/performer refinement], ADDED: 2010-01-xx*/
488
489 /* for PC Studio Podcast */
490         char                    *pContentGroup;
491
492 /* for ID3V2 Tag */
493         char                    *pEncBy;                                /*Encoded by */
494         char                    *pURL;                                  /*User defined URL link frame for ID3V2 Tag */
495         char                    *pOriginArtist;                 /*Original artist(s)/performer(s) */
496         char                    *pComposer;                             /*Composer */
497         char                    *pUnsyncLyrics;                 /*Unsychronised lyrics/text transcription */
498         GList           *pSyncLyrics;                           /*Sychronised lyrics/text */
499
500         AvTagVer2ImageInfo                      imageInfo;      /*Album art   attached feature */
501         AvTagVer2AdditionalData         tagV2Info; /*Needed data for ID3 tag parsing */
502
503 /*for ID3V1 Tag */
504         unsigned char   genre;
505
506 } AvFileContentInfo;
507
508 typedef struct {
509         int             videocodec;
510         int             audiocodec;
511         int             width;
512         int             height;
513 } AvExtraInfo;
514
515 typedef struct {
516         unsigned long   time_info;
517         char                            *lyric_info;
518 } AvSynclyricsInfo;
519
520 void mm_file_free_synclyrics_list(GList *synclyrics_list);
521
522 inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo)
523 {
524         if (pInfo) {
525                 if (pInfo->pToc) mmfile_free(pInfo->pToc);
526                 if (pInfo->pTitle) mmfile_free(pInfo->pTitle);
527                 if (pInfo->pArtist) mmfile_free(pInfo->pArtist);
528                 if (pInfo->pAuthor) mmfile_free(pInfo->pAuthor);
529                 if (pInfo->pCopyright) mmfile_free(pInfo->pCopyright);
530                 if (pInfo->pDescription) mmfile_free(pInfo->pDescription);
531                 if (pInfo->pComment) mmfile_free(pInfo->pComment);
532                 if (pInfo->pRating) mmfile_free(pInfo->pRating);
533                 if (pInfo->pAlbum) mmfile_free(pInfo->pAlbum);
534                 if (pInfo->pAlbum_Artist) mmfile_free(pInfo->pAlbum_Artist);
535                 if (pInfo->pYear) mmfile_free(pInfo->pYear);
536                 if (pInfo->pGenre) mmfile_free(pInfo->pGenre);
537                 if (pInfo->pTrackNum) mmfile_free(pInfo->pTrackNum);
538                 if (pInfo->pRecDate) mmfile_free(pInfo->pRecDate);
539                 if (pInfo->pConductor) mmfile_free(pInfo->pConductor);
540                 if (pInfo->pContentGroup) mmfile_free(pInfo->pContentGroup);
541                 if (pInfo->pEncBy) mmfile_free(pInfo->pEncBy);
542                 if (pInfo->pURL) mmfile_free(pInfo->pURL);
543                 if (pInfo->pOriginArtist) mmfile_free(pInfo->pOriginArtist);
544                 if (pInfo->pComposer) mmfile_free(pInfo->pComposer);
545                 if (pInfo->pUnsyncLyrics) mmfile_free(pInfo->pUnsyncLyrics);
546                 if (pInfo->imageInfo.pImageBuf) mmfile_free(pInfo->imageInfo.pImageBuf);
547                 if (pInfo->imageInfo.imageDescription) mmfile_free(pInfo->imageInfo.imageDescription);
548                 if (strlen(pInfo->imageInfo.imageMIMEType) > 0) memset(pInfo->imageInfo.imageMIMEType, 0, MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH);
549         }
550 }
551
552
553 bool    mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo, unsigned char *buffer);  /*20050401 Condol : for MP3 content Info. */
554 bool    mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer);
555 bool    mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer);
556 bool    mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer);
557 void    mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo);
558 int             MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext);
559
560
561 #ifdef __cplusplus
562 }
563 #endif
564
565 #endif /*_MMFILE_UTILS_H_*/
566