summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/Makefile.am38
-rwxr-xr-xtests/mm_file_memtrace_reader.c224
-rwxr-xr-xtests/mm_file_test.c368
-rwxr-xr-xtests/mm_file_traverse.h37
-rwxr-xr-xtests/mm_file_traverser.c120
5 files changed, 787 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100755
index 0000000..94bfa72
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,38 @@
+bin_PROGRAMS = mm_file_test
+mm_file_test_DEPENDENCIES = $(top_builddir)/libmmffile.la
+
+
+mm_file_test_SOURCES = mm_file_test.c \
+ mm_file_traverser.c
+
+mm_file_test_CFLAGS = -I$(top_builddir)/include \
+ $(MMCOMMON_CFLAGS) \
+ -I$(includedir) \
+ -D_LARGEFILE64_SOURCE \
+ -D_FILE_OFFSET_BITS=64 \
+ $(GLIB_CFLAGS)
+
+mm_file_test_LDADD = $(MMCOMMON_LIBS) \
+ $(top_builddir)/libmmffile.la \
+ $(top_builddir)/utils/libmmfile_utils.la \
+ $(GLIB_LIBS)
+
+
+if USE_DYN
+else
+mm_file_test_LDADD += $(top_builddir)/codecs/ffmpeg/libmmfile_codecs.la \
+ $(top_builddir)/formats/ffmpeg/libmmfile_formats.la
+endif
+
+
+bin_PROGRAMS += memtrace_reader
+
+memtrace_reader_SOURCES = mm_file_memtrace_reader.c
+
+memtrace_reader_CFLAGS = -I/$(srcdir)/include \
+ -D_LARGEFILE64_SOURCE \
+ -D_FILE_OFFSET_BITS=64
+
+memtrace_reader_DEPENDENCIES =
+memtrace_reader_LDADD =
+
diff --git a/tests/mm_file_memtrace_reader.c b/tests/mm_file_memtrace_reader.c
new file mode 100755
index 0000000..8354a92
--- /dev/null
+++ b/tests/mm_file_memtrace_reader.c
@@ -0,0 +1,224 @@
+/*
+ * libmm-fileinfo
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define LINE_BUFFER_LEN 512
+#define ADDR_BUFFER_LEN 12
+
+#define MALLOC_STRING "MMALLOC: addr="
+#define FREE_STRING "MEMFREE: addr="
+#define PREFIX_STRING_LEN 14
+
+
+
+int get_address (char *linebuff, char *ptrbuff)
+{
+ char *head = linebuff;
+
+ if (!linebuff || !ptrbuff)
+ return 0;
+
+ head = head + PREFIX_STRING_LEN;
+
+ while (*head != ' ')
+ {
+ *ptrbuff = *head;
+ ptrbuff++;
+ head++;
+ }
+
+ return 1;
+}
+
+int main (int argc, char *argv[])
+{
+ char linebuffer[LINE_BUFFER_LEN];
+ char ptrbuffer[ADDR_BUFFER_LEN];
+
+ int alloccount = 0;
+ int freecount = 0;
+
+ if (argc != 2)
+ {
+ printf ("Usage: ./memtrace-read memtrace.mtr\n");
+ exit (1);
+ }
+
+ FILE *fp1 = fopen (argv[1], "r");
+ FILE *fp2 = fopen ("memtrace-result.txt", "w");
+
+ if (!fp1 || !fp2)
+ {
+ printf ("fail to open %s\n", argv[1]);
+ exit (1);
+ }
+
+ while (1)
+ {
+ memset (linebuffer, 0x00, LINE_BUFFER_LEN);
+ memset (ptrbuffer, 0x00, ADDR_BUFFER_LEN);
+
+ if (fgets (linebuffer, LINE_BUFFER_LEN, fp1) == NULL)
+ break;
+
+ if (memcmp (MALLOC_STRING, linebuffer, PREFIX_STRING_LEN) == 0)
+ {
+ get_address (linebuffer, ptrbuffer);
+ alloccount++;
+ }
+
+ if (memcmp (FREE_STRING, linebuffer, PREFIX_STRING_LEN) == 0)
+ {
+ get_address (linebuffer, ptrbuffer);
+ freecount++;
+ }
+ }
+
+ if (alloccount != freecount)
+ {
+ char alloclist[alloccount][ADDR_BUFFER_LEN];
+ int alloccountlist[alloccount];
+ char freelist[freecount][ADDR_BUFFER_LEN];
+ int freecountlist[freecount];
+
+ int i = 0;
+ int allocindex = 0;
+ int freeindex = 0;
+ int totalcount = 0;
+
+ memset (alloclist, 0x00, alloccount*ADDR_BUFFER_LEN);
+ memset (alloccountlist, 0x00, alloccount*4);
+
+ memset (freelist, 0x00, freecount*ADDR_BUFFER_LEN);
+ memset (freecountlist, 0x00, freecount*4);
+
+ fseek (fp1, 0, SEEK_SET);
+
+ while (1)
+ {
+ memset (linebuffer, 0x00, LINE_BUFFER_LEN);
+ memset (ptrbuffer, 0x00, ADDR_BUFFER_LEN);
+
+ if (fgets (linebuffer, LINE_BUFFER_LEN, fp1) == NULL)
+ break;
+
+ totalcount++;
+ if (memcmp (MALLOC_STRING, linebuffer, PREFIX_STRING_LEN) == 0)
+ {
+ int i = 0;
+
+ get_address (linebuffer, ptrbuffer);
+
+ for (i = 0; i < alloccount; i++)
+ {
+ if (memcmp (ptrbuffer, alloclist[i], strlen(ptrbuffer)) == 0)
+ {
+ alloccountlist[i]++;
+ break;
+ }
+ }
+
+ if ( i == alloccount)
+ {
+ memcpy (alloclist[allocindex], ptrbuffer, strlen(ptrbuffer));
+ alloccountlist[allocindex]++;
+ allocindex++;
+ }
+ }
+
+ if (memcmp (FREE_STRING, linebuffer, PREFIX_STRING_LEN) == 0)
+ {
+ int i = 0;
+
+ get_address (linebuffer, ptrbuffer);
+
+ for (i = 0; i < freecount; i++)
+ {
+ if (memcmp (ptrbuffer, freelist[i], strlen(ptrbuffer)) == 0)
+ {
+ freecountlist[i]++;
+ break;
+ }
+ }
+
+ if ( i == freecount)
+ {
+ memcpy (freelist[freeindex], ptrbuffer, strlen(ptrbuffer));
+ freecountlist[freeindex]++;
+ freeindex++;
+ }
+ }
+ }
+
+ printf ("Total: %d mem operation\n", totalcount);
+
+ int i1 = 0, i2 = 0;
+
+
+ fprintf (fp2, "-------------------------------------------------------------\n");
+ fprintf (fp2, "ADDRESS (malloc count, free cout, diff)\n");
+
+
+ for ( i1 = 0; i1 < allocindex; i1++)
+ {
+ for (i2 = 0; i2 < freeindex; i2++)
+ {
+ if (strcmp (alloclist[i1], freelist[i2]) == 0)
+ {
+ if (strcmp (alloclist[i1], "Checked") != 0)
+ break;
+ }
+ }
+
+ if (i2 == freeindex)
+ {
+ // fprintf (fp2, "%s error\n", alloclist[i1]);
+ }
+ else
+ {
+ fprintf (fp2, "%s %12d %8d %8d\n", alloclist[i1], alloccountlist[i1], freecountlist[i2], alloccountlist[i1] - freecountlist[i2]);
+ strcpy (alloclist[i1], "Checked");
+ strcpy (freelist[i2], "Checked");
+ }
+ }
+
+ for (i = 0; i < allocindex; i++)
+ {
+ if ( strcmp (alloclist[i], "Checked") != 0 )
+ fprintf (fp2, "%s error\n", alloclist[i]);
+ }
+
+ for (i = 0; i < freeindex; i++)
+ {
+ if ( strcmp (freelist[i], "Checked") != 0 )
+ fprintf (fp2, "%s error\n", freelist[i]);
+ }
+ }
+
+ fclose (fp1);
+ fclose (fp2);
+
+ exit (0);
+}
+
diff --git a/tests/mm_file_test.c b/tests/mm_file_test.c
new file mode 100755
index 0000000..47f9466
--- /dev/null
+++ b/tests/mm_file_test.c
@@ -0,0 +1,368 @@
+/*
+ * libmm-fileinfo
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include <mm_file.h>
+#include <mm_error.h>
+
+#include "mm_file_traverse.h"
+
+#define MM_TIME_CHECK_START \
+{ FILE *msg_tmp_fp = fopen("time_check.txt", "a+"); struct timeval start, finish; gettimeofday(&start, NULL);
+#define MM_TIME_CHECK_FINISH(title) \
+gettimeofday(&finish, NULL); \
+double end_time = (finish.tv_sec + 1e-6*finish.tv_usec); \
+double start_time = (start.tv_sec + 1e-6*start.tv_usec); \
+fprintf(msg_tmp_fp, "%s\n", title); \
+fprintf(msg_tmp_fp, " - start_time: %3.5lf sec\n", start_time); \
+fprintf(msg_tmp_fp, " - finish_time: %3.5lf sec\n", end_time); \
+fprintf(msg_tmp_fp, " - elapsed time: %3.5lf sec\n", end_time - start_time); \
+fflush(msg_tmp_fp); fclose(msg_tmp_fp); }
+
+typedef struct _mmfile_value {
+ int len;
+ union {
+ int i_val;
+ double d_val;
+ char *s_val;
+ void *p_val;
+ } value;
+}mmfile_value_t;
+
+typedef struct _TagContext {
+ mmfile_value_t artist;
+ mmfile_value_t title;
+ mmfile_value_t album;
+ mmfile_value_t genre;
+ mmfile_value_t author;
+ mmfile_value_t copyright;
+ mmfile_value_t date; //string
+ mmfile_value_t recdate; //string
+ mmfile_value_t description;
+ mmfile_value_t artwork; //data
+ mmfile_value_t artwork_size; //int
+ mmfile_value_t artwork_mime;
+ mmfile_value_t track_num;
+ mmfile_value_t classfication;
+ mmfile_value_t rating;
+ mmfile_value_t conductor;
+ mmfile_value_t longitude; //-> double
+ mmfile_value_t latitude;
+ mmfile_value_t altitude; //<-double
+ mmfile_value_t unsynclyrics;
+ mmfile_value_t synclyrics_size;
+}TagContext_t;
+
+typedef struct _ContentContext {
+ int duration;
+ int video_codec;
+ int video_bitrate;
+ int video_fps;
+ int video_w;
+ int video_h;
+ int video_track_id;
+ int video_track_num;
+ int audio_codec;
+ int audio_bitrate;
+ int audio_channel;
+ int audio_samplerate;
+ int audio_track_id;
+ int audio_track_num;
+ mmfile_value_t thumbnail;
+}ContentContext_t;
+
+
+char * AudioCodecTypeString [] = {
+ "AMR", "G723.1", "MP3", "OGG", "AAC", "WMA", "MMF", "ADPCM", "WAVE", "WAVE NEW", "MIDI", "IMELODY", "MXMF", "MPEG1-Layer1 codec", "MPEG1-Layer2 codec",
+ "G711", "G722", "G722.1", "G722.2 (AMR-WB)", "G723 wideband speech", "G726 (ADPCM)", "G728 speech", "G729", "G729a", "G729.1",
+ "Real",
+ "AAC-Low complexity", "AAC-Main profile", "AAC-Scalable sample rate", "AAC-Long term prediction", "AAC-High Efficiency v1", "AAC-High efficiency v2",
+ "DolbyDigital", "Apple Lossless", "Sony proprietary", "SPEEX", "Vorbis", "AIFF", "AU", "None (will be deprecated)",
+ "PCM", "ALAW", "MULAW", "MS ADPCM"
+};
+
+
+char * VideoCodecTypeString [] = {
+ "None (will be deprecated)",
+ "H263", "H264", "H26L", "MPEG4", "MPEG1", "WMV", "DIVX", "XVID", "H261", "H262/MPEG2-part2", "H263v2", "H263v3",
+ "Motion JPEG", "MPEG2", "MPEG4 part-2 Simple profile", "MPEG4 part-2 Advanced Simple profile", "MPEG4 part-2 Main profile",
+ "MPEG4 part-2 Core profile", "MPEG4 part-2 Adv Coding Eff profile", "MPEG4 part-2 Adv RealTime Simple profile",
+ "MPEG4 part-10 (h.264)", "Real", "VC-1", "AVS", "Cinepak", "Indeo", "Theora"
+};
+
+
+
+FILE *fpFailList = NULL;
+
+static int mmfile_get_file_infomation (void *data, void* user_data);
+
+inline static int mm_file_is_little_endian (void)
+{
+ int i = 0x00000001;
+ return ((char *)&i)[0];
+}
+
+static int
+_is_file_exist (const char *filename)
+{
+ int ret = 1;
+ if (filename) {
+ const char* to_access = (strstr(filename,"file://")!=NULL)? filename+7:filename;
+ ret = access (to_access, R_OK );
+ if (ret != 0) {
+ printf ("file [%s] not found.\n", to_access);
+ }
+ }
+ return !ret;
+}
+
+
+int main(int argc, char **argv)
+{
+ struct stat statbuf;
+
+
+ if (_is_file_exist (argv[1])) {
+ int ret = lstat (argv[1], &statbuf);
+ if ( ret < 0 ) {
+ printf ("lstat error[%d]\n", ret);
+ return MMFILE_FAIL;
+ }
+
+ if (fpFailList == NULL) {
+ fpFailList = fopen ("/opt/var/log/mmfile_fails.txt", "w");
+ }
+
+ if ( S_ISDIR (statbuf.st_mode) ) {
+ mmfile_get_file_names (argv[1], mmfile_get_file_infomation, NULL);
+ } else {
+ mmfile_get_file_infomation (argv[1], NULL);
+ }
+
+ if (fpFailList != NULL) {
+ fflush (fpFailList);
+ fclose (fpFailList);
+ }
+ }
+
+ exit(0);
+}
+
+static int mmfile_get_file_infomation (void *data, void* user_data)
+{
+ MMHandleType content_attrs = 0;
+ MMHandleType tag_attrs = 0;
+ char *err_attr_name = NULL;
+ int audio_track_num = 0;
+ int video_track_num = 0;
+ int ret = 0;
+ char filename[512];
+
+ memset (filename, 0x00, 512);
+ memcpy (filename, (char*)data, strlen ((char*)data));
+
+ MM_TIME_CHECK_START
+
+ printf ("Extracting information for [%s] \n", filename);
+ /* get track info */
+ ret = mm_file_get_stream_info(filename, &audio_track_num, &video_track_num);
+ if (ret == MM_ERROR_NONE) {
+ printf ("# audio=%d, video=%d\n", audio_track_num, video_track_num);
+ } else {
+ printf ("Failed to mm_file_get_stream_info() error=[%x]\n", ret);
+ }
+
+ /* get content handle */
+ ret = mm_file_create_content_attrs(&content_attrs, filename);
+
+ if (ret == MM_ERROR_NONE && content_attrs) {
+ ContentContext_t ccontent;
+ memset (&ccontent, 0, sizeof (ContentContext_t));
+
+ ret = mm_file_get_attrs(content_attrs, &err_attr_name, MM_FILE_CONTENT_DURATION, &ccontent.duration, NULL);
+ printf("# duration: %d\n", ccontent.duration);
+
+ if (ret != MM_ERROR_NONE && err_attr_name)
+ {
+ printf("failed to get %s\n", err_attr_name);
+ free(err_attr_name);
+ err_attr_name = NULL;
+ }
+
+ if (audio_track_num)
+ {
+ mm_file_get_attrs(content_attrs,
+ NULL,
+ MM_FILE_CONTENT_AUDIO_CODEC, &ccontent.audio_codec,
+ MM_FILE_CONTENT_AUDIO_SAMPLERATE, &ccontent.audio_samplerate,
+ MM_FILE_CONTENT_AUDIO_BITRATE, &ccontent.audio_bitrate,
+ MM_FILE_CONTENT_AUDIO_CHANNELS, &ccontent.audio_channel,
+ MM_FILE_CONTENT_AUDIO_TRACK_INDEX, &ccontent.audio_track_id,
+ MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &ccontent.audio_track_num,
+ NULL);
+ printf ("[Audio] ----------------------------------------- \n");
+ printf("# audio codec: %d ", ccontent.audio_codec);
+ printf ("[%s]\n", (ccontent.audio_codec >= 0 && ccontent.audio_codec < MM_AUDIO_CODEC_NUM)? AudioCodecTypeString[ccontent.audio_codec] : "Invalid");
+ printf("# audio samplerate: %d Hz\n", ccontent.audio_samplerate);
+ printf("# audio bitrate: %d bps\n", ccontent.audio_bitrate);
+ printf("# audio channel: %d\n", ccontent.audio_channel);
+ printf("# audio track id: %d\n", ccontent.audio_track_id);
+ printf("# audio track num: %d\n", ccontent.audio_track_num);
+ }
+
+ if (video_track_num)
+ {
+ mm_file_get_attrs(content_attrs,
+ NULL,
+ MM_FILE_CONTENT_VIDEO_CODEC, &ccontent.video_codec,
+ MM_FILE_CONTENT_VIDEO_BITRATE, &ccontent.video_bitrate,
+ MM_FILE_CONTENT_VIDEO_FPS, &ccontent.video_fps,
+ MM_FILE_CONTENT_VIDEO_TRACK_INDEX, &ccontent.video_track_id,
+ MM_FILE_CONTENT_VIDEO_WIDTH, &ccontent.video_w,
+ MM_FILE_CONTENT_VIDEO_HEIGHT, &ccontent.video_h,
+ MM_FILE_CONTENT_VIDEO_THUMBNAIL, &ccontent.thumbnail.value.p_val, &ccontent.thumbnail.len,
+ NULL);
+
+ printf ("[Video] ----------------------------------------- \n");
+ printf("# video codec: %d ", ccontent.video_codec);
+ printf ("[%s]\n", (ccontent.video_codec >= 0 && ccontent.video_codec < MM_VIDEO_CODEC_NUM)? VideoCodecTypeString[ccontent.video_codec] : "Invalid");
+ printf("# video bitrate: %d bps\n", ccontent.video_bitrate);
+ printf("# video fps: %d\n", ccontent.video_fps);
+ printf("# video track id: %d\n", ccontent.video_track_id);
+ printf("# video width/height: %d x %d\n", ccontent.video_w, ccontent.video_h);
+ printf("# video thumbnail: %p\n", ccontent.thumbnail.value.p_val);
+ }
+
+ mm_file_destroy_content_attrs(content_attrs);
+ } else {
+ printf ("Failed to mm_file_create_content_attrs() error=[%x]\n", ret);
+ }
+
+ /* get tag handle */
+ ret = mm_file_create_tag_attrs(&tag_attrs, filename);
+
+ if (ret == MM_ERROR_NONE && tag_attrs) {
+ TagContext_t ctag;
+ memset (&ctag, 0, sizeof (TagContext_t));
+ /* get attributes of tag */
+ ret = mm_file_get_attrs( tag_attrs,
+ &err_attr_name,
+ MM_FILE_TAG_ARTIST, &ctag.artist.value.s_val, &ctag.artist.len,
+ MM_FILE_TAG_ALBUM, &ctag.album.value.s_val, &ctag.album.len,
+ MM_FILE_TAG_TITLE, &ctag.title.value.s_val, &ctag.title.len,
+ MM_FILE_TAG_GENRE, &ctag.genre.value.s_val, &ctag.genre.len,
+ MM_FILE_TAG_AUTHOR, &ctag.author.value.s_val, &ctag.author.len,
+ MM_FILE_TAG_COPYRIGHT, &ctag.copyright.value.s_val, &ctag.copyright.len,
+ MM_FILE_TAG_DATE, &ctag.date.value.s_val, &ctag.date.len,
+ MM_FILE_TAG_RECDATE, &ctag.recdate.value.s_val, &ctag.recdate.len,
+ MM_FILE_TAG_DESCRIPTION, &ctag.description.value.s_val, &ctag.description.len,
+ MM_FILE_TAG_ARTWORK, &ctag.artwork.value.p_val, &ctag.artwork.len,
+ MM_FILE_TAG_ARTWORK_SIZE, &ctag.artwork_size.value.i_val,
+ MM_FILE_TAG_ARTWORK_MIME, &ctag.artwork_mime.value.s_val, &ctag.artwork_mime.len,
+ MM_FILE_TAG_TRACK_NUM, &ctag.track_num.value.s_val, &ctag.track_num.len,
+ MM_FILE_TAG_CLASSIFICATION, &ctag.classfication.value.s_val, &ctag.classfication.len,
+ MM_FILE_TAG_RATING, &ctag.rating.value.s_val, &ctag.rating.len,
+ MM_FILE_TAG_LONGITUDE, &ctag.longitude.value.d_val,
+ MM_FILE_TAG_LATIDUE, &ctag.latitude.value.d_val,
+ MM_FILE_TAG_ALTIDUE, &ctag.altitude.value.d_val,
+ MM_FILE_TAG_CONDUCTOR, &ctag.conductor.value.s_val, &ctag.conductor.len,
+ MM_FILE_TAG_UNSYNCLYRICS, &ctag.unsynclyrics.value.s_val, &ctag.unsynclyrics.len,
+ MM_FILE_TAG_SYNCLYRICS_NUM, &ctag.synclyrics_size.value.i_val,
+ NULL);
+ if (ret != MM_ERROR_NONE && err_attr_name)
+ {
+ printf("failed to get %s attrs\n", err_attr_name);
+ free(err_attr_name);
+ err_attr_name = NULL;
+
+ if (msg_tmp_fp) /* opened by MM_TIME_CHECK_START */
+ {
+ fclose (msg_tmp_fp);
+ msg_tmp_fp = NULL;
+ }
+
+ return -1;
+ }
+
+ /* print tag information */
+ printf ("[Tag] =================================== \n");
+ printf("# artist: %s\n", ctag.artist.value.s_val);
+ printf("# title: %s\n", ctag.title.value.s_val);
+ printf("# album: %s\n", ctag.album.value.s_val);
+ printf("# genre: %s\n", ctag.genre.value.s_val);
+ printf("# author: %s\n", ctag.author.value.s_val);
+ printf("# copyright: %s\n", ctag.copyright.value.s_val);
+ printf("# year: %s\n", ctag.date.value.s_val);
+ printf("# recdate: %s\n", ctag.recdate.value.s_val);
+ printf("# description: %s\n", ctag.description.value.s_val);
+ printf("# artwork: %p\n", ctag.artwork.value.p_val);
+ printf("# artwork_size: %d\n", ctag.artwork_size.value.i_val);
+ printf("# artwork_mime: %s\n", ctag.artwork_mime.value.s_val);
+ printf("# track number: %s\n", ctag.track_num.value.s_val);
+ printf("# classification: %s\n", ctag.classfication.value.s_val);
+ printf("# rating: %s\n", ctag.rating.value.s_val);
+ printf("# longitude: %f\n", ctag.longitude.value.d_val);
+ printf("# latitude: %f\n", ctag.latitude.value.d_val);
+ printf("# altitude: %f\n", ctag.altitude.value.d_val);
+ printf("# conductor: %s\n", ctag.conductor.value.s_val);
+ printf("# unsynclyrics_length: [%d]\n", ctag.unsynclyrics.len);
+ printf("# unsynclyrics: %s\n", ctag.unsynclyrics.value.s_val);
+ printf("# synclyrics size: %d\n", ctag.synclyrics_size.value.i_val);
+
+ if(ctag.synclyrics_size.value.i_val > 0) {
+ int idx = 0;
+ unsigned long time_info = 0;
+ char * lyrics_info = NULL;
+
+ printf("# synclyrics: \n");
+
+ for(idx = 0; idx < ctag.synclyrics_size.value.i_val; idx++) {
+ ret = mm_file_get_synclyrics_info(tag_attrs, idx, &time_info, &lyrics_info);
+ if(ret == MM_ERROR_NONE) {
+ printf("[%2d][%6d][%s]\n", idx, time_info, lyrics_info);
+ } else {
+ printf("Error when get lyrics\n");
+ break;
+ }
+ }
+ }
+
+ /* release tag */
+ mm_file_destroy_tag_attrs(tag_attrs);
+ } else {
+ printf ("Failed to mm_file_create_tag_attrs() error=[%x]\n", ret);
+ }
+
+
+ printf ("=================================================\n\n");
+
+ MM_TIME_CHECK_FINISH (filename);
+
+ return 0;
+}
diff --git a/tests/mm_file_traverse.h b/tests/mm_file_traverse.h
new file mode 100755
index 0000000..cfca7cf
--- /dev/null
+++ b/tests/mm_file_traverse.h
@@ -0,0 +1,37 @@
+/*
+ * libmm-fileinfo
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MM_FILE_TRAVERSE_H_
+#define _MM_FILE_TRAVERSE_H_
+
+#define MMFILE_PATH_MAX 256
+
+typedef enum
+{
+ MMFILE_FAIL = 0,
+ MMFILE_SUCCESS
+} MMFILE_RETURN;
+
+typedef int (*MMFunc) (void *data, void* user_data);
+
+int mmfile_get_file_names (char *root_dir, MMFunc cbfunc, void* user_data);
+
+#endif /* _MM_FILE_TRAVERSE_H_ */
diff --git a/tests/mm_file_traverser.c b/tests/mm_file_traverser.c
new file mode 100755
index 0000000..990ee04
--- /dev/null
+++ b/tests/mm_file_traverser.c
@@ -0,0 +1,120 @@
+/*
+ * libmm-fileinfo
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#include "mm_file_traverse.h"
+
+static GList *g_directories = NULL;
+
+int mmfile_get_file_names (char *root_dir, MMFunc cbfunc, void* user_data)
+{
+ struct stat statbuf;
+ struct dirent *dirp;
+ DIR *dp;
+
+ char pdirname[MMFILE_PATH_MAX+1];
+
+ memset (pdirname, 0x00, MMFILE_PATH_MAX+1);
+
+ if ( lstat (root_dir, &statbuf) < 0 )
+ {
+ printf ("lstat error\n");
+ return MMFILE_FAIL;
+ }
+
+ if ( S_ISDIR (statbuf.st_mode) == 0 )
+ {
+ printf ("it is not directory\n");
+ return MMFILE_FAIL;
+ }
+
+ g_directories = g_list_append(g_directories, strdup (root_dir));
+
+
+ int i = 0;
+ gpointer element_data = NULL;
+ while ( (element_data = g_list_nth_data (g_directories, i)) != NULL )
+ {
+ if (strlen ((char*) element_data) > 0 && strlen ((char*) element_data) <= MMFILE_PATH_MAX)
+ {
+ strcpy (pdirname, (char*) element_data);
+
+ if ( (dp = opendir (pdirname)) != NULL )
+ {
+ while ( (dirp = readdir (dp)) != NULL )
+ {
+ char cdirname[MMFILE_PATH_MAX+1];
+
+ if ( strcmp (dirp->d_name, ".") == 0 ||
+ strcmp (dirp->d_name, "..") == 0 )
+ {
+ continue;
+ }
+
+ memset (cdirname, 0x00, MMFILE_PATH_MAX+1);
+ strcpy (cdirname, pdirname);
+ strcat (cdirname, "/");
+ strcat (cdirname, dirp->d_name);
+
+ if ( lstat (cdirname, &statbuf) < 0 )
+ {
+ printf ("lstat error\n");
+ return MMFILE_FAIL;
+ }
+
+ if ( S_ISDIR (statbuf.st_mode) )
+ {
+ printf ("directory: %s\n", cdirname);
+ g_directories = g_list_append(g_directories, strdup (cdirname));
+ }
+ else
+ {
+ printf ("file: %s\n", cdirname);
+ if ( cbfunc != NULL )
+ {
+ cbfunc (cdirname, user_data);
+ }
+ }
+
+ }
+
+ closedir (dp);
+ }
+ }
+
+ i++;
+ }
+
+ g_list_free (g_directories);
+
+ return MMFILE_SUCCESS;
+
+
+}
+