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>
38 #endif /* __cplusplus */
46 * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
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.
57 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
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 STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
63 #define SQLITE3_FINALIZE(x) {if(x != NULL) {sqlite3_finalize(x);}}
65 #define MEDIA_CONTENT_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
66 #define MEDIA_CONTENT_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
67 #define MEDIA_CONTENT_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_SYS_DATA, "file-manager-service/.thumb/thumb_default.png")
68 #define MEDIA_CONTENT_INSERT_FILES_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/")
70 #define MAX_QUERY_SIZE 4096
71 #define DEFAULT_QUERY_SIZE 1024
72 #define COLLATE_STR_SIZE 32
73 #define MEDIA_CONTENT_UUID_SIZE 36
74 #define BATCH_REQUEST_MAX 300
83 MEDIA_INFO_ADDED_TIME,
84 MEDIA_INFO_MODIFIED_TIME,
85 MEDIA_INFO_THUMBNAIL_PATH,
86 MEDIA_INFO_DESCRIPTION,
87 MEDIA_INFO_RATING, //10
91 MEDIA_INFO_CONTENT_NAME,
93 MEDIA_INFO_LOCATION_TAG,
94 MEDIA_INFO_AGE_RATING,
97 MEDIA_INFO_STORAGE_TYPE, //20
101 MEDIA_INFO_EXPOSURE_TIME,
107 MEDIA_INFO_DATETAKEN, //30
108 MEDIA_INFO_ORIENTATION,
112 MEDIA_INFO_ALBUM_ARTIST,
116 MEDIA_INFO_RECORDED_DATE,
117 MEDIA_INFO_COPYRIGHT, //40
118 MEDIA_INFO_TRACK_NUM,
120 MEDIA_INFO_BITPERSAMPLE,
122 MEDIA_INFO_PLAYED_COUNT,
123 MEDIA_INFO_LAST_PLAYED_TIME,
124 MEDIA_INFO_LAST_PLAYED_POSITION,
125 MEDIA_INFO_SAMPLERATE,
127 MEDIA_INFO_BURST_ID, //50
130 MEDIA_INFO_SYNC_STATUS,
131 MEDIA_INFO_STORAGE_UUID,
136 MEDIA_CONTENT_TYPE = 0,
137 MEDIA_THUMBNAIL_TYPE,
139 } media_info_error_type_e;
144 MEDIA_TAG_UPDATE_TAG_NAME,
149 MEDIA_PLAYLIST_REMOVE,
150 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
151 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
152 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
153 } playlist_function_e;
159 MEDIA_GROUP_PLAYLIST,
161 MEDIA_GROUP_BOOKMARK,
162 MEDIA_GROUP_TAG_BY_MEDIA_ID,
163 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
168 MEDIA_BATCH_INSERT_NORMAL,
169 MEDIA_BATCH_INSERT_BURSTSHOT,
170 } media_batch_insert_e;
172 typedef struct _filter_s
177 media_content_order_e order_type;
178 media_content_collation_e condition_collate_type;
179 media_content_collation_e order_collate_type;
186 char *folder_id; //image id, audio id, video id
189 time_t modified_time;
206 char *thumbnail_path;
214 char *album_art_path;
219 int playlist_id; //playlist id
220 char *name; // playlist name
221 char *thumbnail_path; //playlist thumbnail path
237 media_content_orientation_e orientation;
290 media_content_type_e media_type;
292 unsigned long long size;
294 time_t modified_time;
296 char *thumbnail_path;
319 image_meta_s *image_meta;
320 video_meta_s *video_meta;
321 audio_meta_s *audio_meta;
326 char *media_id; // media_uuid
327 int function; // Add, remove, modify
328 char *tag_name; // tag_name
333 char *media_id; // media_uuid
334 int function; // Add, remove, modify
335 char *playlist_name; // playlist_name
336 char *thumbnail_path; //playlist thumbnail path
337 int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
338 int play_order; //play_order
339 }media_playlist_item_s;
346 char *storage_account;
350 typedef struct _attribute_map_s
352 GHashTable *attr_map;
357 media_info_s *handle;
359 media_thumbnail_completed_cb thumbnail_completed_cb;
360 }media_thumbnail_cb_s;
364 media_insert_completed_cb insert_completed_cb;
365 char *insert_list_path;
371 media_content_db_update_cb update_noti_cb;
375 typedef struct attribute_s *attribute_h;
378 typedef struct _media_content_cb_data {
379 media_scan_completed_cb callback;
381 } media_content_scan_cb_data;
385 #define DB_TABLE_MEDIA "media"
386 #define DB_TABLE_FOLDER "folder"
387 #define DB_TABLE_ALBUM "album"
388 #define DB_TABLE_TAG "tag"
389 #define DB_TABLE_TAG_MAP "tag_map"
390 #define DB_TABLE_PLAYLIST "playlist"
391 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
392 #define DB_TABLE_BOOKMARK "bookmark"
393 #define DB_TABLE_STORAGE "storage"
394 #define DB_TABLE_MEDIA_VIEW "media"
397 #define DB_VIEW_PLAYLIST "playlist_view"
398 #define DB_VIEW_TAG "tag_view"
401 #define DB_TABLE_ALIAS_MEDIA "m"
402 #define DB_TABLE_ALIAS_FOLDER "f"
403 #define DB_TABLE_ALIAS_PLAYLIST "p"
404 #define DB_TABLE_ALIAS_PLAYLIST_MAP "pm"
405 #define DB_TABLE_ALIAS_TAG "t"
406 #define DB_TABLE_ALIAS_BOOKMARK "b"
407 #define DB_TABLE_ALIAS_ALBUM "a"
409 /* DB field for media */
410 #define DB_FIELD_MEDIA_ID "media_uuid"
411 #define DB_FIELD_MEDIA_PATH "path"
412 #define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
413 #define DB_FIELD_MEDIA_TYPE "media_type"
414 #define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
415 #define DB_FIELD_MEDIA_SIZE "size"
416 #define DB_FIELD_MEDIA_ADDED_TIME "added_time"
417 #define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
418 #define DB_FIELD_MEDIA_TIMELINE "timeline"
419 #define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
420 #define DB_FIELD_MEDIA_TITLE "title"
421 #define DB_FIELD_MEDIA_ALBUM "album"
422 #define DB_FIELD_MEDIA_ARTIST "artist"
423 #define DB_FIELD_MEDIA_ALBUM_ARTIST "album_artist"
424 #define DB_FIELD_MEDIA_GENRE "genre"
425 #define DB_FIELD_MEDIA_COMPOSER "composer"
426 #define DB_FIELD_MEDIA_YEAR "year"
427 #define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
428 #define DB_FIELD_MEDIA_COPYRIGHT "copyright"
429 #define DB_FIELD_MEDIA_TRACK_NUM "track_num"
430 #define DB_FIELD_MEDIA_DESCRIPTION "description"
431 #define DB_FIELD_MEDIA_BITRATE "bitrate"
432 #define DB_FIELD_MEDIA_BITPERSAMPLE "bitpersample"
433 #define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
434 #define DB_FIELD_MEDIA_CHANNEL "channel"
435 #define DB_FIELD_MEDIA_DURATION "duration"
436 #define DB_FIELD_MEDIA_LONGITUDE "longitude"
437 #define DB_FIELD_MEDIA_LATITUDE "latitude"
438 #define DB_FIELD_MEDIA_ALTITUDE "altitude"
439 #define DB_FIELD_MEDIA_WIDTH "width"
440 #define DB_FIELD_MEDIA_HEIGHT "height"
441 #define DB_FIELD_MEDIA_DATETAKEN "datetaken"
442 #define DB_FIELD_MEDIA_ORIENTATION "orientation"
443 #define DB_FIELD_MEDIA_BURST_ID "burst_id"
444 #define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
445 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
446 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
447 #define DB_FIELD_MEDIA_RATING "rating"
448 #define DB_FIELD_MEDIA_FAVOURITE "favourite"
449 #define DB_FIELD_MEDIA_AUTHOR "author"
450 #define DB_FIELD_MEDIA_PROVIDER "provider"
451 #define DB_FIELD_MEDIA_CONTENT_NAME "content_name"
452 #define DB_FIELD_MEDIA_CATEGORY "category"
453 #define DB_FIELD_MEDIA_LOCATION_TAG "location_tag"
454 #define DB_FIELD_MEDIA_AGE_RATING "age_rating"
455 #define DB_FIELD_MEDIA_KEYWORD "keyword"
456 #define DB_FIELD_MEDIA_WEATHER "weather"
457 #define DB_FIELD_MEDIA_IS_DRM "is_drm"
458 #define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
459 #define DB_FIELD_MEDIA_EXPOSURE_TIME "exposure_time"
460 #define DB_FIELD_MEDIA_FNUMBER "fnumber"
461 #define DB_FIELD_MEDIA_ISO "iso"
462 #define DB_FIELD_MEDIA_MODEL "model"
463 #define DB_FIELD_MEDIA_FILE_NAME_PINYIN "file_name_pinyin"
464 #define DB_FIELD_MEDIA_TITLE_PINYIN "title_pinyin"
465 #define DB_FIELD_MEDIA_ALBUM_PINYIN "album_pinyin"
466 #define DB_FIELD_MEDIA_ARTIST_PINYIN "artist_pinyin"
467 #define DB_FIELD_MEDIA_ALBUM_ARTIST_PINYIN "album_artist_pinyin"
468 #define DB_FIELD_MEDIA_GENRE_PINYIN "genre_pinyin"
469 #define DB_FIELD_MEDIA_COMPOSER_PINYIN "composer_pinyin"
470 #define DB_FIELD_MEDIA_COPYRIGHT_PINYIN "copyright_pinyin"
471 #define DB_FIELD_MEDIA_DESCRIPTION_PINYIN "description_pinyin"
472 #define DB_FIELD_MEDIA_AUTHOR_PINYIN "author_pinyin"
473 #define DB_FIELD_MEDIA_PROVIDER_PINYIN "provider_pinyin"
474 #define DB_FIELD_MEDIA_CONTENT_NAME_PINYIN "content_name_pinyin"
475 #define DB_FIELD_MEDIA_CATEGORY_PINYIN "category_pinyin"
476 #define DB_FIELD_MEDIA_LOCATION_TAG_PINYIN "location_tag_pinyin"
477 #define DB_FIELD_MEDIA_AGE_RATING_PINYIN "age_rating_pinyin"
478 #define DB_FIELD_MEDIA_KEYWORD_PINYIN "keyword_pinyin"
480 /* DB field for folder */
481 #define DB_FIELD_FOLDER_ID "folder_uuid"
482 #define DB_FIELD_FOLDER_PATH "path"
483 #define DB_FIELD_FOLDER_NAME "name"
484 #define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time"
485 #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
486 #define DB_FIELD_FOLDER_NAME_PINYIN "name_pinyin"
487 #define DB_FIELD_FOLDER_ORDER "folder_order"
489 /* DB field for playlist */
490 #define DB_FIELD_PLAYLIST_ID "playlist_id"
491 #define DB_FIELD_PLAYLIST_NAME "name"
492 #define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
493 #define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count"
495 /* DB field for tag */
496 #define DB_FIELD_TAG_ID "tag_id"
497 #define DB_FIELD_TAG_NAME "name"
498 #define DB_FIELD_TAG_MEDIA_COUNT "media_count"
500 /* DB field for bookmark */
501 #define DB_FIELD_BOOKMARK_ID "bookmark_id"
502 #define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time"
504 /* DB field for album*/
505 #define DB_FIELD_ALBUM_ID "album_id"
506 #define DB_FIELD_ALBUM_NAME "name"
507 #define DB_FIELD_ALBUM_ARTIST "artist"
509 /* DB Query Keyword */
510 #define QUERY_KEYWORD_AND "AND"
511 #define QUERY_KEYWORD_OR "OR"
512 #define QUERY_KEYWORD_ORDER_BY "ORDER BY"
513 #define QUERY_KEYWORD_LIMIT "limit"
514 #define QUERY_KEYWORD_DESC "DESC"
515 #define QUERY_KEYWORD_SPACE " "
516 #define QUERY_KEYWORD_OPEN_BRACKET "("
517 #define QUERY_KEYWORD_BRACKET ")"
520 #define FOLDER_MEDIA_JOIN "("DB_TABLE_FOLDER" AS f INNER JOIN '%s' AS m ON f.folder_uuid=m.folder_uuid) WHERE m.validity=1 "
521 #define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN '%s' AS m \
522 ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
523 #define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN '%s' AS m \
524 ON (a.album_id = m.album_id)) WHERE m.validity=1"
527 #define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
528 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM '%s' WHERE validity=1 "
530 #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
531 #define SELECT_FOLDER_LIST_BY_STORAGE_ID SELECT_FOLDER_LIST"AND f.storage_uuid='%s' "
532 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
533 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, p_thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
535 /* Get Group Count */
536 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
537 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
538 #define SELECT_FOLDER_COUNT_BY_STORAGE_ID SELECT_FOLDER_COUNT"AND f.storage_uuid='%s' "
539 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
540 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
541 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
542 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
543 /*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)*/
545 /* Get Media Count of Group */
546 #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"
547 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM '%s' WHERE validity=1 "
548 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND album_id='%d'"
549 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP //to apply limit condition.
550 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL //to apply limit condition.
551 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND folder_uuid='%q'"
552 #define SELECT_MEDIA_COUNT_FROM_STORAGE "SELECT COUNT(*) FROM '%s' WHERE validity=1 AND storage_uuid='%q'"
553 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
554 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
556 /* Get Group Info by Group ID*/
557 #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
558 #define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
559 #define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
560 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
561 #define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
562 #define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
565 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
566 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'"
567 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d"
568 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
569 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
571 /* Get Media list of Group */
572 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
573 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"
576 #define UPDATE_FOLDER_ORDER "UPDATE "DB_TABLE_FOLDER" SET folder_order=%d WHERE folder_uuid=%Q"
579 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
580 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
581 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d"
582 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
583 #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) "
584 #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) "
585 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
586 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
587 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d"
588 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d"
591 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
592 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
593 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
596 #define UPDATE_AV_META_FROM_MEDIA "UPDATE '%s' SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
597 #define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE '%s' SET orientation=%d, weather=%Q WHERE media_uuid='%q'"
599 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1"
600 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND media_uuid='%s'"
601 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND path='%q'"
602 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND album_id=%d"
603 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s='%q'"
604 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND %s IS NULL"
605 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND folder_uuid='%s'"
606 #define SELECT_MEDIA_FROM_STORAGE "SELECT "MEDIA_INFO_ITEM" FROM '%s' WHERE validity=1 AND storage_uuid='%s'"
607 #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"
608 #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"
609 #define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
610 #define SELECT_MEDIA_STORAGE_ID_BY_ID "SELECT storage_uuid FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q'"
613 #define DELETE_MEDIA_FROM_MEDIA_BATCH "DELETE FROM '%s' WHERE %s"
614 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
615 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
616 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
619 #define SELECT_STORAGE_COUNT "SELECT COUNT(*) FROM "DB_TABLE_STORAGE" WHERE validity=1"
620 #define SELECT_STORAGE_LIST "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1"
621 #define SELECT_STORAGE_INFO_FROM_STORAGE "SELECT * FROM "DB_TABLE_STORAGE" WHERE validity=1 AND storage_uuid='%s'"
623 #define DEFAULT_MEDIA_STORAGE_ID "media"
625 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
626 int _content_error_capi(int type, int cotent_error);
627 int _content_query_sql(char *query_str);
628 MediaSvcHandle* _content_get_db_handle(void);
629 attribute_h _content_get_attirbute_handle(void);
630 attribute_h _content_get_alias_attirbute_handle(void);
631 int _media_info_get_media_info_from_db(const char *path, const char *storage_id, media_info_h media);
632 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
633 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
634 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
635 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
636 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
637 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
638 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
639 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
640 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
641 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
642 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
643 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
644 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);
645 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);
646 int _media_db_get_media_group_item_count(const char *group_name, filter_h filter, media_group_e group, int *item_count);
647 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);
648 int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
649 int _media_db_get_storage_id_by_media_id(const char *media_id, char *storage_id);
653 * @brief Creates a media filter attribute handle.
654 * @details This function creates a media filter attribute handle. The handle can be
655 * used to convert to attributes of database from attributes of user.
656 * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
657 * @param[out] filter A handle to media filter attribute
658 * @return 0 on success, otherwise a negative error value.
659 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
660 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
661 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
662 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
663 * @see media_filter_attribute_destory()
666 int _media_filter_attribute_create(attribute_h *attr);
670 * @brief Add the attributes to the handle.
671 * @details This function add the attribute to handle.
672 * @param[in] filter The handle to media filter attribute
673 * @param[in] user_attr The user attribute
674 * @param[in] platform_attr The platform attribute
675 * @return 0 on success, otherwise a negative error value.
676 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
677 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
678 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
679 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
680 * @see media_filter_attribute_remove()
683 int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr);
687 * @brief Destroys a media filter attribute handle.
688 * @details The function frees all resources related to the media filter attribute handle. The filter attribute
689 * handle no longer can be used to perform any operation. A new handle
690 * has to be created before the next usage.
692 * @param[in] filter The handle to media filter attribute
693 * @return 0 on success, otherwise a negative error value.
694 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
695 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
696 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
697 * @see media_filter_create()
700 int _media_filter_attribute_destory(attribute_h attr);
704 * @brief Replace to platform attributes from user attributes.
705 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
706 * @param[in] filter The handle to media filter attribute
707 * @param[in] user_attr The user attribute
708 * @param[in] platform_attr The platform attribute
709 * @return 0 on success, otherwise a negative error value.
710 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
711 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
712 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
713 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
714 * @see media_filter_attribute_create()
715 * @see media_filter_attribute_destory()
718 int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
723 * @brief Replace to platform attributes from user attributes.
724 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
725 * @param[in] filter The handle to media filter attribute
726 * @param[in] attr The attribute
727 * @param[in] generated_option The handle to generated option
728 * @return 0 on success, otherwise a negative error value.
729 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
730 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
731 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED Filed DB
732 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
733 * @see media_filter_attribute_create()
734 * @see media_filter_attribute_destory()
738 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
740 #define FONT_COLOR_RESET "\033[0m"
741 #define FONT_COLOR_RED "\033[31m"
742 #define FONT_COLOR_GREEN "\033[32m"
743 #define FONT_COLOR_YELLOW "\033[33m"
744 #define FONT_COLOR_BLUE "\033[34m"
745 #define FONT_COLOR_PURPLE "\033[35m"
746 #define FONT_COLOR_CYAN "\033[36m"
747 #define FONT_COLOR_GRAY "\033[37m"
749 #define media_content_gettid() syscall(__NR_gettid)
751 #define media_content_retv_if(expr, val) do { \
753 LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
758 #define media_content_debug(fmt, arg...) do { \
759 LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
762 #define media_content_info(fmt, arg...) do { \
763 LOGI(FONT_COLOR_GREEN"[%d]"fmt"", media_content_gettid() ,##arg); \
766 #define media_content_error(fmt, arg...) do { \
767 LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg); \
770 #define media_content_debug_func() do { \
771 LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid()); \
774 #define media_content_sec_debug(fmt, arg...) do { \
775 SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
778 #define media_content_sec_warn(fmt, arg...) do { \
779 SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",media_content_gettid(), ##arg); \
782 #define media_content_sec_error(fmt, arg...) do { \
783 SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg); \
786 #define ERR_BUF_LENGTH 256
787 #define media_content_stderror(fmt) do { \
788 char buf[ERR_BUF_LENGTH] = {0, }; \
789 strerror_r(errno, buf, ERR_BUF_LENGTH); \
790 LOGE(FONT_COLOR_RED fmt" : STANDARD ERROR [%s]", buf); \
795 #endif /* __cplusplus */
796 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/