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_MEDIA_INFO_PRIVATE_H__
19 #define __TIZEN_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 #ifdef _USE_TV_PROFILE
36 #include <media_content_type_product.h>
41 #endif /* __cplusplus */
49 * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
52 * @file media_info_private.h
53 * @brief This file contains the media info API and related structure and enumeration. \n
54 * Description of the audio, video,image content involves: album, artist, album_artist, author, genre and description tags. \n
55 * Parameters of the recording are also supported, as: format, bitrate, duration, size etc. \n
56 * Defenitions of media DB fields and tables, operations with media data relating to DB and handling with media filter attributes.
60 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
62 #define SAFE_STRLCPY(dst, src, n) ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
63 #define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
64 #define SAFE_FREE(src) {if (src) {free(src); src = NULL; } }
65 #define SAFE_G_FREE(src) {if (src) {g_free(src); src = NULL; } }
66 #define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
67 #define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
68 #define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
70 #define MEDIA_CONTENT_INSERT_FILES_PATH "/tmp"
71 #define MEDIA_CONTENT_EMPTY_STRING ""
73 #define MAX_QUERY_SIZE 4096
74 #define MAX_PATH_LEN 4096
75 #define DEFAULT_QUERY_SIZE 1024
76 #define COLLATE_STR_SIZE 32
77 #define MEDIA_CONTENT_UUID_SIZE 36
78 #define BATCH_REQUEST_MAX 300
89 MEDIA_INFO_ADDED_TIME,
90 MEDIA_INFO_MODIFIED_TIME,
91 MEDIA_INFO_THUMBNAIL_PATH,
92 MEDIA_INFO_DESCRIPTION,
97 MEDIA_INFO_CONTENT_NAME,
99 MEDIA_INFO_LOCATION_TAG,
100 MEDIA_INFO_AGE_RATING,
103 MEDIA_INFO_STORAGE_TYPE,
104 MEDIA_INFO_LONGITUDE,
107 MEDIA_INFO_EXPOSURE_TIME,
113 MEDIA_INFO_DATETAKEN,
114 MEDIA_INFO_ORIENTATION,
118 MEDIA_INFO_ALBUM_ARTIST,
122 MEDIA_INFO_RECORDED_DATE,
123 MEDIA_INFO_COPYRIGHT,
124 MEDIA_INFO_TRACK_NUM,
126 MEDIA_INFO_BITPERSAMPLE,
128 MEDIA_INFO_PLAYED_COUNT,
129 MEDIA_INFO_LAST_PLAYED_TIME,
130 MEDIA_INFO_LAST_PLAYED_POSITION,
131 MEDIA_INFO_SAMPLERATE,
136 MEDIA_INFO_SYNC_STATUS,
137 MEDIA_INFO_STORAGE_UUID,
139 MEDIA_INFO_STITCHED_INFO,
140 MEDIA_INFO_EXTRACT_FLAG,
141 MEDIA_INFO_MODIFIED_MONTH,
142 #ifdef _USE_SENIOR_MODE
150 MEDIA_CONTENT_TYPE = 0,
151 MEDIA_THUMBNAIL_TYPE,
153 } media_info_error_type_e;
158 MEDIA_TAG_UPDATE_TAG_NAME,
163 MEDIA_PLAYLIST_REMOVE,
164 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
165 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
166 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
167 } playlist_function_e;
173 MEDIA_GROUP_PLAYLIST,
175 MEDIA_GROUP_BOOKMARK,
176 MEDIA_GROUP_TAG_BY_MEDIA_ID,
177 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
179 MEDIA_GROUP_FACE_BY_MEDIA_ID,
185 MEDIA_BATCH_INSERT_NORMAL,
186 MEDIA_BATCH_INSERT_BURSTSHOT,
187 } media_batch_insert_e;
189 typedef struct _filter_s {
193 media_content_order_e order_type;
194 media_content_collation_e condition_collate_type;
195 media_content_collation_e order_collate_type;
202 char *parent_folder_id;
205 time_t modified_time;
206 media_content_storage_e storage_type;
221 char *thumbnail_path;
229 char *album_art_path;
235 char *thumbnail_path;
251 media_content_orientation_e orientation;
254 typedef struct _image_mm_meta_s {
307 media_content_type_e media_type;
309 unsigned long long size;
311 time_t modified_time;
313 char *thumbnail_path;
334 char *modified_month;
337 unsigned int request_id;
338 unsigned int face_request_id;
342 #ifdef _USE_SENIOR_MODE
346 image_meta_s *image_meta;
347 video_meta_s *video_meta;
348 audio_meta_s *audio_meta;
361 char *thumbnail_path;
362 int playlist_member_id;
364 } media_playlist_item_s;
374 char *face_id; /* face uuid */
375 char *media_id; /* media uuid */
376 unsigned int face_rect_x; /* x position of face */
377 unsigned int face_rect_y; /* y position of face */
378 unsigned int face_rect_w; /* width of face */
379 unsigned int face_rect_h; /* height of face */
380 int orientation; /* orientation */
381 char *face_tag; /* face tag */
388 unsigned long long size;
407 int program_start_time;
408 int program_end_time;
417 int hard_of_hearing_radio;
425 char* modified_month;
438 unsigned long long size;
443 time_t modified_time;
449 typedef struct _attribute_map_s {
450 GHashTable *attr_map;
454 media_info_s *handle;
456 media_thumbnail_completed_cb thumbnail_completed_cb;
457 } media_thumbnail_cb_s;
460 media_info_s *handle;
462 media_face_detection_completed_cb face_completed_cb;
466 media_insert_completed_cb insert_completed_cb;
467 char *insert_list_path;
472 media_content_db_update_cb update_noti_cb;
476 typedef struct attribute_s *attribute_h;
479 typedef struct _media_content_cb_data {
480 media_scan_completed_cb callback;
482 } media_content_scan_cb_data;
484 typedef struct _media_content_scan_cb_data_v2 {
485 media_scan_completed_cb_v2 callback;
487 } media_content_scan_cb_data_v2;
490 #define DB_TABLE_MEDIA "media"
491 #define DB_TABLE_FOLDER "folder"
492 #define DB_TABLE_ALBUM "album"
493 #define DB_TABLE_TAG "tag"
494 #define DB_TABLE_TAG_MAP "tag_map"
495 #define DB_TABLE_PLAYLIST "playlist"
496 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
497 #define DB_TABLE_BOOKMARK "bookmark"
498 #define DB_TABLE_STORAGE "storage"
499 #define DB_TABLE_MEDIA_VIEW "media_view"
500 #define DB_TABLE_FACE "face"
501 #define DB_TABLE_FACE_SCAN_LIST "face_scan_list"
502 #define DB_TABLE_PVR "pvr"
503 #define DB_TABLE_UHD "uhd"
506 #define DB_VIEW_PLAYLIST "playlist_view"
507 #define DB_VIEW_TAG "tag_view"
510 #define DB_TABLE_ALIAS_MEDIA "m"
511 #define DB_TABLE_ALIAS_FOLDER "f"
512 #define DB_TABLE_ALIAS_PLAYLIST "p"
513 #define DB_TABLE_ALIAS_PLAYLIST_MAP "pm"
514 #define DB_TABLE_ALIAS_TAG "t"
515 #define DB_TABLE_ALIAS_BOOKMARK "b"
516 #define DB_TABLE_ALIAS_ALBUM "a"
518 /* DB field for media */
519 #define DB_FIELD_MEDIA_ID "media_uuid"
520 #define DB_FIELD_MEDIA_PATH "path"
521 #define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
522 #define DB_FIELD_MEDIA_TYPE "media_type"
523 #define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
524 #define DB_FIELD_MEDIA_SIZE "size"
525 #define DB_FIELD_MEDIA_ADDED_TIME "added_time"
526 #define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
527 #define DB_FIELD_MEDIA_FOLDER_ID "folder_uuid"
528 #define DB_FIELD_MEDIA_TIMELINE "timeline"
529 #define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
530 #define DB_FIELD_MEDIA_TITLE "title"
531 #define DB_FIELD_MEDIA_ALBUM "album"
532 #define DB_FIELD_MEDIA_ARTIST "artist"
533 #define DB_FIELD_MEDIA_ALBUM_ARTIST "album_artist"
534 #define DB_FIELD_MEDIA_GENRE "genre"
535 #define DB_FIELD_MEDIA_COMPOSER "composer"
536 #define DB_FIELD_MEDIA_YEAR "year"
537 #define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
538 #define DB_FIELD_MEDIA_COPYRIGHT "copyright"
539 #define DB_FIELD_MEDIA_TRACK_NUM "track_num"
540 #define DB_FIELD_MEDIA_DESCRIPTION "description"
541 #define DB_FIELD_MEDIA_BITRATE "bitrate"
542 #define DB_FIELD_MEDIA_BITPERSAMPLE "bitpersample"
543 #define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
544 #define DB_FIELD_MEDIA_CHANNEL "channel"
545 #define DB_FIELD_MEDIA_DURATION "duration"
546 #define DB_FIELD_MEDIA_LONGITUDE "longitude"
547 #define DB_FIELD_MEDIA_LATITUDE "latitude"
548 #define DB_FIELD_MEDIA_ALTITUDE "altitude"
549 #define DB_FIELD_MEDIA_WIDTH "width"
550 #define DB_FIELD_MEDIA_HEIGHT "height"
551 #define DB_FIELD_MEDIA_DATETAKEN "datetaken"
552 #define DB_FIELD_MEDIA_ORIENTATION "orientation"
553 #define DB_FIELD_MEDIA_BURST_ID "burst_id"
554 #define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
555 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
556 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
557 #define DB_FIELD_MEDIA_RATING "rating"
558 #define DB_FIELD_MEDIA_FAVOURITE "favourite"
559 #define DB_FIELD_MEDIA_AUTHOR "author"
560 #define DB_FIELD_MEDIA_PROVIDER "provider"
561 #define DB_FIELD_MEDIA_CONTENT_NAME "content_name"
562 #define DB_FIELD_MEDIA_CATEGORY "category"
563 #define DB_FIELD_MEDIA_LOCATION_TAG "location_tag"
564 #define DB_FIELD_MEDIA_AGE_RATING "age_rating"
565 #define DB_FIELD_MEDIA_KEYWORD "keyword"
566 #define DB_FIELD_MEDIA_WEATHER "weather"
567 #define DB_FIELD_MEDIA_IS_DRM "is_drm"
568 #define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
569 #define DB_FIELD_MEDIA_MODIFIED_MONTH "modified_month"
570 #define DB_FIELD_MEDIA_MODIFIED_DATE "modified_date"
571 #define DB_FIELD_MEDIA_EXPOSURE_TIME "exposure_time"
572 #define DB_FIELD_MEDIA_FNUMBER "fnumber"
573 #define DB_FIELD_MEDIA_ISO "iso"
574 #define DB_FIELD_MEDIA_MODEL "model"
575 #define DB_FIELD_MEDIA_FILE_NAME_PINYIN "file_name_pinyin"
576 #define DB_FIELD_MEDIA_TITLE_PINYIN "title_pinyin"
577 #define DB_FIELD_MEDIA_ALBUM_PINYIN "album_pinyin"
578 #define DB_FIELD_MEDIA_ARTIST_PINYIN "artist_pinyin"
579 #define DB_FIELD_MEDIA_ALBUM_ARTIST_PINYIN "album_artist_pinyin"
580 #define DB_FIELD_MEDIA_GENRE_PINYIN "genre_pinyin"
581 #define DB_FIELD_MEDIA_COMPOSER_PINYIN "composer_pinyin"
582 #define DB_FIELD_MEDIA_COPYRIGHT_PINYIN "copyright_pinyin"
583 #define DB_FIELD_MEDIA_DESCRIPTION_PINYIN "description_pinyin"
584 #define DB_FIELD_MEDIA_AUTHOR_PINYIN "author_pinyin"
585 #define DB_FIELD_MEDIA_PROVIDER_PINYIN "provider_pinyin"
586 #define DB_FIELD_MEDIA_CONTENT_NAME_PINYIN "content_name_pinyin"
587 #define DB_FIELD_MEDIA_CATEGORY_PINYIN "category_pinyin"
588 #define DB_FIELD_MEDIA_LOCATION_TAG_PINYIN "location_tag_pinyin"
589 #define DB_FIELD_MEDIA_AGE_RATING_PINYIN "age_rating_pinyin"
590 #define DB_FIELD_MEDIA_KEYWORD_PINYIN "keyword_pinyin"
591 #define DB_FIELD_MEDIA_360 "is_360"
592 #define DB_FIELD_MEDIA_STITCHED_INFO "stitched_info"
593 #ifdef _USE_SENIOR_MODE
594 #define DB_FIELD_MEDIA_CONTACT "contact"
595 #define DB_FIELD_MEDIA_APP_DATA "app_data"
598 /* DB field for folder */
599 #define DB_FIELD_FOLDER_ID "folder_uuid"
600 #define DB_FIELD_FOLDER_PATH "path"
601 #define DB_FIELD_FOLDER_NAME "name"
602 #define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time"
603 #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
604 #define DB_FIELD_FOLDER_NAME_PINYIN "name_pinyin"
605 #define DB_FIELD_FOLDER_ORDER "folder_order"
606 #define DB_FIELD_FOLDER_PARENT_FOLDER_ID "parent_folder_uuid"
608 /* DB field for playlist */
609 #define DB_FIELD_PLAYLIST_ID "playlist_id"
610 #define DB_FIELD_PLAYLIST_NAME "name"
611 #define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
612 #define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count"
614 /* DB field for tag */
615 #define DB_FIELD_TAG_ID "tag_id"
616 #define DB_FIELD_TAG_NAME "name"
617 #define DB_FIELD_TAG_MEDIA_COUNT "media_count"
619 /* DB field for bookmark */
620 #define DB_FIELD_BOOKMARK_ID "bookmark_id"
621 #define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time"
622 #define DB_FIELD_BOOKMARK_NAME "name"
624 /* DB field for album*/
625 #define DB_FIELD_ALBUM_ID "album_id"
626 #define DB_FIELD_ALBUM_NAME "name"
627 #define DB_FIELD_ALBUM_ARTIST "artist"
629 /* DB field for Storage*/
630 #define DB_FIELD_STORAGE_ID "storage_uuid"
631 #define DB_FIELD_STORAGE_PATH "storage_path"
633 /* DB field for Face */
634 #define DB_FIELD_FACE_ID "face_uuid"
635 #define DB_FIELD_FACE_TAG "face_tag"
637 /* DB field for PVR*/
638 #define DB_FIELD_PVR_DURATION "duration"
639 #define DB_FIELD_PVR_TIME_ZONE "timezone"
640 #define DB_FIELD_PVR_PTC "ptc"
641 #define DB_FIELD_PVR_MAJOR "major"
642 #define DB_FIELD_PVR_MINOR "minor"
643 #define DB_FIELD_PVR_CHANNEL_TYPE "channel_type"
644 #define DB_FIELD_PVR_CHANNEL_NAME "channel_name"
645 #define DB_FIELD_PVR_CHANNEL_NUM "channel_num"
646 #define DB_FIELD_PVR_PROGRAM_TITLE "program_title"
647 #define DB_FIELD_PVR_PROGRAM_NUM "program_num"
648 #define DB_FIELD_PVR_PROGRAM_CRID "program_crid"
649 #define DB_FIELD_PVR_GUIDANCE "guidance"
650 #define DB_FIELD_PVR_SYNOPSIS "synopsis"
651 #define DB_FIELD_PVR_GENRE "genre"
652 #define DB_FIELD_PVR_LANGUAGE "language"
653 #define DB_FIELD_PVR_EMBARGO_TIME "embargo_time"
654 #define DB_FIELD_PVR_EXPIRY_TIME "expiry_time"
655 #define DB_FIELD_PVR_START_TIME "start_time"
656 #define DB_FIELD_PVR_PROGRAM_START_TIME "program_start_time"
657 #define DB_FIELD_PVR_PROGRAM_END_TIME "program_end_time"
658 #define DB_FIELD_PVR_PROGRAM_DATE "program_date"
659 #define DB_FIELD_PVR_PARENTAL_RATING "parental_rating"
660 #define DB_FIELD_PVR_TIMER_RECORD "timer_record"
661 #define DB_FIELD_PVR_SERIES_RECORD "series_record"
662 #define DB_FIELD_PVR_HD "hd"
663 #define DB_FIELD_PVR_SUBTITLE "subtitle"
664 #define DB_FIELD_PVR_TTX "ttx"
665 #define DB_FIELD_PVR_AD "ad"
666 #define DB_FIELD_PVR_HARDOF_HEARINGRADIO "hard_of_hearing_radio"
667 #define DB_FIELD_PVR_DATA_SERVICE "data_service"
668 #define DB_FIELD_PVR_CONTENT_LOCK "content_lock"
669 #define DB_FIELD_PVR_CONTENT_WATCH "content_watch"
670 #define DB_FIELD_PVR_HAS_AUDIO_ONLY "has_audio_only"
671 #define DB_FIELD_PVR_IS_LOCAL_RECORD "is_local_record"
672 #define DB_FIELD_PVR_RESOLUTION "resolution"
673 #define DB_FIELD_PVR_ASPECTRATIO "aspectratio"
674 #define DB_FIELD_PVR_MODIFIED_MONTH "modified_month"
675 #define DB_FIELD_PVR_MODIFIED_DATE "modified_date"
676 #define DB_FIELD_PVR_SPORTS_TYPE "sports_type"
677 #define DB_FIELD_PVR_GUIDANCE_LENGTH "guidance_length"
678 #define DB_FIELD_PVR_TVMODE "tvmode"
679 #define DB_FIELD_PVR_PLAY_COUNT "play_count"
680 #define DB_FIELD_PVR_PRIVATE_DATA "private_data"
682 /* DB fiedl for UHD */
683 #define DB_FIELD_UHD_CONTENT_TITLE "content_title"
684 #define DB_FIELD_UHD_RELEASE_DATE "release_date"
685 #define DB_FIELD_UHD_SUB_TYPE "sub_type"
686 #define DB_FIELD_UHD_FILE_NAME "file_name"
687 #define DB_FIELD_UHD_PLAYED_COUNT "played_count"
689 /* DB Query Keyword */
690 #define QUERY_KEYWORD_AND "AND"
691 #define QUERY_KEYWORD_OR "OR"
692 #define QUERY_KEYWORD_ORDER_BY "ORDER BY"
693 #define QUERY_KEYWORD_LIMIT "limit"
694 #define QUERY_KEYWORD_DESC "DESC"
695 #define QUERY_KEYWORD_SPACE " "
696 #define QUERY_KEYWORD_OPEN_BRACKET "("
697 #define QUERY_KEYWORD_BRACKET ")"
700 /*#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) " */
701 #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 "
702 #define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m \
703 ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
704 #define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN '%s' AS m \
705 ON (a.album_id = m.album_id)) WHERE m.validity=1"
706 #define FACE_MEDIA_JOIN "("DB_TABLE_FACE" AS fa INNER JOIN '%s' AS m \
707 ON (fa.media_uuid = m.media_uuid)) WHERE m.validity=1"
710 #define SELECT_MEDIA_GROUP_AND_COUNT "SELECT %s, COUNT(*) FROM '%s' WHERE validity=1 "
713 #define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
714 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM '%s' WHERE validity=1 "
716 #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, f.parent_folder_uuid FROM "FOLDER_MEDIA_JOIN
717 #define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND f.storage_uuid='%s' "
718 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
719 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
721 /* Get Group Count */
722 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
723 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
724 #define SELECT_FOLDER_COUNT_BY_STORAGE_ID SELECT_FOLDER_COUNT"AND f.storage_uuid='%s' "
725 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
726 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
727 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
728 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
729 /*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)*/
731 /* Get Media Count of Group */
732 #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" */
733 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM '%s' WHERE validity=1 "
734 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND album_id='%d'"
735 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP /*to apply limit condition. */
736 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL /* to apply limit condition. */
737 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'"
738 #define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'"
739 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
740 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
742 /* Get Group Info by Group ID*/
743 #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
744 #define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
745 #define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
746 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
747 #define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
748 #define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
751 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
752 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q';"
753 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d;"
754 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
755 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
757 /* Get Media list of Group */
758 #ifdef _USE_SENIOR_MODE
759 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
760 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, stitched_info, extract_flag, modified_date, contact, app_data"
762 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
763 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, stitched_info, extract_flag, modified_date"
767 #define UPDATE_FOLDER_ORDER "UPDATE "DB_TABLE_FOLDER" SET folder_order=%d WHERE folder_uuid=%Q"
770 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
771 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d;"
772 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d;"
773 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
774 #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) "
775 #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) "
776 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
777 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
778 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d;"
779 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d;"
782 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path, name) VALUES ('%q', '%d', %Q, %Q)"
783 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
784 #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'"
785 #define SELECT_BOOKMARK_ID_FROM_BOOKMARK "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s' AND marked_time=%d"
787 #define UPDATE_BOOKMARK_FROM_BOOKMARK "UPDATE "DB_TABLE_BOOKMARK" SET name=%Q WHERE bookmark_id=%d;"
790 #define UPDATE_AV_META_FROM_MEDIA "UPDATE '%s' SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
791 #define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE '%s' SET orientation=%d, weather=%Q WHERE media_uuid='%q'"
793 #define UPDATE_VIDEO_MM_DATA_FROM_MEDIA "UPDATE '%s' SET bitrate=%d, duration=%d, width=%d, height=%d WHERE media_uuid='%q'"
794 #define UPDATE_AUDIO_MM_DATA_FROM_MEDIA "UPDATE '%s' SET duration=%d, bitrate=%d, bitpersample=%d, samplerate=%d, channel=%d WHERE media_uuid='%q'"
795 #define UPDATE_IMAGE_MM_DATA_FROM_MEDIA "UPDATE '%s' SET width=%d, height=%d WHERE media_uuid='%q'"
796 #define SELECT_VIDEO_MM_DATA_FROM_MEDIA "SELECT bitrate, duration, width, height FROM '%s' WHERE media_uuid='%q'"
797 #define SELECT_AUDIO_MM_DATA_FROM_MEDIA "SELECT duration, bitrate, bitpersample, samplerate, channel FROM '%s' WHERE media_uuid='%q'"
798 #define SELECT_IMAGE_MM_DATA_FROM_MEDIA "SELECT width, height FROM '%s' WHERE media_uuid='%q'"
800 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1"
801 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND media_uuid='%s'"
802 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND path='%q'"
803 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND album_id=%d"
804 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s='%q'"
805 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s IS NULL"
806 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND folder_uuid='%s'"
807 #define SELECT_MEDIA_FROM_STORAGE "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND storage_uuid='%s'"
808 #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"
809 #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"
810 #define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
811 #define SELECT_MEDIA_STORAGE_ID_BY_ID "SELECT storage_uuid FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
814 #define DELETE_MEDIA_FROM_MEDIA_BATCH "DELETE FROM '%s' WHERE %s"
815 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
816 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
817 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
820 #define SELECT_STORAGE_COUNT "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
821 #define SELECT_STORAGE_LIST "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1"
822 #define SELECT_STORAGE_INFO_FROM_STORAGE "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_uuid='%s'"
825 #define DELETE_FACE_FROM_FACE "DELETE FROM "DB_TABLE_FACE" WHERE face_uuid='%q'"
826 #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) VALUES ('%q', '%q', %d, %d, %d, %d, %d, %Q);"
827 #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'"
828 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1"
829 #define SELECT_FACE_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
830 #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'"
831 #define SELECT_FACE_PATH_FROM_MEDIA "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'"
833 #define DEFAULT_MEDIA_STORAGE_ID "media"
835 #define SELECT_VALID_STORAGE_FROM_PVR "WHERE storage_uuid IN (SELECT storage_uuid FROM "DB_TABLE_STORAGE" WHERE validity=1)"
836 #define SELECT_PVR_COUNT "SELECT COUNT(*) FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
837 #define SELECT_PVR_LIST "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
838 #define SELECT_PVR_COUNT_BY_STORAGE_ID SELECT_PVR_COUNT" AND storage_uuid='%s'"
839 #define SELECT_PVR_LIST_BY_STORAGE_ID SELECT_PVR_LIST" AND storage_uuid='%s'"
840 #define SELECT_PVR_FROM_PVR "SELECT * FROM "DB_TABLE_PVR" WHERE media_uuid='%q'"
841 #define UPDATE_PVR_META_FROM_PVR "UPDATE "DB_TABLE_PVR" SET program_title=%Q, content_lock=%d, content_watch=%d, play_count=%d, highlight=%d WHERE media_uuid='%q'"
842 #define UPDATE_PVR_LOCAL_RECORD_PVR "UPDATE "DB_TABLE_PVR" SET is_local_record=%d WHERE path='%q' AND storage_uuid='%q'"
844 #define SELECT_PVR_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
845 #define SELECT_PVR_GROUP_LIST_BY_STORAGE_ID "SELECT DISTINCT %s FROM "DB_TABLE_PVR" WHERE storage_uuid='%s'"
846 #define SELECT_PVR_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_PVR_GROUP_LIST
847 #define SELECT_PVR_GROUP_COUNT_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_GROUP_LIST_BY_STORAGE_ID
848 #define SELECT_PVR_FROM_GROUP "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR" AND %s='%q'"
849 #define SELECT_PVR_FROM_GROUP_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_PVR" WHERE storage_uuid='%s' AND %s='%q'"
850 #define SELECT_PVR_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP
851 #define SELECT_PVR_COUNT_FROM_GROUP_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_BY_STORAGE_ID
852 #define SELECT_PVR_FROM_GROUP_NULL "SELECT * FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR" AND %s IS NULL"
853 #define SELECT_PVR_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_PVR" WHERE storage_uuid='%s' AND %s IS NULL"
854 #define SELECT_PVR_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_NULL
855 #define SELECT_PVR_COUNT_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_PVR_FROM_GROUP_NULL_BY_STORAGE_ID
856 #define SELECT_PVR_GROUP_AND_COUNT_BY_STORAGE_ID "SELECT %s, COUNT(*) FROM "DB_TABLE_PVR" WHERE storage_uuid='%s'"
857 #define SELECT_PVR_GROUP_AND_COUNT "SELECT %s, COUNT(*) FROM "DB_TABLE_PVR" "SELECT_VALID_STORAGE_FROM_PVR
859 #define SELECT_VALID_STORAGE_FROM_UHD "WHERE storage_uuid IN (SELECT storage_uuid FROM "DB_TABLE_STORAGE" WHERE validity=1)"
860 #define SELECT_UHD_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD
861 #define SELECT_UHD_GROUP_LIST_BY_STORAGE_ID "SELECT DISTINCT %s FROM "DB_TABLE_UHD" WHERE storage_uuid='%s'"
862 #define SELECT_UHD_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_UHD_GROUP_LIST
863 #define SELECT_UHD_GROUP_COUNT_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_UHD_GROUP_LIST_BY_STORAGE_ID
864 #define SELECT_UHD_FROM_GROUP "SELECT * FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD" AND %s='%q'"
865 #define SELECT_UHD_FROM_GROUP_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_UHD" WHERE storage_uuid='%s' AND %s='%q'"
866 #define SELECT_UHD_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_UHD_FROM_GROUP
867 #define SELECT_UHD_COUNT_FROM_GROUP_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_UHD_FROM_GROUP_BY_STORAGE_ID
868 #define SELECT_UHD_FROM_GROUP_NULL "SELECT * FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD" AND %s IS NULL"
869 #define SELECT_UHD_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT * FROM "DB_TABLE_UHD" WHERE storage_uuid='%s' AND %s IS NULL"
870 #define SELECT_UHD_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_UHD_FROM_GROUP_NULL
871 #define SELECT_UHD_COUNT_FROM_GROUP_NULL_BY_STORAGE_ID "SELECT COUNT(*) FROM ("SELECT_UHD_FROM_GROUP_NULL_BY_STORAGE_ID
872 #define SELECT_UHD_GROUP_AND_COUNT_BY_STORAGE_ID "SELECT %s, COUNT(*) FROM "DB_TABLE_UHD" WHERE storage_uuid='%s'"
873 #define SELECT_UHD_GROUP_AND_COUNT "SELECT %s, COUNT(*) FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD
875 #define SELECT_UHD_COUNT "SELECT COUNT(*) FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD
876 #define SELECT_UHD_COUNT_BY_STORAGE_ID SELECT_UHD_COUNT" AND storage_uuid='%s'"
877 #define SELECT_UHD_LIST "SELECT * FROM "DB_TABLE_UHD" "SELECT_VALID_STORAGE_FROM_UHD
878 #define SELECT_UHD_LIST_BY_STORAGE_ID SELECT_UHD_LIST" AND storage_uuid='%s'"
879 #define SELECT_UHD_FROM_UHD "SELECT * FROM "DB_TABLE_UHD" WHERE media_uuid='%q'"
880 #define UPDATE_UHD_META_FROM_UHD "UPDATE "DB_TABLE_UHD" SET content_title=%Q, release_date=%Q, played_position=%d, sub_type=%d, played_count=%d WHERE media_uuid='%q'"
882 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
883 int _content_error_capi(int type, int cotent_error);
884 int _content_query_sql(char *query_str);
885 MediaSvcHandle* _content_get_db_handle(void);
886 attribute_h _content_get_attirbute_handle(void);
887 attribute_h _content_get_alias_attirbute_handle(void);
888 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
889 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
890 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
891 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
892 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
893 int _media_db_get_media_group_and_count(media_group_e group, filter_h filter, media_group_and_count_cb callback, void *user_data);
894 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
895 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
896 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
897 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
898 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
899 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
900 int _media_db_get_face(const char *media_id, filter_h filter, media_face_cb callback, void *user_data);
901 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
902 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
903 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);
904 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);
905 #ifdef _USE_SENIOR_MODE
906 int _content_query_prepare_by_union_select(sqlite3_stmt **stmt, char *select_query1, char *condition_query1, char *option_query1, char *select_query2, char *condition_query2, char *option_query2);
907 int _media_db_get_group_item_by_union_select(const char *group_name, filter_h filter1, filter_h filter2, media_info_cb callback, void *user_data);
909 int _media_db_get_media_group_item_count(const char *group_name, filter_h filter, media_group_e group, int *item_count);
910 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);
911 int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
912 int _media_db_get_storage_id_by_media_id(const char *media_id, char *storage_id);
913 int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
914 int _media_db_get_storage_id_by_media_id(const char *media_id, char *storage_id);
915 int _media_db_get_pvr(filter_h filter, media_pvr_cb callback, void *user_data);
916 void _media_pvr_item_get_detail(sqlite3_stmt* stmt, media_pvr_h pvr);
917 int _media_db_get_pvr_group_item(const char *group_name, filter_h filter, media_group_e group, media_pvr_cb callback, void *user_data);
918 int _media_db_get_uhd(filter_h filter, media_uhd_cb callback, void *user_data);
919 void _media_uhd_item_get_detail(sqlite3_stmt* stmt, media_uhd_h uhd);
923 * @brief Creates a media filter attribute handle.
924 * @details This function creates a media filter attribute handle. The handle can be
925 * used to convert to attributes of database from attributes of user.
926 * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
927 * @param[out] filter A handle to media filter attribute
928 * @return 0 on success, otherwise a negative error value.
929 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
930 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
931 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
932 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
933 * @see media_filter_attribute_destory()
936 int _media_filter_attribute_create(attribute_h *attr);
940 * @brief Add the attributes to the handle.
941 * @details This function add the attribute to handle.
942 * @param[in] filter The handle to media filter attribute
943 * @param[in] user_attr The user attribute
944 * @param[in] platform_attr The platform attribute
945 * @return 0 on success, otherwise a negative error value.
946 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
947 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
948 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
949 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
950 * @see media_filter_attribute_remove()
953 int _media_filter_attribute_add(attribute_h atrr, const char *user_attr, const char *platform_attr);
957 * @brief Destroys a media filter attribute handle.
958 * @details The function frees all resources related to the media filter attribute handle. The filter attribute
959 * handle no longer can be used to perform any operation. A new handle
960 * has to be created before the next usage.
962 * @param[in] filter The handle to media filter attribute
963 * @return 0 on success, otherwise a negative error value.
964 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
965 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
966 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
967 * @see media_filter_create()
970 int _media_filter_attribute_destory(attribute_h attr);
974 * @brief Replace to platform attributes from user attributes.
975 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
976 * @param[in] filter The handle to media filter attribute
977 * @param[in] user_attr The user attribute
978 * @param[in] platform_attr The platform attribute
979 * @return 0 on success, otherwise a negative error value.
980 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
981 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
982 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
983 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
984 * @see media_filter_attribute_create()
985 * @see media_filter_attribute_destory()
988 int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
993 * @brief Replace to platform attributes from user attributes.
994 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
995 * @param[in] filter The handle to media filter attribute
996 * @param[in] attr The attribute
997 * @param[in] generated_option The handle to generated option
998 * @return 0 on success, otherwise a negative error value.
999 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
1000 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
1001 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED Filed DB
1002 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
1003 * @see media_filter_attribute_create()
1004 * @see media_filter_attribute_destory()
1008 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
1010 GMutex* _content_get_db_mutex(void);
1013 #define FONT_COLOR_RESET "\033[0m"
1014 #define FONT_COLOR_RED "\033[31m"
1015 #define FONT_COLOR_GREEN "\033[32m"
1016 #define FONT_COLOR_YELLOW "\033[33m"
1017 #define FONT_COLOR_BLUE "\033[34m"
1018 #define FONT_COLOR_PURPLE "\033[35m"
1019 #define FONT_COLOR_CYAN "\033[36m"
1020 #define FONT_COLOR_GRAY "\033[37m"
1022 #define media_content_gettid() syscall(__NR_gettid)
1024 #define media_content_retv_if(expr, val) do { \
1026 LOGE(FONT_COLOR_RED"[%d]"FONT_COLOR_RESET, media_content_gettid()); \
1031 #define media_content_retvm_if(expr, val, fmt, arg...) do { \
1033 LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1038 #define media_content_warn(fmt, arg...) do { \
1039 LOGW(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1042 #define media_content_debug(fmt, arg...) do { \
1043 LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
1046 #define media_content_info(fmt, arg...) do { \
1047 LOGI(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1050 #define media_content_error(fmt, arg...) do { \
1051 LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1054 #define media_content_debug_func() do { \
1055 LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid()); \
1058 #define media_content_sec_debug(fmt, arg...) do { \
1059 SECURE_LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1062 #define media_content_sec_warn(fmt, arg...) do { \
1063 SECURE_LOGW(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1066 #define media_content_sec_error(fmt, arg...) do { \
1067 SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET, media_content_gettid(), ##arg); \
1070 #define ERR_BUF_LENGTH 256
1071 #define media_content_stderror(fmt) do { \
1072 char media_content_stderror_buf[ERR_BUF_LENGTH] = {0, }; \
1073 strerror_r(errno, media_content_stderror_buf, ERR_BUF_LENGTH); \
1074 LOGE(FONT_COLOR_RED fmt" : STANDARD ERROR [%s]"FONT_COLOR_RESET, media_content_stderror_buf); \
1079 #endif /* __cplusplus */
1080 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/