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>
33 #include <tzplatform_config.h>
37 #endif /* __cplusplus */
43 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
45 #define SAFE_STRLCPY(dst, src, n) ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
46 #define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
47 #define SAFE_FREE(src) {if(src) {free(src); src = NULL;}}
48 #define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
49 #define SQLITE3_FINALIZE(x) {if(x != NULL) {sqlite3_finalize(x);}}
51 #define MEDIA_CONTENT_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
52 #define MEDIA_CONTENT_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
53 #define MEDIA_CONTENT_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png")
54 #define MEDIA_CONTENT_INSERT_FILES_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/")
56 #define MAX_QUERY_SIZE 4096
57 #define MIN_QUERY_SIZE 256
58 #define DEFAULT_QUERY_SIZE 1024
59 #define MAX_KEYWORD_SIZE 2048
60 #define COLLATE_STR_SIZE 32
61 #define MEDIA_CONTENT_UUID_SIZE 36
62 #define BATCH_REQUEST_MAX 300
66 MEDIA_CONTENT_TYPE = 0,
69 } media_info_error_type_e;
82 MEDIA_TAG_UPDATE_TAG_NAME,
87 MEDIA_PLAYLIST_REMOVE,
88 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
89 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
90 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
91 } playlist_function_e;
100 MEDIA_GROUP_TAG_BY_MEDIA_ID,
101 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
105 MEDIA_BATCH_INSERT_NORMAL,
106 MEDIA_BATCH_INSERT_BURSTSHOT,
107 } media_batch_insert_e;
109 typedef struct _filter_s
113 media_content_order_e order_type;
114 media_content_collation_e condition_collate_type;
115 media_content_collation_e order_collate_type;
122 char *folder_id; //image id, audio id, video id
125 time_t modified_time;
126 media_content_storage_e storage_type;
140 char *thumbnail_path;
148 char *album_art_path;
153 int playlist_id; //playlist id
154 char *name; // playlist name
155 char *thumbnail_path; //playlist thumbnail path
166 media_content_orientation_e orientation;
213 char *media_id; //image id, audio id, video id
216 media_content_type_e media_type;
218 unsigned long long size;
220 time_t modified_time;
221 char *thumbnail_path;
238 image_meta_s *image_meta;
239 video_meta_s *video_meta;
240 audio_meta_s *audio_meta;
265 char *media_id; // media_uuid
266 int function; // Add, remove, modify
267 char *tag_name; // tag_name
272 char *media_id; // media_uuid
273 int function; // Add, remove, modify
274 char *playlist_name; // playlist_name
275 char *thumbnail_path; //playlist thumbnail path
276 int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
277 int play_order; //play_order
278 }media_playlist_item_s;
280 typedef struct _attribute_map_s
282 GHashTable *attr_map;
287 media_info_s *handle;
289 media_thumbnail_completed_cb thumbnail_completed_cb;
290 }media_thumbnail_cb_s;
294 media_insert_completed_cb insert_completed_cb;
295 char *insert_list_path;
301 media_content_db_update_cb update_noti_cb;
305 typedef struct attribute_s *attribute_h;
308 typedef struct _media_content_cb_data {
309 media_scan_completed_cb callback;
311 } media_content_scan_cb_data;
315 #define DB_TABLE_MEDIA "media"
316 #define DB_TABLE_FOLDER "folder"
317 #define DB_TABLE_ALBUM "album"
318 #define DB_TABLE_TAG "tag"
319 #define DB_TABLE_TAG_MAP "tag_map"
320 #define DB_TABLE_PLAYLIST "playlist"
321 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
322 #define DB_TABLE_BOOKMARK "bookmark"
325 #define DB_VIEW_PLAYLIST "playlist_view"
326 #define DB_VIEW_TAG "tag_view"
329 #define DB_TABLE_ALIAS_MEDIA "m"
330 #define DB_TABLE_ALIAS_FOLDER "f"
331 #define DB_TABLE_ALIAS_PLAYLIST "p"
332 #define DB_TABLE_ALIAS_PLAYLIST_MAP "pm"
333 #define DB_TABLE_ALIAS_TAG "t"
334 #define DB_TABLE_ALIAS_BOOKMARK "b"
335 #define DB_TABLE_ALIAS_ALBUM "a"
337 /* DB field for media */
338 #define DB_FIELD_MEDIA_ID "media_uuid"
339 #define DB_FIELD_MEDIA_PATH "path"
340 #define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
341 #define DB_FIELD_MEDIA_TYPE "media_type"
342 #define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
343 #define DB_FIELD_MEDIA_SIZE "size"
344 #define DB_FIELD_MEDIA_ADDED_TIME "added_time"
345 #define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
346 #define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
347 #define DB_FIELD_MEDIA_TITLE "title"
348 #define DB_FIELD_MEDIA_ALBUM "album"
349 #define DB_FIELD_MEDIA_ARTIST "artist"
350 #define DB_FIELD_MEDIA_GENRE "genre"
351 #define DB_FIELD_MEDIA_COMPOSER "composer"
352 #define DB_FIELD_MEDIA_YEAR "year"
353 #define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
354 #define DB_FIELD_MEDIA_COPYRIGHT "copyright"
355 #define DB_FIELD_MEDIA_TRACK_NUM "track_num"
356 #define DB_FIELD_MEDIA_DESCRIPTION "description"
357 #define DB_FIELD_MEDIA_BITRATE "bitrate"
358 #define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
359 #define DB_FIELD_MEDIA_CHANNEL "channel"
360 #define DB_FIELD_MEDIA_DURATION "duration"
361 #define DB_FIELD_MEDIA_LONGITUDE "longitude"
362 #define DB_FIELD_MEDIA_LATITUDE "latitude"
363 #define DB_FIELD_MEDIA_ALTITUDE "altitude"
364 #define DB_FIELD_MEDIA_WIDTH "width"
365 #define DB_FIELD_MEDIA_HEIGHT "height"
366 #define DB_FIELD_MEDIA_DATETAKEN "datetaken"
367 #define DB_FIELD_MEDIA_ORIENTATION "orientation"
368 #define DB_FIELD_MEDIA_BURST_ID "burst_id"
369 #define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
370 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
371 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
372 #define DB_FIELD_MEDIA_RATING "rating"
373 #define DB_FIELD_MEDIA_FAVOURITE "favourite"
374 #define DB_FIELD_MEDIA_AUTHOR "author"
375 #define DB_FIELD_MEDIA_PROVIDER "provider"
376 #define DB_FIELD_MEDIA_CONTENT_NAME "content_name"
377 #define DB_FIELD_MEDIA_CATEGORY "category"
378 #define DB_FIELD_MEDIA_LOCATION_TAG "location_tag"
379 #define DB_FIELD_MEDIA_AGE_RATING "age_rating"
380 #define DB_FIELD_MEDIA_KEYWORD "keyword"
381 #define DB_FIELD_MEDIA_IS_DRM "is_drm"
382 #define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
384 /* DB field for folder */
385 #define DB_FIELD_FOLDER_ID "folder_uuid"
386 #define DB_FIELD_FOLDER_PATH "path"
387 #define DB_FIELD_FOLDER_NAME "name"
388 #define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time"
389 #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
391 /* DB field for playlist */
392 #define DB_FIELD_PLAYLIST_ID "playlist_id"
393 #define DB_FIELD_PLAYLIST_NAME "name"
394 #define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
395 #define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count"
397 /* DB field for tag */
398 #define DB_FIELD_TAG_ID "tag_id"
399 #define DB_FIELD_TAG_NAME "name"
400 #define DB_FIELD_TAG_MEDIA_COUNT "media_count"
402 /* DB field for bookmark */
403 #define DB_FIELD_BOOKMARK_ID "bookmark_id"
404 #define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time"
406 /* DB field for album*/
407 #define DB_FIELD_ALBUM_ID "album_id"
408 #define DB_FIELD_ALBUM_NAME "name"
409 #define DB_FIELD_ALBUM_ARTIST "artist"
411 /* DB Query Keyword */
412 #define QUERY_KEYWORD_AND "AND"
413 #define QUERY_KEYWORD_OR "OR"
414 #define QUERY_KEYWORD_ORDER_BY "ORDER BY"
415 #define QUERY_KEYWORD_LIMIT "limit"
416 #define QUERY_KEYWORD_DESC "DESC"
417 #define QUERY_KEYWORD_SPACE " "
418 #define QUERY_KEYWORD_BRACKET ")"
419 #define UPDATE_SQL "UPDATE %s SET %s WHERE %s"
422 #define SELECT_EMPTY_PLAYLIST "SELECT playlist_id, name FROM "DB_TABLE_PLAYLIST" WHERE playlist_id NOT IN (select playlist_id from "DB_TABLE_PLAYLIST_MAP")"
423 #define SELECT_EMPTY_TAG "SELECT tag_id, name FROM "DB_TABLE_TAG" WHERE tag_id NOT IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP")"
424 #define FOLDER_MEDIA_JOIN "("DB_TABLE_FOLDER" AS f INNER JOIN "DB_TABLE_MEDIA" AS m ON f.folder_uuid=m.folder_uuid) WHERE m.validity=1"
425 #define PLAYLISTMAP_MEDIA_JOIN "("DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
426 ON (pm.media_uuid = m.media_uuid)) WHERE m.validity=1"
427 #define SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN "SELECT DISTINCT p.playlist_id, p.name FROM "DB_TABLE_PLAYLIST" AS p INNER JOIN "DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
428 ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid) WHERE m.validity=1"
429 #define SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN "SELECT DISTINCT t.tag_id, t.name FROM "DB_TABLE_TAG" AS t INNER JOIN "DB_TABLE_MEDIA" AS m INNER JOIN "DB_TABLE_TAG_MAP" AS tm \
430 ON (tm.media_uuid = m.media_uuid and tm.tag_id=t.tag_id) WHERE m.validity=1"
431 #define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN "DB_TABLE_MEDIA" AS m \
432 ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
433 #define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN "DB_TABLE_MEDIA" AS m \
434 ON (a.album_id = m.album_id)) WHERE m.validity=1"
437 #define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
438 #define SELECT_ARTIST_LIST "SELECT DISTINCT artist FROM "DB_TABLE_MEDIA" WHERE validity=1"
439 #define SELECT_GENRE_LIST "SELECT DISTINCT genre FROM "DB_TABLE_MEDIA" WHERE validity=1"
440 #define SELECT_COMPOSER_LIST "SELECT DISTINCT composer FROM "DB_TABLE_MEDIA" WHERE validity=1 "
441 #define SELECT_YEAR_LIST "SELECT DISTINCT year FROM "DB_TABLE_MEDIA" WHERE validity=1 "
442 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 "
444 #define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time FROM "FOLDER_MEDIA_JOIN
445 //#define SELECT_TAG_LIST SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN
446 //#define SELECT_PLAYLIST_LIST SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN
447 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
448 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
449 #define SELECT_BOOKMARK_LIST "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN
451 /* Get Group Count */
452 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
453 #define SELECT_ARTIST_COUNT "SELECT COUNT(DISTINCT artist) FROM "DB_TABLE_MEDIA" WHERE validity=1"
454 #define SELECT_GENRE_COUNT "SELECT COUNT(DISTINCT genre) FROM "DB_TABLE_MEDIA" WHERE validity=1"
455 #define SELECT_COMPOSER_COUNT "SELECT COUNT(DISTINCT composer) FROM "DB_TABLE_MEDIA" WHERE validity=1"
456 #define SELECT_YEAR_COUNT "SELECT COUNT(DISTINCT year) FROM "DB_TABLE_MEDIA" WHERE validity=1"
457 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
458 //#define SELECT_TAG_COUNT "SELECT COUNT(*) FROM ("SELECT_TAG_LIST
459 //#define SELECT_PLAYLIST_COUNT "SELECT COUNT(*) FROM ("SELECT_PLAYLIST_LIST
460 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
461 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
462 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
463 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
464 /*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)*/
466 /* Get Media Count of Group */
467 #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"
468 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
469 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
470 #define SELECT_MEDIA_COUNT_FROM_ARTIST "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
471 #define SELECT_MEDIA_COUNT_FROM_GENRE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
472 #define SELECT_MEDIA_COUNT_FROM_COMPOSER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND composer='%q'"
473 #define SELECT_MEDIA_COUNT_FROM_YEAR "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
474 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP //to apply limit condition.
475 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL //to apply limit condition.
476 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
477 //#define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid IN (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1"
478 //#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND media_uuid IN (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1"
479 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
480 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
482 /* Get Group Info by Group ID*/
483 #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
484 #define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
485 #define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
486 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
487 #define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
488 #define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
491 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
492 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'"
493 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d"
494 //#define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%q')"
495 //#define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%s')"
496 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%q'"
497 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
500 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
501 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
502 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d"
503 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
504 //#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d"
505 #define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d "
507 //#define SELECT_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT play_order FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d and _id=%d"
508 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
509 //#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT MAX(play_order) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d"
510 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
511 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d"
512 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d"
515 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
516 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
517 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
518 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s'"
521 #define MEDIA_AV_META "media_uuid, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position"
522 #define MEDIA_IMAGE_META "media_uuid, width, height, datetaken, orientation"
523 #define SELECT_IMAGE_FROM_MEDIA "SELECT "MEDIA_IMAGE_META" FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
524 #define SELECT_AUDIO_FROM_MEDIA "SELECT "MEDIA_AV_META", samplerate, channel FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
525 #define SELECT_VIDEO_FROM_MEDIA "SELECT "MEDIA_AV_META", width, height FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
528 #define UPDATE_AV_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
529 #define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET orientation=%d WHERE media_uuid='%q'"
531 /* Get Media list of Group */
532 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
533 // rating, favourite, author, provider, content_name, category, location_tag, age_rating, is_drm, storage_type"
534 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
535 rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel, burst_id"
537 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
538 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'"
539 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND path='%q'"
540 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d"
541 #define SELECT_MEDIA_FROM_ARTIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
542 #define SELECT_MEDIA_FROM_GENRE "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
543 #define SELECT_MEDIA_FROM_COMPOSER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND author='%q'"
544 #define SELECT_MEDIA_FROM_YEAR "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
545 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'"
546 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL"
547 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
548 #define SELECT_MEDIA_FROM_TAG "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
549 #define SELECT_MEDIA_FROM_PLAYLIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
550 #define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
553 #define DELETE_MEDIA_FROM_MEDIA "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
554 #define DELETE_MEDIA_FROM_MEDIA_BATCH "DELETE FROM "DB_TABLE_MEDIA" WHERE %s"
555 #define DELETE_FOLDER_FROM_FOLDER "DELETE FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%q'"
556 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
557 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
558 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
564 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
569 int _content_error_capi(int type, int cotent_error);
574 int _content_query_sql(char *query_str);
579 MediaSvcHandle* _content_get_db_handle(void);
584 attribute_h _content_get_attirbute_handle(void);
589 attribute_h _content_get_alias_attirbute_handle(void);
594 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
599 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
604 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
609 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
614 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
619 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
624 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
629 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
634 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
639 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
644 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
649 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
654 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);
659 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);
664 int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count);
669 int _media_db_get_media_group_item(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data);
672 * @brief Creates a media filter attribute handle.
673 * @details This function creates a media filter attribute handle. The handle can be
674 * used to convert to attributes of database from attributes of user.
675 * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
676 * @param[out] filter A handle to media filter attribute
677 * @return 0 on success, otherwise a negative error value.
678 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
679 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
680 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
681 * @see media_filter_attribute_destory()
684 int _media_filter_attribute_create(attribute_h *attr);
687 * @brief Add the attributes to the handle.
688 * @details This function add the attribute to handle.
689 * @param[in] filter The handle to media filter attribute
690 * @param[in] user_attr The user attribute
691 * @param[in] platform_attr The platform attribute
692 * @return 0 on success, otherwise a negative error value.
693 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
694 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
695 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
696 * @see media_filter_attribute_remove()
699 int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr);
702 * @brief Destroys a media filter attribute handle.
703 * @details The function frees all resources related to the media filter attribute handle. The filter attribute
704 * handle no longer can be used to perform any operation. A new handle
705 * has to be created before the next usage.
707 * @param[in] filter The handle to media filter attribute
708 * @return 0 on success, otherwise a negative error value.
709 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
710 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
711 * @see media_filter_create()
714 int _media_filter_attribute_destory(attribute_h attr);
717 * @brief Replace to platform attributes from user attributes.
718 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
719 * @param[in] filter The handle to media filter attribute
720 * @param[in] user_attr The user attribute
721 * @param[in] platform_attr The platform attribute
722 * @return 0 on success, otherwise a negative error value.
723 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
724 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
725 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
726 * @see media_filter_attribute_create()
727 * @see media_filter_attribute_destory()
730 int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
731 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
733 #define FONT_COLOR_RESET "\033[0m"
734 #define FONT_COLOR_RED "\033[31m"
735 #define FONT_COLOR_GREEN "\033[32m"
736 #define FONT_COLOR_YELLOW "\033[33m"
737 #define FONT_COLOR_BLUE "\033[34m"
738 #define FONT_COLOR_PURPLE "\033[35m"
739 #define FONT_COLOR_CYAN "\033[36m"
740 #define FONT_COLOR_GRAY "\033[37m"
742 #define media_content_gettid() syscall(__NR_gettid)
744 #define media_content_retv_if(expr, val) do { \
746 LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
751 #define media_content_debug(fmt, arg...) do { \
752 LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
755 #define media_content_info(fmt, arg...) do { \
756 LOGD(FONT_COLOR_GREEN"[%d]"fmt"", media_content_gettid() ,##arg); \
759 #define media_content_error(fmt, arg...) do { \
760 LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg); \
763 #define media_content_debug_func() do { \
764 LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid()); \
771 #endif /* __cplusplus */
772 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/