4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@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.
26 #include <mm_util_imgp.h>
27 #include <mm_util_jpeg.h>
29 #include "media-thumbnail.h"
30 #include "media-thumbnail-private.h"
31 #include "media-thumb-debug.h"
32 #include "media-thumb-ipc.h"
33 #include "media-thumb-util.h"
35 int save_to_file_with_gdk(unsigned char *data, int w, int h, int is_bgra)
39 gdk_pixbuf_save(data,"/mnt/nfs/test.jpg","jpeg", &error, NULL);
41 thumb_dbg ("Error saving image file /mnt/nfs/test.jpg ");
48 int main(int argc, char *argv[])
52 const char *origin_path = NULL;
54 if ((argc != 3) && (argc != 4)) {
55 printf("Usage: %s [test mode number] [path]\n", argv[0]);
60 origin_path = argv[2];
62 if (origin_path && (mode == 1)) {
63 printf("Test _thumbnail_get_data\n");
65 GdkPixbuf *data = NULL;
73 media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
74 //media_thumb_type thumb_type = MEDIA_THUMB_SMALL;
75 media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
76 //media_thumb_format thumb_format = MEDIA_THUMB_RGB888;
80 long start = thumb_get_debug_time();
82 err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, tzplatform_getuid(TZ_USER_NAME));
84 printf("_thumbnail_get_data failed - %d\n", err);
88 printf("Size : %d, W:%d, H:%d\n", thumb_size, thumb_w, thumb_h);
89 printf("Origin W:%d, Origin H:%d\n", origin_w, origin_h);
91 err = save_to_file_with_gdk(data, thumb_w, thumb_h, is_bgra);
93 printf("_thumbnail_get_data failed - %d\n", err);
96 printf("file save success\n");
101 long end = thumb_get_debug_time();
102 printf("Time : %f\n", ((double)(end - start) / (double)CLOCKS_PER_SEC));
104 } else if (mode == 2) {
105 printf("Test thumbnail_request_from_db\n");
106 //const char *origin_path = "/opt/media/test/movie1.mp4";
107 //const char *origin_path = "/opt/media/test/high.jpg";
108 //const char *origin_path = "/opt/media/test/movie2.avi";
109 char thumb_path[MAX_PATH_SIZE + 1];
111 err = thumbnail_request_from_db(origin_path, thumb_path, sizeof(thumb_path), tzplatform_getuid(TZ_USER_NAME));
113 printf("thumbnail_request_from_db failed : %d\n", err);
117 printf("Success!! (%s)\n", thumb_path);
118 } else if (mode == 3) {
119 printf("Test thumbnail_request_save_to_file\n");
120 const char *thumb_path = NULL;
123 thumb_path = argv[3];
125 printf("3 mode requires target path of thumbnail\n");
129 err = thumbnail_request_save_to_file(origin_path, MEDIA_THUMB_LARGE, thumb_path, tzplatform_getuid(TZ_USER_NAME));
131 printf("thumbnail_request_save_to_file failed : %d\n", err);
135 printf("Success!!\n");
136 } else if (origin_path && mode == 4) {
137 printf("Test thumbnail_generate_hash_code\n");
138 char hash[255] = {0,};
140 err = thumbnail_generate_hash_code(origin_path, hash, sizeof(hash));
142 printf("thumbnail_generate_hash_code failed : %d\n", err);
145 printf("Hash : %s\n", hash);
148 printf("Success!!\n");
149 } else if (mode == 5) {
150 printf("Test thumbnail_request_extract_all_thumbs\n");
152 err = thumbnail_request_extract_all_thumbs(tzplatform_getuid(TZ_USER_NAME));
154 printf("thumbnail_request_extract_all_thumbs failed : %d\n", err);
157 printf("thumbnail_request_extract_all_thumbs success!\n");
159 } else if (mode == 6) {
160 printf("Test thumbnail_request_cancel_media\n");
162 err = thumbnail_request_cancel_media(origin_path,tzplatform_getuid(TZ_USER_NAME));
164 printf("thumbnail_request_cancel_media failed : %d\n", err);
167 printf("thumbnail_request_cancel_media success!\n");
169 } else if (mode == 7) {
170 printf("Test thumbnail_request_cancel_all\n");
172 err = thumbnail_request_cancel_all();
174 printf("thumbnail_request_cancel_all failed : %d\n", err);
177 printf("thumbnail_request_cancel_all success!\n");
181 thumb_dbg("Test is Completed");