5451174037de13cc3eba67e09d82609a36fa9640
[framework/multimedia/libmedia-service.git] / include / media-info.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_INFO_H_
25 #define _MEDIA_INFO_H_
26
27 #include "media-info-types.h"
28 #include "media-info-error.h"
29 #include <sqlite3.h>
30 #include <glib.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 /**
38         @defgroup       MEDIA_INFO      Media Information Service
39          @{
40           * @file                       media-info.h
41           * @brief              This file defines API's for media information service.
42           * @version            1.0
43  */
44
45 /**
46         @defgroup MP_DB_API    Database Manager API
47         @{
48
49         @par
50         manage the service database.
51  */
52
53
54 /**
55  *      mediainfo_open:
56  *      Open media information service library. This is the function that an user who wants to use media information service calls first.
57  *      This function connects to the media database.
58  *
59  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
60  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
61  *      @see            mediainfo_close
62  *      @pre            None.
63  *      @post           call mediainfo_close() to close the media database
64  *      @remark The database name is "/opt/dbspace/.media.db".
65  *      @par example
66  *      @code
67
68 #include <media-info.h>
69
70 void open_media_db()
71 {
72         int ret = MEDIA_INFO_ERROR_NONE;
73         // open media database
74         ret = mediainfo_open();
75         // open failed
76         if (ret < 0)
77         {
78                 printf( "Cannot open media db. error code->%d", ret);
79                 return;
80         }
81
82         return;
83 }
84
85  *      @endcode
86  */
87 int mediainfo_open(void);
88
89 /**
90  *      mediainfo_close:
91  *      Open media information service library. This is the function that an user who wants to finalize media information service calls before closing the application.
92  *      This function disconnects to the media database.
93  *
94  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
95  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
96  *      @see            mediainfo_open
97  *      @pre            None.
98  *      @post           call mediainfo_open() to open the media database
99  *      @remark The database name is "/opt/dbspace/.media.db".
100  *      @par example
101  *      @code
102
103 #include <media-info.h>
104
105 void close_media_db()
106 {
107         int ret = MEDIA_INFO_ERROR_NONE;
108         // close media database
109         ret = mediainfo_close();
110         // close failed
111         if (ret < 0)
112         {
113                 printf( "Cannot close media db. error code->%d", ret);
114                 return;
115         }
116
117         return;
118 }
119
120  *      @endcode
121  */
122 int mediainfo_close(void);
123
124 /**
125  *      mediainfo_connect_db_with_handle:
126  *      Connect to the media database. This is the function that an user who wants to get a handle to access the media database. 
127  *      This function connects to the media database.
128  *
129  *  @param              db_handle [out]         Handle to access database using sqlite3 libs
130  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
131  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
132  *      @see            mediainfo_disconnect_db_with_handle
133  *      @pre            None.
134  *      @post           call mediainfo_connect_db_with_handle to connect to the media database
135  *      @remark The database name is "/opt/dbspace/.media.db".
136  *      @par example
137  *      @code
138
139 #include <media-info.h>
140
141 void connect_media_db()
142 {
143         int ret = MEDIA_INFO_ERROR_NONE;
144         sqlite3* my_handle = NULL;
145
146         // connect to the media database
147         ret = mediainfo_connect_db_with_handle(&my_handle);
148
149         if (ret < 0)
150         {
151                 printf("Fatal error to connect DB\n");
152                 return;
153         }
154
155         return;
156 }
157
158  *      @endcode
159  */
160 int mediainfo_connect_db_with_handle(sqlite3** db_handle);
161
162
163 /**
164  *      mediainfo_disconnect_db_with_handle:
165  *      Disconnect to the media database. This is the function that an user who wants to disconnect the media database. 
166  *      This function disconnects to the media database.
167  *
168  *  @param              db_handle [out]         Handle to access database using sqlite3 libs
169  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
170  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
171  *      @see            mediainfo_connect_db_with_handle
172  *      @pre            None.
173  *      @post           call mediainfo_disconnect_db_with_handle to disconnect to the media database
174  *      @remark The database name is "/opt/dbspace/.media.db".
175  *      @par example
176  *      @code
177
178 #include <media-info.h>
179
180 void disconnect_media_db()
181 {
182         int ret = MEDIA_INFO_ERROR_NONE;
183         sqlite3* my_handle = NULL;
184
185         // connect to the media database
186         ret = mediainfo_connect_db_with_handle(&my_handle);
187
188         if (ret < 0)
189         {
190                 printf("Fatal error to connect DB\n");
191                 return;
192         }
193
194         //
195         // Do something using my_handle
196         //
197         
198
199         ret = mediainfo_disconnect_db_with_handle(my_handle);
200         if (ret < 0)
201         {
202                 printf("Fatal error to disconnect DB\n");
203         }
204
205         return;
206 }
207
208  *      @endcode
209  */
210 int mediainfo_disconnect_db_with_handle(sqlite3* db_handle);
211
212 /**
213  *      mediainfo_register_file:
214  *      This function registers multimedia file to media DB
215  *  When you did some file operations such as Create, Copy, Move, Rename, and Delete in phone or mmc storage, media-server registers the result to database automatically by inotify mechanism.
216  *  However, automatic registration will have a little delay because the method is asynchronous.
217  *  If you want to register some files to database immediately, you should use this API.
218  *
219  *  @param              file_full_path [in]             full path of file for register
220  *      @return         This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
221  *                              Please refer 'media-info-error.h' to know the exact meaning of the error.
222  *      @see            None.
223  *      @pre            None.
224  *      @post           None.
225  *      @remark The database name is "/opt/dbspace/.media.db".
226  *                   You have to use this API only for registering multimedia files. If you try to register no multimedia file, this API returns error.
227  *      @par example
228  *      @code
229
230 #include <media-info.h>
231
232 int main()
233 {
234         int result = -1;
235
236         result = mediainfo_register_file("/opt/media/test.txt");
237         if( result < 0 )
238         {
239                 printf("FAIL to mediainfo_register_file\n");
240                 return 0;
241         }
242         else
243         {
244                 printf("SUCCESS to register file\n");
245         }
246         
247         return 0;
248 }
249
250  *      @endcode
251  */
252 DEPRECATED_API int mediainfo_register_file(const char *file_full_path);
253
254 typedef GArray* minfo_list;
255
256 DEPRECATED_API int mediainfo_list_new(minfo_list *list);
257
258 DEPRECATED_API int mediainfo_list_add(minfo_list list, const char* file_full_path);
259
260 DEPRECATED_API int mediainfo_list_free(minfo_list list);
261
262 DEPRECATED_API int mediainfo_register_files(const minfo_list list);
263
264
265 /** @} */
266
267 /**
268         @}
269  */
270
271 #ifdef __cplusplus
272 }
273 #endif
274
275 #endif /*_MEDIA_INFO_H_*/