Add to search ebooks with keywords
[platform/core/multimedia/libmedia-service.git] / src / include / common / media-svc-util.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@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
23
24 #ifndef _MEDIA_SVC_UTIL_H_
25 #define _MEDIA_SVC_UTIL_H_
26
27 #include <string.h>
28 #include <stdbool.h>
29 #include <sqlite3.h>
30 #include <time.h>
31 #include <media-util.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #define STRING_VALID(str)       (str != NULL && strlen(str) > 0)
38
39 #define SAFE_STRLCAT(dst, src, n) do { \
40                                 if (src) \
41                                         g_strlcat(dst, src, n); \
42                         } while (0)
43
44 #define SAFE_STRLCPY(dst, src, n) do { \
45                                 if (src) \
46                                         g_strlcpy(dst, src, n); \
47                         } while (0)
48
49 /**
50  * Media meta data information
51  */
52 typedef struct {
53         char            *title;                         /**< track title*/
54         char            *album;                         /**< album name*/
55         char            *artist;                                /**< artist name*/
56         char            *album_artist;          /**< artist name*/
57         char            *genre;                         /**< genre of track*/
58         char            *composer;                      /**< composer name*/
59         char            *year;                          /**< year*/
60         char            *recorded_date;         /**< recorded date*/
61         char            *copyright;                     /**< copyright*/
62         char            *track_num;                     /**< track number*/
63         char            *description;                   /**< description*/
64         int             bitrate;                                /**< bitrate*/
65         int             samplerate;                     /**< samplerate*/
66         int             channel;                                /**< channel*/
67         int             duration;                       /**< duration*/
68         float           longitude;                      /**< longitude*/
69         float           latitude;                               /**< latitude*/
70         float           altitude;                               /**< altitude*/
71         char            *exposure_time;         /**< exposure_time*/
72         float           fnumber;                        /**< fnumber*/
73         int             iso;                                    /**< iso*/
74         char            *model;                         /**< model*/
75         int             width;                          /**< width*/
76         int             height;                         /**< height*/
77         char            *datetaken;                     /**< datetaken*/
78         int             orientation;                    /**< orientation*/
79         int             rating;                         /**< user defined rating */
80         int             bitpersample;           /**< bitrate*/
81
82         char            *title_pinyin;                                  /**< pinyin for title*/
83         char            *album_pinyin;                          /**< pinyin for album*/
84         char            *artist_pinyin;                                 /**< pinyin for artist*/
85         char            *album_artist_pinyin;                   /**< pinyin for album_artist*/
86         char            *genre_pinyin;                                  /**< pinyin for genre*/
87         char            *composer_pinyin;                               /**< pinyin for composer*/
88         char            *copyright_pinyin;                              /**< pinyin for copyright*/
89         char            *description_pinyin;                    /**< pinyin for description*/
90         int             is_360;
91 } media_svc_content_meta_s;
92
93 /**
94  * Media data information
95  */
96 typedef struct {
97         char            *media_uuid;                                    /**< Unique ID of item */
98         char            *path;                                          /**< Full path of media file */
99         char            *file_name;                                     /**< File name of media file. Display name */
100         char            *file_name_pinyin;                              /**< File name pinyin of media file. Display name */
101         int             media_type;                                     /**< Type of media file : internal/external */
102         char            *mime_type;                                     /**< Full path and file name of media file */
103         unsigned long long      size;                                                   /**< size */
104         time_t  added_time;                                     /**< added time, time_t */
105         time_t  modified_time;                          /**< modified time, time_t */
106         time_t  timeline;                                       /**< timeline of media, time_t */
107         char            *folder_uuid;                                   /**< Unique ID of folder */
108         int             album_id;                                       /**< Unique ID of album */
109         char            *thumbnail_path;                                /**< Thumbnail image file path */
110         int             is_drm;                                         /**< is_drm. o or 1 */
111         int             storage_type;                                   /**< Storage of media file : internal/external */
112         char            *storage_uuid;                                  /**< Unique ID of storage */
113         media_svc_content_meta_s        media_meta;     /**< meta data structure for audio files */
114 } media_svc_content_info_s;
115
116 /**
117  * Type definition for content type
118  */
119 typedef enum {
120         MEDIA_SVC_MEDIA_TYPE_IMAGE      = 0,    /**< Image Content*/
121         MEDIA_SVC_MEDIA_TYPE_VIDEO      = 1,    /**< Video Content*/
122         MEDIA_SVC_MEDIA_TYPE_SOUND      = 2,    /**< Sound Content like Ringtone*/
123         MEDIA_SVC_MEDIA_TYPE_MUSIC      = 3,    /**< Music Content like mp3*/
124         MEDIA_SVC_MEDIA_TYPE_OTHER      = 4,    /**< Not media Content*/
125         MEDIA_SVC_MEDIA_TYPE_BOOK       = 5,    /**< Book Content like epub*/
126 } media_svc_media_type_e;
127
128 char * _media_info_generate_uuid(void);
129 void _media_svc_remove_file(const char *path);
130 int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
131 int _media_svc_get_file_time(const char *full_path);
132 char * _media_svc_get_title_by_path(const char *path);
133 int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh);
134 int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info);
135 int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
136 int _media_svc_extract_book_metadata(media_svc_content_info_s *content_info);
137 void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
138 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid);
139 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);
140 bool _media_svc_check_pinyin_support(void);
141 int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *path);
142 int _media_svc_get_media_type(const char *path, int *mediatype);
143 bool _media_svc_is_valid_storage_type(ms_user_storage_type_e storage_type);
144 bool _media_svc_is_keyword_included(const char *path, const char *keyword);
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /*_MEDIA_SVC_UTIL_H_*/