f8ff57abb854b39d8e629e3d0551df02f470349b
[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-util.h"
23 #include <tzplatform_config.h>
24
25 #ifndef _MEDIA_THUMB_UTIL_H_
26 #define _MEDIA_THUMB_UTIL_H_
27
28 #define SAFE_FREE(src)      { if (src) {free(src); src = NULL; } }
29 #define THUMB_MALLOC(src, size) { if (size <= 0) {src = NULL; } \
30                                                         else { src = malloc(size); if (src) memset(src, 0x0, size); } }
31
32 typedef enum {
33         MEDIA_THUMB_BGRA,                       /* BGRA, especially provided for evas users */
34         MEDIA_THUMB_RGB888,                     /* RGB888 */
35 } media_thumb_format;
36
37 #define THUMB_NONE_TYPE    -1   /* None */
38 #define THUMB_IMAGE_TYPE   0    /* Image */
39 #define THUMB_VIDEO_TYPE   1    /* Video */
40
41 #define THUMB_PATH_PHONE                MEDIA_ROOT_PATH_INTERNAL                /**< File path prefix of files stored in phone */
42 #define THUMB_PATH_MMC          MEDIA_ROOT_PATH_SDCARD          /**< File path prefix of files stored in mmc card */
43
44 #define THUMB_PHONE_PATH        tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/phone")
45 #define THUMB_MMC_PATH          tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/mmc")
46
47 #define THUMB_DEFAULT_PATH      tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png")
48
49 typedef enum {
50         THUMB_PHONE,                    /**< Stored only in phone */
51         THUMB_MMC                               /**< Stored only in MMC */
52 } media_thumb_store_type;
53
54 int _media_thumb_get_store_type_by_path(const char *full_path);
55
56 int _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
57
58 int _media_thumb_get_file_type(const char *file_full_path);
59
60 char* _media_thumb_generate_hash_name(const char *file);
61
62 int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
63
64 int _media_thumb_remove_file(const char *path);
65
66 #endif /*_MEDIA_THUMB_UTIL_H_*/
67