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 */
31 /* internal MM header files */
32 #include <mm_attrs_private.h>
34 /* internal MM File headers */
35 #include "mm_file_debug.h"
36 #include "mm_file_formats.h"
37 #include "mm_file_format_frame.h"
38 #include "mm_file_codecs.h"
39 #include "mm_file_utils.h"
44 /*#define CHECK_TIME */
50 gettimeofday(&tv, NULL);
51 return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
61 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
64 #define _SEEK_POINT_ 3000 /*1000 = 1 seconds*/
66 #define MM_FILE_TAG_SYNCLYRICS "tag-synclyrics" /**< Synchronized Lyrics Information*/
76 MM_FILE_PARSE_TYPE_SIMPLE, /*parse audio/video track num only*/
77 MM_FILE_PARSE_TYPE_NORMAL, /*parse infomation without thumbnail*/
78 MM_FILE_PARSE_TYPE_ALL, /*parse all infomation*/
79 MM_FILE_PARSE_TYPE_SAFE, /*parse infomation without both thumbnail and stream full-searching*/
90 void *formatFuncHandle;
91 void *codecFuncHandle;
99 static mmf_attrs_construct_info_t g_tag_attrs[] = {
100 {(char *)"tag-artist", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
101 {(char *)"tag-title", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
102 {(char *)"tag-album", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
103 {(char *)"tag-album-artist", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
104 {(char *)"tag-genre", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
105 {(char *)"tag-author", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
106 {(char *)"tag-copyright", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
107 {(char *)"tag-date", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
108 {(char *)"tag-description", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
109 {(char *)"tag-comment", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
110 {(char *)"tag-artwork", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
111 {(char *)"tag-artwork-size", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
112 {(char *)"tag-artwork-mime", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
113 {(char *)"tag-track-num", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
114 {(char *)"tag-classification", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
115 {(char *)"tag-rating", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
116 {(char *)"tag-longitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
117 {(char *)"tag-latitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
118 {(char *)"tag-altitude", MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *)0},
119 {(char *)"tag-conductor", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
120 {(char *)"tag-unsynclyrics", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
121 {(char *)"tag-synclyrics-num", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
122 {(char *)"tag-synclyrics", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
123 {(char *)"tag-recdate", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
124 {(char *)"tag-rotate", MMF_VALUE_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL},
125 {(char *)"tag-cdis", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
126 {(char *)"tag-smta", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
127 {(char *)"tag-360", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
128 {(char *)"tag-stitched_info", 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-format", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
135 {(char *)"content-video-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
136 {(char *)"content-video-fps", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
137 {(char *)"content-video-width", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
138 {(char *)"content-video-height", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
139 {(char *)"content-video-thumbnail", MMF_VALUE_TYPE_DATA, MM_ATTRS_FLAG_RW, (void *)NULL},
140 {(char *)"content-video-track-index", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
141 {(char *)"content-video-track-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
142 {(char *)"content-audio-codec", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
143 {(char *)"content-audio-bitrate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
144 {(char *)"content-audio-channels", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
145 {(char *)"content-audio-samplerate", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
146 {(char *)"content-audio-track-index", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
147 {(char *)"content-audio-track-count", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
148 {(char *)"content-audio-bitpersample", MMF_VALUE_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0},
151 #ifdef __MMFILE_DYN_LOADING__
152 #define MMFILE_FORMAT_SO_FILE_NAME LIBDIR"/libmmfile_formats.so"
153 #define MMFILE_CODEC_SO_FILE_NAME LIBDIR"/libmmfile_codecs.so"
155 int (*mmfile_format_open)(MMFileFormatContext **formatContext, MMFileSourceType *fileSrc);
156 int (*mmfile_format_read_stream)(MMFileFormatContext *formatContext);
157 int (*mmfile_format_read_frame)(MMFileFormatContext *formatContext, unsigned int timestamp, MMFileFormatFrame *frame);
158 int (*mmfile_format_read_tag)(MMFileFormatContext *formatContext);
159 int (*mmfile_format_close)(MMFileFormatContext *formatContext);
160 int (*mmfile_codec_open)(MMFileCodecContext **codecContext, int codecType, int codecId, MMFileCodecFrame *input);
161 int (*mmfile_codec_decode)(MMFileCodecContext *codecContext, MMFileCodecFrame *output);
162 int (*mmfile_codec_close)(MMFileCodecContext *codecContext);
163 int (*mmfile_format_get_frame)(const char *path, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height);
164 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);
167 #ifdef __MMFILE_DYN_LOADING__
168 static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
170 /* static int dll_func_initialized = 0; //disabled */
174 /* Get from function argument */
175 void *formatFuncHandle = NULL;
176 void *codecFuncHandle = NULL;
179 if (dll_func_initialized) {
184 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
185 if (!formatFuncHandle) {
186 debug_error(DEBUG, "error: %s\n", "libmmfile_formats.so open error");
191 mmfile_format_open = dlsym(formatFuncHandle, "mmfile_format_open");
192 mmfile_format_read_stream = dlsym(formatFuncHandle, "mmfile_format_read_stream");
193 mmfile_format_read_frame = dlsym(formatFuncHandle, "mmfile_format_read_frame");
194 mmfile_format_read_tag = dlsym(formatFuncHandle, "mmfile_format_read_tag");
195 mmfile_format_close = dlsym(formatFuncHandle, "mmfile_format_close");
197 if (!mmfile_format_open ||
198 !mmfile_format_read_stream ||
199 !mmfile_format_read_frame ||
200 !mmfile_format_read_tag ||
201 !mmfile_format_close) {
203 debug_error(DEBUG, "error: %s\n", "format function load error");
208 /*closed at app termination.*/
209 /*dlclose (formatFuncHandle); */
211 codecFuncHandle = dlopen(MMFILE_CODEC_SO_FILE_NAME, RTLD_LAZY | RTLD_GLOBAL);
212 if (!codecFuncHandle) {
213 debug_error(DEBUG, "error: %s\n", "libmmfile_codecs.so open error");
218 mmfile_codec_open = dlsym(codecFuncHandle, "mmfile_codec_open");
219 mmfile_codec_decode = dlsym(codecFuncHandle, "mmfile_codec_decode");
220 mmfile_codec_close = dlsym(codecFuncHandle, "mmfile_codec_close");
222 if (!mmfile_codec_open || !mmfile_codec_decode || !mmfile_codec_close) {
223 debug_error(DEBUG, "error: %s\n", "codec function load error");
228 /*closed at app termination.*/
229 /*dlclose (codecFuncHandle); */
231 /* dll_func_initialized = 1; // disabled */
233 pHandle->codecFuncHandle = codecFuncHandle;
234 pHandle->formatFuncHandle = formatFuncHandle;
239 if (formatFuncHandle) dlclose(formatFuncHandle);
240 if (codecFuncHandle) dlclose(codecFuncHandle);
245 static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
247 debug_fenter(RELEASE);
249 if (pHandle->formatFuncHandle) {
250 dlclose(pHandle->formatFuncHandle);
252 if (pHandle->codecFuncHandle) {
253 dlclose(pHandle->codecFuncHandle);
256 debug_fleave(RELEASE);
260 #endif /* __MMFILE_DYN_LOADING__ */
266 _is_file_exist(const char *filename)
270 const char *to_access = (strstr(filename, "file://") != NULL) ? filename + 7 : filename;
271 ret = access(to_access, R_OK);
273 debug_error(DEBUG, "file [%s] not found.\n", to_access);
280 _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
283 MMHandleType hattrs = CAST_MM_HANDLE(attrs);
285 if (formatContext->commandType == MM_FILE_TAG) {
286 if (formatContext->title) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_TITLE, formatContext->title);
287 if (formatContext->artist) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ARTIST, formatContext->artist);
288 if (formatContext->author) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_AUTHOR, formatContext->author);
289 if (formatContext->composer && formatContext->author == NULL)
290 mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_AUTHOR, formatContext->composer);
291 if (formatContext->album) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ALBUM, formatContext->album);
292 if (formatContext->album_artist) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ALBUM_ARTIST, formatContext->album_artist);
293 if (formatContext->copyright) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_COPYRIGHT, formatContext->copyright);
294 if (formatContext->description) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_DESCRIPTION, formatContext->description);
295 if (formatContext->comment) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_COMMENT, formatContext->comment);
296 if (formatContext->genre) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_GENRE, formatContext->genre);
297 if (formatContext->classification) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_CLASSIFICATION, formatContext->classification);
298 if (formatContext->year) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_DATE, formatContext->year);
299 if (formatContext->tagTrackNum) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_TRACK_NUM, formatContext->tagTrackNum);
300 if (formatContext->rating) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_RATING, formatContext->rating);
301 if (formatContext->conductor) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_CONDUCTOR, formatContext->conductor);
302 if (formatContext->recDate) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_RECDATE, formatContext->recDate);
303 if (formatContext->rotate) mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_ROTATE, formatContext->rotate);
304 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_LONGITUDE, formatContext->longitude);
305 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_LATIDUE, formatContext->latitude);
306 mm_attrs_set_double_by_name(hattrs, MM_FILE_TAG_ALTIDUE, formatContext->altitude);
307 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SYNCLYRICS_NUM, formatContext->syncLyricsNum);
308 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_CDIS, formatContext->cdis);
309 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SMTA, formatContext->smta);
311 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_360, formatContext->is_360);
312 mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_STITCHED_INFO, formatContext->stitched_info);
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_FORMAT, formatContext->formatType);
342 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_CODEC, videoStream->codecId);
343 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_BITRATE, videoStream->bitRate);
344 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_FPS, videoStream->framePerSec);
345 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_WIDTH, videoStream->width);
346 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_HEIGHT, videoStream->height);
348 if (formatContext->thumbNail && formatContext->thumbNail->frameData) {
349 void *thumbNailCopy = NULL;
350 thumbNailCopy = mmfile_malloc(formatContext->thumbNail->frameSize);
352 if (NULL != thumbNailCopy) {
353 memcpy(thumbNailCopy, formatContext->thumbNail->frameData, formatContext->thumbNail->frameSize);
354 mm_attrs_set_data_by_name(hattrs, MM_FILE_CONTENT_VIDEO_THUMBNAIL, thumbNailCopy, formatContext->thumbNail->frameSize);
355 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_WIDTH, formatContext->thumbNail->frameWidth);
356 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_HEIGHT, formatContext->thumbNail->frameHeight);
361 if (formatContext->audioTotalTrackNum > 0 &&
362 formatContext->nbStreams > 0 &&
363 formatContext->streams[MMFILE_AUDIO_STREAM]) {
365 MMFileFormatStream *audioStream = formatContext->streams[MMFILE_AUDIO_STREAM];
367 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_CODEC, audioStream->codecId);
368 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_CHANNELS, audioStream->nbChannel);
369 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_BITRATE, audioStream->bitRate);
370 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_SAMPLERATE, audioStream->samplePerSec);
371 mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, audioStream->bitPerSample);
378 ret = mmf_attrs_commit((MMHandleType)hattrs);
384 _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO *parse)
386 MMFileFormatContext *formatContext = NULL;
387 MMFileCodecContext *codecContext = NULL;
388 MMFileFormatFrame frameContext = {0, };
389 MMFileCodecFrame codecFrame = {0, };
390 MMFileCodecFrame decodedFrame = {0, };
395 return FILEINFO_ERROR_FILE_INTERNAL;
397 ret = mmfile_format_open(&formatContext, src);
398 if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
399 debug_error(DEBUG, "error: mmfile_format_open\n");
400 ret = FILEINFO_ERROR_FILE_INTERNAL;
404 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL) {
405 if (parse->type == MM_FILE_PARSE_TYPE_SAFE)
406 formatContext->cdis = 1;
407 ret = mmfile_format_read_stream(formatContext);
408 if (MMFILE_FORMAT_FAIL == ret) {
409 debug_error(DEBUG, "error: mmfile_format_read_stream\n");
410 ret = FILEINFO_ERROR_FILE_INTERNAL;
414 parse->audio_track_num = formatContext->audioTotalTrackNum;
415 parse->video_track_num = formatContext->videoTotalTrackNum;
417 /* check uhqa content*/
418 if (formatContext->streams[MMFILE_AUDIO_STREAM] != NULL) {
419 parse->is_uhqa = formatContext->streams[MMFILE_AUDIO_STREAM]->is_uhqa;
421 parse->is_uhqa = FALSE;
424 if (parse->type >= MM_FILE_PARSE_TYPE_ALL) {
425 if (formatContext->videoTotalTrackNum > 0) {
427 /*why below code needed?
428 This API is for extracting some attributes not metadata(TAG). mm_file_create_content_attrs() use this API.
429 but MMFileUtilGetMetaDataFromMP4() Extract just TAG info. That is needed for mm_file_create_tag_attrs()*/
431 if (parse->type != MM_FILE_PARSE_TYPE_SAFE) {
432 if (formatContext->formatType == MM_FILE_FORMAT_3GP || formatContext->formatType == MM_FILE_FORMAT_MP4) {
433 MMFileUtilGetMetaDataFromMP4(formatContext);
437 MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM];
438 unsigned int timestamp = _SEEK_POINT_;
440 ret = mmfile_format_read_frame(formatContext, timestamp, &frameContext);
441 if (MMFILE_FORMAT_FAIL == ret) {
442 debug_error(DEBUG, "error: mmfile_format_read_frame\n");
443 ret = FILEINFO_ERROR_FILE_INTERNAL;
447 if (frameContext.bCompressed) {
448 codecFrame.frameDataSize = frameContext.frameSize;
449 codecFrame.width = frameContext.frameWidth;
450 codecFrame.height = frameContext.frameHeight;
451 codecFrame.frameData = frameContext.frameData;
452 codecFrame.configLen = frameContext.configLenth;
453 codecFrame.configData = frameContext.configData;
454 codecFrame.version = videoStream->version;
456 ret = mmfile_codec_open(&codecContext, MMFILE_VIDEO_DECODE, videoStream->codecId, &codecFrame);
457 if (MMFILE_FORMAT_FAIL == ret) {
458 debug_error(DEBUG, "error: mmfile_codec_open\n");
459 ret = FILEINFO_ERROR_FILE_INTERNAL;
463 ret = mmfile_codec_decode(codecContext, &decodedFrame);
464 if (MMFILE_FORMAT_FAIL == ret) {
465 debug_error(DEBUG, "error: mmfile_codec_decode\n");
466 ret = FILEINFO_ERROR_FILE_INTERNAL;
470 /* set video thumbnail */
471 formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
472 if (NULL == formatContext->thumbNail) {
473 debug_error(DEBUG, "error: mmfile_malloc\n");
474 ret = FILEINFO_ERROR_FILE_INTERNAL;
478 formatContext->thumbNail->frameSize = decodedFrame.frameDataSize;
479 formatContext->thumbNail->frameWidth = decodedFrame.width;
480 formatContext->thumbNail->frameHeight = decodedFrame.height;
481 formatContext->thumbNail->frameData = decodedFrame.frameData;
482 formatContext->thumbNail->configLenth = 0;
483 formatContext->thumbNail->configData = NULL;
485 formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
486 if (NULL == formatContext->thumbNail) {
487 debug_error(DEBUG, "error: mmfile_format_read_frame\n");
488 ret = FILEINFO_ERROR_FILE_INTERNAL;
492 formatContext->thumbNail->frameSize = frameContext.frameSize;
493 formatContext->thumbNail->frameWidth = frameContext.frameWidth;
494 formatContext->thumbNail->frameHeight = frameContext.frameHeight;
495 formatContext->thumbNail->frameData = frameContext.frameData;
496 formatContext->thumbNail->configLenth = 0;
497 formatContext->thumbNail->configData = NULL;
503 * if MM_FILE_PARSE_TYPE_SIMPLE, just get number of each stream.
505 parse->audio_track_num = formatContext->audioTotalTrackNum;
506 parse->video_track_num = formatContext->videoTotalTrackNum;
509 #ifdef __MMFILE_TEST_MODE__
510 mmfile_format_print_frame(&frameContext);
513 formatContext->commandType = MM_FILE_CONTENTS;
515 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL)
516 _info_set_attr_media(attrs, formatContext);
518 if (frameContext.bCompressed) {
519 if (frameContext.frameData) mmfile_free(frameContext.frameData);
520 if (frameContext.configData) mmfile_free(frameContext.configData);
522 if (decodedFrame.frameData) {
523 mmfile_free(decodedFrame.frameData);
524 formatContext->thumbNail->frameData = NULL;
526 if (decodedFrame.configData) {
527 mmfile_free(decodedFrame.configData);
528 formatContext->thumbNail->configData = NULL;
531 if (frameContext.frameData) {
532 mmfile_free(frameContext.frameData);
533 formatContext->thumbNail->frameData = NULL;
535 if (frameContext.configData) {
536 mmfile_free(frameContext.configData);
537 formatContext->thumbNail->configData = NULL;
542 mmfile_format_close(formatContext);
545 mmfile_codec_close(codecContext);
548 return FILEINFO_ERROR_NONE;
551 formatContext->commandType = MM_FILE_CONTENTS;
553 if (frameContext.bCompressed) {
554 if (frameContext.frameData)
555 mmfile_free(frameContext.frameData);
557 if (frameContext.configData)
558 mmfile_free(frameContext.configData);
560 if (decodedFrame.frameData) {
561 mmfile_free(decodedFrame.frameData);
562 if (formatContext->thumbNail)
563 formatContext->thumbNail->frameData = NULL;
566 if (decodedFrame.configData) {
567 mmfile_free(decodedFrame.configData);
568 if (formatContext->thumbNail)
569 formatContext->thumbNail->configData = NULL;
572 if (frameContext.frameData) {
573 mmfile_free(frameContext.frameData);
574 if (formatContext->thumbNail)
575 formatContext->thumbNail->frameData = NULL;
578 if (frameContext.configData) {
579 mmfile_free(frameContext.configData);
580 if (formatContext->thumbNail)
581 formatContext->thumbNail->configData = NULL;
585 if (parse->type >= MM_FILE_PARSE_TYPE_NORMAL)
586 _info_set_attr_media(attrs, formatContext);
589 mmfile_format_close(formatContext);
592 mmfile_codec_close(codecContext);
594 return FILEINFO_ERROR_NONE;
598 if (frameContext.bCompressed) {
599 if (frameContext.frameData)
600 mmfile_free(frameContext.frameData);
602 if (frameContext.configData)
603 mmfile_free(frameContext.configData);
605 if (decodedFrame.frameData) {
606 mmfile_free(decodedFrame.frameData);
607 if (formatContext->thumbNail)
608 formatContext->thumbNail->frameData = NULL;
611 if (decodedFrame.configData) {
612 mmfile_free(decodedFrame.configData);
613 if (formatContext->thumbNail)
614 formatContext->thumbNail->configData = NULL;
617 if (frameContext.frameData) {
618 mmfile_free(frameContext.frameData);
619 if (formatContext->thumbNail)
620 formatContext->thumbNail->frameData = NULL;
623 if (frameContext.configData) {
624 mmfile_free(frameContext.configData);
625 if (formatContext->thumbNail)
626 formatContext->thumbNail->configData = NULL;
631 mmfile_format_close(formatContext);
633 /* if (codecContext) { mmfile_codec_close(codecContext); } */ /*dead code*/
640 _get_tag_info(mmf_attrs_t *attrs, MMFileSourceType *src)
642 MMFileFormatContext *formatContext = NULL;
645 ret = mmfile_format_open(&formatContext, src);
646 if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
647 debug_error(DEBUG, "error: mmfile_format_open\n");
648 ret = FILEINFO_ERROR_FILE_INTERNAL;
652 ret = mmfile_format_read_tag(formatContext);
653 if (MMFILE_FORMAT_FAIL == ret) {
654 debug_warning(DEBUG, "reading tag is fail\n");
655 ret = FILEINFO_ERROR_FILE_INTERNAL;
659 formatContext->commandType = MM_FILE_TAG;
661 _info_set_attr_media(attrs, formatContext);
664 mmfile_format_close(formatContext);
667 return FILEINFO_ERROR_NONE;
672 mmfile_format_close(formatContext);
675 return FILEINFO_ERROR_FILE_INTERNAL;
682 int mm_file_get_attrs(MMHandleType attrs, char **err_attr_name, const char *first_attribute_name, ...)
684 int ret = FILEINFO_ERROR_NONE;
688 debug_error(DEBUG, "Invalid arguments [attrs 0]\n");
689 return FILEINFO_ERROR_INVALID_ARGUMENT;
692 if (first_attribute_name == NULL) {
693 debug_error(DEBUG, "Invalid arguments [first_attribute_name null]\n");
694 return FILEINFO_ERROR_INVALID_ARGUMENT;
697 /* get requested attributes */
698 va_start(var_args, first_attribute_name);
699 ret = mm_attrs_get_valist(attrs, err_attr_name, first_attribute_name, var_args);
702 if (ret != FILEINFO_ERROR_NONE) {
704 debug_error(DEBUG, "failed to get %s\n", *err_attr_name);
711 int mm_file_get_synclyrics_info(MMHandleType tag_attrs, int index, unsigned long *time_info, char **lyrics)
713 int ret = FILEINFO_ERROR_NONE;
714 AvSynclyricsInfo *sync_lyric_item = NULL;
715 GList *synclyrics_list = NULL;
717 debug_fenter(RELEASE);
719 if ((mmf_attrs_t *)tag_attrs == NULL) {
720 debug_error(DEBUG, "invalid handle");
721 return FILEINFO_ERROR_INVALID_ARGUMENT;
724 ret = mm_attrs_get_data_by_name(tag_attrs, MM_FILE_TAG_SYNCLYRICS, (void **)&synclyrics_list);
725 if (ret != FILEINFO_ERROR_NONE) {
726 debug_warning(RELEASE, "get data fail");
730 if (synclyrics_list != NULL) {
732 sync_lyric_item = (AvSynclyricsInfo *)g_list_nth_data(synclyrics_list, index);
734 if (sync_lyric_item == NULL) {
735 debug_warning(RELEASE, "synclyric item is NULL");
736 return FILEINFO_ERROR_ATTR_NOT_EXIST;
739 *time_info = sync_lyric_item->time_info;
740 *lyrics = sync_lyric_item->lyric_info;
743 debug_warning(RELEASE, "synclyrics_list is NULL");
744 return FILEINFO_ERROR_ATTR_NOT_EXIST;
751 int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
753 int ret = FILEINFO_ERROR_NONE;
754 mmf_attrs_t *attrs = NULL;
755 MMFileSourceType src;
757 debug_fenter(RELEASE);
759 /* Check argument here */
760 if (tag_attrs == NULL) {
761 debug_error(DEBUG, "Invalid arguments [tag null]\n");
762 return FILEINFO_ERROR_INVALID_ARGUMENT;
764 if (filename == NULL) {
765 debug_error(DEBUG, "Invalid arguments [filename null]\n");
766 return FILEINFO_ERROR_INVALID_ARGUMENT;
768 if (strlen(filename) == 0) {
769 debug_error(DEBUG, "Invalid arguments [filename size 0]\n");
770 return FILEINFO_ERROR_INVALID_ARGUMENT;
774 #ifdef __MMFILE_DYN_LOADING__
775 MMFILE_FUNC_HANDLE func_handle;
777 ret = _load_dynamic_functions(&func_handle);
779 debug_error(DEBUG, "load library error\n");
780 return FILEINFO_ERROR_FILE_INTERNAL;
784 /*set source file infomation*/
785 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
787 ret = _is_file_exist(filename);
789 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
794 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
796 debug_error(DEBUG, "attribute internal error.\n");
797 ret = FILEINFO_ERROR_FILE_INTERNAL;
801 ret = _get_tag_info(attrs, &src);
802 if (ret != FILEINFO_ERROR_NONE) {
803 mmf_attrs_free((MMHandleType)attrs);
805 debug_error(DEBUG, "failed to get tag: %s\n", filename);
808 *tag_attrs = (MMHandleType)attrs;
811 #ifdef __MMFILE_DYN_LOADING__
812 _unload_dynamic_functions(&func_handle);
815 debug_fleave(RELEASE);
822 int mm_file_destroy_tag_attrs(MMHandleType tag_attrs)
824 void *artwork = NULL;
825 GList *synclyrics_list = NULL;
826 int ret = FILEINFO_ERROR_NONE;
828 debug_fenter(RELEASE);
830 if ((mmf_attrs_t *)tag_attrs == NULL) {
831 debug_error(DEBUG, "invalid handle.\n");
832 return FILEINFO_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 debug_fleave(RELEASE);
855 int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filename)
857 mmf_attrs_t *attrs = NULL;
858 MMFileSourceType src = {0, };
859 MMFILE_PARSE_INFO parse = {0, };
862 debug_fenter(RELEASE);
864 /* Check argument here */
865 if (contents_attrs == NULL) {
866 debug_error(DEBUG, "Invalid arguments [contents null]\n");
867 return FILEINFO_ERROR_INVALID_ARGUMENT;
869 if (filename == NULL) {
870 debug_error(DEBUG, "Invalid arguments [filename null]\n");
871 return FILEINFO_ERROR_INVALID_ARGUMENT;
873 if (strlen(filename) == 0) {
874 debug_error(DEBUG, "Invalid arguments [filename size 0]\n");
875 return FILEINFO_ERROR_INVALID_ARGUMENT;
879 #ifdef __MMFILE_DYN_LOADING__
880 MMFILE_FUNC_HANDLE func_handle;
887 ret = _load_dynamic_functions(&func_handle);
889 debug_error(DEBUG, "load library error\n");
890 return FILEINFO_ERROR_FILE_INTERNAL;
894 debug_msg(DEBUG, "_load_dynamic_functions() = %lld\n", gettime() - ti);
899 /*set source file infomation*/
900 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
902 ret = _is_file_exist(filename);
904 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
909 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
911 debug_error(DEBUG, "attribute internal error.\n");
912 ret = FILEINFO_ERROR_FILE_INTERNAL;
917 parse.type = MM_FILE_PARSE_TYPE_ALL;
918 ret = _get_contents_info(attrs, &src, &parse);
919 if (ret != FILEINFO_ERROR_NONE) {
920 mmf_attrs_free((MMHandleType)attrs);
922 debug_error(DEBUG, "failed to get contents: %s\n", filename);
925 *contents_attrs = (MMHandleType) attrs;
929 #ifdef __MMFILE_DYN_LOADING__
935 _unload_dynamic_functions(&func_handle);
938 debug_msg(DEBUG, "_unload_dynamic_functions() = %lld\n", gettime() - ti);
943 debug_fleave(RELEASE);
950 int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *data, unsigned int size, int format)
952 mmf_attrs_t *attrs = NULL;
953 MMFileSourceType src;
954 /*MMFILE_PARSE_INFO parse = {0, };*/
957 debug_fenter(RELEASE);
959 /* Check argument here */
960 if (tag_attrs == NULL || data == NULL) {
961 debug_error(DEBUG, "Invalid arguments\n");
962 return FILEINFO_ERROR_INVALID_ARGUMENT;
965 #ifdef __MMFILE_DYN_LOADING__
966 MMFILE_FUNC_HANDLE func_handle;
968 ret = _load_dynamic_functions(&func_handle);
970 debug_error(DEBUG, "load library error\n");
971 return FILEINFO_ERROR_FILE_INTERNAL;
975 MM_FILE_SET_MEDIA_MEM_SRC(src, data, size, format);
978 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
980 debug_error(DEBUG, "attribute internal error.\n");
981 ret = FILEINFO_ERROR_FILE_INTERNAL;
985 /*parse.type = MM_FILE_PARSE_TYPE_ALL;*/
986 ret = _get_tag_info(attrs, &src);
987 if (ret != FILEINFO_ERROR_NONE) {
988 mmf_attrs_free((MMHandleType)attrs);
990 debug_error(DEBUG, "failed to get tag");
993 *tag_attrs = (MMHandleType)attrs;
996 #ifdef __MMFILE_DYN_LOADING__
997 _unload_dynamic_functions(&func_handle);
1000 debug_fleave(RELEASE);
1007 int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const void *data, unsigned int size, int format)
1009 mmf_attrs_t *attrs = NULL;
1010 MMFileSourceType src;
1011 MMFILE_PARSE_INFO parse = {0, };
1014 debug_fenter(RELEASE);
1016 /* Check argument here */
1017 if (contents_attrs == NULL || data == NULL) {
1018 debug_error(DEBUG, "Invalid arguments\n");
1019 return FILEINFO_ERROR_INVALID_ARGUMENT;
1022 #ifdef __MMFILE_DYN_LOADING__
1023 MMFILE_FUNC_HANDLE func_handle;
1025 ret = _load_dynamic_functions(&func_handle);
1027 debug_error(DEBUG, "load library error\n");
1028 return FILEINFO_ERROR_FILE_INTERNAL;
1032 MM_FILE_SET_MEDIA_MEM_SRC(src, data, size, format);
1035 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1037 debug_error(DEBUG, "attribute internal error.\n");
1038 ret = FILEINFO_ERROR_FILE_INTERNAL;
1042 parse.type = MM_FILE_PARSE_TYPE_ALL;
1043 ret = _get_contents_info(attrs, &src, &parse);
1044 if (ret != FILEINFO_ERROR_NONE) {
1045 mmf_attrs_free((MMHandleType)attrs);
1047 debug_error(DEBUG, "failed to get contents");
1050 *contents_attrs = (MMHandleType)attrs;
1053 #ifdef __MMFILE_DYN_LOADING__
1054 _unload_dynamic_functions(&func_handle);
1057 debug_fleave(RELEASE);
1064 int mm_file_destroy_content_attrs(MMHandleType contents_attrs)
1066 void *thumbnail = NULL;
1067 int ret = FILEINFO_ERROR_NONE;
1069 debug_fenter(RELEASE);
1071 if ((mmf_attrs_t *)contents_attrs == NULL) {
1072 debug_error(DEBUG, "invalid handle.\n");
1073 return FILEINFO_ERROR_INVALID_ARGUMENT;
1076 ret = mm_attrs_get_data_by_name(contents_attrs, MM_FILE_CONTENT_VIDEO_THUMBNAIL, &thumbnail);
1077 if (thumbnail != NULL) {
1078 mmfile_free(thumbnail);
1081 mmf_attrs_free(contents_attrs);
1083 debug_fleave(RELEASE);
1090 int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *video_stream_num)
1092 MMFileSourceType src = {0, };
1093 MMFILE_PARSE_INFO parse = {0, };
1097 debug_fenter(RELEASE);
1099 if (filename == NULL || strlen(filename) == 0 || audio_stream_num == NULL || video_stream_num == NULL) {
1100 debug_error(DEBUG, "Invalid arguments\n");
1101 return FILEINFO_ERROR_INVALID_ARGUMENT;
1104 #ifdef __MMFILE_DYN_LOADING__
1105 MMFILE_FUNC_HANDLE func_handle;
1107 ret = _load_dynamic_functions(&func_handle);
1109 debug_error(DEBUG, "load library error\n");
1110 return FILEINFO_ERROR_FILE_INTERNAL;
1114 /*set source file infomation*/
1115 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1117 ret = _is_file_exist(filename);
1119 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
1123 parse.type = MM_FILE_PARSE_TYPE_SIMPLE;
1124 ret = _get_contents_info(NULL, &src, &parse);
1125 if (ret != FILEINFO_ERROR_NONE) {
1126 debug_error(DEBUG, "failed to get stream info: %s\n", filename);
1128 if (parse.audio_track_num == 0 && parse.video_track_num == 0) {
1129 debug_error(DEBUG, "empty header. retry to get stream info: %s\n", filename);
1130 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1131 ret = _get_contents_info(NULL, &src, &parse);
1135 /*set number of each stream*/
1136 *audio_stream_num = parse.audio_track_num;
1137 *video_stream_num = parse.video_track_num;
1140 #ifdef __MMFILE_DYN_LOADING__
1141 _unload_dynamic_functions(&func_handle);
1144 debug_fleave(RELEASE);
1150 int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char *filename)
1152 mmf_attrs_t *attrs = NULL;
1153 MMFileSourceType src = {0, };
1154 MMFILE_PARSE_INFO parse = {0, };
1157 debug_fenter(RELEASE);
1159 #ifdef __MMFILE_DYN_LOADING__
1160 MMFILE_FUNC_HANDLE func_handle;
1162 ret = _load_dynamic_functions(&func_handle);
1164 debug_error(DEBUG, "load library error\n");
1165 return FILEINFO_ERROR_FILE_INTERNAL;
1168 if (filename == NULL) {
1169 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1172 if (strlen(filename) == 0) {
1173 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1178 /*set source file infomation*/
1179 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1181 ret = _is_file_exist(filename);
1183 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
1188 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1190 debug_error(DEBUG, "attribute internal error.\n");
1191 ret = FILEINFO_ERROR_FILE_INTERNAL;
1195 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1196 ret = _get_contents_info(attrs, &src, &parse);
1197 if (ret != FILEINFO_ERROR_NONE) {
1198 mmf_attrs_free((MMHandleType)attrs);
1200 debug_error(DEBUG, "failed to get contents: %s\n", filename);
1203 *contents_attrs = (MMHandleType) attrs;
1206 #ifdef __MMFILE_DYN_LOADING__
1207 _unload_dynamic_functions(&func_handle);
1210 debug_fleave(RELEASE);
1216 int mm_file_create_content_attrs_safe(MMHandleType *contents_attrs, const char *filename)
1218 mmf_attrs_t *attrs = NULL;
1219 MMFileSourceType src = {0, };
1220 MMFILE_PARSE_INFO parse = {0, };
1223 debug_fenter(RELEASE);
1225 #ifdef __MMFILE_DYN_LOADING__
1226 MMFILE_FUNC_HANDLE func_handle;
1228 ret = _load_dynamic_functions(&func_handle);
1230 debug_error(DEBUG, "load library error\n");
1231 return FILEINFO_ERROR_FILE_INTERNAL;
1234 if (filename == NULL) {
1235 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1238 if (strlen(filename) == 0) {
1239 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1244 /*set source file infomation*/
1245 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1247 ret = _is_file_exist(filename);
1249 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
1254 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1256 debug_error(DEBUG, "attribute internal error.\n");
1257 ret = FILEINFO_ERROR_FILE_INTERNAL;
1261 parse.type = MM_FILE_PARSE_TYPE_SAFE;
1262 ret = _get_contents_info(attrs, &src, &parse);
1263 if (ret != FILEINFO_ERROR_NONE) {
1264 mmf_attrs_free((MMHandleType)attrs);
1266 debug_error(DEBUG, "failed to get contents: %s\n", filename);
1269 *contents_attrs = (MMHandleType) attrs;
1272 #ifdef __MMFILE_DYN_LOADING__
1273 _unload_dynamic_functions(&func_handle);
1276 debug_fleave(RELEASE);
1282 int mm_file_get_video_frame(const char *path, double timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
1285 void *formatFuncHandle = NULL;
1288 debug_error(DEBUG, "Invalid arguments [Path is Null]\n");
1289 return FILEINFO_ERROR_INVALID_ARGUMENT;
1292 #ifdef __MMFILE_DYN_LOADING__
1293 /* Get from function argument */
1294 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
1295 if (!formatFuncHandle) {
1296 debug_error(DEBUG, "error : dlopen");
1300 mmfile_format_get_frame = dlsym(formatFuncHandle, "mmfile_format_get_frame");
1301 if (!mmfile_format_get_frame) {
1302 debug_error(DEBUG, "error : load library");
1307 debug_msg(RELEASE, "file path [%s] is_accurate [%d]", path, is_accurate);
1309 ret = mmfile_format_get_frame(path, timestamp, is_accurate, frame, size, width, height);
1310 if (ret == MMFILE_FORMAT_FAIL) {
1311 debug_error(DEBUG, "error : get frame");
1315 if (formatFuncHandle) dlclose(formatFuncHandle);
1317 return FILEINFO_ERROR_NONE;
1320 if (formatFuncHandle) dlclose(formatFuncHandle);
1322 return FILEINFO_ERROR_FILE_INTERNAL;
1326 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)
1329 void *formatFuncHandle = NULL;
1332 debug_error(DEBUG, "Invalid arguments [data is Null]\n");
1333 return FILEINFO_ERROR_INVALID_ARGUMENT;
1336 if (datasize == 0) {
1337 debug_error(DEBUG, "Invalid arguments [datasize is zero]\n");
1338 return FILEINFO_ERROR_INVALID_ARGUMENT;
1341 #ifdef __MMFILE_DYN_LOADING__
1342 /* Get from function argument */
1343 formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
1344 if (!formatFuncHandle) {
1345 debug_error(DEBUG, "error : dlopen");
1349 mmfile_format_get_frame_from_memory = dlsym(formatFuncHandle, "mmfile_format_get_frame_from_memory");
1350 if (!mmfile_format_get_frame_from_memory) {
1351 debug_error(DEBUG, "error : load library");
1356 debug_msg(RELEASE, "data [%p], data_size[%d], is_accurate [%d]", data, datasize, is_accurate);
1358 ret = mmfile_format_get_frame_from_memory(data, datasize, timestamp, is_accurate, frame, size, width, height);
1359 if (ret == MMFILE_FORMAT_FAIL) {
1360 debug_error(DEBUG, "error : get frame");
1364 if (formatFuncHandle) dlclose(formatFuncHandle);
1366 return FILEINFO_ERROR_NONE;
1369 if (formatFuncHandle) dlclose(formatFuncHandle);
1371 return FILEINFO_ERROR_FILE_INTERNAL;
1375 int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
1377 mmf_attrs_t *attrs = NULL;
1378 MMFileSourceType src = {0, };
1379 MMFILE_PARSE_INFO parse = {0, };
1382 #ifdef __MMFILE_DYN_LOADING__
1383 MMFILE_FUNC_HANDLE func_handle;
1385 ret = _load_dynamic_functions(&func_handle);
1387 debug_error(DEBUG, "load library error\n");
1388 return FILEINFO_ERROR_FILE_INTERNAL;
1391 if (filename == NULL) {
1392 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1395 if (strlen(filename) == 0) {
1396 ret = FILEINFO_ERROR_INVALID_ARGUMENT;
1401 /*set source file infomation*/
1402 MM_FILE_SET_MEDIA_FILE_SRC(src, filename);
1404 ret = _is_file_exist(filename);
1406 ret = FILEINFO_ERROR_FILE_NOT_FOUND;
1411 attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
1413 debug_error(DEBUG, "attribute internal error.\n");
1414 ret = FILEINFO_ERROR_FILE_INTERNAL;
1418 parse.type = MM_FILE_PARSE_TYPE_NORMAL;
1419 ret = _get_contents_info(attrs, &src, &parse);
1420 if (ret == FILEINFO_ERROR_NONE) {
1421 *is_uhqa = parse.is_uhqa;
1423 debug_error(DEBUG, "_get_contents_info failed\n");
1427 mmf_attrs_free((MMHandleType)attrs);
1431 #ifdef __MMFILE_DYN_LOADING__
1432 _unload_dynamic_functions(&func_handle);
1435 debug_fleave(RELEASE);