Fix deadlock during extracting tags
[platform/core/multimedia/libmm-fileinfo.git] / mm_file.c
index 8c9123e..c2e9385 100755 (executable)
--- a/mm_file.c
+++ b/mm_file.c
@@ -124,12 +124,43 @@ static mmf_attrs_construct_info_t g_tag_attrs[] = {
        {(char *)"tag-rotate",                  MMF_VALUE_TYPE_STRING,  MM_ATTRS_FLAG_RW, (void *)NULL},
        {(char *)"tag-cdis",                    MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"tag-smta",                    MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
-       {(char *)"tag-360",                     MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-spherical",                                       MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-stitched",                                        MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-stitching-software",                      MMF_VALUE_TYPE_STRING,  MM_ATTRS_FLAG_RW, (void *)NULL},
+       {(char *)"tag-projection-type",                         MMF_VALUE_TYPE_STRING,  MM_ATTRS_FLAG_RW, (void *)NULL},
+       {(char *)"tag-stereo-mode",                                     MMF_VALUE_TYPE_STRING,  MM_ATTRS_FLAG_RW, (void *)NULL},
+       {(char *)"tag-source-count",                            MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-init-view-heading",                       MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-init-view-pitch",                         MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-init-view-roll",                          MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-timestamp",                                       MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-full-pano-width",                         MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-full-pano-height",                        MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-cropped-area-image-width",        MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-cropped-area-image-height",       MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-cropped-area-left",                       MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-cropped-area-top",                        MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-ambisonic-type",                          MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-ambisonic-format",                        MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"tag-ambisonic-order",                         MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"stereo-mode-v2",                                              MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"metadata-source-v2",                                  MMF_VALUE_TYPE_STRING,  MM_ATTRS_FLAG_RW, (void *)NULL},
+       {(char *)"proj-type-v2",                                                MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"pose-yaw-degrees-v2",                                 MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"pose-pitch-degrees-v2",                               MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"pose-roll-degrees-v2",                                MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"cbmp-layout-v2",                                              MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"cbmp-padding-v2",                                             MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"equi-projection-bounds-top-v2",               MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"equi-projection-bounds-bottom-v2",    MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"equi-projection-bounds-left-v2",              MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"equi-projection-bounds-right-v2",             MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
 };
 
 static mmf_attrs_construct_info_t g_content_attrs[] = {
        {(char *)"content-duration",                    MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"content-video-codec",         MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
+       {(char *)"content-video-format",                MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"content-video-bitrate",               MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"content-video-fps",                   MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
        {(char *)"content-video-width",         MMF_VALUE_TYPE_INT,             MM_ATTRS_FLAG_RW, (void *)0},
@@ -181,7 +212,7 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
 
        formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
        if (!formatFuncHandle) {
-               debug_error("error: %s\n", "libmmfile_formats.so open error");
+               debug_error(DEBUG, "error: %s\n", "libmmfile_formats.so open error");
                ret = 0;
                goto exception;
        }
@@ -198,7 +229,7 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
            !mmfile_format_read_tag ||
            !mmfile_format_close) {
 
-               debug_error("error: %s\n", "format function load error");
+               debug_error(DEBUG, "error: %s\n", "format function load error");
                ret = 0;
                goto exception;
        }
@@ -208,7 +239,7 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
 
        codecFuncHandle = dlopen(MMFILE_CODEC_SO_FILE_NAME, RTLD_LAZY | RTLD_GLOBAL);
        if (!codecFuncHandle) {
-               debug_error("error: %s\n", "libmmfile_codecs.so open error");
+               debug_error(DEBUG, "error: %s\n", "libmmfile_codecs.so open error");
                ret = 0;
                goto exception;
        }
@@ -218,7 +249,7 @@ static int _load_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
        mmfile_codec_close              = dlsym(codecFuncHandle, "mmfile_codec_close");
 
        if (!mmfile_codec_open || !mmfile_codec_decode || !mmfile_codec_close) {
-               debug_error("error: %s\n", "codec function load error");
+               debug_error(DEBUG, "error: %s\n", "codec function load error");
                ret = 0;
                goto exception;
        }
@@ -242,9 +273,7 @@ exception:
 
 static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
 {
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        if (pHandle->formatFuncHandle) {
                dlclose(pHandle->formatFuncHandle);
@@ -253,9 +282,7 @@ static void _unload_dynamic_functions(MMFILE_FUNC_HANDLE *pHandle)
                dlclose(pHandle->codecFuncHandle);
        }
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 }
 
 
@@ -272,7 +299,7 @@ _is_file_exist(const char *filename)
                const char *to_access = (strstr(filename, "file://") != NULL) ? filename + 7 : filename;
                ret = access(to_access, R_OK);
                if (ret != 0) {
-                       debug_error("file [%s] not found.\n", to_access);
+                       debug_error(DEBUG, "file [%s] not found.\n", to_access);
                }
        }
        return !ret;
@@ -310,7 +337,39 @@ _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
                mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_CDIS, formatContext->cdis);
                mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SMTA, formatContext->smta);
 
-               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_360, formatContext->is_360);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL, formatContext->isSpherical);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_STITCHED, formatContext->isStitched);
+               if (formatContext->stitchingSoftware)   mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_SPHERICAL_STITCHING_SOFTWARE, formatContext->stitchingSoftware);
+               if (formatContext->projectionType)              mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_SPHERICAL_PROJECTION_TYPE, formatContext->projectionType);
+               if (formatContext->stereoMode)                  mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_SPHERICAL_STEREO_MODE, formatContext->stereoMode);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_SOURCE_COUNT, formatContext->sourceCount);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_INIT_VIEW_HEADING, formatContext->initViewHeading);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_INIT_VIEW_PITCH, formatContext->initViewPitch);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_INIT_VIEW_ROLL, formatContext->initViewRoll);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_TIMESTAMP, formatContext->timestamp);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_FULL_PANO_WIDTH, formatContext->fullPanoWidth);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_FULL_PANO_HEIGHT, formatContext->fullPanoHeight);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_CROPPED_AREA_IMAGE_WIDTH, formatContext->croppedAreaImageWidth);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_CROPPED_AREA_IMAGE_HEIGHT, formatContext->croppedAreaImageHeight);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_CROPPED_AREA_LEFT, formatContext->croppedAreaLeft);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_CROPPED_AREA_TOP, formatContext->croppedAreaTop);
+
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_AMBISONIC_TYPE, formatContext->ambisonicType);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_AMBISONIC_FORMAT, formatContext->ambisonicFormat);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_AMBISONIC_ORDER, formatContext->ambisonicOrder);
+
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_STEREO_MODE, formatContext->stereoModeV2);
+               if (formatContext->metadataSourceV2)    mm_attrs_set_string_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_METADATA_SOURCE, formatContext->metadataSourceV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_PROJ_TYPE, formatContext->projTypeV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_POSE_YAW, formatContext->poseYawV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_POSE_PITCH, formatContext->posePitchV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_POSE_ROLL, formatContext->poseRollV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_CBMP_LAYOUT, formatContext->cbmpLayoutV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_CBMP_PADDING, formatContext->cbmpPaddingV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_EQUI_BOUNDS_TOP, formatContext->equiBoundsTopV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_EQUI_BOUNDS_BOTTOM, formatContext->equiBoundsBottomV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_EQUI_BOUNDS_LEFT, formatContext->equiBoundsLeftV2);
+               mm_attrs_set_int_by_name(hattrs, MM_FILE_TAG_SPHERICAL_V2_EQUI_BOUNDS_RIGHT, formatContext->equiBoundsRightV2);
 
                if ((formatContext->syncLyricsNum > 0) && (formatContext->syncLyrics))
                        mm_attrs_set_data_by_name(hattrs, MM_FILE_TAG_SYNCLYRICS, formatContext->syncLyrics, formatContext->syncLyricsNum);
@@ -339,6 +398,7 @@ _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
 
                        MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM];
 
+                       mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_FORMAT, formatContext->formatType);
                        mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_CODEC, videoStream->codecId);
                        mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_BITRATE, videoStream->bitRate);
                        mm_attrs_set_int_by_name(hattrs, MM_FILE_CONTENT_VIDEO_FPS, videoStream->framePerSec);
@@ -375,7 +435,7 @@ _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
        }
 
        /*commit attrs*/
-       ret = mmf_attrs_commit((MMHandleType)hattrs);
+       mmf_attrs_commit((MMHandleType)hattrs);
 
        return ret;
 }
@@ -396,7 +456,7 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
 
        ret = mmfile_format_open(&formatContext, src);
        if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
-               debug_error("error: mmfile_format_open\n");
+               debug_error(DEBUG, "error: mmfile_format_open\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto exception;
        }
@@ -406,7 +466,7 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
                        formatContext->cdis = 1;
                ret = mmfile_format_read_stream(formatContext);
                if (MMFILE_FORMAT_FAIL == ret) {
-                       debug_error("error: mmfile_format_read_stream\n");
+                       debug_error(DEBUG, "error: mmfile_format_read_stream\n");
                        ret = FILEINFO_ERROR_FILE_INTERNAL;
                        goto exception;
                }
@@ -424,17 +484,22 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
                if (parse->type >= MM_FILE_PARSE_TYPE_ALL) {
                        if (formatContext->videoTotalTrackNum > 0) {
 
+/*why below code needed?
+This API is for extracting some attributes not metadata(TAG). mm_file_create_content_attrs() use this API.
+but MMFileUtilGetMetaDataFromMP4() Extract just TAG info. That is needed for mm_file_create_tag_attrs()*/
+#if 0
                                if (parse->type != MM_FILE_PARSE_TYPE_SAFE) {
                                        if (formatContext->formatType == MM_FILE_FORMAT_3GP || formatContext->formatType == MM_FILE_FORMAT_MP4) {
                                                MMFileUtilGetMetaDataFromMP4(formatContext);
                                        }
                                }
+#endif
                                MMFileFormatStream *videoStream = formatContext->streams[MMFILE_VIDEO_STREAM];
                                unsigned int timestamp = _SEEK_POINT_;
 
                                ret = mmfile_format_read_frame(formatContext, timestamp, &frameContext);
                                if (MMFILE_FORMAT_FAIL == ret) {
-                                       debug_error("error: mmfile_format_read_frame\n");
+                                       debug_error(DEBUG, "error: mmfile_format_read_frame\n");
                                        ret = FILEINFO_ERROR_FILE_INTERNAL;
                                        goto warning;
                                }
@@ -450,14 +515,14 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
 
                                        ret = mmfile_codec_open(&codecContext, MMFILE_VIDEO_DECODE, videoStream->codecId, &codecFrame);
                                        if (MMFILE_FORMAT_FAIL == ret) {
-                                               debug_error("error: mmfile_codec_open\n");
+                                               debug_error(DEBUG, "error: mmfile_codec_open\n");
                                                ret = FILEINFO_ERROR_FILE_INTERNAL;
                                                goto warning;
                                        }
 
                                        ret = mmfile_codec_decode(codecContext, &decodedFrame);
                                        if (MMFILE_FORMAT_FAIL == ret) {
-                                               debug_error("error: mmfile_codec_decode\n");
+                                               debug_error(DEBUG, "error: mmfile_codec_decode\n");
                                                ret = FILEINFO_ERROR_FILE_INTERNAL;
                                                goto warning;
                                        }
@@ -465,7 +530,7 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
                                        /* set video thumbnail */
                                        formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
                                        if (NULL == formatContext->thumbNail) {
-                                               debug_error("error: mmfile_malloc\n");
+                                               debug_error(DEBUG, "error: mmfile_malloc\n");
                                                ret = FILEINFO_ERROR_FILE_INTERNAL;
                                                goto warning;
                                        }
@@ -479,7 +544,7 @@ _get_contents_info(mmf_attrs_t *attrs, MMFileSourceType *src, MMFILE_PARSE_INFO
                                } else {
                                        formatContext->thumbNail = mmfile_malloc(sizeof(MMFileFormatFrame));
                                        if (NULL == formatContext->thumbNail) {
-                                               debug_error("error: mmfile_format_read_frame\n");
+                                               debug_error(DEBUG, "error: mmfile_format_read_frame\n");
                                                ret = FILEINFO_ERROR_FILE_INTERNAL;
                                                goto warning;
                                        }
@@ -639,14 +704,14 @@ _get_tag_info(mmf_attrs_t *attrs, MMFileSourceType *src)
 
        ret = mmfile_format_open(&formatContext, src);
        if (MMFILE_FORMAT_FAIL == ret || formatContext == NULL) {
-               debug_error("error: mmfile_format_open\n");
+               debug_error(DEBUG, "error: mmfile_format_open\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto exception;
        }
 
        ret = mmfile_format_read_tag(formatContext);
        if (MMFILE_FORMAT_FAIL == ret) {
-               debug_warning("reading tag is fail\n");
+               debug_warning(DEBUG, "reading tag is fail\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto exception;
        }
@@ -680,12 +745,12 @@ int mm_file_get_attrs(MMHandleType attrs, char **err_attr_name, const char *firs
        va_list var_args;
 
        if (!attrs) {
-               debug_error("Invalid arguments [attrs 0]\n");
+               debug_error(DEBUG, "Invalid arguments [attrs 0]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
        if (first_attribute_name == NULL) {
-               debug_error("Invalid arguments [first_attribute_name null]\n");
+               debug_error(DEBUG, "Invalid arguments [first_attribute_name null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -696,7 +761,7 @@ int mm_file_get_attrs(MMHandleType attrs, char **err_attr_name, const char *firs
 
        if (ret != FILEINFO_ERROR_NONE) {
                if (err_attr_name) {
-                       debug_error("failed to get %s\n", *err_attr_name);
+                       debug_error(DEBUG, "failed to get %s\n", *err_attr_name);
                }
        }
 
@@ -709,20 +774,16 @@ int mm_file_get_synclyrics_info(MMHandleType tag_attrs, int index, unsigned long
        AvSynclyricsInfo *sync_lyric_item = NULL;
        GList *synclyrics_list = NULL;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        if ((mmf_attrs_t *)tag_attrs == NULL) {
-               debug_error("invalid handle");
+               debug_error(DEBUG, "invalid handle");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
        ret = mm_attrs_get_data_by_name(tag_attrs, MM_FILE_TAG_SYNCLYRICS, (void **)&synclyrics_list);
        if (ret != FILEINFO_ERROR_NONE) {
-#ifdef __MMFILE_TEST_MODE__
-               debug_warning("get data fail");
-#endif
+               debug_warning(RELEASE, "get data fail");
                return ret;
        }
 
@@ -731,9 +792,7 @@ int mm_file_get_synclyrics_info(MMHandleType tag_attrs, int index, unsigned long
                sync_lyric_item = (AvSynclyricsInfo *)g_list_nth_data(synclyrics_list, index);
 
                if (sync_lyric_item == NULL) {
-#ifdef __MMFILE_TEST_MODE__
-                       debug_warning("synclyric item is NULL");
-#endif
+                       debug_warning(RELEASE, "synclyric item is NULL");
                        return FILEINFO_ERROR_ATTR_NOT_EXIST;
                }
 
@@ -741,9 +800,7 @@ int mm_file_get_synclyrics_info(MMHandleType tag_attrs, int index, unsigned long
                *lyrics = sync_lyric_item->lyric_info;
 
        } else {
-#ifdef __MMFILE_TEST_MODE__
-               debug_warning("synclyrics_list is NULL");
-#endif
+               debug_warning(RELEASE, "synclyrics_list is NULL");
                return FILEINFO_ERROR_ATTR_NOT_EXIST;
        }
 
@@ -757,21 +814,19 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
        mmf_attrs_t *attrs = NULL;
        MMFileSourceType src;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        /* Check argument here */
        if (tag_attrs == NULL) {
-               debug_error("Invalid arguments [tag null]\n");
+               debug_error(DEBUG, "Invalid arguments [tag null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
        if (filename == NULL) {
-               debug_error("Invalid arguments [filename null]\n");
+               debug_error(DEBUG, "Invalid arguments [filename null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
        if (strlen(filename) == 0)      {
-               debug_error("Invalid arguments [filename size 0]\n");
+               debug_error(DEBUG, "Invalid arguments [filename size 0]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -781,7 +836,7 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -798,7 +853,7 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -807,7 +862,7 @@ int mm_file_create_tag_attrs(MMHandleType *tag_attrs, const char *filename)
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get tag: %s\n", filename);
+               debug_error(DEBUG, "failed to get tag: %s\n", filename);
        }
 
        *tag_attrs = (MMHandleType)attrs;
@@ -817,9 +872,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -832,12 +885,10 @@ int mm_file_destroy_tag_attrs(MMHandleType tag_attrs)
        GList *synclyrics_list = NULL;
        int ret = FILEINFO_ERROR_NONE;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        if ((mmf_attrs_t *)tag_attrs == NULL) {
-               debug_error("invalid handle.\n");
+               debug_error(DEBUG, "invalid handle.\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -855,9 +906,7 @@ int mm_file_destroy_tag_attrs(MMHandleType tag_attrs)
 
        mmf_attrs_free(tag_attrs);
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -870,21 +919,19 @@ int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filen
        MMFILE_PARSE_INFO parse = {0, };
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        /* Check argument here */
        if (contents_attrs == NULL) {
-               debug_error("Invalid arguments [contents null]\n");
+               debug_error(DEBUG, "Invalid arguments [contents null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
        if (filename == NULL) {
-               debug_error("Invalid arguments [filename null]\n");
+               debug_error(DEBUG, "Invalid arguments [filename null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
        if (strlen(filename) == 0)      {
-               debug_error("Invalid arguments [filename size 0]\n");
+               debug_error(DEBUG, "Invalid arguments [filename size 0]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -899,12 +946,12 @@ int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filen
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 
 #ifdef CHECK_TIME
-       debug_msg("_load_dynamic_functions() = %lld\n", gettime() - ti);
+       debug_msg(DEBUG, "_load_dynamic_functions() = %lld\n", gettime() - ti);
 #endif
 
 #endif
@@ -921,7 +968,7 @@ int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filen
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -932,7 +979,7 @@ int mm_file_create_content_attrs(MMHandleType *contents_attrs, const char *filen
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get contents: %s\n", filename);
+               debug_error(DEBUG, "failed to get contents: %s\n", filename);
        }
 
        *contents_attrs = (MMHandleType) attrs;
@@ -948,14 +995,12 @@ END:
        _unload_dynamic_functions(&func_handle);
 
 #ifdef CHECK_TIME
-       debug_msg("_unload_dynamic_functions() = %lld\n", gettime() - ti);
+       debug_msg(DEBUG, "_unload_dynamic_functions() = %lld\n", gettime() - ti);
 #endif
 
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -969,13 +1014,11 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
        /*MMFILE_PARSE_INFO parse = {0, };*/
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        /* Check argument here */
        if (tag_attrs == NULL || data == NULL) {
-               debug_error("Invalid arguments\n");
+               debug_error(DEBUG, "Invalid arguments\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -984,7 +1027,7 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -994,7 +1037,7 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("tag", g_tag_attrs, ARRAY_SIZE(g_tag_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -1004,7 +1047,7 @@ int mm_file_create_tag_attrs_from_memory(MMHandleType *tag_attrs, const void *da
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get tag");
+               debug_error(DEBUG, "failed to get tag");
        }
 
        *tag_attrs = (MMHandleType)attrs;
@@ -1014,9 +1057,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1030,13 +1071,11 @@ int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const
        MMFILE_PARSE_INFO parse = {0, };
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        /* Check argument here */
        if (contents_attrs == NULL || data == NULL) {
-               debug_error("Invalid arguments\n");
+               debug_error(DEBUG, "Invalid arguments\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1045,7 +1084,7 @@ int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -1055,7 +1094,7 @@ int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -1065,7 +1104,7 @@ int mm_file_create_content_attrs_from_memory(MMHandleType *contents_attrs, const
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get contents");
+               debug_error(DEBUG, "failed to get contents");
        }
 
        *contents_attrs = (MMHandleType)attrs;
@@ -1075,9 +1114,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1089,12 +1126,10 @@ int mm_file_destroy_content_attrs(MMHandleType contents_attrs)
        void *thumbnail = NULL;
        int ret = FILEINFO_ERROR_NONE;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        if ((mmf_attrs_t *)contents_attrs == NULL) {
-               debug_error("invalid handle.\n");
+               debug_error(DEBUG, "invalid handle.\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1105,9 +1140,7 @@ int mm_file_destroy_content_attrs(MMHandleType contents_attrs)
 
        mmf_attrs_free(contents_attrs);
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1121,12 +1154,10 @@ int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *vi
 
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
        if (filename == NULL || strlen(filename) == 0 || audio_stream_num == NULL || video_stream_num == NULL) {
-               debug_error("Invalid arguments\n");
+               debug_error(DEBUG, "Invalid arguments\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1135,7 +1166,7 @@ int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *vi
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -1152,10 +1183,10 @@ int mm_file_get_stream_info(const char *filename, int *audio_stream_num, int *vi
        parse.type = MM_FILE_PARSE_TYPE_SIMPLE;
        ret = _get_contents_info(NULL, &src, &parse);
        if (ret != FILEINFO_ERROR_NONE) {
-               debug_error("failed to get stream info: %s\n", filename);
+               debug_error(DEBUG, "failed to get stream info: %s\n", filename);
        } else {
                if (parse.audio_track_num == 0 && parse.video_track_num == 0) {
-                       debug_error("empty header. retry to get stream info: %s\n", filename);
+                       debug_error(DEBUG, "empty header. retry to get stream info: %s\n", filename);
                        parse.type = MM_FILE_PARSE_TYPE_NORMAL;
                        ret = _get_contents_info(NULL, &src, &parse);
                }
@@ -1170,9 +1201,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1185,16 +1214,14 @@ int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char
        MMFILE_PARSE_INFO parse = {0, };
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
 #ifdef __MMFILE_DYN_LOADING__
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -1220,7 +1247,7 @@ int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -1230,7 +1257,7 @@ int mm_file_create_content_attrs_simple(MMHandleType *contents_attrs, const char
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get contents: %s\n", filename);
+               debug_error(DEBUG, "failed to get contents: %s\n", filename);
        }
 
        *contents_attrs = (MMHandleType) attrs;
@@ -1240,9 +1267,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1255,16 +1280,14 @@ int mm_file_create_content_attrs_safe(MMHandleType *contents_attrs, const char *
        MMFILE_PARSE_INFO parse = {0, };
        int ret = 0;
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fenter();
-#endif
+       debug_fenter(RELEASE);
 
 #ifdef __MMFILE_DYN_LOADING__
        MMFILE_FUNC_HANDLE func_handle;
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -1290,7 +1313,7 @@ int mm_file_create_content_attrs_safe(MMHandleType *contents_attrs, const char *
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -1300,7 +1323,7 @@ int mm_file_create_content_attrs_safe(MMHandleType *contents_attrs, const char *
        if (ret != FILEINFO_ERROR_NONE) {
                mmf_attrs_free((MMHandleType)attrs);
                attrs = NULL;
-               debug_error("failed to get contents: %s\n", filename);
+               debug_error(DEBUG, "failed to get contents: %s\n", filename);
        }
 
        *contents_attrs = (MMHandleType) attrs;
@@ -1310,9 +1333,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
 }
@@ -1324,7 +1345,7 @@ int mm_file_get_video_frame(const char *path, double timestamp, bool is_accurate
        void *formatFuncHandle = NULL;
 
        if (path == NULL) {
-               debug_error("Invalid arguments [Path is Null]\n");
+               debug_error(DEBUG, "Invalid arguments [Path is Null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1332,24 +1353,22 @@ int mm_file_get_video_frame(const char *path, double timestamp, bool is_accurate
        /* Get from function argument */
        formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
        if (!formatFuncHandle) {
-               debug_error("error : dlopen");
+               debug_error(DEBUG, "error : dlopen");
                goto exception;
        }
 
        mmfile_format_get_frame = dlsym(formatFuncHandle, "mmfile_format_get_frame");
        if (!mmfile_format_get_frame) {
-               debug_error("error : load library");
+               debug_error(DEBUG, "error : load library");
                goto exception;
        }
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_msg("file path [%s] is_accurate [%d]", path, is_accurate);
-#endif
+       debug_msg(RELEASE, "file path [%s] is_accurate [%d]", path, is_accurate);
 
        ret = mmfile_format_get_frame(path, timestamp, is_accurate, frame, size, width, height);
        if (ret  == MMFILE_FORMAT_FAIL) {
-               debug_error("error : get frame");
+               debug_error(DEBUG, "error : get frame");
                goto exception;
        }
 
@@ -1370,12 +1389,12 @@ int mm_file_get_video_frame_from_memory(const void *data, unsigned int datasize,
        void *formatFuncHandle = NULL;
 
        if (data == NULL) {
-               debug_error("Invalid arguments [data is Null]\n");
+               debug_error(DEBUG, "Invalid arguments [data is Null]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
        if (datasize == 0) {
-               debug_error("Invalid arguments [datasize is zero]\n");
+               debug_error(DEBUG, "Invalid arguments [datasize is zero]\n");
                return FILEINFO_ERROR_INVALID_ARGUMENT;
        }
 
@@ -1383,24 +1402,22 @@ int mm_file_get_video_frame_from_memory(const void *data, unsigned int datasize,
        /* Get from function argument */
        formatFuncHandle = dlopen(MMFILE_FORMAT_SO_FILE_NAME, RTLD_LAZY);
        if (!formatFuncHandle) {
-               debug_error("error : dlopen");
+               debug_error(DEBUG, "error : dlopen");
                goto exception;
        }
 
        mmfile_format_get_frame_from_memory = dlsym(formatFuncHandle, "mmfile_format_get_frame_from_memory");
        if (!mmfile_format_get_frame_from_memory) {
-               debug_error("error : load library");
+               debug_error(DEBUG, "error : load library");
                goto exception;
        }
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_msg("data [%p], data_size[%d], is_accurate [%d]", data, datasize, is_accurate);
-#endif
+       debug_msg(RELEASE, "data [%p], data_size[%d], is_accurate [%d]", data, datasize, is_accurate);
 
        ret = mmfile_format_get_frame_from_memory(data, datasize, timestamp, is_accurate, frame, size, width, height);
        if (ret  == MMFILE_FORMAT_FAIL) {
-               debug_error("error : get frame");
+               debug_error(DEBUG, "error : get frame");
                goto exception;
        }
 
@@ -1427,7 +1444,7 @@ int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
 
        ret = _load_dynamic_functions(&func_handle);
        if (ret == 0) {
-               debug_error("load library error\n");
+               debug_error(DEBUG, "load library error\n");
                return FILEINFO_ERROR_FILE_INTERNAL;
        }
 #endif
@@ -1453,7 +1470,7 @@ int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
        /*set attrs*/
        attrs = (mmf_attrs_t *) mmf_attrs_new_from_data("content", g_content_attrs, ARRAY_SIZE(g_content_attrs), NULL, NULL);
        if (!attrs) {
-               debug_error("attribute internal error.\n");
+               debug_error(DEBUG, "attribute internal error.\n");
                ret = FILEINFO_ERROR_FILE_INTERNAL;
                goto END;
        }
@@ -1463,7 +1480,7 @@ int mm_file_check_uhqa(const char *filename, bool *is_uhqa)
        if (ret == FILEINFO_ERROR_NONE) {
                *is_uhqa = parse.is_uhqa;
        } else {
-               debug_error("_get_contents_info failed\n");
+               debug_error(DEBUG, "_get_contents_info failed\n");
                *is_uhqa = FALSE;
        }
 
@@ -1475,9 +1492,7 @@ END:
        _unload_dynamic_functions(&func_handle);
 #endif
 
-#ifdef __MMFILE_TEST_MODE__
-       debug_fleave();
-#endif
+       debug_fleave(RELEASE);
 
        return ret;
-}
\ No newline at end of file
+}