4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Haejeong Kim <backto.kim@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <unistd.h> /*for access*/
25 #include <string.h> /*for strXXX*/
28 /* exported MM header files */
33 /* internal MM header files */
34 #include <mm_attrs_private.h>
36 /* internal MM File headers */
37 #include "mm_file_debug.h"
38 #include "mm_file_formats.h"
39 #include "mm_file_format_frame.h"
40 #include "mm_file_codecs.h"
41 #include "mm_file_utils.h"
46 /*#define CHECK_TIME */
52 gettimeofday(&tv, NULL);
53 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
63 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
66 #define _SEEK_POINT_ 3000 /*1000 = 1 seconds*/
68 #define MM_FILE_TAG_SYNCLYRICS "tag-synclyrics" /**< Synchronized Lyrics Information*/
78 MM_FILE_PARSE_TYPE_SIMPLE, /*parse audio/video track num only*/
79 MM_FILE_PARSE_TYPE_NORMAL, /*parse infomation without thumbnail*/
80 MM_FILE_PARSE_TYPE_ALL, /*parse all infomation*/
81 MM_FILE_PARSE_TYPE_SAFE, /*parse infomation without both thumbnail and stream full-searching*/
92 void *formatFuncHandle;
93 void *codecFuncHandle;
101 static mmf_attrs_construct_info_t g_tag_attrs[] = {
102 {(char *)"tag-artist", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
103 {(char *)"tag-title", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
104 {(char *)"tag-album", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
105 {(char *)"tag-album-artist", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
106 {(char *)"tag-genre", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
107 {(char *)"tag-author", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
108 {(char *)"tag-copyright", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
109 {(char *)"tag-date", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
110 {(char *)"tag-description", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
111 {(char *)"tag-comment", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
112 {(char *)"tag-artwork", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
113 {(char *)"tag-artwork-size", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
114 {(char *)"tag-artwork-mime", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
115 {(char *)"tag-track-num", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
116 {(char *)"tag-classification", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
117 {(char *)"tag-rating", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
118 {(char *)"tag-longitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
119 {(char *)"tag-latitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
120 {(char *)"tag-altitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
121 {(char *)"tag-conductor", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
122 {(char *)"tag-unsynclyrics", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
123 {(char *)"tag-synclyrics-num", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
124 {(char *)"tag-synclyrics", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
125 {(char *)"tag-recdate", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
126 {(char *)"tag-rotate", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
127 {(char *)"tag-cdis", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
128 {(char *)"tag-smta", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
131 static mmf_attrs_construct_info_t g_content_attrs[] = {
132 {(char *)"content-duration", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
133 {(char *)"content-video-codec", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
134 {(char *)"content-video-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
135 {(char *)"content-video-fps", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
136 {(char *)"content-video-width", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
137 {(char *)"content-video-height", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
138 {(char *)"content-video-thumbnail", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
139 {(char *)"content-video-track-index", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
140 {(char *)"content-video-track-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
141 {(char *)"content-audio-codec", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
142 {(char *)"content-audio-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
143 {(char *)"content-audio-channels", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
144 {(char *)"content-audio-samplerate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
145 {(char *)"content-audio-track-index", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
146 {(char *)"content-audio-track-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
147 {(char *)"content-audio-bitpersample", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
150 #ifdef __MMFILE_DYN_LOADING__
151 #define MMFILE_FORMAT_SO_FILE_NAME "libmmfile_formats.so"
152 #define MMFILE_CODEC_SO_FILE_NAME "libmmfile_codecs.so"
154 int (*mmfile_format_open)(MMFileFormatContext **formatContext, MMFileSourceType *fileSrc);
155 int (*mmfile_format_read_stream)(MMFileFormatContext *formatContext);
156 int (*mmfile_format_read_frame)(MMFileFormatContext *formatContext, unsigned int timestamp, MMFileFormatFrame *frame);
157 int (*mmfile_format_read_tag)(MMFileFormatContext *formatContext);
158 int (*mmfile_format_close)(MMFileFormatContext *formatContext);
159 int (*mmfile_codec_open)(MMFileCodecContext **codecContext, int codecType, int codecId, MMFileCodecFrame *input);
160 int (*mmfile_codec_decode)(MMFileCodecContext *codecContext, MMFileCodecFrame *output);
161 int (*mmfile_codec_close)(MMFileCodecContext *codecContext);
162 int (*mmfile_format_get_frame)(const char *path, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height);
163 int (*mmfile_format_get_frame_from_memory)(const void *data, unsigned int datasize, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height);
166 #ifdef __MMFILE_DYN_LOADING__
167 static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
169 /* static int dll_func_initialized = 0; //disabled */
173 /* Get from function argument */
174 void *formatFuncHandle = NULL;
175 void *codecFuncHandle = NULL;
178 if (dll_func_initialized) {
183 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
184 if (!formatFuncHandle) {
185 debug_error("error: %s\n", "libmmfile_formats.so open error");
190 mmfile_format_open = dlsym(formatFuncHandle, "mmfile_format_open");
191 mmfile_format_read_stream = dlsym(formatFuncHandle, "mmfile_format_read_stream");
192 mmfile_format_read_frame = dlsym(formatFuncHandle, "mmfile_format_read_frame");
193 mmfile_format_read_tag = dlsym(formatFuncHandle, "mmfile_format_read_tag");
194 mmfile_format_close = dlsym(formatFuncHandle, "mmfile_format_close");
196 if (!mmfile_format_open ||
197 !mmfile_format_read_stream ||
198 !mmfile_format_read_frame ||
199 !mmfile_format_read_tag ||
200 !mmfile_format_close) {
202 debug_error("error: %s\n", "format function load error");
207 /*closed at app termination.*/
208 /*dlclose (formatFuncHandle); */
210 codecFuncHandle = dlopen(MMFILE_CODEC_SO_FILE_NAME, RTLD_LAZY | RTLD_GLOBAL);
211 if (!codecFuncHandle) {
212 debug_error("error: %s\n", "libmmfile_codecs.so open error");
217 mmfile_codec_open = dlsym(codecFuncHandle, "mmfile_codec_open");
218 mmfile_codec_decode = dlsym(codecFuncHandle, "mmfile_codec_decode");
219 mmfile_codec_close = dlsym(codecFuncHandle, "mmfile_codec_close");
221 if (!mmfile_codec_open || !mmfile_codec_decode || !mmfile_codec_close) {
222 debug_error("error: %s\n", "codec function load error");
227 /*closed at app termination.*/
228 /*dlclose (codecFuncHandle); */
230 /* dll_func_initialized = 1; // disabled */
232 pHandle->codecFuncHandle = codecFuncHandle;
233 pHandle->formatFuncHandle = formatFuncHandle;
238 if (formatFuncHandle) dlclose(formatFuncHandle);
239 if (codecFuncHandle) dlclose(codecFuncHandle);
244 static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
246 #ifdef __MMFILE_TEST_MODE__
250 if (pHandle->formatFuncHandle) {
251 dlclose(pHandle->formatFuncHandle);
253 if (pHandle->codecFuncHandle) {
254 dlclose(pHandle->codecFuncHandle);
257 #ifdef __MMFILE_TEST_MODE__
263 #endif /* __MMFILE_DYN_LOADING__ */
269 _is_file_exist(const char *filename)
273 const char *to_access = (strstr(filename, "file://") != NULL) ? filename + 7 : filename;
274 ret = access(to_access, R_OK);
276 debug_error("file [%s] not found.\n", to_access);
283 _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
286 MMHandleType hattrs = CAST_MM_HANDLE(attrs);
288 if (formatContext->commandType == MM_FILE_TAG) {
289 if (formatContext->title) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_TITLE, formatContext->title);
290 if (formatContext->artist) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ARTIST, formatContext->artist);
291 if (formatContext->author) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_AUTHOR, formatContext->author);
292 if (formatContext->composer && formatContext->author == NULL)
293 mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_AUTHOR, formatContext->composer);
294 if (formatContext->album) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ALBUM, formatContext->album);
295 if (formatContext->album_artist) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ALBUM_ARTIST, formatContext->album_artist);
296 if (formatContext->copyright) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_COPYRIGHT, formatContext->copyright);
297 if (formatContext->description) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_DESCRIPTION, formatContext->description);
298 if (formatContext->comment) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_COMMENT, formatContext->comment);
299 if (formatContext->genre) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_GENRE, formatContext->genre);
300 if (formatContext->classification) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_CLASSIFICATION, formatContext->classification);
301 if (formatContext->year) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_DATE, formatContext->year);
302 if (formatContext->tagTrackNum) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_TRACK_NUM, formatContext->tagTrackNum);
303 if (formatContext->rating) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_RATING, formatContext->rating);
304 if (formatContext->conductor) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_CONDUCTOR, formatContext->conductor);
305 if (formatContext->recDate) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_RECDATE, formatContext->recDate);
306 if (formatContext->rotate) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ROTATE, formatContext->rotate);
307 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_LONGITUDE, formatContext->longitude);
308 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_LATIDUE, formatContext->latitude);
309 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_ALTIDUE, formatContext->altitude);
310 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SYNCLYRICS_NUM, formatContext->syncLyricsNum);
311 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_CDIS, formatContext->cdis);
312 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SMTA, formatContext->smta);
314 if ((formatContext->syncLyricsNum > 0) && (formatContext->syncLyrics))
315 mm_attrs_set_data_by_name(hattrs, MM_FILE_TAG_SYNCLYRICS, formatContext->syncLyrics, formatContext->syncLyricsNum);
317 if (formatContext->unsyncLyrics) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_UNSYNCLYRICS, formatContext->unsyncLyrics);
319 if (formatContext->artwork && formatContext->artworkSize > 0) {
320 void *artworkCopy = NULL;
321 artworkCopy = mmfile_malloc((formatContext->artworkSize));
322 if (NULL != artworkCopy) {
323 memcpy(artworkCopy, formatContext->artwork, formatContext->artworkSize);
324 mm_attrs_set_data_by_name(hattrs, MM_FILE_TAG_ARTWORK, artworkCopy, formatContext->artworkSize);
325 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_ARTWORK_SIZE, formatContext->artworkSize);
326 if (formatContext->artworkMime) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ARTWORK_MIME, formatContext->artworkMime);
329 } else if (formatContext->commandType == MM_FILE_CONTENTS) {
331 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_DURATION, formatContext->duration);
332 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_TRACK_COUNT, formatContext->audioTotalTrackNum);
333 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, formatContext->videoTotalTrackNum);
335 if (formatContext->videoTotalTrackNum > 0 &&
336 formatContext->nbStreams > 0 &&
337 formatContext->streams[MMFILE_VIDEO_STREAM]) {
339 MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM];
341 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_CODEC, videoStream->codecId);
342 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_BITRATE, videoStream->bitRate);
343 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_FPS, videoStream->framePerSec);
344 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_WIDTH, videoStream->width);
345 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_HEIGHT, videoStream->height);
347 if (formatContext->thumbNail && formatContext->thumbNail->frameData) {
348 void *thumbNailCopy = NULL;
349 thumbNailCopy = mmfile_malloc(formatContext->thumbNail->frameSize);
351 if (NULL != thumbNailCopy) {
352 memcpy(thumbNailCopy, formatContext->thumbNail->frameData, formatContext->thumbNail->frameSize);
353 mm_attrs_set_data_by_name(hattrs, MM_FILE_CONTENT_VIDEO_THUMBNAIL, thumbNailCopy, formatContext->thumbNail->frameSize);
354 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_WIDTH, formatContext->thumbNail->frameWidth);
355 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_HEIGHT, formatContext->thumbNail->frameHeight);
360 if (formatContext->audioTotalTrackNum > 0 &&
361 formatContext->nbStreams > 0 &&
362 formatContext->streams[MMFILE_AUDIO_STREAM]) {
364 MMFileFormatStream *audioStream = formatContext->streams[MMFILE_AUDIO_STREAM];
366 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_CODEC, audioStream->codecId);
367 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_CHANNELS, audioStream->nbChannel);
368 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_BITRATE, audioStream->bitRate);
369 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_SAMPLERATE, audioStream->samplePerSec);
370 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, audioStream->bitPerSample);
377 ret = mmf_attrs_commit((MMHandleType)hattrs);
383 _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO *parse)
385 MMFileFormatContext *formatContext = NULL;
386 MMFileCodecContext *codecContext = NULL;
387 MMFileFormatFrame frameContext = {0, };
388 MMFileCodecFrame codecFrame = {0, };
389 MMFileCodecFrame decodedFrame = {0, };
394 return MM_ERROR_FILE_INTERNAL;
396 ret = mmfile_format_open(&formatContext, src);
397 if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
398 debug_error("error: mmfile_format_open\n");
399 ret = MM_ERROR_FILE_INTERNAL;
403 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL) {
404 if (parse->type == MM_FILE_PARSE_TYPE_SAFE)
405 formatContext->cdis = 1;
406 ret = mmfile_format_read_stream(formatContext);
407 if (MMFILE_FORMAT_FAIL == ret) {
408 debug_error("error: mmfile_format_read_stream\n");
409 ret = MM_ERROR_FILE_INTERNAL;
413 parse->audio_track_num = formatContext->audioTotalTrackNum;
414 parse->video_track_num = formatContext->videoTotalTrackNum;
416 /* check uhqa content*/
417 if (formatContext->streams[MMFILE_AUDIO_STREAM] != NULL) {
418 parse->is_uhqa = formatContext->streams[MMFILE_AUDIO_STREAM]->is_uhqa;
420 parse->is_uhqa = FALSE;
423 if (parse->type >= MM_FILE_PARSE_TYPE_ALL) {
424 if (formatContext->videoTotalTrackNum > 0) {
426 if (parse->type != MM_FILE_PARSE_TYPE_SAFE) {
427 if (formatContext->formatType == MM_FILE_FORMAT_3GP || formatContext->formatType == MM_FILE_FORMAT_MP4) {
428 MMFileUtilGetMetaDataFromMP4(formatContext);
431 MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM];
432 unsigned int timestamp = _SEEK_POINT_;
434 ret = mmfile_format_read_frame(formatContext, timestamp, &frameContext);
435 if (MMFILE_FORMAT_FAIL == ret) {
436 debug_error("error: mmfile_format_read_frame\n");
437 ret = MM_ERROR_FILE_INTERNAL;
441 if (frameContext.bCompressed) {
442 codecFrame.frameDataSize = frameContext.frameSize;
443 codecFrame.width = frameContext.frameWidth;
444 codecFrame.height = frameContext.frameHeight;
445 codecFrame.frameData = frameContext.frameData;
446 codecFrame.configLen = frameContext.configLenth;
447 codecFrame.configData = frameContext.configData;
448 codecFrame.version = videoStream->version;
450 ret = mmfile_codec_open(&codecContext, MMFILE_VIDEO_DECODE, videoStream->codecId, &codecFrame);
451 if (MMFILE_FORMAT_FAIL == ret) {
452 debug_error("error: mmfile_codec_open\n");
453 ret = MM_ERROR_FILE_INTERNAL;
457 ret = mmfile_codec_decode(codecContext, &decodedFrame);
458 if (MMFILE_FORMAT_FAIL == ret) {
459 debug_error("error: mmfile_codec_decode\n");
460 ret = MM_ERROR_FILE_INTERNAL;
464 /* set video thumbnail */
465 formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
466 if (NULL == formatContext->thumbNail) {
467 debug_error("error: mmfile_malloc\n");
468 ret = MM_ERROR_FILE_INTERNAL;
472 formatContext->thumbNail->frameSize = decodedFrame.frameDataSize;
473 formatContext->thumbNail->frameWidth = decodedFrame.width;
474 formatContext->thumbNail->frameHeight = decodedFrame.height;
475 formatContext->thumbNail->frameData = decodedFrame.frameData;
476 formatContext->thumbNail->configLenth = 0;
477 formatContext->thumbNail->configData = NULL;
479 formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
480 if (NULL == formatContext->thumbNail) {
481 debug_error("error: mmfile_format_read_frame\n");
482 ret = MM_ERROR_FILE_INTERNAL;
486 formatContext->thumbNail->frameSize = frameContext.frameSize;
487 formatContext->thumbNail->frameWidth = frameContext.frameWidth;
488 formatContext->thumbNail->frameHeight = frameContext.frameHeight;
489 formatContext->thumbNail->frameData = frameContext.frameData;
490 formatContext->thumbNail->configLenth = 0;
491 formatContext->thumbNail->configData = NULL;
497 * if MM_FILE_PARSE_TYPE_SIMPLE, just get number of each stream.
499 parse->audio_track_num = formatContext->audioTotalTrackNum;
500 parse->video_track_num = formatContext->videoTotalTrackNum;
503 #ifdef __MMFILE_TEST_MODE__
504 mmfile_format_print_frame(&frameContext);
507 formatContext->commandType = MM_FILE_CONTENTS;
509 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL)
510 _info_set_attr_media(attrs, formatContext);
512 if (frameContext.bCompressed) {
513 if (frameContext.frameData) mmfile_free(frameContext.frameData);
514 if (frameContext.configData) mmfile_free(frameContext.configData);
516 if (decodedFrame.frameData) {
517 mmfile_free(decodedFrame.frameData);
518 formatContext->thumbNail->frameData = NULL;
520 if (decodedFrame.configData) {
521 mmfile_free(decodedFrame.configData);
522 formatContext->thumbNail->configData = NULL;
525 if (frameContext.frameData) {
526 mmfile_free(frameContext.frameData);
527 formatContext->thumbNail->frameData = NULL;
529 if (frameContext.configData) {
530 mmfile_free(frameContext.configData);
531 formatContext->thumbNail->configData = NULL;
536 mmfile_format_close(formatContext);
539 mmfile_codec_close(codecContext);
542 return MM_ERROR_NONE;
545 formatContext->commandType = MM_FILE_CONTENTS;
547 if (frameContext.bCompressed) {
548 if (frameContext.frameData)
549 mmfile_free(frameContext.frameData);
551 if (frameContext.configData)
552 mmfile_free(frameContext.configData);
554 if (decodedFrame.frameData) {
555 mmfile_free(decodedFrame.frameData);
556 formatContext->thumbNail->frameData = NULL;
559 if (decodedFrame.configData) {
560 mmfile_free(decodedFrame.configData);
561 formatContext->thumbNail->configData = NULL;
564 if (frameContext.frameData) {
565 mmfile_free(frameContext.frameData);
566 formatContext->thumbNail->frameData = NULL;
569 if (frameContext.configData) {
570 mmfile_free(frameContext.configData);
571 formatContext->thumbNail->configData = NULL;
575 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL)
576 _info_set_attr_media(attrs, formatContext);
579 mmfile_format_close(formatContext);
582 mmfile_codec_close(codecContext);
584 return MM_ERROR_NONE;
588 if (frameContext.bCompressed) {
589 if (frameContext.frameData)
590 mmfile_free(frameContext.frameData);
592 if (frameContext.configData)
593 mmfile_free(frameContext.configData);
595 if (decodedFrame.frameData) {
596 mmfile_free(decodedFrame.frameData);
597 formatContext->thumbNail->frameData = NULL;
600 if (decodedFrame.configData) {
601 mmfile_free(decodedFrame.configData);
602 formatContext->thumbNail->configData = NULL;
605 if (frameContext.frameData) {
606 mmfile_free(frameContext.frameData);
607 formatContext->thumbNail->frameData = NULL;
610 if (frameContext.configData) {
611 mmfile_free(frameContext.configData);
612 formatContext->thumbNail->configData = NULL;
617 mmfile_format_close(formatContext);
619 /* if (codecContext) { mmfile_codec_close(codecContext); } */ /*dead code*/
626 _get_tag_info(mmf_attrs_t *attrs, MMFileSourceType *src)
628 MMFileFormatContext *formatContext = NULL;
631 ret = mmfile_format_open(&formatContext, src);
632 if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
633 debug_error("error: mmfile_format_open\n");
634 ret = MM_ERROR_FILE_INTERNAL;
638 ret = mmfile_format_read_tag(formatContext);
639 if (MMFILE_FORMAT_FAIL == ret) {
640 debug_warning("reading tag is fail\n");
641 ret = MM_ERROR_FILE_INTERNAL;
645 formatContext->commandType = MM_FILE_TAG;
647 _info_set_attr_media(attrs, formatContext);
650 mmfile_format_close(formatContext);
653 return MM_ERROR_NONE;
658 mmfile_format_close(formatContext);
661 return MM_ERROR_FILE_INTERNAL;
668 int mm_file_get_attrs(MMHandleType attrs, char **err_attr_name, const char *first_attribute_name, ...)
670 int ret = MM_ERROR_NONE;
674 debug_error("Invalid arguments [attrs 0]\n");
675 return MM_ERROR_INVALID_ARGUMENT;
678 if (first_attribute_name == NULL) {
679 debug_error("Invalid arguments [first_attribute_name null]\n");
680 return MM_ERROR_INVALID_ARGUMENT;
683 /* get requested attributes */
684 va_start(var_args, first_attribute_name);
685 ret = mm_attrs_get_valist(attrs, err_attr_name, first_attribute_name, var_args);
688 if (ret != MM_ERROR_NONE) {
690 debug_error("failed to get %s\n", *err_attr_name);
697 int mm_file_get_synclyrics_info(MMHandleType tag_attrs, int index, unsigned long *time_info, char **lyrics)
699 int ret = MM_ERROR_NONE;
700 AvSynclyricsInfo *sync_lyric_item = NULL;
701 GList *synclyrics_list = NULL;
703 #ifdef __MMFILE_TEST_MODE__
707 if ((mmf_attrs_t *)tag_attrs == NULL) {
708 debug_error("invalid handle");
709 return MM_ERROR_INVALID_ARGUMENT;
712 ret = mm_attrs_get_data_by_name(tag_attrs, MM_FILE_TAG_SYNCLYRICS, (void **)&synclyrics_list);
713 if (ret != MM_ERROR_NONE) {
714 #ifdef __MMFILE_TEST_MODE__
715 debug_warning("get data fail");
720 if (synclyrics_list != NULL) {
722 sync_lyric_item = (AvSynclyricsInfo *)g_list_nth_data(synclyrics_list, index);
724 if (sync_lyric_item == NULL) {
725 #ifdef __MMFILE_TEST_MODE__
726 debug_warning("synclyric item is NULL");
728 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
731 *time_info = sync_lyric_item->time_info;
732 *lyrics = sync_lyric_item->lyric_info;
735 #ifdef __MMFILE_TEST_MODE__
736 debug_warning("synclyrics_list is NULL");
738 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
745 int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
747 int ret = MM_ERROR_NONE;
748 mmf_attrs_t *attrs = NULL;
749 MMFileSourceType src;
751 #ifdef __MMFILE_TEST_MODE__
755 /* Check argument here */
756 if (tag_attrs == NULL) {
757 debug_error("Invalid arguments [tag null]\n");
758 return MM_ERROR_INVALID_ARGUMENT;
760 if (filename == NULL) {
761 debug_error("Invalid arguments [filename null]\n");
762 return MM_ERROR_INVALID_ARGUMENT;
764 if (strlen(filename) == 0) {
765 debug_error("Invalid arguments [filename size 0]\n");
766 return MM_ERROR_INVALID_ARGUMENT;
770 #ifdef __MMFILE_DYN_LOADING__
771 MMFILE_FUNC_HANDLE func_handle;
773 ret = _load_dynamic_functions(&func_handle);
775 debug_error("load library error\n");
776 return MM_ERROR_FILE_INTERNAL;
780 /*set source file infomation*/
781 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
783 ret = _is_file_exist(filename);
785 ret = MM_ERROR_FILE_NOT_FOUND;
790 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
792 debug_error("attribute internal error.\n");
793 ret = MM_ERROR_FILE_INTERNAL;
797 ret = _get_tag_info(attrs, &src);
798 if (ret != MM_ERROR_NONE) {
799 mmf_attrs_free((MMHandleType)attrs);
801 debug_error("failed to get tag: %s\n", filename);
804 *tag_attrs = (MMHandleType)attrs;
807 #ifdef __MMFILE_DYN_LOADING__
808 _unload_dynamic_functions(&func_handle);
811 #ifdef __MMFILE_TEST_MODE__
820 int mm_file_destroy_tag_attrs(MMHandleType tag_attrs)
822 void *artwork = NULL;
823 GList *synclyrics_list = NULL;
824 int ret = MM_ERROR_NONE;
826 #ifdef __MMFILE_TEST_MODE__
830 if ((mmf_attrs_t *)tag_attrs == NULL) {
831 debug_error("invalid handle.\n");
832 return MM_ERROR_INVALID_ARGUMENT;
835 ret = mm_attrs_get_data_by_name(tag_attrs, MM_FILE_TAG_ARTWORK, &artwork);
837 if (artwork != NULL) {
838 mmfile_free(artwork);
841 ret = mm_attrs_get_data_by_name(tag_attrs, MM_FILE_TAG_SYNCLYRICS, (void **)&synclyrics_list);
843 if (synclyrics_list != NULL) {
844 mm_file_free_synclyrics_list(synclyrics_list);
847 mmf_attrs_free(tag_attrs);
849 #ifdef __MMFILE_TEST_MODE__
857 int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filename)
859 mmf_attrs_t *attrs = NULL;
860 MMFileSourceType src = {0, };
861 MMFILE_PARSE_INFO parse = {0, };
864 #ifdef __MMFILE_TEST_MODE__
868 /* Check argument here */
869 if (contents_attrs == NULL) {
870 debug_error("Invalid arguments [contents null]\n");
871 return MM_ERROR_INVALID_ARGUMENT;
873 if (filename == NULL) {
874 debug_error("Invalid arguments [filename null]\n");
875 return MM_ERROR_INVALID_ARGUMENT;
877 if (strlen(filename) == 0) {
878 debug_error("Invalid arguments [filename size 0]\n");
879 return MM_ERROR_INVALID_ARGUMENT;
883 #ifdef __MMFILE_DYN_LOADING__
884 MMFILE_FUNC_HANDLE func_handle;
891 ret = _load_dynamic_functions(&func_handle);
893 debug_error("load library error\n");
894 return MM_ERROR_FILE_INTERNAL;
898 debug_msg("_load_dynamic_functions() = %lld\n", gettime() - ti);
903 /*set source file infomation*/
904 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
906 ret = _is_file_exist(filename);
908 ret = MM_ERROR_FILE_NOT_FOUND;
913 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
915 debug_error("attribute internal error.\n");
916 ret = MM_ERROR_FILE_INTERNAL;
921 parse.type = MM_FILE_PARSE_TYPE_ALL;
922 ret = _get_contents_info(attrs, &src, &parse);
923 if (ret != MM_ERROR_NONE) {
924 mmf_attrs_free((MMHandleType)attrs);
926 debug_error("failed to get contents: %s\n", filename);
929 *contents_attrs = (MMHandleType) attrs;
933 #ifdef __MMFILE_DYN_LOADING__
939 _unload_dynamic_functions(&func_handle);
942 debug_msg("_unload_dynamic_functions() = %lld\n", gettime() - ti);
947 #ifdef __MMFILE_TEST_MODE__
956 int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *data, unsigned int size, int format)
958 mmf_attrs_t *attrs = NULL;
959 MMFileSourceType src;
960 /*MMFILE_PARSE_INFO parse = {0, };*/
963 #ifdef __MMFILE_TEST_MODE__
967 /* Check argument here */
968 if (tag_attrs == NULL || data == NULL) {
969 debug_error("Invalid arguments\n");
970 return MM_ERROR_INVALID_ARGUMENT;
973 #ifdef __MMFILE_DYN_LOADING__
974 MMFILE_FUNC_HANDLE func_handle;
976 ret = _load_dynamic_functions(&func_handle);
978 debug_error("load library error\n");
979 return MM_ERROR_FILE_INTERNAL;
983 MM_FILE_SET_MEDIA_MEM_SRC(src, data, size, format);
986 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
988 debug_error("attribute internal error.\n");
989 ret = MM_ERROR_FILE_INTERNAL;
993 /*parse.type = MM_FILE_PARSE_TYPE_ALL;*/
994 ret = _get_tag_info(attrs, &src);
995 if (ret != MM_ERROR_NONE) {
996 mmf_attrs_free((MMHandleType)attrs);
998 debug_error("failed to get tag");
1001 *tag_attrs = (MMHandleType)attrs;
1004 #ifdef __MMFILE_DYN_LOADING__
1005 _unload_dynamic_functions(&func_handle);
1008 #ifdef __MMFILE_TEST_MODE__
1017 int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const void *data, unsigned int size, int format)
1019 mmf_attrs_t *attrs = NULL;
1020 MMFileSourceType src;
1021 MMFILE_PARSE_INFO parse = {0, };
1024 #ifdef __MMFILE_TEST_MODE__
1028 /* Check argument here */
1029 if (contents_attrs == NULL || data == NULL) {
1030 debug_error("Invalid arguments\n");
1031 return MM_ERROR_INVALID_ARGUMENT;
1034 #ifdef __MMFILE_DYN_LOADING__
1035 MMFILE_FUNC_HANDLE func_handle;
1037 ret = _load_dynamic_functions(&func_handle);
1039 debug_error("load library error\n");
1040 return MM_ERROR_FILE_INTERNAL;
1044 MM_FILE_SET_MEDIA_MEM_SRC(src, data, size, format);
1047 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1049 debug_error("attribute internal error.\n");
1050 ret = MM_ERROR_FILE_INTERNAL;
1054 parse.type = MM_FILE_PARSE_TYPE_ALL;
1055 ret = _get_contents_info(attrs, &src, &parse);
1056 if (ret != MM_ERROR_NONE) {
1057 mmf_attrs_free((MMHandleType)attrs);
1059 debug_error("failed to get contents");
1062 *contents_attrs = (MMHandleType)attrs;
1065 #ifdef __MMFILE_DYN_LOADING__
1066 _unload_dynamic_functions(&func_handle);
1069 #ifdef __MMFILE_TEST_MODE__
1078 int mm_file_destroy_content_attrs(MMHandleType contents_attrs)
1080 void *thumbnail = NULL;
1081 int ret = MM_ERROR_NONE;
1083 #ifdef __MMFILE_TEST_MODE__
1087 if ((mmf_attrs_t *)contents_attrs == NULL) {
1088 debug_error("invalid handle.\n");
1089 return MM_ERROR_INVALID_ARGUMENT;
1092 ret = mm_attrs_get_data_by_name(contents_attrs, MM_FILE_CONTENT_VIDEO_THUMBNAIL, &thumbnail);
1093 if (thumbnail != NULL) {
1094 mmfile_free(thumbnail);
1097 mmf_attrs_free(contents_attrs);
1099 #ifdef __MMFILE_TEST_MODE__
1108 int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *video_stream_num)
1110 MMFileSourceType src = {0, };
1111 MMFILE_PARSE_INFO parse = {0, };
1115 #ifdef __MMFILE_TEST_MODE__
1119 if (filename == NULL || strlen(filename) == 0 || audio_stream_num == NULL || video_stream_num == NULL) {
1120 debug_error("Invalid arguments\n");
1121 return MM_ERROR_INVALID_ARGUMENT;
1124 #ifdef __MMFILE_DYN_LOADING__
1125 MMFILE_FUNC_HANDLE func_handle;
1127 ret = _load_dynamic_functions(&func_handle);
1129 debug_error("load library error\n");
1130 return MM_ERROR_FILE_INTERNAL;
1134 /*set source file infomation*/
1135 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1137 ret = _is_file_exist(filename);
1139 ret = MM_ERROR_FILE_NOT_FOUND;
1143 parse.type = MM_FILE_PARSE_TYPE_SIMPLE;
1144 ret = _get_contents_info(NULL, &src, &parse);
1145 if (ret != MM_ERROR_NONE) {
1146 debug_error("failed to get stream info: %s\n", filename);
1148 if (parse.audio_track_num == 0 && parse.video_track_num == 0) {
1149 debug_error("empty header. retry to get stream info: %s\n", filename);
1150 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1151 ret = _get_contents_info(NULL, &src, &parse);
1155 /*set number of each stream*/
1156 *audio_stream_num = parse.audio_track_num;
1157 *video_stream_num = parse.video_track_num;
1160 #ifdef __MMFILE_DYN_LOADING__
1161 _unload_dynamic_functions(&func_handle);
1164 #ifdef __MMFILE_TEST_MODE__
1172 int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char *filename)
1174 mmf_attrs_t *attrs = NULL;
1175 MMFileSourceType src = {0, };
1176 MMFILE_PARSE_INFO parse = {0, };
1179 #ifdef __MMFILE_TEST_MODE__
1183 #ifdef __MMFILE_DYN_LOADING__
1184 MMFILE_FUNC_HANDLE func_handle;
1186 ret = _load_dynamic_functions(&func_handle);
1188 debug_error("load library error\n");
1189 return MM_ERROR_FILE_INTERNAL;
1192 if (filename == NULL) {
1193 ret = MM_ERROR_INVALID_ARGUMENT;
1196 if (strlen(filename) == 0) {
1197 ret = MM_ERROR_INVALID_ARGUMENT;
1202 /*set source file infomation*/
1203 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1205 ret = _is_file_exist(filename);
1207 ret = MM_ERROR_FILE_NOT_FOUND;
1212 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1214 debug_error("attribute internal error.\n");
1215 ret = MM_ERROR_FILE_INTERNAL;
1219 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1220 ret = _get_contents_info(attrs, &src, &parse);
1221 if (ret != MM_ERROR_NONE) {
1222 mmf_attrs_free((MMHandleType)attrs);
1224 debug_error("failed to get contents: %s\n", filename);
1227 *contents_attrs = (MMHandleType) attrs;
1230 #ifdef __MMFILE_DYN_LOADING__
1231 _unload_dynamic_functions(&func_handle);
1234 #ifdef __MMFILE_TEST_MODE__
1242 int mm_file_create_content_attrs_safe(MMHandleType *contents_attrs, const char *filename)
1244 mmf_attrs_t *attrs = NULL;
1245 MMFileSourceType src = {0, };
1246 MMFILE_PARSE_INFO parse = {0, };
1249 #ifdef __MMFILE_TEST_MODE__
1253 #ifdef __MMFILE_DYN_LOADING__
1254 MMFILE_FUNC_HANDLE func_handle;
1256 ret = _load_dynamic_functions(&func_handle);
1258 debug_error("load library error\n");
1259 return MM_ERROR_FILE_INTERNAL;
1262 if (filename == NULL) {
1263 ret = MM_ERROR_INVALID_ARGUMENT;
1266 if (strlen(filename) == 0) {
1267 ret = MM_ERROR_INVALID_ARGUMENT;
1272 /*set source file infomation*/
1273 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1275 ret = _is_file_exist(filename);
1277 ret = MM_ERROR_FILE_NOT_FOUND;
1282 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1284 debug_error("attribute internal error.\n");
1285 ret = MM_ERROR_FILE_INTERNAL;
1289 parse.type = MM_FILE_PARSE_TYPE_SAFE;
1290 ret = _get_contents_info(attrs, &src, &parse);
1291 if (ret != MM_ERROR_NONE) {
1292 mmf_attrs_free((MMHandleType)attrs);
1294 debug_error("failed to get contents: %s\n", filename);
1297 *contents_attrs = (MMHandleType) attrs;
1300 #ifdef __MMFILE_DYN_LOADING__
1301 _unload_dynamic_functions(&func_handle);
1304 #ifdef __MMFILE_TEST_MODE__
1312 int mm_file_get_video_frame(const char *path, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
1315 void *formatFuncHandle = NULL;
1318 debug_error("Invalid arguments [Path is Null]\n");
1319 return MM_ERROR_INVALID_ARGUMENT;
1322 #ifdef __MMFILE_DYN_LOADING__
1323 /* Get from function argument */
1324 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
1325 if (!formatFuncHandle) {
1326 debug_error("error : dlopen");
1330 mmfile_format_get_frame = dlsym(formatFuncHandle, "mmfile_format_get_frame");
1331 if (!mmfile_format_get_frame) {
1332 debug_error("error : load library");
1337 #ifdef __MMFILE_TEST_MODE__
1338 debug_msg("file path [%s] is_accurate [%d]", path, is_accurate);
1341 ret = mmfile_format_get_frame(path, timestamp, is_accurate, frame, size, width, height);
1342 if (ret == MMFILE_FORMAT_FAIL) {
1343 debug_error("error : get frame");
1347 if (formatFuncHandle) dlclose(formatFuncHandle);
1349 return MM_ERROR_NONE;
1352 if (formatFuncHandle) dlclose(formatFuncHandle);
1354 return MM_ERROR_FILE_INTERNAL;
1358 int mm_file_get_video_frame_from_memory(const void *data, unsigned int datasize, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
1361 void *formatFuncHandle = NULL;
1364 debug_error("Invalid arguments [data is Null]\n");
1365 return MM_ERROR_INVALID_ARGUMENT;
1368 if (datasize == 0) {
1369 debug_error("Invalid arguments [datasize is zero]\n");
1370 return MM_ERROR_INVALID_ARGUMENT;
1373 #ifdef __MMFILE_DYN_LOADING__
1374 /* Get from function argument */
1375 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
1376 if (!formatFuncHandle) {
1377 debug_error("error : dlopen");
1381 mmfile_format_get_frame_from_memory = dlsym(formatFuncHandle, "mmfile_format_get_frame_from_memory");
1382 if (!mmfile_format_get_frame_from_memory) {
1383 debug_error("error : load library");
1388 #ifdef __MMFILE_TEST_MODE__
1389 debug_msg("data [%p], data_size[%d], is_accurate [%d]", data, datasize, is_accurate);
1392 ret = mmfile_format_get_frame_from_memory(data, datasize, timestamp, is_accurate, frame, size, width, height);
1393 if (ret == MMFILE_FORMAT_FAIL) {
1394 debug_error("error : get frame");
1398 if (formatFuncHandle) dlclose(formatFuncHandle);
1400 return MM_ERROR_NONE;
1403 if (formatFuncHandle) dlclose(formatFuncHandle);
1405 return MM_ERROR_FILE_INTERNAL;
1409 int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
1411 mmf_attrs_t *attrs = NULL;
1412 MMFileSourceType src = {0, };
1413 MMFILE_PARSE_INFO parse = {0, };
1416 #ifdef __MMFILE_DYN_LOADING__
1417 MMFILE_FUNC_HANDLE func_handle;
1419 ret = _load_dynamic_functions(&func_handle);
1421 debug_error("load library error\n");
1422 return MM_ERROR_FILE_INTERNAL;
1425 if (filename == NULL) {
1426 ret = MM_ERROR_INVALID_ARGUMENT;
1429 if (strlen(filename) == 0) {
1430 ret = MM_ERROR_INVALID_ARGUMENT;
1435 /*set source file infomation*/
1436 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1438 ret = _is_file_exist(filename);
1440 ret = MM_ERROR_FILE_NOT_FOUND;
1445 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1447 debug_error("attribute internal error.\n");
1448 ret = MM_ERROR_FILE_INTERNAL;
1452 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1453 ret = _get_contents_info(attrs, &src, &parse);
1454 if (ret == MM_ERROR_NONE) {
1455 *is_uhqa = parse.is_uhqa;
1457 debug_error("_get_contents_info failed\n");
1461 mmf_attrs_free((MMHandleType)attrs);
1465 #ifdef __MMFILE_DYN_LOADING__
1466 _unload_dynamic_functions(&func_handle);
1469 #ifdef __MMFILE_TEST_MODE__