fdda9ee019acc41c35d0e3ebb7e6c016df19fcad
[platform/core/multimedia/libmedia-thumbnail.git] / src / include / util / media-thumb-util.h
1 /*
2  * libmedia-thumbnail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #include "media-thumb-types.h"
23 #include "media-thumb-debug.h"
24 #include "media-util.h"
25 #include <tzplatform_config.h>
26 #include <gdk-pixbuf/gdk-pixbuf.h>
27
28 #ifndef _MEDIA_THUMB_UTIL_H_
29 #define _MEDIA_THUMB_UTIL_H_
30
31 #define SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
32
33 #ifndef _USE_NEW_MEDIA_DB_
34 #define THUMB_NONE_TYPE    0x00000000  /* None */
35 #define THUMB_IMAGE_TYPE    0x00000001  /* Image */
36 #define THUMB_VIDEO_TYPE    0x00000002  /* Video */
37 #else
38 #define THUMB_NONE_TYPE    -1   /* None */
39 #define THUMB_IMAGE_TYPE   0    /* Image */
40 #define THUMB_VIDEO_TYPE   1    /* Video */
41 #endif
42
43 #define THUMB_PATH_PHONE        MEDIA_ROOT_PATH_INTERNAL        /**< File path prefix of files stored in phone */
44 #define THUMB_PATH_MMC          MEDIA_ROOT_PATH_SDCARD          /**< File path prefix of files stored in mmc card */
45
46 #define THUMB_PHONE_PATH        tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/phone")
47 #define THUMB_MMC_PATH          tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/mmc")
48
49 #define THUMB_DEFAULT_PATH      tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png")
50
51 typedef enum
52 {
53         THUMB_PHONE,                    /**< Stored only in phone */
54         THUMB_MMC                               /**< Stored only in MMC */
55 } media_thumb_store_type;
56
57 int _media_thumb_get_length(media_thumb_type thumb_type);
58
59 int _media_thumb_get_store_type_by_path(const char *full_path);
60
61 int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
62
63 int _media_thumb_get_file_type(const char *file_full_path);
64
65 int _media_thumb_remove_file(const char *path);
66
67 char* _media_thumb_generate_hash_name(const char *file);
68
69 int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
70
71 int _media_thumb_save_to_file_with_gdk(GdkPixbuf *data,
72                                                                                         int w,
73                                                                                         int h,
74                                                                                         gboolean alpha,
75                                                                                         char *thumb_path);
76
77 int _media_thumb_get_width(media_thumb_type thumb_type);
78
79 int _media_thumb_get_height(media_thumb_type thumb_type);
80
81 int _thumbnail_get_data(const char *origin_path,
82                                                 media_thumb_type thumb_type,
83                                                 media_thumb_format format,
84                                                 unsigned char **data,
85                                                 int *size,
86                                                 int *width,
87                                                 int *height,
88                                                 int *origin_width,
89                                                 int *origin_height,
90                                                 int *alpha,
91                                                 uid_t uid);
92
93 int _thumbnail_get_raw_data(const char *origin_path,
94                                                 media_thumb_format format,
95                                                 unsigned char **data,
96                                                 int *size,
97                                                 int *width,
98                                                 int *height,
99                                                 uid_t uid);
100
101 #endif /*_MEDIA_THUMB_UTIL_H_*/
102