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>
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 MEDIA_DATA_PATH"/.thumb/thumb_default.png"
54 #define MEDIA_CONTENT_INSERT_FILES_PATH MEDIA_DATA_PATH"/"
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
65 MEDIA_CONTENT_TYPE = 0,
68 } media_info_error_type_e;
81 MEDIA_TAG_UPDATE_TAG_NAME,
86 MEDIA_PLAYLIST_REMOVE,
87 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
88 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
89 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
90 } playlist_function_e;
99 MEDIA_GROUP_TAG_BY_MEDIA_ID,
100 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
104 MEDIA_BATCH_INSERT_NORMAL,
105 MEDIA_BATCH_INSERT_BURSTSHOT,
106 } media_batch_insert_e;
108 typedef struct _filter_s
112 media_content_order_e order_type;
113 media_content_collation_e condition_collate_type;
114 media_content_collation_e order_collate_type;
121 char *folder_id; //image id, audio id, video id
124 time_t modified_time;
125 media_content_storage_e storage_type;
139 char *thumbnail_path;
147 char *album_art_path;
152 int playlist_id; //playlist id
153 char *name; // playlist name
154 char *thumbnail_path; //playlist thumbnail path
164 media_content_orientation_e orientation;
211 char *media_id; //image id, audio id, video id
214 media_content_type_e media_type;
216 unsigned long long size;
218 time_t modified_time;
219 char *thumbnail_path;
235 image_meta_s *image_meta;
236 video_meta_s *video_meta;
237 audio_meta_s *audio_meta;
262 char *media_id; // media_uuid
263 int function; // Add, remove, modify
264 char *tag_name; // tag_name
269 char *media_id; // media_uuid
270 int function; // Add, remove, modify
271 char *playlist_name; // playlist_name
272 char *thumbnail_path; //playlist thumbnail path
273 int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
274 int play_order; //play_order
275 }media_playlist_item_s;
277 typedef struct _attribute_map_s
279 GHashTable *attr_map;
284 media_info_s *handle;
286 media_thumbnail_completed_cb thumbnail_completed_cb;
287 }media_thumbnail_cb_s;
291 media_insert_completed_cb insert_completed_cb;
292 char *insert_list_path;
298 media_content_db_update_cb update_noti_cb;
302 typedef struct attribute_s *attribute_h;
305 typedef struct _media_content_cb_data {
306 media_scan_completed_cb callback;
308 } media_content_scan_cb_data;
312 #define DB_TABLE_MEDIA "media"
313 #define DB_TABLE_FOLDER "folder"
314 #define DB_TABLE_ALBUM "album"
315 #define DB_TABLE_TAG "tag"
316 #define DB_TABLE_TAG_MAP "tag_map"
317 #define DB_TABLE_PLAYLIST "playlist"
318 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
319 #define DB_TABLE_BOOKMARK "bookmark"
322 #define DB_VIEW_PLAYLIST "playlist_view"
323 #define DB_VIEW_TAG "tag_view"
326 #define DB_TABLE_ALIAS_MEDIA "m"
327 #define DB_TABLE_ALIAS_FOLDER "f"
328 #define DB_TABLE_ALIAS_PLAYLIST "p"
329 #define DB_TABLE_ALIAS_PLAYLIST_MAP "pm"
330 #define DB_TABLE_ALIAS_TAG "t"
331 #define DB_TABLE_ALIAS_BOOKMARK "b"
332 #define DB_TABLE_ALIAS_ALBUM "a"
334 /* DB field for media */
335 #define DB_FIELD_MEDIA_ID "media_uuid"
336 #define DB_FIELD_MEDIA_PATH "path"
337 #define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
338 #define DB_FIELD_MEDIA_TYPE "media_type"
339 #define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
340 #define DB_FIELD_MEDIA_SIZE "size"
341 #define DB_FIELD_MEDIA_ADDED_TIME "added_time"
342 #define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
343 #define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
344 #define DB_FIELD_MEDIA_TITLE "title"
345 #define DB_FIELD_MEDIA_ALBUM "album"
346 #define DB_FIELD_MEDIA_ARTIST "artist"
347 #define DB_FIELD_MEDIA_GENRE "genre"
348 #define DB_FIELD_MEDIA_COMPOSER "composer"
349 #define DB_FIELD_MEDIA_YEAR "year"
350 #define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
351 #define DB_FIELD_MEDIA_COPYRIGHT "copyright"
352 #define DB_FIELD_MEDIA_TRACK_NUM "track_num"
353 #define DB_FIELD_MEDIA_DESCRIPTION "description"
354 #define DB_FIELD_MEDIA_BITRATE "bitrate"
355 #define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
356 #define DB_FIELD_MEDIA_CHANNEL "channel"
357 #define DB_FIELD_MEDIA_DURATION "duration"
358 #define DB_FIELD_MEDIA_LONGITUDE "longitude"
359 #define DB_FIELD_MEDIA_LATITUDE "latitude"
360 #define DB_FIELD_MEDIA_ALTITUDE "altitude"
361 #define DB_FIELD_MEDIA_WIDTH "width"
362 #define DB_FIELD_MEDIA_HEIGHT "height"
363 #define DB_FIELD_MEDIA_DATETAKEN "datetaken"
364 #define DB_FIELD_MEDIA_ORIENTATION "orientation"
365 #define DB_FIELD_MEDIA_BURST_ID "burst_id"
366 #define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
367 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
368 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
369 #define DB_FIELD_MEDIA_RATING "rating"
370 #define DB_FIELD_MEDIA_FAVOURITE "favourite"
371 #define DB_FIELD_MEDIA_AUTHOR "author"
372 #define DB_FIELD_MEDIA_PROVIDER "provider"
373 #define DB_FIELD_MEDIA_CONTENT_NAME "content_name"
374 #define DB_FIELD_MEDIA_CATEGORY "category"
375 #define DB_FIELD_MEDIA_LOCATION_TAG "location_tag"
376 #define DB_FIELD_MEDIA_AGE_RATING "age_rating"
377 #define DB_FIELD_MEDIA_KEYWORD "keyword"
378 #define DB_FIELD_MEDIA_IS_DRM "is_drm"
379 #define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
381 /* DB field for folder */
382 #define DB_FIELD_FOLDER_ID "folder_uuid"
383 #define DB_FIELD_FOLDER_PATH "path"
384 #define DB_FIELD_FOLDER_NAME "name"
385 #define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time"
386 #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
388 /* DB field for playlist */
389 #define DB_FIELD_PLAYLIST_ID "playlist_id"
390 #define DB_FIELD_PLAYLIST_NAME "name"
391 #define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
392 #define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count"
394 /* DB field for tag */
395 #define DB_FIELD_TAG_ID "tag_id"
396 #define DB_FIELD_TAG_NAME "name"
397 #define DB_FIELD_TAG_MEDIA_COUNT "media_count"
399 /* DB field for bookmark */
400 #define DB_FIELD_BOOKMARK_ID "bookmark_id"
401 #define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time"
403 /* DB field for album*/
404 #define DB_FIELD_ALBUM_ID "album_id"
405 #define DB_FIELD_ALBUM_NAME "name"
406 #define DB_FIELD_ALBUM_ARTIST "artist"
408 /* DB Query Keyword */
409 #define QUERY_KEYWORD_AND "AND"
410 #define QUERY_KEYWORD_OR "OR"
411 #define QUERY_KEYWORD_ORDER_BY "ORDER BY"
412 #define QUERY_KEYWORD_LIMIT "limit"
413 #define QUERY_KEYWORD_DESC "DESC"
414 #define QUERY_KEYWORD_SPACE " "
415 #define QUERY_KEYWORD_BRACKET ")"
416 #define UPDATE_SQL "UPDATE %s SET %s WHERE %s"
419 #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")"
420 #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")"
421 #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"
422 #define PLAYLISTMAP_MEDIA_JOIN "("DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
423 ON (pm.media_uuid = m.media_uuid)) WHERE m.validity=1"
424 #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 \
425 ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid) WHERE m.validity=1"
426 #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 \
427 ON (tm.media_uuid = m.media_uuid and tm.tag_id=t.tag_id) WHERE m.validity=1"
428 #define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN "DB_TABLE_MEDIA" AS m \
429 ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
430 #define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN "DB_TABLE_MEDIA" AS m \
431 ON (a.album_id = m.album_id)) WHERE m.validity=1"
434 #define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
435 #define SELECT_ARTIST_LIST "SELECT DISTINCT artist FROM "DB_TABLE_MEDIA" WHERE validity=1"
436 #define SELECT_GENRE_LIST "SELECT DISTINCT genre FROM "DB_TABLE_MEDIA" WHERE validity=1"
437 #define SELECT_COMPOSER_LIST "SELECT DISTINCT composer FROM "DB_TABLE_MEDIA" WHERE validity=1 "
438 #define SELECT_YEAR_LIST "SELECT DISTINCT year FROM "DB_TABLE_MEDIA" WHERE validity=1 "
439 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 "
441 #define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time FROM "FOLDER_MEDIA_JOIN
442 //#define SELECT_TAG_LIST SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN
443 //#define SELECT_PLAYLIST_LIST SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN
444 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
445 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
446 #define SELECT_BOOKMARK_LIST "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN
448 /* Get Group Count */
449 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
450 #define SELECT_ARTIST_COUNT "SELECT COUNT(DISTINCT artist) FROM "DB_TABLE_MEDIA" WHERE validity=1"
451 #define SELECT_GENRE_COUNT "SELECT COUNT(DISTINCT genre) FROM "DB_TABLE_MEDIA" WHERE validity=1"
452 #define SELECT_COMPOSER_COUNT "SELECT COUNT(DISTINCT composer) FROM "DB_TABLE_MEDIA" WHERE validity=1"
453 #define SELECT_YEAR_COUNT "SELECT COUNT(DISTINCT year) FROM "DB_TABLE_MEDIA" WHERE validity=1"
454 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
455 //#define SELECT_TAG_COUNT "SELECT COUNT(*) FROM ("SELECT_TAG_LIST
456 //#define SELECT_PLAYLIST_COUNT "SELECT COUNT(*) FROM ("SELECT_PLAYLIST_LIST
457 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
458 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
459 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
460 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
461 /*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)*/
463 /* Get Media Count of Group */
464 #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"
465 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
466 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
467 #define SELECT_MEDIA_COUNT_FROM_ARTIST "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
468 #define SELECT_MEDIA_COUNT_FROM_GENRE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
469 #define SELECT_MEDIA_COUNT_FROM_COMPOSER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND composer='%q'"
470 #define SELECT_MEDIA_COUNT_FROM_YEAR "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
471 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP //to apply limit condition.
472 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL //to apply limit condition.
473 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
474 //#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"
475 //#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"
476 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
477 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
479 /* Get Group Info by Group ID*/
480 #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
481 #define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
482 #define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
483 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
484 #define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
485 #define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
488 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
489 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'"
490 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d"
491 //#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')"
492 //#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')"
493 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%q'"
494 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
497 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
498 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
499 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d"
500 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
501 //#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d"
502 #define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d "
504 //#define SELECT_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT play_order FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d and _id=%d"
505 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
506 //#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT MAX(play_order) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d"
507 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
508 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d"
509 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d"
512 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
513 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
514 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
515 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s'"
518 #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"
519 #define MEDIA_IMAGE_META "media_uuid, width, height, datetaken, orientation"
520 #define SELECT_IMAGE_FROM_MEDIA "SELECT "MEDIA_IMAGE_META" FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
521 #define SELECT_AUDIO_FROM_MEDIA "SELECT "MEDIA_AV_META", samplerate, channel FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
522 #define SELECT_VIDEO_FROM_MEDIA "SELECT "MEDIA_AV_META", width, height FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
525 #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'"
526 #define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET orientation=%d WHERE media_uuid='%q'"
528 /* Get Media list of Group */
529 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
530 // rating, favourite, author, provider, content_name, category, location_tag, age_rating, is_drm, storage_type"
531 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
532 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"
534 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
535 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'"
536 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND path='%q'"
537 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d"
538 #define SELECT_MEDIA_FROM_ARTIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
539 #define SELECT_MEDIA_FROM_GENRE "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
540 #define SELECT_MEDIA_FROM_COMPOSER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND author='%q'"
541 #define SELECT_MEDIA_FROM_YEAR "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
542 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'"
543 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL"
544 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
545 #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"
546 #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"
547 #define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
550 #define DELETE_MEDIA_FROM_MEDIA "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
551 #define DELETE_MEDIA_FROM_MEDIA_BATCH "DELETE FROM "DB_TABLE_MEDIA" WHERE %s"
552 #define DELETE_FOLDER_FROM_FOLDER "DELETE FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%q'"
553 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
554 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
555 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
561 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
566 int _content_error_capi(int type, int cotent_error);
571 int _content_query_sql(char *query_str);
576 MediaSvcHandle* _content_get_db_handle(void);
581 attribute_h _content_get_attirbute_handle(void);
586 attribute_h _content_get_alias_attirbute_handle(void);
591 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
596 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
601 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
606 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
611 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
616 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
621 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
626 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
631 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
636 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
641 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
646 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
651 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);
656 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);
661 int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count);
666 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);
669 * @brief Creates a media filter attribute handle.
670 * @details This function creates a media filter attribute handle. The handle can be
671 * used to convert to attributes of database from attributes of user.
672 * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
673 * @param[out] filter A handle to media filter attribute
674 * @return 0 on success, otherwise a negative error value.
675 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
676 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
677 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
678 * @see media_filter_attribute_destory()
681 int _media_filter_attribute_create(attribute_h *attr);
684 * @brief Add the attributes to the handle.
685 * @details This function add the attribute to handle.
686 * @param[in] filter The handle to media filter attribute
687 * @param[in] user_attr The user attribute
688 * @param[in] platform_attr The platform attribute
689 * @return 0 on success, otherwise a negative error value.
690 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
691 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
692 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
693 * @see media_filter_attribute_remove()
696 int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr);
699 * @brief Destroys a media filter attribute handle.
700 * @details The function frees all resources related to the media filter attribute handle. The filter attribute
701 * handle no longer can be used to perform any operation. A new handle
702 * has to be created before the next usage.
704 * @param[in] filter The handle to media filter attribute
705 * @return 0 on success, otherwise a negative error value.
706 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
707 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
708 * @see media_filter_create()
711 int _media_filter_attribute_destory(attribute_h attr);
714 * @brief Replace to platform attributes from user attributes.
715 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
716 * @param[in] filter The handle to media filter attribute
717 * @param[in] user_attr The user attribute
718 * @param[in] platform_attr The platform attribute
719 * @return 0 on success, otherwise a negative error value.
720 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
721 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
722 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
723 * @see media_filter_attribute_create()
724 * @see media_filter_attribute_destory()
727 int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
728 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
730 #define FONT_COLOR_RESET "\033[0m"
731 #define FONT_COLOR_RED "\033[31m"
732 #define FONT_COLOR_GREEN "\033[32m"
733 #define FONT_COLOR_YELLOW "\033[33m"
734 #define FONT_COLOR_BLUE "\033[34m"
735 #define FONT_COLOR_PURPLE "\033[35m"
736 #define FONT_COLOR_CYAN "\033[36m"
737 #define FONT_COLOR_GRAY "\033[37m"
739 #define media_content_gettid() syscall(__NR_gettid)
741 #define media_content_retv_if(expr, val) do { \
743 LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
748 #define media_content_debug(fmt, arg...) do { \
749 LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
752 #define media_content_info(fmt, arg...) do { \
753 LOGD(FONT_COLOR_GREEN"[%d]"fmt"", media_content_gettid() ,##arg); \
756 #define media_content_error(fmt, arg...) do { \
757 LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg); \
760 #define media_content_debug_func() do { \
761 LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid()); \
768 #endif /* __cplusplus */
769 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/