Tizen 2.1 base
[framework/multimedia/media-server.git] / lib / include / media-util-register.h
1 /*
2  *  Media Utility
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Yong Yeon Kim <yy9875.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  * This file defines api utilities of contents manager engines.
24  *
25  * @file                media-util-register.h
26  * @author      Yong Yeon Kim(yy9875.kim@samsung.com)
27  * @version     1.0
28  * @brief
29  */
30  #ifndef _MEDIA_UTIL_REGISTER_H_
31 #define _MEDIA_UTIL_REGISTER_H_
32
33 #include <glib.h>
34 #include <stdbool.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /**
41  * @fn          int ms_media_file_register(const char *file_full_path);
42  * @brief               This function registers multimedia file to media DB
43  *                      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.
44  *                      However, automatic registration will have a little delay because the method is asynchronous.
45  *                      If you want to register some files to database immediately, you should use this API.
46  *
47  * @param       file_full_path [in]             full path of file for register
48  * @return      This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
49  *                      Please refer 'media-info-error.h' to know the exact meaning of the error.
50  * @see         None.
51  * @pre         None.
52  * @post                None.
53  * @remark      The database name is "/opt/usr/dbspace/.media.db".
54  *                  You have to use this API only for registering multimedia files. If you try to register no multimedia file, this API returns error.
55  * @par example
56  * @code
57
58 #include <media-info.h>
59
60 int main()
61 {
62         int result = -1;
63
64         result = ms_media_file_register("/opt/usr/media/test.mp3");
65         if( result < 0 )
66         {
67                 printf("FAIL to mediainfo_register_file\n");
68                 return 0;
69         }
70         else
71         {
72                 printf("SUCCESS to register file\n");
73         }
74
75         return 0;
76 }
77
78  *      @endcode
79  */
80 int media_file_register(const char *file_full_path);
81
82 typedef enum
83 {
84         MEDIA_DIRECTORY_SCAN = 0,
85         MEDIA_FILES_REGISTER,
86 } media_request_type_e;
87
88 typedef struct
89 {
90         int pid;
91         int result;
92         int request_type;
93         char *complete_path; /* if the request type is MEDIA_FILES_REGISTER, this value will be NULL. */
94 }media_request_result_s;
95
96 typedef void (*scan_complete_cb)(media_request_result_s *, void *);
97 typedef void (*insert_complete_cb)(media_request_result_s *, void *);
98
99 int media_directory_scanning_async(const char *directory_path, bool recusive_on, scan_complete_cb user_callback, void *user_data);
100
101 int media_files_register(const char *list_path, insert_complete_cb user_callback, void *user_data);
102
103 /**
104 * @}
105 */
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif /*_MEDIA_UTIL_REGISTER_H_*/