41da0e266e2ef279e20677d7d6b1b9831c5edba3
[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
104
105 /*////////////////////////////////////////////////////////////////////// */
106 /*                       IO HANDLER API                               // */
107 /*////////////////////////////////////////////////////////////////////// */
108 #define MMFILE_URI_MAX_LEN     512
109 #define MMFILE_FILE_URI        "file://"
110 #define MMFILE_FILE_URI_LEN    7
111 #define MMFILE_MEM_URI         "mem://"
112 #define MMFILE_MEM_URI_LEN     6
113 #define MMFILE_MMAP_URI        "mmap://"
114 #define MMFILE_MMAP_URI_LEN    7
115
116 #define MMFILE_RDONLY           O_RDONLY
117 #define MMFILE_WRONLY           O_WRONLY
118 #define MMFILE_RDWR                     O_RDWR
119
120 #define MMFILE_SEEK_SET         SEEK_SET
121 #define MMFILE_SEEK_CUR         SEEK_CUR
122 #define MMFILE_SEEK_END         SEEK_END
123
124 typedef struct MMFileIOFunc {
125         const char      *handleName;
126         int     (*mmfile_open)(MMFileIOHandle *h, const char *filename, int flags);
127         int     (*mmfile_read)(MMFileIOHandle *h, unsigned char *buf, int size);
128         int     (*mmfile_write)(MMFileIOHandle *h, unsigned char *buf, int size);
129         int64_t(*mmfile_seek)(MMFileIOHandle *h, int64_t pos, int whence);
130         long long(*mmfile_tell)(MMFileIOHandle *h);
131         int     (*mmfile_close)(MMFileIOHandle *h);
132         struct MMFileIOFunc *next;
133 } MMFileIOFunc;
134
135
136 int mmfile_register_io_func(MMFileIOFunc *iofunc);
137 int mmfile_register_io_all();
138
139 int                     mmfile_open(MMFileIOHandle **h, const char *filename, int flags);
140 int                     mmfile_read(MMFileIOHandle *h, unsigned char *buf, int size);
141 int                     mmfile_write(MMFileIOHandle *h, unsigned char *buf, int size);
142 int64_t         mmfile_seek(MMFileIOHandle *h, int64_t pos, int whence);
143 long long       mmfile_tell(MMFileIOHandle *h);
144 int                     mmfile_close(MMFileIOHandle *h);
145
146
147
148 /*////////////////////////////////////////////////////////////////////// */
149 /*                            MIME  API                               // */
150 /*////////////////////////////////////////////////////////////////////// */
151 #define MMFILE_FILE_FMT_MAX_LEN 25
152 #define MMFILE_MIMETYPE_MAX_LEN 40
153 #define MMFILE_FILE_EXT_MAX_LEN 7
154
155 int mmfile_util_get_ffmpeg_format(const char *mime, char *ffmpegFormat);
156 int mmfile_util_get_file_ext(const char *mime, char *ext);
157
158
159
160 /*////////////////////////////////////////////////////////////////////// */
161 /*                            PRINT API                               // */
162 /*////////////////////////////////////////////////////////////////////// */
163 void mmfile_format_print_contents(MMFileFormatContext *in);
164 void mmfile_format_print_tags(MMFileFormatContext *in);
165 void mmfile_codec_print(MMFileCodecContext *in);
166 void mmfile_format_print_frame(MMFileFormatFrame *in);
167
168
169
170
171 /*////////////////////////////////////////////////////////////////////// */
172 /*                            STRING API                              // */
173 /*////////////////////////////////////////////////////////////////////// */
174 char **mmfile_strsplit(const char *string, const char *delimiter);
175 void mmfile_strfreev(char **str_array);
176 int  mmfile_util_wstrlen(unsigned short *wText);
177 short *mmfile_swap_2byte_string(short *mszOutput, short *mszInput, int length);
178 char *mmfile_get_charset(const char *str);
179 char *mmfile_string_convert(const char *str, unsigned int len,
180                             const char *to_codeset, const char *from_codeset,
181                             gsize *bytes_read,
182                             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,
207                               unsigned char *dst, eMMFilePixelFormat dst_fmt, int dst_width, int dst_height);
208
209
210
211 /*////////////////////////////////////////////////////////////////////// */
212 /*                            MEMORY API                              // */
213 /*////////////////////////////////////////////////////////////////////// */
214 void *mmfile_malloc(unsigned int size);
215 #define mmfile_free(ptr)  do { if((ptr)) { mmfile_free_r((ptr)); (ptr) = NULL;} } while (0)
216 void  mmfile_free_r(void *ptr);
217 void *mmfile_realloc(void *ptr, unsigned int size);
218 void *mmfile_memset(void *s, int c, unsigned int n);
219 void *mmfile_memcpy(void *dest, const void *src, unsigned int n);
220
221 /*////////////////////////////////////////////////////////////////////// */
222 /*                        DATA STRUCTURE API                          // */
223 /*////////////////////////////////////////////////////////////////////// */
224 typedef void *MMFileList;
225 MMFileList mmfile_list_alloc();
226 MMFileList mmfile_list_append(MMFileList list, void *data);
227 MMFileList mmfile_list_prepend(MMFileList list, void *data);
228 MMFileList mmfile_list_find(MMFileList list, void *data);
229 MMFileList mmfile_list_first(MMFileList list);
230 MMFileList mmfile_list_last(MMFileList list);
231 MMFileList mmfile_list_nth(MMFileList list, unsigned int n);
232 MMFileList mmfile_list_next(MMFileList list);
233 MMFileList mmfile_list_previous(MMFileList list);
234 unsigned int mmfile_list_length(MMFileList list);
235 MMFileList mmfile_list_remove(MMFileList list, void *data);
236 MMFileList mmfile_list_remove_all(MMFileList list, void *data);
237 MMFileList mmfile_list_reverse(MMFileList list);
238 void mmfile_list_free(MMFileList list);
239
240
241
242 /*////////////////////////////////////////////////////////////////////// */
243 /*                            MEMORY DEBUG API                        // */
244 /*////////////////////////////////////////////////////////////////////// */
245 #ifdef __MMFILE_MEM_TRACE__
246 void *mmfile_malloc_debug(unsigned int size, const char *func, unsigned int line);
247 void *mmfile_calloc_debug(unsigned int nmemb, unsigned int size, const char *func, unsigned int line);
248 void  mmfile_free_debug(void *ptr, const char *func, unsigned int line);
249 void *mmfile_realloc_debug(void *ptr, unsigned int size, const char *func, unsigned int line);
250 void *mmfile_memset_debug(void *s, int c, unsigned int n, const char *func, unsigned int line);
251 void *mmfile_memcpy_debug(void *dest, const void *src, unsigned int n, const char *func, unsigned int line);
252
253 char *mmfile_string_convert_debug(const char *str, unsigned int len,
254                                   const char *to_codeset, const char *from_codeset,
255                                   int *bytes_read,
256                                   int *bytes_written,
257                                   const char *func,
258                                   unsigned int line);
259 char *mmfile_strdup_debug(const char *str, const char *func, unsigned int line);
260
261 #define mmfile_malloc(size)         mmfile_malloc_debug((size), __func__, __LINE__)
262 #define mmfile_calloc(size)         mmfile_calloc_debug((size), __func__, __LINE__)
263 #define mmfile_free(ptr)            do { mmfile_free_debug((ptr), __func__, __LINE__); (ptr) = NULL; } while (0)
264 #define mmfile_realloc(ptr, size)   mmfile_realloc_debug((ptr), (size), __func__, __LINE__)
265 #define mmfile_memset(ptr, c, n)    mmfile_memset_debug((ptr), (c), (n),  __func__, __LINE__)
266 #define mmfile_memcpy(dest, src, n) mmfile_memcpy_debug((ptr), (src), (n), __func__, __LINE__)
267
268 #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__)
269 #define mmfile_strdup(x)   mmfile_strdup_debug((x), __func__, __LINE__)
270
271 #endif
272
273
274
275 /*////////////////////////////////////////////////////////////////////// */
276 /*                            TAG API                                 // */
277 /*////////////////////////////////////////////////////////////////////// */
278
279 #define MM_FILE_REVERSE_BYTE_ORDER_INT(i) ((int)((((i)&0xFF000000)>>24) | (((i)&0x00FF0000)>>8) | (((i)&0x0000FF00)<<8) | (((i)&0x000000FF)<<24)))
280 #define MM_FILE_REVERSE_BYTE_ORDER_SHORT(s) ((short)((((s)&0xFF00)>>8) | (((s)&0x00FF)<<8)))
281
282 #define _FREE_EX(ptr)               { if ((ptr)) {mmfile_free ((ptr)); (ptr) = NULL;} }
283 #define _STRNCPY_EX(dst,src,size)   { if ((size>0)) {strncpy((char*)(dst), (char*)(src),(size)); *((dst) + (size)) = '\0';}}
284
285 inline static int __AvMemstr(unsigned char *mem, unsigned char *str, int str_len, int search_range)
286 {
287         int offset = 0;
288         unsigned char *pSrc = mem;
289
290         for (offset = 0; offset < search_range; offset++) {
291                 pSrc = mem + offset;
292                 if (memcmp(pSrc, str, str_len) == 0)
293                         return offset;
294         }
295
296         return -1;
297 }
298
299 #define IS_ID3V2_TAG(x) (((x))[0] == 0x49 && ((x))[1] == 0x44 && ((x))[2] == 0x33)
300 #define IS_INCLUDE_URL(x)       (((x))[0] == 0x2D && ((x))[1] == 0x2D && ((x))[2] == 0x3E)
301 #define IS_INCLUDE_URL_UTF16(x) (((x))[0] == 0x2D && ((x))[1] == NULL && ((x))[2] == 0x2D && ((x))[3] == NULL && ((x))[4] == 0x3E && ((x))[5] == NULL)
302 #define IS_ENCODEDBY_UTF16(x)   (((x))[0] == 0xFF && ((x))[1] == 0xFE)
303 #define IS_ENCODEDBY_UTF16_R(x) (((x))[0] == 0xFE && ((x))[1] == 0xFF)
304
305 #define NEWLINE_OF_UTF16(x)     (((x))[0] == 0xFF && ((x))[1] == 0xFE && ((x))[2] == 0x00 && ((x))[3] == 0x00)
306 #define NEWLINE_OF_UTF16_R(x)   (((x))[0] == 0xFE && ((x))[1] == 0xFF && ((x))[2] == 0x00 && ((x))[3] == 0x00)
307
308
309 #define AV_WM_LOCALCODE_SIZE_MAX                2
310 #define MP3_TAGv2_HEADER_LEN 10
311 #define MP3_TAGv2_23_TXT_HEADER_LEN 10
312 #define MP3_TAGv2_22_TXT_HEADER_LEN 6
313 #define TAGV1_SEEK_GAP 10
314
315
316 typedef enum {
317         AV_ID3V2_PICTURE_TYPE_MIN,
318         AV_ID3V2_PICTURE_TYPE_OTHER = AV_ID3V2_PICTURE_TYPE_MIN,
319         AV_ID3V2_PICTURE_TYPE_PNG_ONLY_FILEICON,
320         AV_ID3V2_PICTURE_TYPE_OTHER_FILEICON,
321         AV_ID3V2_PICTURE_TYPE_FRONT_COVER,
322         AV_ID3V2_PICTURE_TYPE_BACK_COVER,
323         AV_ID3V2_PICTURE_TYPE_LEAFLET_PAGE,
324         AV_ID3V2_PICTURE_TYPE_MEDIA_SIDEOFCD,
325         AV_ID3V2_PICTURE_TYPE_LEAD_ARTIST,
326         AV_ID3V2_PICTURE_TYPE_ARTIST_PERFORMER,
327         AV_ID3V2_PICTURE_TYPE_CONDUCTOR,
328         AV_ID3V2_PICTURE_TYPE_BAND_ORCHESTRA,
329         AV_ID3V2_PICTURE_TYPE_COMPOSER,
330         AV_ID3V2_PICTURE_TYPE_LYRICIST_TEXTWRITER,
331         AV_ID3V2_PICTURE_TYPE_RECORDING_LOCATION,
332         AV_ID3V2_PICTURE_TYPE_DURING_RECORDING,
333         AV_ID3V2_PICTURE_TYPE_DURING_PERFORMANCE,
334         AV_ID3V2_PICTURE_TYPE_MOVIE_VIDEO_SCREEN_CAPTURE,
335         AV_ID3V2_PICTURE_TYPE_BRIGHT_COLOURED_FISH,
336         AV_ID3V2_PICTURE_TYPE_ILLUSTRATION,
337         AV_ID3V2_PICTURE_TYPE_BAND_ARTIST_LOGOTYPE,
338         AV_ID3V2_PICTURE_TYPE_PUBLISHER_STUDIO_LOGOTYPE,
339
340         AV_ID3V2_PICTURE_TYPE_MAX,
341         AV_ID3V2_PICTURE_TYPE_UNKNOWN   = AV_ID3V2_PICTURE_TYPE_MAX /* Unknown picture type */
342
343 } AvID3v2PictureType;
344
345
346 #define MP3TAGINFO_SIZE                                                 128         /* file end 128 byte  */
347 #define MP3_ID3_TITLE_LENGTH                                    30
348 #define MP3_ID3_ARTIST_LENGTH                                   30
349 #define MP3_ID3_ALBUM_LENGTH                                    30
350 #define MP3_ID3_YEAR_LENGTH                                             4
351 #define MP3_ID3_DESCRIPTION_LENGTH                              30
352 #define MP3_ID3_GENRE_LENGTH                                    30
353
354 #define MP3_ID3_TRACKNUM_LENGTH                                 30
355 #define MP3_ID3_ENCBY_LENGTH                                    30
356 #define MP3_ID3_URL_LENGTH                                              100
357 #define MP3_ID3_FRAMEID_LENGTH                                  30
358 #define MP3_ID3_ORIGINARTIST_LENGTH                             30
359 #define MP3_ID3_COMPOSER_LENGTH                                 100
360 #define MP3_ID3_IMAGE_DESCRIPTION_MAX_LENGTH    65
361 #define MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH              31
362 #define MP3_ID3_IMAGE_EXT_MAX_LENGTH                    4
363 #define TCC_FM_PATH_MOUNT_MMC                                   "/Mount/Mmc"
364
365
366
367 typedef enum {
368         AV_ID3V2_ISO_8859 = 0,
369         AV_ID3V2_UTF16,
370         AV_ID3V2_UTF16_BE,
371         AV_ID3V2_UTF8,
372         AV_ID3V2_MAX
373
374 } AvID3v2EncodingType;
375
376
377 typedef struct {
378         char    *pImageBuf;
379         char    *imageDescription;
380         char    imageMIMEType[MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH];
381         char    imageExt[MP3_ID3_IMAGE_EXT_MAX_LENGTH];
382         int             pictureType;
383         int             imageLen;
384         int             imgDesLen;
385         int     imgMimetypeLen;
386         bool    bURLInfo;
387
388 } AvTagVer2ImageInfo;
389
390 typedef struct {
391         int             tagLen;
392         char    tagVersion;
393
394         bool    bTagVer2Found;
395
396         bool    bTitleMarked;
397         bool    bArtistMarked;
398         bool    bAlbumMarked;
399         bool    bAlbum_ArtistMarked;
400         bool    bYearMarked;
401         bool    bDescriptionMarked;
402         bool    bGenreMarked;
403
404         bool    bTrackNumMarked;
405         bool    bEncByMarked;
406         bool    bURLMarked;
407         bool    bCopyRightMarked;
408         bool    bOriginArtistMarked;
409         bool    bComposerMarked;
410         bool    bImageMarked;
411         bool    bRecDateMarked;
412         bool    bContentGroupMarked;
413         bool    bUnsyncLyricsMarked;
414         bool    bSyncLyricsMarked;
415
416         bool    bConductorMarked;
417
418         bool    bGenreUTF16;
419
420 } AvTagVer2AdditionalData;
421
422
423 typedef struct {
424         int             titleLen;
425         int             artistLen;
426         int             authorLen;
427         int             copyrightLen;
428         int             descriptionLen;
429         int             commentLen;
430         int             ratingLen;
431         int             albumLen;
432         int             yearLen;
433         int             genreLen;
434         int             tracknumLen;
435         int             recdateLen;
436         int             conductorLen;
437         int             album_artistLen;
438
439 /* for PC Studio Podcast */
440         int     contentGroupLen;
441
442 /* for ID3V2 Tag */
443         int             encbyLen;
444         int             urlLen;
445         int             originartistLen;
446         int             composerLen;
447         int             unsynclyricsLen;
448         int             syncLyricsNum;
449
450 /* To send resolution info to appl from OEM */
451         int     width;
452         int     height;
453
454         unsigned int    bitRate;
455         unsigned int    sampleRate;
456         unsigned int    channels;
457 /*      unsigned long   creationTime; */
458         long long               duration;
459
460 /* for mp3 Info */
461         char                    *pToc;                  /* VBR??? SeekPosition?? ????? ???? TOC ??????? ?????? ??\EF\BF???? char ?ò÷, 100 ????? ???? */
462         unsigned int    mpegVersion;    /* 1 : mpeg 1,    2 : mpeg 2, 3 : mpeg2.5 */
463         unsigned int    layer;                  /* 1 : layer1, 2 : layer2, 3 : layer3 */
464         unsigned int    channelIndex;   /* 0 : stereo, 1 : joint_stereo, 2 : dual_channel, 3 : mono */
465         unsigned int    objectType;
466         unsigned int    headerType;
467         long long               fileLen;                /* mp3 ?????? ??u ???? */
468         long                    headerPos;              /* mp3 ????\EF\BF?o?????? ??????? ??? */
469         long long               datafileLen;    /* ID3Tag???? ??????? ???? mp3 frame???? ????,  VBR??? XHEADDATA ?? bytes ?? ?????? */
470         int                             frameSize;              /* mp3 frame ?? ???? ??? */
471         int                             frameNum;               /* mp3 ????? ???????? ?? ?????¡Æ\EF\BF? */
472         bool                    bVbr;                   /* VBR mp3? */
473         bool                    bPadding;               /* Padding? */
474         bool                    bV1tagFound;
475
476         char                    *pTitle;                /*Title/songname/ */
477         char                    *pArtist;               /*Lead performer(s)/Soloist(s), */
478         char                    *pAuthor;               /*Author */
479         char                    *pCopyright;
480         char                    *pDescription;
481         char                    *pComment;
482         char                    *pRating;
483         char                    *pAlbum;                /*Album/Movie/ */
484         char                    *pAlbum_Artist;
485         char                    *pYear;
486         char                    *pGenre;
487         char                    *pTrackNum;             /*Track number/Position in set */
488         char                    *pRecDate;              /*Recording dates */
489
490         char                    *pConductor;            /*[#TPE3 Conductor/performer refinement], ADDED: 2010-01-xx*/
491
492 /* for PC Studio Podcast */
493         char                    *pContentGroup;
494
495 /* for ID3V2 Tag */
496         char                    *pEncBy;                                /*Encoded by */
497         char                    *pURL;                                  /*User defined URL link frame for ID3V2 Tag */
498         char                    *pOriginArtist;                 /*Original artist(s)/performer(s) */
499         char                    *pComposer;                             /*Composer */
500         char                    *pUnsyncLyrics;                 /*Unsychronised lyrics/text transcription */
501         GList           *pSyncLyrics;                           /*Sychronised lyrics/text */
502
503         AvTagVer2ImageInfo                      imageInfo;      /*Album art   attached feature */
504         AvTagVer2AdditionalData         tagV2Info; /*Needed data for ID3 tag parsing */
505
506 /*for ID3V1 Tag */
507         unsigned char   genre;
508
509 } AvFileContentInfo;
510
511 typedef struct {
512         int             videocodec;
513         int             audiocodec;
514         int     width;
515         int     height;
516 } AvExtraInfo;
517
518 typedef struct {
519         unsigned long   time_info;
520         char                    *lyric_info;
521 } AvSynclyricsInfo;
522
523 void mm_file_free_synclyrics_list(GList *synclyrics_list);
524
525 inline static void mm_file_free_AvFileContentInfo(AvFileContentInfo *pInfo)
526 {
527         if (pInfo) {
528                 if (pInfo->pToc) mmfile_free(pInfo->pToc);
529                 if (pInfo->pTitle) mmfile_free(pInfo->pTitle);
530                 if (pInfo->pArtist) mmfile_free(pInfo->pArtist);
531                 if (pInfo->pAuthor) mmfile_free(pInfo->pAuthor);
532                 if (pInfo->pCopyright) mmfile_free(pInfo->pCopyright);
533                 if (pInfo->pDescription) mmfile_free(pInfo->pDescription);
534                 if (pInfo->pComment) mmfile_free(pInfo->pComment);
535                 if (pInfo->pRating) mmfile_free(pInfo->pRating);
536                 if (pInfo->pAlbum) mmfile_free(pInfo->pAlbum);
537                 if (pInfo->pAlbum_Artist) mmfile_free(pInfo->pAlbum_Artist);
538                 if (pInfo->pYear) mmfile_free(pInfo->pYear);
539                 if (pInfo->pGenre) mmfile_free(pInfo->pGenre);
540                 if (pInfo->pTrackNum) mmfile_free(pInfo->pTrackNum);
541                 if (pInfo->pRecDate) mmfile_free(pInfo->pRecDate);
542                 if (pInfo->pConductor) mmfile_free(pInfo->pConductor);
543                 if (pInfo->pContentGroup) mmfile_free(pInfo->pContentGroup);
544                 if (pInfo->pEncBy) mmfile_free(pInfo->pEncBy);
545                 if (pInfo->pURL) mmfile_free(pInfo->pURL);
546                 if (pInfo->pOriginArtist) mmfile_free(pInfo->pOriginArtist);
547                 if (pInfo->pComposer) mmfile_free(pInfo->pComposer);
548                 if (pInfo->pUnsyncLyrics) mmfile_free(pInfo->pUnsyncLyrics);
549                 if (pInfo->imageInfo.pImageBuf) mmfile_free(pInfo->imageInfo.pImageBuf);
550                 if (pInfo->imageInfo.imageDescription) mmfile_free(pInfo->imageInfo.imageDescription);
551                 if (strlen(pInfo->imageInfo.imageMIMEType) > 0) memset(pInfo->imageInfo.imageMIMEType, 0, MP3_ID3_IMAGE_MIME_TYPE_MAX_LENGTH);
552         }
553 }
554
555
556 bool    mm_file_id3tag_parse_v110(AvFileContentInfo *pInfo, unsigned char *buffer);  /*20050401 Condol : for MP3 content Info. */
557 bool    mm_file_id3tag_parse_v222(AvFileContentInfo *pInfo, unsigned char *buffer);
558 bool    mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer);
559 bool    mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer);
560 void    mm_file_id3tag_restore_content_info(AvFileContentInfo *pInfo);
561 int             MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext);
562
563
564 #ifdef __cplusplus
565 }
566 #endif
567
568 #endif /*_MMFILE_UTILS_H_*/
569