2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__
19 #define __TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__
23 #include <asm/unistd.h>
29 #include <media-svc.h>
30 #include <media_content_type.h>
32 #include <media-util.h>
34 #include <tzplatform_config.h>
35 #include <media_content_type_product.h>
39 #endif /* __cplusplus */
47 * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
50 * @file media_info_private.h
51 * @brief This file contains the media info API and related structure and enumeration. \n
52 * Description of the audio, video,image content involves: album, artist, album_artist, genre and description tags. \n
53 * Parameters of the recording are also supported, as: format, bitrate, duration, size etc. \n
54 * Definitions of media DB fields and tables, operations with media data relating to DB and handling with media filter attributes.
58 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
60 #define STRING_VALID(str) (str && strlen(str) > 0)
62 #define MAX_QUERY_SIZE 4096
63 #define MAX_PATH_LEN 4096
64 #define DEFAULT_QUERY_SIZE 1024
65 #define MEDIA_CONTENT_UUID_SIZE 36
66 #define BATCH_REQUEST_MAX 300
67 #define BATCH_REQUEST_FILE_LEN 255
76 MEDIA_INFO_ADDED_TIME,
77 MEDIA_INFO_MODIFIED_TIME,
78 MEDIA_INFO_THUMBNAIL_PATH,
79 MEDIA_INFO_DESCRIPTION,
86 MEDIA_INFO_EXPOSURE_TIME,
93 MEDIA_INFO_ORIENTATION,
97 MEDIA_INFO_ALBUM_ARTIST,
101 MEDIA_INFO_RECORDED_DATE,
102 MEDIA_INFO_COPYRIGHT,
103 MEDIA_INFO_TRACK_NUM,
105 MEDIA_INFO_BITPERSAMPLE,
107 MEDIA_INFO_SAMPLERATE,
110 MEDIA_INFO_STORAGE_UUID,
112 MEDIA_INFO_PLAYED_COUNT,
113 MEDIA_INFO_LAST_PLAYED_TIME,
114 MEDIA_INFO_LAST_PLAYED_POSITION,
115 MEDIA_INFO_STITCHED_INFO,
116 MEDIA_INFO_EXTRACT_FLAG,
117 MEDIA_INFO_MODIFIED_DATE, /** Playlist pm_id issue. (Use MAX)*/
124 MEDIA_TAG_UPDATE_TAG_NAME,
129 MEDIA_PLAYLIST_REMOVE,
130 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
131 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
132 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
133 } playlist_function_e;
139 MEDIA_GROUP_PLAYLIST,
141 MEDIA_GROUP_BOOKMARK,
142 MEDIA_GROUP_TAG_BY_MEDIA_ID,
143 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
145 MEDIA_GROUP_FACE_BY_MEDIA_ID,
148 typedef struct _filter_s {
152 media_content_order_e order_type;
153 media_content_collation_e condition_collate_type;
154 media_content_collation_e order_collate_type;
157 bool is_full_condition;
178 char *thumbnail_path;
186 char *album_art_path;
192 char *thumbnail_path;
205 media_content_orientation_e orientation;
256 media_content_type_e media_type;
258 unsigned long long size;
260 time_t modified_time;
262 char *thumbnail_path;
275 unsigned int face_request_id;
279 image_meta_s *image_meta;
280 video_meta_s *video_meta;
281 audio_meta_s *audio_meta;
282 book_meta_s *book_meta;
295 char *thumbnail_path;
296 int playlist_member_id;
298 } media_playlist_item_s;
301 int face_id; /* face id */
302 char *media_id; /* media uuid */
303 unsigned int face_rect_x; /* x position of face */
304 unsigned int face_rect_y; /* y position of face */
305 unsigned int face_rect_w; /* width of face */
306 unsigned int face_rect_h; /* height of face */
307 int orientation; /* orientation */
308 char *face_tag; /* face tag */
315 unsigned long long size;
334 int program_start_time;
335 int program_end_time;
344 int hard_of_hearing_radio;
352 char* modified_month;
358 unsigned int service_profile;
364 unsigned long long size;
369 time_t modified_time;
375 media_insert_completed_cb insert_completed_cb;
376 char *insert_list_path;
381 media_content_db_update_cb update_noti_cb;
385 typedef struct _media_content_cb_data {
386 media_scan_completed_cb callback;
388 } media_content_scan_cb_data;
390 typedef struct _media_content_scan_cb_data_v2 {
391 media_scan_completed_cb_v2 callback;
393 } media_content_scan_cb_data_v2;
396 #define DB_TABLE_MEDIA "media"
397 #define DB_TABLE_FOLDER "folder"
398 #define DB_TABLE_ALBUM "album"
399 #define DB_TABLE_TAG "tag"
400 #define DB_TABLE_TAG_MAP "tag_map"
401 #define DB_TABLE_PLAYLIST "playlist"
402 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
403 #define DB_TABLE_BOOKMARK "bookmark"
404 #define DB_TABLE_STORAGE "storage"
405 #define DB_TABLE_FACE "face"
406 #define DB_TABLE_FACE_SCAN_LIST "face_scan_list"
407 #define DB_TABLE_PVR "pvr"
408 #define DB_TABLE_UHD "uhd"
411 #define DB_VIEW_PLAYLIST "playlist_view"
412 #define DB_VIEW_TAG "tag_view"
414 /* DB field for media */
415 #define DB_FIELD_MEDIA_DISPLAY_NAME "media_display_name"
416 #define DB_FIELD_MEDIA_TYPE "media_type"
417 #define DB_FIELD_MEDIA_MIME_TYPE "media_mime_type"
418 #define DB_FIELD_MEDIA_SIZE "media_size"
419 #define DB_FIELD_MEDIA_ADDED_TIME "media_added_time"
420 #define DB_FIELD_MEDIA_MODIFIED_TIME "media_modified_time"
421 #define DB_FIELD_MEDIA_TITLE "media_title"
422 #define DB_FIELD_MEDIA_ALBUM "media_album"
423 #define DB_FIELD_MEDIA_ARTIST "media_artist"
424 #define DB_FIELD_MEDIA_ALBUM_ARTIST "media_album_artist"
425 #define DB_FIELD_MEDIA_GENRE "media_genre"
426 #define DB_FIELD_MEDIA_COMPOSER "media_composer"
427 #define DB_FIELD_MEDIA_YEAR "media_year"
428 #define DB_FIELD_MEDIA_RECORDED_DATE "media_recorded_date"
429 #define DB_FIELD_MEDIA_COPYRIGHT "media_copyright"
430 #define DB_FIELD_MEDIA_TRACK_NUM "media_track_num"
431 #define DB_FIELD_MEDIA_DESCRIPTION "media_description"
432 #define DB_FIELD_MEDIA_RATING "media_rating"
433 #define DB_FIELD_MEDIA_LONGITUDE "media_longitude"
434 #define DB_FIELD_MEDIA_LATITUDE "media_latitude"
435 #define DB_FIELD_MEDIA_ALTITUDE "media_altitude"
437 #define DB_FIELD_MEDIA_MODIFIED_DATE "modified_date"
439 /* DB field for PVR*/
440 #define DB_FIELD_PVR_CHANNEL_NAME "channel_name"
441 #define DB_FIELD_PVR_CHANNEL_NUM "channel_num"
442 #define DB_FIELD_PVR_PROGRAM_TITLE "program_title"
443 #define DB_FIELD_PVR_MODIFIED_DATE "modified_date"
446 #define FOLDER_MEDIA_JOIN DB_TABLE_FOLDER" NATURAL LEFT OUTER JOIN "DB_TABLE_MEDIA" WHERE validity=1 "
447 #define BOOKMARK_MEDIA_JOIN DB_TABLE_BOOKMARK" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity=1 "
448 #define ALBUM_MEDIA_JOIN DB_TABLE_ALBUM" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity=1 "
449 #define FACE_MEDIA_JOIN DB_TABLE_FACE" NATURAL JOIN "DB_TABLE_MEDIA" WHERE validity=1 "
452 #define SELECT_MEDIA_GROUP_AND_COUNT "SELECT %s, COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
453 #define SELECT_MEDIA_GROUP_AND_COUNT_BY_STORAGE_ID SELECT_MEDIA_GROUP_AND_COUNT"AND storage_uuid='%s' "
456 #define SELECT_ALBUM_LIST "SELECT DISTINCT album_id, name, artist, album_art FROM "ALBUM_MEDIA_JOIN
457 #define SELECT_ALBUM_LIST_BY_STORAGE_ID SELECT_ALBUM_LIST"AND storage_uuid='%s' "
458 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 "
459 #define SELECT_MEDIA_GROUP_LIST_BY_STORAGE_ID SELECT_MEDIA_GROUP_LIST"AND storage_uuid='%s' "
461 #define SELECT_FOLDER_LIST "SELECT DISTINCT folder_id, folder_path, folder_name, storage_uuid FROM "FOLDER_MEDIA_JOIN
462 #define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND storage_uuid='%s' "
463 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE 1 "
464 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, playlist_name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
466 /* Get Group Count */
467 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT album_id) FROM "ALBUM_MEDIA_JOIN
468 #define SELECT_ALBUM_COUNT_BY_STORAGE_ID SELECT_ALBUM_COUNT"AND storage_uuid='%s' "
469 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT folder_id) FROM "FOLDER_MEDIA_JOIN
470 #define SELECT_FOLDER_COUNT_BY_STORAGE_ID SELECT_FOLDER_COUNT"AND storage_uuid='%s' "
471 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
472 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
473 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN
474 #define SELECT_BOOKMARK_COUNT_BY_STORAGE_ID SELECT_BOOKMARK_COUNT"AND storage_uuid='%s' "
475 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
476 #define SELECT_MEDIA_GROUP_COUNT_BY_STORAGE_ID SELECT_MEDIA_GROUP_COUNT"AND storage_uuid='%s' "
477 /*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)*/
479 /* Get Media Count of Group */
480 #define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM (SELECT media_id FROM "DB_TABLE_MEDIA" WHERE validity=1 "
481 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA"AND storage_id='%s' "
482 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
483 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE"AND storage_uuid='%s' "
484 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
485 #define SELECT_MEDIA_COUNT_FROM_ALBUM_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_ALBUM" AND storage_uuid='%s'"
486 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP
487 #define SELECT_MEDIA_COUNT_FROM_GROUP_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_GROUP" AND storage_uuid='%s'"
488 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL
489 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL_BY_STORAGE_ID SELECT_MEDIA_COUNT_FROM_GROUP_NULL" AND storage_uuid='%s'"
490 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_id='%s' "
491 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND tag_media_count>0) "
492 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) "
494 /* Get Group Info by Group ID*/
495 #define SELECT_ALBUM_FROM_ALBUM "SELECT name, artist, album_art FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
496 #define SELECT_FOLDER_FROM_FOLDER "SELECT folder_path, folder_name, storage_uuid FROM "DB_TABLE_FOLDER" WHERE folder_id='%s'"
497 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT playlist_name, thumbnail_path FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
498 #define SELECT_TAG_FROM_TAG "SELECT tag_name FROM "DB_TABLE_TAG" WHERE tag_id=%d"
499 #define SELECT_TAG_BY_NAME "SELECT tag_id FROM "DB_TABLE_TAG" WHERE tag_name='%q'"
502 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (tag_name) VALUES (%Q)"
503 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_id='%q';"
504 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET tag_name='%q' WHERE tag_id=%d;"
505 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_id = '%s'"
506 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, tag_name FROM "DB_VIEW_TAG" WHERE media_id = '%s' "
508 /* Get Media list of Group */
509 #define MEDIA_INFO_ITEM "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_added_time, media_modified_time, media_thumbnail_path, media_description, \
510 media_rating, media_favourite, media_is_drm, media_longitude, media_latitude, media_altitude, exposure_time, fnumber, iso, \
511 model, media_width, media_height, media_datetaken, orientation, media_title, media_album, media_artist, media_album_artist, media_genre, \
512 media_composer, media_year, media_recorded_date, media_copyright, media_track_num, media_bitrate, media_bitpersample, media_duration, media_samplerate, media_channel, \
513 media_timeline, storage_uuid, media_360, played_count, last_played_time, last_played_position, stitched_info, extract_flag, modified_date"
516 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (playlist_name) VALUES (%Q)"
517 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET playlist_name='%q' WHERE playlist_id=%d;"
518 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d;"
519 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE playlist_name='%q'"
520 #define SELECT_PLAYLIST_ITEM_ALL_FROM_PLAYLIST_VIEW "SELECT "MEDIA_INFO_ITEM", pm_id FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and playlist_media_count>0) "
521 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT playlist_member_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
522 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(playlist_member_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
523 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;"
524 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET playlist_member_order=%d WHERE playlist_id=%d AND _id=%d;"
525 #define INSERT_PLAYLIST_ITEM_TO_PLAYLIST_MAP "INSERT INTO "DB_TABLE_PLAYLIST_MAP" (playlist_id, media_id, playlist_member_order) VALUES (%d, '%q', %d);"
528 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name) VALUES ('%q', '%d', %Q, %Q)"
529 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND media_id='%s'"
530 #define SELECT_BOOKMARK_LIST "SELECT bookmark_id, media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN
531 #define SELECT_BOOKMARK_LIST_BY_STORAGE_ID SELECT_BOOKMARK_LIST"AND storage_uuid='%s' "
532 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT bookmark_id, media_id, bookmark_marked_time, bookmark_thumbnail_path, bookmark_name FROM "BOOKMARK_MEDIA_JOIN" AND media_id='%s'"
533 #define SELECT_BOOKMARK_ID_FROM_BOOKMARK "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_id='%s' AND bookmark_marked_time=%d"
535 #define UPDATE_BOOKMARK_FROM_BOOKMARK "UPDATE "DB_TABLE_BOOKMARK" SET bookmark_name=%Q WHERE bookmark_id=%d;"
537 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
538 #define SELECT_MEDIA_ITEM_BY_STORAGE_ID SELECT_MEDIA_ITEM" AND storage_uuid='%s'"
539 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_id='%s'"
540 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_path='%q'"
541 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d "
542 #define SELECT_MEDIA_FROM_ALBUM_BY_STORAGE_ID SELECT_MEDIA_FROM_ALBUM" AND storage_uuid='%s' "
543 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'"
544 #define SELECT_MEDIA_FROM_GROUP_BY_STORAGE_ID SELECT_MEDIA_FROM_GROUP" AND storage_uuid='%s'"
545 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL"
546 #define SELECT_MEDIA_FROM_GROUP_NULL_BY_STORAGE_ID SELECT_MEDIA_FROM_GROUP_NULL" AND storage_uuid='%s'"
547 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_id='%s'"
548 #define SELECT_MEDIA_FROM_STORAGE "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND storage_uuid='%s'"
549 #define SELECT_MEDIA_FROM_TAG "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_id IN (SELECT media_id FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
550 #define SELECT_MEDIA_FROM_TAG_BY_STORAGE_ID SELECT_MEDIA_FROM_TAG" AND storage_uuid='%s'"
551 #define SELECT_MEDIA_FROM_PLAYLIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_id IN (SELECT media_id FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
552 #define SELECT_MEDIA_FROM_PLAYLIST_BY_STORAGE_ID SELECT_MEDIA_FROM_PLAYLIST" AND storage_uuid='%s'"
553 #define SELECT_MEDIA_PATH_BY_ID "SELECT media_path FROM "DB_TABLE_MEDIA" WHERE media_id='%q'"
554 #define SELECT_MEDIA_STORAGE_ID_BY_ID "SELECT storage_uuid FROM "DB_TABLE_MEDIA" WHERE media_id='%q'"
557 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
558 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
559 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
562 #define SELECT_STORAGE_COUNT "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
563 #define SELECT_STORAGE_LIST "SELECT storage_id, storage_path FROM "DB_TABLE_STORAGE" WHERE validity=1"
564 #define SELECT_STORAGE_INFO_FROM_STORAGE "SELECT storage_path FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_id='%s'"
567 #define DELETE_FACE_FROM_FACE "DELETE FROM "DB_TABLE_FACE" WHERE media_face_id=%d"
568 #define INSERT_FACE_TO_FACE "INSERT INTO "DB_TABLE_FACE" (media_id, face_rect_x , face_rect_y, face_rect_w, face_rect_h, face_orientation, media_face_tag) VALUES ('%q', %d, %d, %d, %d, %d, %Q);"
569 #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, face_orientation=%d, media_face_tag=%Q WHERE media_face_id=%d"
570 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE media_id='%q' AND validity=1"
571 #define SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE media_id='%q' AND media_type=0 AND validity=1"
572 #define SELECT_FACE_COUNT "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN
573 #define SELECT_FACE_COUNT_BY_STORAGE_ID SELECT_FACE_COUNT"AND storage_uuid='%s' "
574 #define SELECT_FACE_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND media_id='%s'"
575 #define SELECT_FACE_LIST "SELECT media_face_id, media_id, face_rect_x, face_rect_y, face_rect_w, face_rect_h, face_orientation, media_face_tag FROM "FACE_MEDIA_JOIN
576 #define SELECT_FACE_LIST_BY_STORAGE_ID SELECT_FACE_LIST"AND storage_uuid='%s' "
577 #define SELECT_FACE_LIST_BY_MEDIA_ID "SELECT media_face_id, media_id, face_rect_x, face_rect_y, face_rect_w, face_rect_h, face_orientation, media_face_tag FROM "FACE_MEDIA_JOIN" AND media_id='%s'"
578 #define UPDATE_MEDIA_INFO_IN_FACE_SCAN_LIST "UPDATE "DB_TABLE_FACE_SCAN_LIST" SET modified_time = 0 WHERE media_id IN (SELECT media_id FROM "DB_TABLE_FACE" WHERE media_face_id=%d)"
579 #define SELECT_FACE_ID "SELECT media_face_id FROM "DB_TABLE_FACE" WHERE media_id='%q' AND face_rect_x=%d AND face_rect_y=%d AND face_rect_w=%d AND face_rect_h=%d AND face_orientation=%d"
581 #define SELECT_VALID_STORAGE_FROM_PVR "WHERE storage_uuid IN (SELECT storage_id FROM "DB_TABLE_STORAGE" WHERE validity=1)"
582 #define SELECT_PVR_LIST "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
583 #define SELECT_PVR_LIST_BY_STORAGE_ID SELECT_PVR_LIST" AND storage_uuid='%s'"
584 #define SELECT_PVR_FROM_PVR "SELECT * FROM "DB_TABLE_PVR" WHERE media_id='%q'"
585 #define UPDATE_PVR_META_FROM_PVR "UPDATE "DB_TABLE_PVR" SET program_title=%Q, content_lock=%d, content_watch=%d, play_count=%d WHERE media_id='%q'"
587 #define SELECT_PVR_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
588 #define SELECT_PVR_GROUP_LIST_BY_STORAGE_ID "SELECT DISTINCT %s FROM "DB_TABLE_PVR" WHERE storage_uuid='%s'"
589 #define SELECT_PVR_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_PVR_GROUP_LIST
590 #define SELECT_PVR_GROUP_COUNT_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_GROUP_LIST_BY_STORAGE_ID
591 #define SELECT_PVR_FROM_GROUP "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR" AND %s='%q'"
592 #define SELECT_PVR_FROM_GROUP_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_PVR" WHERE storage_uuid='%s' AND %s='%q'"
593 #define SELECT_PVR_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP
594 #define SELECT_PVR_COUNT_FROM_GROUP_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_BY_STORAGE_ID
595 #define SELECT_PVR_FROM_GROUP_NULL "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR" AND %s IS NULL"
596 #define SELECT_PVR_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_PVR" WHERE storage_uuid='%s' AND %s IS NULL"
597 #define SELECT_PVR_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_NULL
598 #define SELECT_PVR_COUNT_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_NULL_BY_STORAGE_ID
599 #define SELECT_PVR_GROUP_AND_COUNT_BY_STORAGE_ID "SELECT %s, COUNT(*) FROM "DB_TABLE_PVR" WHERE storage_uuid='%s'"
600 #define SELECT_PVR_GROUP_AND_COUNT "SELECT %s, COUNT(*) FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
602 #define SELECT_VALID_STORAGE_FROM_UHD "WHERE storage_uuid IN (SELECT storage_id FROM "DB_TABLE_STORAGE" WHERE validity=1)"
604 #define SELECT_UHD_LIST "SELECT * FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD
605 #define SELECT_UHD_LIST_BY_STORAGE_ID SELECT_UHD_LIST" AND storage_uuid='%s'"
606 #define SELECT_UHD_FROM_UHD "SELECT * FROM "DB_TABLE_UHD" WHERE media_id='%q'"
607 #define UPDATE_UHD_META_FROM_UHD "UPDATE "DB_TABLE_UHD" SET content_title=%Q, played_position=%d, played_count=%d WHERE media_id='%q'"
609 int _content_query_prepare(const char *select_query, const char *condition_query, const char *option_query, sqlite3_stmt **stmt);
610 int _content_get_result(const char *query, sqlite3_stmt **stmt);
611 int _content_error_capi(int internal_error);
612 int _content_query_sql(char *query_str);
613 sqlite3 * _content_get_db_handle(void);
614 uid_t _content_get_uid(void);
615 int _media_info_get_media_info_from_db(const char *path, media_info_h media);
616 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
617 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
618 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
619 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
620 int _media_db_get_media_group_and_count(media_group_e group, filter_h filter, media_group_and_count_cb callback, void *user_data);
621 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
622 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
623 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
624 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
625 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
626 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
627 int _media_db_get_face(const char *media_id, filter_h filter, media_face_cb callback, void *user_data);
628 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
629 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
630 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);
631 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);
632 int _media_db_get_media_group_item_count(const char *group_name, filter_h filter, media_group_e group, int *item_count);
633 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);
634 int _media_db_get_storage_id_by_media_id(const char *media_id, char **storage_id);
635 int _media_db_get_pvr(filter_h filter, media_pvr_cb callback, void *user_data);
636 void _media_pvr_item_get_detail(sqlite3_stmt* stmt, media_pvr_h pvr);
637 int _media_db_get_uhd(filter_h filter, media_uhd_cb callback, void *user_data);
638 void _media_uhd_item_get_detail(sqlite3_stmt* stmt, media_uhd_h uhd);
639 int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
640 int _media_filter_build_condition(bool is_full, const char *condition, media_content_collation_e collate_type, char **result);
641 int _media_filter_build_option(filter_h filter, char **result);
643 GMutex* _content_get_db_mutex(void);
646 #define FONT_COLOR_RESET "\033[0m"
647 #define FONT_COLOR_RED "\033[31m"
648 #define FONT_COLOR_GREEN "\033[32m"
649 #define FONT_COLOR_YELLOW "\033[33m"
650 #define FONT_COLOR_BLUE "\033[34m"
651 #define FONT_COLOR_PURPLE "\033[35m"
652 #define FONT_COLOR_CYAN "\033[36m"
653 #define FONT_COLOR_GRAY "\033[37m"
655 #define media_content_gettid() syscall(__NR_gettid)
657 #define content_retv_if(expr, val) do { \
659 LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, media_content_gettid()); \
664 #define content_retvm_if(expr, val, fmt, arg...) do { \
666 LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
671 #define content_retip_if_fail(expr) do { \
673 LOGE(FONT_COLOR_RED"[%ld] Invalid [%s]"FONT_COLOR_RESET, media_content_gettid(), #expr); \
674 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; \
678 #define content_retipm_if_fail(expr, fmt, arg...) do { \
680 LOGE(FONT_COLOR_RED"[%ld] Cond[%s] value["fmt"]"FONT_COLOR_RESET, media_content_gettid(), #expr, ##arg); \
681 return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; \
685 #define content_warn(fmt, arg...) do { \
686 LOGW(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
689 #define content_debug(fmt, arg...) do { \
690 LOGD(FONT_COLOR_RESET"[%ld]"fmt"", media_content_gettid(), ##arg); \
693 #define content_info(fmt, arg...) do { \
694 LOGI(FONT_COLOR_GREEN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
697 #define content_error(fmt, arg...) do { \
698 LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
701 #define content_sec_debug(fmt, arg...) do { \
702 SECURE_LOGD(FONT_COLOR_CYAN"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
705 #define content_sec_error(fmt, arg...) do { \
706 SECURE_LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
709 #define ERR_BUF_LENGTH 256
710 #define content_stderror(fmt) do { \
711 char media_content_stderror_buf[ERR_BUF_LENGTH] = {0, }; \
712 strerror_r(errno, media_content_stderror_buf, ERR_BUF_LENGTH); \
713 LOGE(FONT_COLOR_RED fmt" : STANDARD ERROR [%s]"FONT_COLOR_RESET, media_content_stderror_buf); \
718 #endif /* __cplusplus */
719 #endif /*__TIZEN_CONTENT_MEDIA_INFO_PRIVATE_H__*/