diff options
author | Haejeong Kim <backto.kim@samsung.com> | 2012-08-21 18:21:53 +0900 |
---|---|---|
committer | Haejeong Kim <backto.kim@samsung.com> | 2012-08-21 18:21:53 +0900 |
commit | c47bcf19438edeba50e3ef20b19b18227bb9e551 (patch) | |
tree | 9d5b3984cd7d12c3b30e6f2b00f9bfc83f525d12 /tests | |
parent | 44d9209751977fa2a6ff189d966d73cf044dfdaf (diff) | |
download | libmm-fileinfo-c47bcf19438edeba50e3ef20b19b18227bb9e551.tar.gz libmm-fileinfo-c47bcf19438edeba50e3ef20b19b18227bb9e551.tar.bz2 libmm-fileinfo-c47bcf19438edeba50e3ef20b19b18227bb9e551.zip |
2.0_beta
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/mm_file_test.c | 49 | ||||
-rwxr-xr-x | tests/mm_file_traverse.h | 2 | ||||
-rwxr-xr-x | tests/mm_file_traverser.c | 3 |
3 files changed, 44 insertions, 10 deletions
diff --git a/tests/mm_file_test.c b/tests/mm_file_test.c index 47f9466..b07673a 100755 --- a/tests/mm_file_test.c +++ b/tests/mm_file_test.c @@ -22,6 +22,7 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <sys/types.h> #include <sys/stat.h> @@ -120,7 +121,7 @@ char * VideoCodecTypeString [] = { FILE *fpFailList = NULL; -static int mmfile_get_file_infomation (void *data, void* user_data); +static int mmfile_get_file_infomation (void *data, void* user_data, bool file_test); inline static int mm_file_is_little_endian (void) { @@ -128,6 +129,20 @@ inline static int mm_file_is_little_endian (void) return ((char *)&i)[0]; } +#define READ_FROM_FILE(FILE_PATH, data, size) \ +do{ \ + FILE * fp = fopen (FILE_PATH, "r"); \ + if (fp) { \ + fseek (fp, 0, SEEK_END); \ + size = ftell(fp); \ + fseek (fp, 0, SEEK_SET); \ + data = malloc (size); \ + fread (data, size, sizeof(char), fp); \ + fclose (fp); \ + printf("file size = %d\n", size ); \ + } \ +}while(0) + static int _is_file_exist (const char *filename) { @@ -146,7 +161,7 @@ _is_file_exist (const char *filename) int main(int argc, char **argv) { struct stat statbuf; - + bool file_test = true; //if you want to test mm_file_create_content_XXX_from_memory() set file_test to false if (_is_file_exist (argv[1])) { int ret = lstat (argv[1], &statbuf); @@ -162,7 +177,7 @@ int main(int argc, char **argv) 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); + mmfile_get_file_infomation (argv[1], NULL, file_test); } if (fpFailList != NULL) { @@ -174,7 +189,7 @@ int main(int argc, char **argv) exit(0); } -static int mmfile_get_file_infomation (void *data, void* user_data) +static int mmfile_get_file_infomation (void *data, void* user_data, bool file_test) { MMHandleType content_attrs = 0; MMHandleType tag_attrs = 0; @@ -198,8 +213,17 @@ static int mmfile_get_file_infomation (void *data, void* user_data) 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(file_test) { + /* get content handle */ + ret = mm_file_create_content_attrs(&content_attrs, filename); + } else { + int file_size = 0; + unsigned char * buffer = NULL; + /* Read file */ + READ_FROM_FILE(filename, buffer, file_size); + + ret =mm_file_create_content_attrs_from_memory(&content_attrs, buffer, file_size, MM_FILE_FORMAT_3GP); + } if (ret == MM_ERROR_NONE && content_attrs) { ContentContext_t ccontent; @@ -264,8 +288,17 @@ static int mmfile_get_file_infomation (void *data, void* user_data) 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(file_test) { + /* get tag handle */ + ret = mm_file_create_tag_attrs(&tag_attrs, filename); + } else { + int file_size = 0; + unsigned char * buffer = NULL; + /* Read file */ + READ_FROM_FILE(filename, buffer, file_size); + + ret =mm_file_create_tag_attrs_from_memory(&tag_attrs, buffer, file_size, MM_FILE_FORMAT_3GP); + } if (ret == MM_ERROR_NONE && tag_attrs) { TagContext_t ctag; diff --git a/tests/mm_file_traverse.h b/tests/mm_file_traverse.h index cfca7cf..fc05bee 100755 --- a/tests/mm_file_traverse.h +++ b/tests/mm_file_traverse.h @@ -30,7 +30,7 @@ typedef enum MMFILE_SUCCESS } MMFILE_RETURN; -typedef int (*MMFunc) (void *data, void* user_data); +typedef int (*MMFunc) (void *data, void* user_data, bool file_test); int mmfile_get_file_names (char *root_dir, MMFunc cbfunc, void* user_data); diff --git a/tests/mm_file_traverser.c b/tests/mm_file_traverser.c index 990ee04..7477c10 100755 --- a/tests/mm_file_traverser.c +++ b/tests/mm_file_traverser.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdbool.h> #include <glib.h> #include "mm_file_traverse.h" @@ -98,7 +99,7 @@ int mmfile_get_file_names (char *root_dir, MMFunc cbfunc, void* user_data) printf ("file: %s\n", cdirname); if ( cbfunc != NULL ) { - cbfunc (cdirname, user_data); + cbfunc (cdirname, user_data, true); } } |