Remove weather in image struct
[platform/core/api/media-content.git] / include / media_info_private.h
1 /*
2 * Copyright (c) 2011 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
18 #ifndef __TIZEN_MEDIA_INFO_PRIVATE_H__
19 #define __TIZEN_MEDIA_INFO_PRIVATE_H__
20
21
22 #include <unistd.h>
23 #include <asm/unistd.h>
24 #include <string.h>
25 #include <sqlite3.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <glib.h>
29 #include <media-svc.h>
30 #include <media_content_type.h>
31 #include <dlog.h>
32 #include <media-util.h>
33 #include <errno.h>
34 #include <tzplatform_config.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39
40 #ifdef LOG_TAG
41 #undef LOG_TAG
42 #endif
43
44
45 /**
46  * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
47 * @{
48 *
49 * @file media_info_private.h
50 * @brief This file contains the media info API and related structure and enumeration. \n
51 *        Description of the audio, video,image content involves: album, artist, album_artist, author, genre and description tags. \n
52 *        Parameters of the recording are also supported, as: format, bitrate, duration, size etc. \n
53 *        Defenitions of media DB fields and tables, operations with media data relating to DB and handling with media filter attributes.
54 */
55
56
57 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
58
59 #define SAFE_STRLCPY(dst, src, n)       ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
60 #define SAFE_STRLCAT(dst, src, n)       g_strlcat(dst, src, n);
61 #define SAFE_FREE(src)          {if (src) {free(src); src = NULL; } }
62 #define SAFE_G_FREE(src)        {if (src) {g_free(src); src = NULL; } }
63 #define STRING_VALID(str)               ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
64 #define SQLITE3_FINALIZE(x)     {if (x != NULL) sqlite3_finalize(x); }
65 #define SQLITE3_SAFE_FREE(x)    {if (x != NULL) {sqlite3_free(x); x = NULL; } }
66
67 #define MEDIA_CONTENT_INSERT_FILES_PATH         "/tmp"
68 #define MEDIA_CONTENT_EMPTY_STRING                      ""
69
70 #define MAX_QUERY_SIZE 4096
71 #define MAX_PATH_LEN 4096
72 #define DEFAULT_QUERY_SIZE 1024
73 #define COLLATE_STR_SIZE 32
74 #define MEDIA_CONTENT_UUID_SIZE 36
75 #define BATCH_REQUEST_MAX 300
76
77 #define EMPTY_STR ""
78
79 typedef enum {
80         MEDIA_INFO_UUID = 0,
81         MEDIA_INFO_PATH,
82         MEDIA_INFO_FILE_NAME,
83         MEDIA_INFO_TYPE,
84         MEDIA_INFO_MIME_TYPE,
85         MEDIA_INFO_SIZE,
86         MEDIA_INFO_ADDED_TIME,
87         MEDIA_INFO_MODIFIED_TIME,
88         MEDIA_INFO_THUMBNAIL_PATH,
89         MEDIA_INFO_DESCRIPTION,
90         MEDIA_INFO_RATING,
91         MEDIA_INFO_FAVOURITE,
92         MEDIA_INFO_AUTHOR,
93         MEDIA_INFO_PROVIDER,
94         MEDIA_INFO_CONTENT_NAME,
95         MEDIA_INFO_CATEGORY,
96         MEDIA_INFO_LOCATION_TAG,
97         MEDIA_INFO_AGE_RATING,
98         MEDIA_INFO_KEYWORD,
99         MEDIA_INFO_IS_DRM,
100         MEDIA_INFO_STORAGE_TYPE,
101         MEDIA_INFO_LONGITUDE,
102         MEDIA_INFO_LATITUDE,
103         MEDIA_INFO_ALTITUDE,
104         MEDIA_INFO_EXPOSURE_TIME,
105         MEDIA_INFO_FNUMBER,
106         MEDIA_INFO_ISO,
107         MEDIA_INFO_MODEL,
108         MEDIA_INFO_WIDTH,
109         MEDIA_INFO_HEIGHT,
110         MEDIA_INFO_DATETAKEN,
111         MEDIA_INFO_ORIENTATION,
112         MEDIA_INFO_TITLE,
113         MEDIA_INFO_ALBUM,
114         MEDIA_INFO_ARTIST,
115         MEDIA_INFO_ALBUM_ARTIST,
116         MEDIA_INFO_GENRE,
117         MEDIA_INFO_COMPOSER,
118         MEDIA_INFO_YEAR,
119         MEDIA_INFO_RECORDED_DATE,
120         MEDIA_INFO_COPYRIGHT,
121         MEDIA_INFO_TRACK_NUM,
122         MEDIA_INFO_BITRATE,
123         MEDIA_INFO_BITPERSAMPLE,
124         MEDIA_INFO_DURATION,
125         MEDIA_INFO_PLAYED_COUNT,
126         MEDIA_INFO_LAST_PLAYED_TIME,
127         MEDIA_INFO_LAST_PLAYED_POSITION,
128         MEDIA_INFO_SAMPLERATE,
129         MEDIA_INFO_CHANNEL,
130         MEDIA_INFO_BURST_ID,
131         MEDIA_INFO_TIMELINE,
132         MEDIA_INFO_WEATHER,
133         MEDIA_INFO_SYNC_STATUS,
134         MEDIA_INFO_STORAGE_UUID,
135         MEDIA_INFO_IS_360,
136         MEDIA_INFO_ITEM_MAX,
137 } media_info_item_e;
138
139 typedef enum {
140         MEDIA_CONTENT_TYPE = 0,
141         MEDIA_THUMBNAIL_TYPE,
142         MEDIA_REGISTER_TYPE
143 } media_info_error_type_e;
144
145 typedef enum {
146         MEDIA_TAG_ADD,
147         MEDIA_TAG_REMOVE,
148         MEDIA_TAG_UPDATE_TAG_NAME,
149 } tag_function_e;
150
151 typedef enum {
152         MEDIA_PLAYLIST_ADD,
153         MEDIA_PLAYLIST_REMOVE,
154         MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
155         MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
156         MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
157 } playlist_function_e;
158
159 typedef enum {
160         MEDIA_GROUP_NONE,
161         MEDIA_GROUP_ALBUM,
162         MEDIA_GROUP_FOLDER,
163         MEDIA_GROUP_PLAYLIST,
164         MEDIA_GROUP_TAG,
165         MEDIA_GROUP_BOOKMARK,
166         MEDIA_GROUP_TAG_BY_MEDIA_ID,
167         MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
168         MEDIA_GROUP_STORAGE,
169         MEDIA_GROUP_FACE,
170         MEDIA_GROUP_FACE_BY_MEDIA_ID,
171 } group_list_e;
172
173 typedef enum {
174         MEDIA_BATCH_INSERT_NORMAL,
175         MEDIA_BATCH_INSERT_BURSTSHOT,
176 } media_batch_insert_e;
177
178 typedef struct _filter_s {
179         char *storage_id;
180         char *condition;
181         char *order_keyword;
182         media_content_order_e order_type;
183         media_content_collation_e condition_collate_type;
184         media_content_collation_e order_collate_type;
185         int offset;
186         int count;
187         bool is_full_condition;
188         bool is_full_order;
189 } filter_s;
190
191 typedef struct {
192         char *folder_id;
193         char *path;
194         char *name;
195         time_t modified_time;
196         media_content_storage_e storage_type;
197         char *storage_uuid;
198         int folder_order;
199 } media_folder_s;
200
201 typedef struct {
202         int tag_id;
203         char *name;
204         GList *item_list;
205 } media_tag_s;
206
207 typedef struct {
208         int bookmark_id;
209         char *media_id;
210         time_t marked_time;
211         char *thumbnail_path;
212         char *name;
213 } media_bookmark_s;
214
215 typedef struct {
216         int album_id;
217         char *name;
218         char *artist;
219         char *album_art_path;
220 } media_album_s;
221
222 typedef struct {
223         int playlist_id;
224         char *name;
225         char *thumbnail_path;
226         GList *item_list;
227 } media_playlist_s;
228
229 typedef struct {
230         char *media_id;
231         int width;
232         int height;
233         char *date_taken;
234         char *title;
235         char *burst_id;
236         char *exposure_time;
237         double fnumber;
238         int iso;
239         char *model;
240         media_content_orientation_e orientation;
241 } image_meta_s;
242
243 typedef struct {
244         char *media_id;
245         char *title;
246         char *album;
247         char *artist;
248         char *album_artist;
249         char *genre;
250         char *composer;
251         char *year;
252         char *recorded_date;
253         char *copyright;
254         char *track_num;
255         int bitrate;
256         int duration;
257         int width;
258         int height;
259         int played_count;
260         int rotation;
261         time_t played_time;
262         int played_position;
263 } video_meta_s;
264
265 typedef struct {
266         char *media_id;
267         char *title;
268         char *album;
269         char *artist;
270         char *album_artist;
271         char *genre;
272         char *composer;
273         char *year;
274         char *recorded_date;
275         char *copyright;
276         char *track_num;
277         int bitrate;
278         int bitpersample;
279         int samplerate;
280         int channel;
281         int duration;
282         int played_count;
283         time_t played_time;
284         int played_position;
285 } audio_meta_s;
286
287 typedef struct {
288         char *media_id;
289         char *file_path;
290         char *display_name;
291         media_content_type_e media_type;
292         char *mime_type;
293         unsigned long long size;
294         time_t added_time;
295         time_t modified_time;
296         time_t timeline;
297         char *thumbnail_path;
298         char *description;
299         double longitude;
300         double latitude;
301         double altitude;
302         char *weather;
303         int rating;
304         time_t favourite;
305         char *title;
306         char *author;
307         char *provider;
308         char *content_name;
309         char *category;
310         char *location_tag;
311         char *age_rating;
312         char *keyword;
313         int is_drm;
314         int storage_type;
315         int played_count;
316         time_t played_time;
317         int played_position;
318         char *storage_uuid;
319         int sync_status;
320         unsigned int request_id;
321         unsigned int face_request_id;
322         int is_360;
323         image_meta_s *image_meta;
324         video_meta_s *video_meta;
325         audio_meta_s *audio_meta;
326 } media_info_s;
327
328 typedef struct {
329         char *media_id;
330         int function;
331         char *tag_name;
332 } media_tag_item_s;
333
334 typedef struct {
335         char *media_id;
336         int function;
337         char *playlist_name;
338         char *thumbnail_path;
339         int playlist_member_id;
340         int play_order;
341 } media_playlist_item_s;
342
343 typedef struct {
344         char *storage_id;
345         char *storage_path;
346         int storage_type;
347 } media_storage_s;
348
349 typedef struct {
350         char *face_id;                          /* face uuid */
351         char *media_id;                 /* media uuid */
352         unsigned int face_rect_x;       /* x position of face */
353         unsigned int face_rect_y;       /* y position of face */
354         unsigned int face_rect_w;       /* width of face */
355         unsigned int face_rect_h;       /* height of face */
356         int orientation;                        /* orientation */
357         char *face_tag;                 /* face tag */
358 } media_face_s;
359
360 typedef struct _attribute_map_s {
361         GHashTable *attr_map;
362 } attribute_s;
363
364 typedef struct {
365         media_info_s *handle;
366         void *user_data;
367         media_thumbnail_completed_cb thumbnail_completed_cb;
368 } media_thumbnail_cb_s;
369
370 typedef struct {
371         media_info_s *handle;
372         void *user_data;
373         media_face_detection_completed_cb face_completed_cb;
374 } media_face_cb_s;
375
376 typedef struct {
377         media_insert_completed_cb insert_completed_cb;
378         char *insert_list_path;
379         void *user_data;
380 } media_insert_cb_s;
381
382 typedef struct {
383         media_content_db_update_cb update_noti_cb;
384         void *user_data;
385 } media_noti_cb_s;
386
387 typedef struct attribute_s *attribute_h;
388
389
390 typedef struct _media_content_cb_data {
391         media_scan_completed_cb callback;
392         void *user_data;
393 } media_content_scan_cb_data;
394
395
396 /* DB Table */
397 #define DB_TABLE_MEDIA                  "media"
398 #define DB_TABLE_FOLDER         "folder"
399 #define DB_TABLE_ALBUM                  "album"
400 #define DB_TABLE_TAG                    "tag"
401 #define DB_TABLE_TAG_MAP                "tag_map"
402 #define DB_TABLE_PLAYLIST               "playlist"
403 #define DB_TABLE_PLAYLIST_MAP   "playlist_map"
404 #define DB_TABLE_BOOKMARK               "bookmark"
405 #define DB_TABLE_STORAGE                "storage"
406 #define DB_TABLE_MEDIA_VIEW     "media_view"
407 #define DB_TABLE_FACE                   "face"
408 #define DB_TABLE_FACE_SCAN_LIST "face_scan_list"
409
410 /* DB View */
411 #define DB_VIEW_PLAYLIST        "playlist_view"
412 #define DB_VIEW_TAG                     "tag_view"
413
414 /* DB Table Alias */
415 #define DB_TABLE_ALIAS_MEDIA                    "m"
416 #define DB_TABLE_ALIAS_FOLDER                   "f"
417 #define DB_TABLE_ALIAS_PLAYLIST                 "p"
418 #define DB_TABLE_ALIAS_PLAYLIST_MAP     "pm"
419 #define DB_TABLE_ALIAS_TAG                              "t"
420 #define DB_TABLE_ALIAS_BOOKMARK         "b"
421 #define DB_TABLE_ALIAS_ALBUM                    "a"
422 #define DB_TABLE_ALIAS_FACE                             "fa"
423
424 /* DB field for media */
425 #define DB_FIELD_MEDIA_ID                                       "media_uuid"
426 #define DB_FIELD_MEDIA_PATH                             "path"
427 #define DB_FIELD_MEDIA_DISPLAY_NAME             "file_name"
428 #define DB_FIELD_MEDIA_TYPE                                     "media_type"
429 #define DB_FIELD_MEDIA_MIME_TYPE                        "mime_type"
430 #define DB_FIELD_MEDIA_SIZE                                     "size"
431 #define DB_FIELD_MEDIA_ADDED_TIME                       "added_time"
432 #define DB_FIELD_MEDIA_MODIFIED_TIME            "modified_time"
433 #define DB_FIELD_MEDIA_TIMELINE                         "timeline"
434 #define DB_FIELD_MEDIA_THUMBNAIL_PATH   "thumbnail_path"
435 #define DB_FIELD_MEDIA_TITLE                            "title"
436 #define DB_FIELD_MEDIA_ALBUM                            "album"
437 #define DB_FIELD_MEDIA_ARTIST                           "artist"
438 #define DB_FIELD_MEDIA_ALBUM_ARTIST                     "album_artist"
439 #define DB_FIELD_MEDIA_GENRE                            "genre"
440 #define DB_FIELD_MEDIA_COMPOSER                 "composer"
441 #define DB_FIELD_MEDIA_YEAR                             "year"
442 #define DB_FIELD_MEDIA_RECORDED_DATE            "recorded_date"
443 #define DB_FIELD_MEDIA_COPYRIGHT                        "copyright"
444 #define DB_FIELD_MEDIA_TRACK_NUM                        "track_num"
445 #define DB_FIELD_MEDIA_DESCRIPTION                      "description"
446 #define DB_FIELD_MEDIA_BITRATE                          "bitrate"
447 #define DB_FIELD_MEDIA_BITPERSAMPLE             "bitpersample"
448 #define DB_FIELD_MEDIA_SAMPLERATE                       "samplerate"
449 #define DB_FIELD_MEDIA_CHANNEL                  "channel"
450 #define DB_FIELD_MEDIA_DURATION                 "duration"
451 #define DB_FIELD_MEDIA_LONGITUDE                        "longitude"
452 #define DB_FIELD_MEDIA_LATITUDE                 "latitude"
453 #define DB_FIELD_MEDIA_ALTITUDE                 "altitude"
454 #define DB_FIELD_MEDIA_WIDTH                            "width"
455 #define DB_FIELD_MEDIA_HEIGHT                           "height"
456 #define DB_FIELD_MEDIA_DATETAKEN                        "datetaken"
457 #define DB_FIELD_MEDIA_ORIENTATION              "orientation"
458 #define DB_FIELD_MEDIA_BURST_ID                 "burst_id"
459 #define DB_FIELD_MEDIA_PLAYED_COUNT             "played_count"
460 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME         "last_played_time"
461 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION     "last_played_position"
462 #define DB_FIELD_MEDIA_RATING                           "rating"
463 #define DB_FIELD_MEDIA_FAVOURITE                        "favourite"
464 #define DB_FIELD_MEDIA_AUTHOR                           "author"
465 #define DB_FIELD_MEDIA_PROVIDER                 "provider"
466 #define DB_FIELD_MEDIA_CONTENT_NAME             "content_name"
467 #define DB_FIELD_MEDIA_CATEGORY                 "category"
468 #define DB_FIELD_MEDIA_LOCATION_TAG             "location_tag"
469 #define DB_FIELD_MEDIA_AGE_RATING                       "age_rating"
470 #define DB_FIELD_MEDIA_KEYWORD                  "keyword"
471 #define DB_FIELD_MEDIA_WEATHER                  "weather"
472 #define DB_FIELD_MEDIA_IS_DRM                           "is_drm"
473 #define DB_FIELD_MEDIA_STORAGE_TYPE             "storage_type"
474 #define DB_FIELD_MEDIA_EXPOSURE_TIME    "exposure_time"
475 #define DB_FIELD_MEDIA_FNUMBER                  "fnumber"
476 #define DB_FIELD_MEDIA_ISO                              "iso"
477 #define DB_FIELD_MEDIA_MODEL                    "model"
478 #define DB_FIELD_MEDIA_FILE_NAME_PINYIN                 "file_name_pinyin"
479 #define DB_FIELD_MEDIA_TITLE_PINYIN                                     "title_pinyin"
480 #define DB_FIELD_MEDIA_ALBUM_PINYIN                             "album_pinyin"
481 #define DB_FIELD_MEDIA_ARTIST_PINYIN                            "artist_pinyin"
482 #define DB_FIELD_MEDIA_ALBUM_ARTIST_PINYIN              "album_artist_pinyin"
483 #define DB_FIELD_MEDIA_GENRE_PINYIN                             "genre_pinyin"
484 #define DB_FIELD_MEDIA_COMPOSER_PINYIN                  "composer_pinyin"
485 #define DB_FIELD_MEDIA_COPYRIGHT_PINYIN                 "copyright_pinyin"
486 #define DB_FIELD_MEDIA_DESCRIPTION_PINYIN                       "description_pinyin"
487 #define DB_FIELD_MEDIA_AUTHOR_PINYIN                            "author_pinyin"
488 #define DB_FIELD_MEDIA_PROVIDER_PINYIN                  "provider_pinyin"
489 #define DB_FIELD_MEDIA_CONTENT_NAME_PINYIN              "content_name_pinyin"
490 #define DB_FIELD_MEDIA_CATEGORY_PINYIN                  "category_pinyin"
491 #define DB_FIELD_MEDIA_LOCATION_TAG_PINYIN              "location_tag_pinyin"
492 #define DB_FIELD_MEDIA_AGE_RATING_PINYIN                        "age_rating_pinyin"
493 #define DB_FIELD_MEDIA_KEYWORD_PINYIN                           "keyword_pinyin"
494 #define DB_FIELD_MEDIA_360                                                      "is_360"
495
496 /* DB field for folder */
497 #define DB_FIELD_FOLDER_ID                              "folder_uuid"
498 #define DB_FIELD_FOLDER_PATH                    "path"
499 #define DB_FIELD_FOLDER_NAME                    "name"
500 #define DB_FIELD_FOLDER_MODIFIED_TIME   "modified_time"
501 #define DB_FIELD_FOLDER_STORAGE_TYPE    "storage_type"
502 #define DB_FIELD_FOLDER_NAME_PINYIN     "name_pinyin"
503 #define DB_FIELD_FOLDER_ORDER                   "folder_order"
504
505 /* DB field for playlist */
506 #define DB_FIELD_PLAYLIST_ID                                    "playlist_id"
507 #define DB_FIELD_PLAYLIST_NAME                          "name"
508 #define DB_FIELD_PLAYLIST_MEMBER_ORDER  "play_order"
509 #define DB_FIELD_PLAYLIST_MEDIA_COUNT                   "media_count"
510
511 /* DB field for tag */
512 #define DB_FIELD_TAG_ID                 "tag_id"
513 #define DB_FIELD_TAG_NAME               "name"
514 #define DB_FIELD_TAG_MEDIA_COUNT                        "media_count"
515
516 /* DB field for bookmark */
517 #define DB_FIELD_BOOKMARK_ID    "bookmark_id"
518 #define DB_FIELD_BOOKMARK_MARKED_TIME   "marked_time"
519 #define DB_FIELD_BOOKMARK_NAME  "name"
520
521 /* DB field for album*/
522 #define DB_FIELD_ALBUM_ID                       "album_id"
523 #define DB_FIELD_ALBUM_NAME             "name"
524 #define DB_FIELD_ALBUM_ARTIST           "artist"
525
526 /* DB field for Storage*/
527 #define DB_FIELD_STORAGE_ID                     "storage_uuid"
528 #define DB_FIELD_STORAGE_PATH           "storage_path"
529
530 /* DB field for Face */
531 #define DB_FIELD_FACE_ID                                "face_uuid"
532 #define DB_FIELD_FACE_TAG                       "face_tag"
533
534 /* DB Query Keyword */
535 #define QUERY_KEYWORD_AND "AND"
536 #define QUERY_KEYWORD_OR "OR"
537 #define QUERY_KEYWORD_ORDER_BY "ORDER BY "
538 #define QUERY_KEYWORD_LIMIT "limit"
539 #define QUERY_KEYWORD_DESC "DESC"
540 #define QUERY_KEYWORD_SPACE " "
541 #define QUERY_KEYWORD_OPEN_BRACKET "("
542 #define QUERY_KEYWORD_BRACKET ")"
543 #define QUERY_KEYWORD_COLLATE "COLLATE "
544
545 /* DB TABLE JOIN */
546 /*#define FOLDER_MEDIA_JOIN                                     "("DB_TABLE_FOLDER" AS f LEFT OUTER JOIN '%s' AS m ON f.folder_uuid=m.folder_uuid AND m.validity=1) WHERE f.storage_uuid IN (SELECT storage_uuid FROM "DB_TABLE_STORAGE" WHERE validity=1) " */
547 #define FOLDER_MEDIA_JOIN                                       "("DB_TABLE_FOLDER" AS f LEFT OUTER JOIN '%s' AS m ON f.folder_uuid=m.folder_uuid AND m.validity=1) WHERE f.validity=1 "
548 #define BOOKMARK_MEDIA_JOIN                             "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m \
549                                                                                         ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
550 #define ALBUM_MEDIA_JOIN                                        "("DB_TABLE_ALBUM" AS a INNER JOIN '%s' AS m \
551                                                                                         ON (a.album_id = m.album_id)) WHERE m.validity=1"
552 #define FACE_MEDIA_JOIN                                         "("DB_TABLE_FACE" AS fa INNER JOIN '%s' AS m \
553                                                                                                 ON (fa.media_uuid = m.media_uuid)) WHERE m.validity=1"
554
555 /* Get Group List */
556 #define SELECT_ALBUM_LIST                       "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
557 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM '%s' WHERE validity=1 "
558
559 #define SELECT_FOLDER_LIST                      "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time, f.storage_uuid, f.folder_order FROM "FOLDER_MEDIA_JOIN
560 #define SELECT_FOLDER_LIST_BY_STORAGE_ID        SELECT_FOLDER_LIST"AND f.storage_uuid='%s' "
561 #define SELECT_TAG_LIST                         "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
562 #define SELECT_PLAYLIST_LIST                    "SELECT DISTINCT playlist_id, name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
563
564 /* Get Group Count */
565 #define SELECT_ALBUM_COUNT              "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
566 #define SELECT_FOLDER_COUNT             "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
567 #define SELECT_FOLDER_COUNT_BY_STORAGE_ID               SELECT_FOLDER_COUNT"AND f.storage_uuid='%s' "
568 #define SELECT_TAG_COUNT                        "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
569 #define SELECT_PLAYLIST_COUNT           "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
570 #define SELECT_BOOKMARK_COUNT   "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
571 #define SELECT_MEDIA_GROUP_COUNT        "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
572 /*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/
573
574 /* Get Media Count of Group */
575 #define SELECT_MEDIA_COUNT_FROM_MEDIA                   "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM               /*to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" */
576 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE    "SELECT COUNT(*) FROM '%s' WHERE validity=1 "
577 #define SELECT_MEDIA_COUNT_FROM_ALBUM                   "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND album_id='%d'"
578 #define SELECT_MEDIA_COUNT_FROM_GROUP                   "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP         /*to apply limit condition. */
579 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL              "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL    /* to apply limit condition. */
580 #define SELECT_MEDIA_COUNT_FROM_FOLDER                  "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'"
581 #define SELECT_MEDIA_COUNT_FROM_STORAGE                 "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'"
582 #define SELECT_MEDIA_COUNT_FROM_TAG                             "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
583 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST                        "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
584
585 /* Get Group Info by Group ID*/
586 #define SELECT_ALBUM_FROM_ALBUM         "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
587 #define SELECT_FOLDER_FROM_FOLDER               "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
588 #define SELECT_FOLDER_BY_PATH                   "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
589 #define SELECT_PLAYLIST_FROM_PLAYLIST   "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
590 #define SELECT_TAG_FROM_TAG                     "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
591 #define SELECT_TAG_BY_NAME                              "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
592
593 /* Tag info*/
594 #define INSERT_TAG_TO_TAG                                               "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
595 #define REMOVE_TAG_ITEM_FROM_TAG_MAP            "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q';"
596 #define UPDATE_TAG_NAME_FROM_TAG                        "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d;"
597 #define SELECT_TAG_COUNT_BY_MEDIA_ID                    "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
598 #define SELECT_TAG_LIST_BY_MEDIA_ID                             "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
599
600 /* Get Media list of Group */
601 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
602                                                         rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, exposure_time, fnumber, iso, model, width, height, datetaken, orientation, title, album, artist, album_artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, bitpersample, duration, played_count, last_played_time, last_played_position, samplerate, channel, burst_id, timeline, weather, sync_status, storage_uuid, is_360"
603
604 /*Folder info*/
605 #define UPDATE_FOLDER_ORDER                                     "UPDATE "DB_TABLE_FOLDER" SET folder_order=%d WHERE folder_uuid=%Q"
606 #define SELECT_FOLDER_ID_BY_PATH                                "SELECT folder_uuid FROM "DB_TABLE_FOLDER" WHERE path = '%s'"
607
608 /* Playlist Info */
609 #define INSERT_PLAYLIST_TO_PLAYLIST                                             "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
610 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST                      "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d;"
611 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST         "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d;"
612 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST                                "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
613 #define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW      "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
614 #define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW     "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
615 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW                    "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
616 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW        "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
617 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP          "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;"
618 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP         "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d;"
619
620 /* Bookmark */
621 #define INSERT_BOOKMARK_TO_BOOKMARK                     "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path, name) VALUES ('%q', '%d', %Q, %Q)"
622 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID               "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
623 #define SELECT_BOOKMARK_LIST                                            "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path, b.name FROM "BOOKMARK_MEDIA_JOIN
624 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID                        "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path, b.name FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
625 #define SELECT_BOOKMARK_ID_FROM_BOOKMARK               "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s' AND marked_time=%d"
626
627 #define UPDATE_BOOKMARK_FROM_BOOKMARK           "UPDATE "DB_TABLE_BOOKMARK" SET name=%Q WHERE bookmark_id=%d;"
628
629 /* Update Meta*/
630 #define UPDATE_AV_META_FROM_MEDIA       "UPDATE '%s' SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
631 #define UPDATE_IMAGE_META_FROM_MEDIA    "UPDATE '%s' SET orientation=%d WHERE media_uuid='%q'"
632
633 #define SELECT_MEDIA_ITEM                                       "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1"
634 #define SELECT_MEDIA_FROM_MEDIA                 "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND media_uuid='%s'"
635 #define SELECT_MEDIA_BY_PATH                            "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND path='%q'"
636 #define SELECT_MEDIA_FROM_ALBUM                 "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND album_id=%d"
637 #define SELECT_MEDIA_FROM_GROUP                 "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s='%q'"
638 #define SELECT_MEDIA_FROM_GROUP_NULL    "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s IS NULL"
639 #define SELECT_MEDIA_FROM_FOLDER                        "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND folder_uuid='%s'"
640 #define SELECT_MEDIA_FROM_STORAGE               "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND storage_uuid='%s'"
641 #define SELECT_MEDIA_FROM_TAG                           "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
642 #define SELECT_MEDIA_FROM_PLAYLIST              "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
643 #define SELECT_MEDIA_PATH_BY_ID                 "SELECT path FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
644 #define SELECT_MEDIA_STORAGE_ID_BY_ID           "SELECT storage_uuid FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
645
646 /* Delete */
647 #define DELETE_MEDIA_FROM_MEDIA_BATCH   "DELETE FROM  '%s' WHERE %s AND storage_type = %d"
648 #define DELETE_PLAYLIST_FROM_PLAYLIST           "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
649 #define DELETE_TAG_FROM_TAG                             "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
650 #define DELETE_BOOKMARK_FROM_BOOKMARK   "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
651
652 /*For batch remove*/
653 #define SELECT_STORAGE_BY_FILTER        "SELECT DISTINCT storage_uuid, storage_type FROM "DB_TABLE_MEDIA_VIEW" WHERE %s"
654 #define SELECT_THUMBNAIL_BY_FILTER      "SELECT DISTINCT thumbnail_path FROM '%s' WHERE %s AND storage_type = %d"
655
656 /* Storage*/
657 #define SELECT_STORAGE_COUNT                            "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
658 #define SELECT_STORAGE_LIST                                     "SELECT storage_uuid, storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1"
659 #define SELECT_STORAGE_INFO_FROM_STORAGE        "SELECT storage_uuid, storage_path, storage_type FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_uuid='%s'"
660
661 /* Face */
662 #define DELETE_FACE_FROM_FACE                   "DELETE FROM "DB_TABLE_FACE" WHERE face_uuid='%q'"
663 #define INSERT_FACE_TO_FACE                             "INSERT INTO "DB_TABLE_FACE" (face_uuid, media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag, user_marked) VALUES ('%q', '%q', %d, %d, %d, %d, %d, %Q, 1);"
664 #define UPDATE_FACE_TO_FACE                     "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_uuid='%q'"
665 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID             "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1"
666 #define SELECT_FACE_COUNT                                       "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN
667 #define SELECT_FACE_COUNT_BY_MEDIA_ID           "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
668 #define SELECT_FACE_LIST                                                "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN
669 #define SELECT_FACE_LIST_BY_MEDIA_ID            "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
670 #define SELECT_FACE_PATH_FROM_MEDIA             "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'"
671 #define SELECT_MEDIA_FROM_FACE                  "SELECT media_uuid FROM "DB_TABLE_FACE" WHERE face_uuid='%q' AND user_marked = 0"
672 #define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST     "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_uuid='%q'"
673
674
675 #define DEFAULT_MEDIA_STORAGE_ID                        "media"
676
677 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
678 int _content_error_capi(int type, int cotent_error);
679 int _content_query_sql(char *query_str);
680 MediaSvcHandle* _content_get_db_handle(void);
681 uid_t _content_get_uid(void);
682 attribute_h _content_get_attirbute_handle(void);
683 attribute_h _content_get_alias_attirbute_handle(void);
684 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
685 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
686 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
687 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
688 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
689 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
690 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
691 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
692 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
693 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
694 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
695 int _media_db_get_face(const char *media_id, filter_h filter, media_face_cb callback, void *user_data);
696 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
697 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
698 int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type);
699 int _media_db_get_group_item(const char *group_name, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type);
700 int _media_db_get_media_group_item_count(const char *group_name, filter_h filter, media_group_e group, int *item_count);
701 int _media_db_get_media_group_item(const char *group_name, filter_h filter, media_group_e group, media_info_cb callback, void *user_data);
702 int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
703 int _media_db_get_storage_id_by_media_id(const char *media_id, char *storage_id);
704
705 /**
706  * @internal
707  * @brief Creates a media filter attribute handle.
708  * @details This function creates a media filter attribute handle. The handle can be
709  * used to convert to attributes of database from attributes of user.
710  * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
711  * @param[out] filter A handle to media filter attribute
712  * @return 0 on success, otherwise a negative error value.
713  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
714  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
715  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
716  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
717  * @see media_filter_attribute_destory()
718  *
719  */
720 int _media_filter_attribute_create(attribute_h *attr);
721
722 /**
723  * @internal
724  * @brief Add the attributes to the handle.
725  * @details This function add the attribute to handle.
726  * @param[in] filter The handle to media filter attribute
727  * @param[in] user_attr The user attribute
728  * @param[in] platform_attr The platform attribute
729  * @return 0 on success, otherwise a negative error value.
730  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
731  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
732  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
733  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
734  * @see media_filter_attribute_remove()
735  *
736  */
737 int _media_filter_attribute_add(attribute_h atrr, const char *user_attr, const char *platform_attr);
738
739 /**
740  * @internal
741  * @brief Destroys a media filter attribute handle.
742  * @details The function frees all resources related to the media filter attribute handle. The filter attribute
743  * handle no longer can be used to perform any operation. A new handle
744  * has to be created before the next usage.
745  *
746  * @param[in] filter The handle to media filter attribute
747  * @return 0 on success, otherwise a negative error value.
748  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
749  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
750  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
751  * @see media_filter_create()
752  *
753  */
754 int _media_filter_attribute_destory(attribute_h attr);
755
756 /**
757  * @internal
758  * @brief Replace to platform attributes from user attributes.
759  * @details This function replace to platform attributes from user attributes to generate the WHERE clause
760  * @param[in] filter The handle to media filter attribute
761  * @param[in] user_attr The user attribute
762  * @param[in] platform_attr The platform attribute
763  * @return 0 on success, otherwise a negative error value.
764  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
765  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
766  * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
767  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
768  * @see media_filter_attribute_create()
769  * @see media_filter_attribute_destory()
770  *
771  */
772 int _media_filter_attribute_generate(attribute_h attr, filter_h filter, char **generated_condition);
773
774 /**
775  * @internal
776  * @brief Replace to platform attributes from user attributes.
777  * @details This function replace to platform attributes from user attributes to generate the WHERE clause
778  * @param[in] filter The handle to media filter attribute
779  * @param[in] attr The attribute
780  * @param[in] generated_option The handle to generated option
781  * @return 0 on success, otherwise a negative error value.
782  * @retval #MEDIA_CONTENT_ERROR_NONE Successful
783  * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
784  * @retval #MEDIA_CONTENT_ERROR_DB_FAILED Filed DB
785  * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
786  * @see media_filter_attribute_create()
787  * @see media_filter_attribute_destory()
788  *
789  */
790
791 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
792
793 int _media_filter_attribute_option_generate_with_full_query(attribute_h attr, filter_h filter, char **generated_option);
794
795
796 #define FONT_COLOR_RESET    "\033[0m"
797 #define FONT_COLOR_RED      "\033[31m"
798 #define FONT_COLOR_GREEN    "\033[32m"
799 #define FONT_COLOR_YELLOW   "\033[33m"
800 #define FONT_COLOR_BLUE     "\033[34m"
801 #define FONT_COLOR_PURPLE   "\033[35m"
802 #define FONT_COLOR_CYAN     "\033[36m"
803 #define FONT_COLOR_GRAY     "\033[37m"
804
805 #define media_content_gettid() syscall(__NR_gettid)
806
807 #define media_content_retv_if(expr, val) do { \
808                         if (expr) { \
809                                 LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, media_content_gettid());    \
810                                 return (val); \
811                         } \
812                 } while (0)
813
814 #define media_content_retvm_if(expr, val, fmt, arg...) do { \
815                         if (expr) { \
816                                 LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
817                                 return (val); \
818                         } \
819                 } while (0)
820
821 #define media_content_warn(fmt, arg...) do { \
822                         LOGW(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
823                 } while (0)
824
825 #define media_content_debug(fmt, arg...) do { \
826                         LOGD(FONT_COLOR_RESET"[%ld]"fmt"", media_content_gettid(), ##arg);     \
827                 } while (0)
828
829 #define media_content_info(fmt, arg...) do { \
830                         LOGI(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
831                 } while (0)
832
833 #define media_content_error(fmt, arg...) do { \
834                         LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
835                 } while (0)
836
837 #define media_content_debug_func() do { \
838                         LOGD(FONT_COLOR_RESET"[%ld]", media_content_gettid());     \
839                 } while (0)
840
841 #define media_content_sec_debug(fmt, arg...) do { \
842                         SECURE_LOGD(FONT_COLOR_CYAN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
843                 } while (0)
844
845 #define media_content_sec_warn(fmt, arg...) do { \
846                         SECURE_LOGW(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
847                 } while (0)
848
849 #define media_content_sec_error(fmt, arg...) do { \
850                         SECURE_LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg);     \
851                 } while (0)
852
853 #define ERR_BUF_LENGTH 256
854 #define media_content_stderror(fmt) do { \
855                         char media_content_stderror_buf[ERR_BUF_LENGTH] = {0, }; \
856                         strerror_r(errno, media_content_stderror_buf, ERR_BUF_LENGTH);  \
857                         LOGE(FONT_COLOR_RED fmt" : STANDARD ERROR [%s]"FONT_COLOR_RESET, media_content_stderror_buf); \
858                 } while (0)
859
860 #ifdef __cplusplus
861 }
862 #endif /* __cplusplus */
863 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/