91d659e327f867b880033656771acc52610d32f6
[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  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21
22 #ifndef _MEDIA_SVC_UTIL_H_
23 #define _MEDIA_SVC_UTIL_H_
24
25 #include <string.h>
26 #include <stdbool.h>
27 #include <sqlite3.h>
28 #include <time.h>
29 #include <media-util.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define STRING_VALID(str)       (str != NULL && strlen(str) > 0)
36
37 /**
38  * Media meta data information
39  */
40 typedef struct {
41         char            *title;                         /**< track title*/
42         char            *album;                         /**< album name*/
43         char            *artist;                                /**< artist name*/
44         char            *album_artist;          /**< artist name*/
45         char            *genre;                         /**< genre of track*/
46         char            *composer;                      /**< composer name*/
47         char            *year;                          /**< year*/
48         char            *recorded_date;         /**< recorded date*/
49         char            *copyright;                     /**< copyright*/
50         char            *track_num;                     /**< track number*/
51         char            *description;                   /**< description*/
52         int             bitrate;                                /**< bitrate*/
53         int             samplerate;                     /**< samplerate*/
54         int             channel;                                /**< channel*/
55         int             duration;                       /**< duration*/
56         float           longitude;                      /**< longitude*/
57         float           latitude;                               /**< latitude*/
58         float           altitude;                               /**< altitude*/
59         char            *exposure_time;         /**< exposure_time*/
60         float           fnumber;                        /**< fnumber*/
61         int             iso;                                    /**< iso*/
62         char            *model;                         /**< model*/
63         int             width;                          /**< width*/
64         int             height;                         /**< height*/
65         char            *datetaken;                     /**< datetaken*/
66         int             orientation;                    /**< orientation*/
67         int             rating;                         /**< user defined rating */
68         int             bitpersample;           /**< bitrate*/
69         int             is_360;
70 } media_svc_content_meta_s;
71
72 /**
73  * Media data information
74  */
75 typedef struct {
76         char            *media_uuid;                                    /**< Unique ID of item */
77         char            *path;                                          /**< Full path of media file */
78         char            *file_name;                                     /**< File name of media file. Display name */
79         int             media_type;                                     /**< Type of media file : internal/external */
80         char            *mime_type;                                     /**< Full path and file name of media file */
81         unsigned long long      size;                                                   /**< size */
82         time_t  added_time;                                     /**< added time, time_t */
83         time_t  modified_time;                          /**< modified time, time_t */
84         time_t  timeline;                                       /**< timeline of media, time_t */
85         long long int folder_id;                                        /**< Unique ID of folder */
86         int             album_id;                                       /**< Unique ID of album */
87         char            *thumbnail_path;                                /**< Thumbnail image file path */
88         char            *storage_uuid;                                  /**< Unique ID of storage */
89         media_svc_content_meta_s        media_meta;     /**< meta data structure for audio files */
90 } media_svc_content_info_s;
91
92 /**
93  * Type definition for content type
94  */
95 typedef enum {
96         MEDIA_SVC_MEDIA_TYPE_IMAGE      = 0,    /**< Image Content*/
97         MEDIA_SVC_MEDIA_TYPE_VIDEO      = 1,    /**< Video Content*/
98         MEDIA_SVC_MEDIA_TYPE_SOUND      = 2,    /**< Sound Content like Ringtone*/
99         MEDIA_SVC_MEDIA_TYPE_MUSIC      = 3,    /**< Music Content like mp3*/
100         MEDIA_SVC_MEDIA_TYPE_OTHER      = 4,    /**< Not media Content*/
101         MEDIA_SVC_MEDIA_TYPE_BOOK       = 5,    /**< Book Content like epub*/
102 } media_svc_media_type_e;
103
104 typedef enum {
105         MEDIA_SVC_SEARCH_TYPE_DIRECT = 0,
106         MEDIA_SVC_SEARCH_TYPE_DB,
107 } media_svc_search_type_e;
108
109 void _media_svc_remove_file(const char *path);
110 int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
111 int _media_svc_get_file_time(const char *full_path);
112 char * _media_svc_get_title_by_path(const char *path);
113 int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, const char *path, bool refresh);
114 int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info);
115 int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
116 int _media_svc_extract_book_metadata(media_svc_content_info_s *content_info);
117 void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
118 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid);
119 int _media_svc_get_media_type(const char *path, int *mediatype);
120 bool _media_svc_is_keyword_included(const char *path, const char *keyword);
121 void _media_svc_update_wordbook(const char *path, uid_t uid);
122 void _media_svc_clean_wordbook(uid_t uid);
123 bool _media_svc_get_matched_list(const char *keyword, uid_t uid, GList **list);
124
125 #ifdef __cplusplus
126 }
127 #endif
128
129 #endif /*_MEDIA_SVC_UTIL_H_*/