ff93d8672d78722e7fc02cc0398c2d24f0f77aeb
[platform/core/api/media-content.git] / include / media_face.h
1 /*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __TIZEN_CONTENT_MEDIA_FACE_H__
18 #define __TIZEN_CONTENT_MEDIA_FACE_H__
19
20 #include <media_content_type.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25
26 /**
27  * @file media_face.h
28  * @brief This file contains the media face function and related to all operations with the face information of the image in Media DB. \n
29  *             Functions include cloning and destroying the media face handler, getting face information such as face id, face coordinates in file, \n
30  *             face tag. Face information will be managed by DB. To insert face information, you should use media_face_insert_to_db() \n
31  *             or media_info_start_face_detection() function. And you can insert,update,delete face information manually.
32  */
33
34 /**
35  * @addtogroup CAPI_CONTENT_MEDIA_FACE_MODULE
36  * @{
37  */
38
39 /**
40  * @brief Clones the media face handle.
41  * @details This function copies the media face handle from a source to
42  * destination. There is no media_face_create() function. The media_face_h is created internally and available through
43  * media face foreach function such as media_face_foreach_face_from_db(). To use this handle outside of these foreach functions,
44  * use this function.
45  *
46  * @since_tizen 3.0
47  * @remarks The @a dst should be released using media_face_destroy().
48  *
49  * @param[out] dst The destination handle to the media face
50  * @param[in] src The source handle to the media face
51  *
52  * @return 0 on success, otherwise a negative error value.
53  *
54  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
55  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
56  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
57  *
58  * @see media_face_destroy()
59  * @see media_face_foreach_face_from_db()
60  */
61 int media_face_clone(media_face_h *dst, media_face_h src);
62
63 /**
64  * @brief Destroys the media face handle.
65  * @details Function frees all resources related to media face handle. This
66  * handle no longer can be used to perform any operations. New handle has to
67  * be created before next usage.
68  *
69  * @since_tizen 3.0
70  *
71  * @param[in] face The media face handle
72  *
73  * @return 0 on success, otherwise a negative error value.
74  *
75  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
76  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
77  *
78  * @pre Get copy of media face handle by calling media_face_clone() or Get media face handle by calling media_info_foreach_face_from_db()
79  *
80  * @see media_face_clone()
81  */
82 int media_face_destroy(media_face_h face);
83
84 /**
85  * @brief Gets the face id from the media face handle.
86  *
87  * @since_tizen 3.0
88  *
89  * @remarks The @a face_id should be released using free().
90  *
91  * @param[in] face The media face handle
92  * @param[out] face_id The ID of the media face
93  *
94  * @return 0 on success, otherwise a negative error value.
95  *
96  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
97  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
98  */
99 int media_face_get_face_id(media_face_h face, char **face_id);
100
101 /**
102  * @brief Gets the media id from the media face handle.
103  *
104  * @since_tizen 3.0
105  *
106  * @remarks The @a media_id should be released using free().
107  *
108  * @param[in] face The media face handle
109  * @param[out] media_id The media ID
110  *
111  * @return 0 on success, otherwise a negative error value.
112  *
113  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
114  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
115  */
116 int media_face_get_media_id(media_face_h face, char **media_id);
117
118  /**
119  * @brief Gets the face's rectangle from the media face handle.
120  * @details This function can get the face's rectangle information. returned rectangle information includes the orientation value.
121  *
122  * @since_tizen 3.0
123  *
124  * @param[in] face The media face handle
125  * @param[out] rect_x The x position of the media face
126  * @param[out] rect_y The y position of the media face
127  * @param[out] rect_w The width of the media face
128  * @param[out] rect_h The height of the media face
129  *
130  * @return 0 on success, otherwise a negative error value.
131  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
132  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
133  */
134 int media_face_get_face_rect(media_face_h face, unsigned int *rect_x, unsigned int *rect_y, unsigned int *rect_w, unsigned int *rect_h);
135
136 /**
137  * @brief Gets the orientation from the media face handle.
138  * @details This function can get the orientation value from the original image.
139  *
140  * @since_tizen 3.0
141  *
142  * @param[in] face The media face handle
143  * @param[out] orientation The orientation of the media face
144  *
145  * @return 0 on success, otherwise a negative error value.
146  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
147  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
148  */
149 int media_face_get_orientation(media_face_h face, media_content_orientation_e *orientation);
150
151 /**
152  * @brief Gets the tag from the media face handle.
153  *
154  * @since_tizen 3.0
155  *
156  * @remarks The @a tag should be released using free().
157  *
158  * @param[in] face The media face handle
159  * @param[out] tag The tag of the media face
160  *
161  * @return 0 on success, otherwise a negative error value.
162  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
163  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
164  */
165 int media_face_get_tag(media_face_h face, char **tag);
166
167 /**
168  * @brief Creates the media face handle.
169  *
170  * @since_tizen 3.0
171  *
172  * @remarks The @a face should be released using media_face_destroy(). \n
173  *          Since 5.5, this function supports only image type.
174  *
175  * @param[in] media_id The media ID
176  * @param[out] face The media face handle
177  *
178  * @return 0 on success, otherwise a negative error value.
179  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
180  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
181  *
182  * @see media_face_destroy()
183  */
184 int media_face_create(const char *media_id, media_face_h *face);
185
186 /**
187  * @brief Sets the face rectangle of the media face handle.
188  *
189  * @since_tizen 3.0
190  *
191  * @param[in] face The media face handle
192  * @param[in] rect_x The integer to set as a position x of face rectangle
193  * @param[in] rect_y The integer to set as a position y of face rectangle
194  * @param[in] rect_w The integer to set as a width of face rectangle
195  * @param[in] rect_h The integer to set as a height of face rectangle
196  *
197  * @return 0 on success, otherwise a negative error value.
198  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
199  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
200  *
201  * @post media_face_insert_to_db()
202  * @post media_face_update_to_db()
203  *
204  */
205 int media_face_set_face_rect(media_face_h face, unsigned int rect_x, unsigned int rect_y, unsigned int rect_w, unsigned int rect_h);
206
207 /**
208  * @brief Sets the orientation of the media face handle.
209  * @details This function may set the value of the original image orientation.
210  *
211  * @since_tizen 3.0
212  *
213  * @param[in] face The media face handle
214  * @param[in] orientation The integer to set as an orientation
215  *
216  * @return 0 on success, otherwise a negative error value.
217  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
218  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
219  *
220  * @post media_face_insert_to_db()
221  * @post media_face_update_to_db()
222  *
223  */
224 int media_face_set_orientation(media_face_h face, media_content_orientation_e orientation);
225
226 /**
227  * @brief Sets the tag of the media face handle.
228  *
229  * @since_tizen 3.0
230  *
231  * @param[in] face The media face handle
232  * @param[in] tag The tag of the media face
233  *
234  * @return 0 on success, otherwise a negative error value.
235  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
236  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
237  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
238  *
239  * @post media_face_insert_to_db()
240  * @post media_face_update_to_db()
241  */
242 int media_face_set_tag(media_face_h face, const char *tag);
243
244 /**
245  * @brief Inserts a new face in the media database.
246  * @since_tizen 3.0
247  *
248  * @privlevel public
249  * @privilege %http://tizen.org/privilege/content.write
250  *
251  * @remarks The @a face should be released using media_face_destroy().
252  *
253  * @param[in] face The media face handle
254  *
255  * @return 0 on success, otherwise a negative error value.
256  *
257  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
258  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
259  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
260  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
261  * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
262  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
263  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
264  * @retval #MEDIA_CONTENT_ERROR_NETWORK           Network fail
265  *
266  * @see media_content_connect()
267  * @see media_face_destroy()
268  * @see media_face_set_face_rect()
269  * @see media_face_set_orientation()
270  * @see media_face_set_tag()
271  */
272 int media_face_insert_to_db(media_face_h face);
273
274 /**
275  * @brief Updates the face details to the media database.
276  *
277  * @details The function updates the given media face in the media database. The function should be called after any change in face, to be updated to the media
278  * database. For example, after using media_face_set_orientation() for setting the orientation of the face, media_face_update_to_db() function should be called so as to update
279  * the given face attributes in the media database.
280  * @since_tizen 3.0
281  *
282  * @privlevel public
283  * @privilege %http://tizen.org/privilege/content.write
284  *
285  * @param[in] face The media face handle to update
286  *
287  * @return 0 on success, otherwise a negative error value.
288  *
289  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
290  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
291  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
292  * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
293  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
294  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
295  * @retval #MEDIA_CONTENT_ERROR_NETWORK           Network fail
296  *
297  * @pre This function requires opened connection to content service by media_content_connect().
298  *
299  * @see media_content_connect()
300  * @see media_face_destroy()
301  * @see media_face_set_face_rect()
302  * @see media_face_set_orientation()
303  * @see media_face_set_tag()
304  *
305  */
306 int media_face_update_to_db(media_face_h face);
307
308 /**
309  * @brief Deletes the face with given face id from the media database.
310  *
311  * @since_tizen 3.0
312  *
313  * @privlevel public
314  * @privilege %http://tizen.org/privilege/content.write
315  *
316  * @param[in] face_id The ID of the media face
317  *
318  * @return 0 on success, otherwise a negative error value.
319  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
320  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
321  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
322  * @retval #MEDIA_CONTENT_ERROR_INVALID_OPERATION Invalid operation
323  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
324  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
325  * @retval #MEDIA_CONTENT_ERROR_NETWORK           Network fail
326  *
327  * @pre This function requires opened connection to content service by media_content_connect().
328  * @see media_content_connect()
329  *
330  */
331 int media_face_delete_from_db(const char *face_id);
332
333 /**
334  * @brief Gets the number of media faces with an optional filter from the media database.
335  * @since_tizen 4.0
336  *
337  * @param[in] filter The handle to the media filter
338  * @param[out] face_count The count of the media faces
339  *
340  * @return @c 0 on success,
341  *         otherwise a negative error value
342  *
343  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
344  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
345  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
346  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
347  *
348  * @pre This function requires opened connection to content service by media_content_connect().
349  *
350  * @see media_content_connect()
351  * @see media_filter_create()
352  */
353 int media_face_get_face_count_from_db(filter_h filter, int *face_count);
354
355 /**
356  * @brief Iterates through the faces with an optional filter from the media database.
357  * @details This function gets all faces associated with the given filter and calls @a callback for every retrieved media face.
358  *          If @c NULL is passed to the @a filter, then no filtering is applied.
359  * @since_tizen 4.0
360  *
361  * @param[in] filter The handle to the media filter
362  * @param[in] callback The callback function to be invoked
363  * @param[in] user_data The user data to be passed to the callback function
364  *
365  * @return @c 0 on success,
366  *         otherwise a negative error value
367  *
368  * @retval #MEDIA_CONTENT_ERROR_NONE              Successful
369  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
370  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY     Out of memory
371  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED         DB Operation failed
372  * @retval #MEDIA_CONTENT_ERROR_DB_BUSY           DB Operation busy
373  *
374  * @pre This function requires opened connection to content service by media_content_connect().
375  * @post This function invokes media_face_cb().
376  *
377  * @see media_content_connect()
378  * @see media_face_cb()
379  * @see media_filter_create()
380  */
381 int media_face_foreach_face_from_db(filter_h filter, media_face_cb callback, void *user_data);
382
383 /**
384  * @}
385  */
386
387 #ifdef __cplusplus
388 }
389 #endif /* __cplusplus */
390
391 #endif /* __TIZEN_CONTENT_MEDIA_FACE_H__ */