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 */
45 * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
48 * @file media_info_private.h
49 * @brief This file contains the media info API and related structure and enumeration. \n
50 * Description of the audio, video,image content involves: album, artist, album_artist, author, genre and description tags. \n
51 * Parameters of the recording are also supported, as: format, bitrate, duration, size etc. \n
52 * Defenitions of media DB fields and tables, operations with media data relating to DB and handling with media filter attributes.
56 #define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
58 #define SAFE_STRLCPY(dst, src, n) ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
59 #define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
60 #define SAFE_FREE(src) {if(src) {free(src); src = NULL;}}
61 #define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
62 #define SQLITE3_FINALIZE(x) {if(x != NULL) {sqlite3_finalize(x);}}
64 #define MEDIA_CONTENT_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
65 #define MEDIA_CONTENT_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
66 #define MEDIA_CONTENT_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_SYS_DATA, "file-manager-service/.thumb/thumb_default.png")
67 #define MEDIA_CONTENT_INSERT_FILES_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/")
69 #define MAX_QUERY_SIZE 4096
70 #define DEFAULT_QUERY_SIZE 1024
71 #define COLLATE_STR_SIZE 32
72 #define MEDIA_CONTENT_UUID_SIZE 36
73 #define BATCH_REQUEST_MAX 300
76 MEDIA_CONTENT_TYPE = 0,
79 } media_info_error_type_e;
84 MEDIA_TAG_UPDATE_TAG_NAME,
89 MEDIA_PLAYLIST_REMOVE,
90 MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
91 MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH,
92 MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
93 } playlist_function_e;
101 MEDIA_GROUP_BOOKMARK,
102 MEDIA_GROUP_TAG_BY_MEDIA_ID,
103 MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
107 MEDIA_BATCH_INSERT_NORMAL,
108 MEDIA_BATCH_INSERT_BURSTSHOT,
109 } media_batch_insert_e;
111 typedef struct _filter_s
115 media_content_order_e order_type;
116 media_content_collation_e condition_collate_type;
117 media_content_collation_e order_collate_type;
124 char *folder_id; //image id, audio id, video id
127 time_t modified_time;
128 media_content_storage_e storage_type;
142 char *thumbnail_path;
150 char *album_art_path;
155 int playlist_id; //playlist id
156 char *name; // playlist name
157 char *thumbnail_path; //playlist thumbnail path
168 media_content_orientation_e orientation;
215 char *media_id; //image id, audio id, video id
218 media_content_type_e media_type;
220 unsigned long long size;
222 time_t modified_time;
223 char *thumbnail_path;
240 image_meta_s *image_meta;
241 video_meta_s *video_meta;
242 audio_meta_s *audio_meta;
247 char *media_id; // media_uuid
248 int function; // Add, remove, modify
249 char *tag_name; // tag_name
254 char *media_id; // media_uuid
255 int function; // Add, remove, modify
256 char *playlist_name; // playlist_name
257 char *thumbnail_path; //playlist thumbnail path
258 int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
259 int play_order; //play_order
260 }media_playlist_item_s;
262 typedef struct _attribute_map_s
264 GHashTable *attr_map;
269 media_info_s *handle;
271 media_thumbnail_completed_cb thumbnail_completed_cb;
272 }media_thumbnail_cb_s;
276 media_insert_completed_cb insert_completed_cb;
277 char *insert_list_path;
283 media_content_db_update_cb update_noti_cb;
287 typedef struct attribute_s *attribute_h;
290 typedef struct _media_content_cb_data {
291 media_scan_completed_cb callback;
293 } media_content_scan_cb_data;
297 #define DB_TABLE_MEDIA "media"
298 #define DB_TABLE_FOLDER "folder"
299 #define DB_TABLE_ALBUM "album"
300 #define DB_TABLE_TAG "tag"
301 #define DB_TABLE_TAG_MAP "tag_map"
302 #define DB_TABLE_PLAYLIST "playlist"
303 #define DB_TABLE_PLAYLIST_MAP "playlist_map"
304 #define DB_TABLE_BOOKMARK "bookmark"
307 #define DB_VIEW_PLAYLIST "playlist_view"
308 #define DB_VIEW_TAG "tag_view"
311 #define DB_TABLE_ALIAS_MEDIA "m"
312 #define DB_TABLE_ALIAS_FOLDER "f"
313 #define DB_TABLE_ALIAS_PLAYLIST "p"
314 #define DB_TABLE_ALIAS_PLAYLIST_MAP "pm"
315 #define DB_TABLE_ALIAS_TAG "t"
316 #define DB_TABLE_ALIAS_BOOKMARK "b"
317 #define DB_TABLE_ALIAS_ALBUM "a"
319 /* DB field for media */
320 #define DB_FIELD_MEDIA_ID "media_uuid"
321 #define DB_FIELD_MEDIA_PATH "path"
322 #define DB_FIELD_MEDIA_DISPLAY_NAME "file_name"
323 #define DB_FIELD_MEDIA_TYPE "media_type"
324 #define DB_FIELD_MEDIA_MIME_TYPE "mime_type"
325 #define DB_FIELD_MEDIA_SIZE "size"
326 #define DB_FIELD_MEDIA_ADDED_TIME "added_time"
327 #define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time"
328 #define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path"
329 #define DB_FIELD_MEDIA_TITLE "title"
330 #define DB_FIELD_MEDIA_ALBUM "album"
331 #define DB_FIELD_MEDIA_ARTIST "artist"
332 #define DB_FIELD_MEDIA_GENRE "genre"
333 #define DB_FIELD_MEDIA_COMPOSER "composer"
334 #define DB_FIELD_MEDIA_YEAR "year"
335 #define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date"
336 #define DB_FIELD_MEDIA_COPYRIGHT "copyright"
337 #define DB_FIELD_MEDIA_TRACK_NUM "track_num"
338 #define DB_FIELD_MEDIA_DESCRIPTION "description"
339 #define DB_FIELD_MEDIA_BITRATE "bitrate"
340 #define DB_FIELD_MEDIA_SAMPLERATE "samplerate"
341 #define DB_FIELD_MEDIA_CHANNEL "channel"
342 #define DB_FIELD_MEDIA_DURATION "duration"
343 #define DB_FIELD_MEDIA_LONGITUDE "longitude"
344 #define DB_FIELD_MEDIA_LATITUDE "latitude"
345 #define DB_FIELD_MEDIA_ALTITUDE "altitude"
346 #define DB_FIELD_MEDIA_WIDTH "width"
347 #define DB_FIELD_MEDIA_HEIGHT "height"
348 #define DB_FIELD_MEDIA_DATETAKEN "datetaken"
349 #define DB_FIELD_MEDIA_ORIENTATION "orientation"
350 #define DB_FIELD_MEDIA_BURST_ID "burst_id"
351 #define DB_FIELD_MEDIA_PLAYED_COUNT "played_count"
352 #define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time"
353 #define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position"
354 #define DB_FIELD_MEDIA_RATING "rating"
355 #define DB_FIELD_MEDIA_FAVOURITE "favourite"
356 #define DB_FIELD_MEDIA_AUTHOR "author"
357 #define DB_FIELD_MEDIA_PROVIDER "provider"
358 #define DB_FIELD_MEDIA_CONTENT_NAME "content_name"
359 #define DB_FIELD_MEDIA_CATEGORY "category"
360 #define DB_FIELD_MEDIA_LOCATION_TAG "location_tag"
361 #define DB_FIELD_MEDIA_AGE_RATING "age_rating"
362 #define DB_FIELD_MEDIA_KEYWORD "keyword"
363 #define DB_FIELD_MEDIA_IS_DRM "is_drm"
364 #define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type"
366 /* DB field for folder */
367 #define DB_FIELD_FOLDER_ID "folder_uuid"
368 #define DB_FIELD_FOLDER_PATH "path"
369 #define DB_FIELD_FOLDER_NAME "name"
370 #define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time"
371 #define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type"
373 /* DB field for playlist */
374 #define DB_FIELD_PLAYLIST_ID "playlist_id"
375 #define DB_FIELD_PLAYLIST_NAME "name"
376 #define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
377 #define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count"
379 /* DB field for tag */
380 #define DB_FIELD_TAG_ID "tag_id"
381 #define DB_FIELD_TAG_NAME "name"
382 #define DB_FIELD_TAG_MEDIA_COUNT "media_count"
384 /* DB field for bookmark */
385 #define DB_FIELD_BOOKMARK_ID "bookmark_id"
386 #define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time"
388 /* DB field for album*/
389 #define DB_FIELD_ALBUM_ID "album_id"
390 #define DB_FIELD_ALBUM_NAME "name"
391 #define DB_FIELD_ALBUM_ARTIST "artist"
393 /* DB Query Keyword */
394 #define QUERY_KEYWORD_AND "AND"
395 #define QUERY_KEYWORD_OR "OR"
396 #define QUERY_KEYWORD_ORDER_BY "ORDER BY"
397 #define QUERY_KEYWORD_LIMIT "limit"
398 #define QUERY_KEYWORD_DESC "DESC"
399 #define QUERY_KEYWORD_SPACE " "
400 #define QUERY_KEYWORD_BRACKET ")"
401 #define UPDATE_SQL "UPDATE %s SET %s WHERE %s"
404 #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")"
405 #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")"
406 #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"
407 #define PLAYLISTMAP_MEDIA_JOIN "("DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
408 ON (pm.media_uuid = m.media_uuid)) WHERE m.validity=1"
409 #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 \
410 ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid) WHERE m.validity=1"
411 #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 \
412 ON (tm.media_uuid = m.media_uuid and tm.tag_id=t.tag_id) WHERE m.validity=1"
413 #define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN "DB_TABLE_MEDIA" AS m \
414 ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
415 #define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN "DB_TABLE_MEDIA" AS m \
416 ON (a.album_id = m.album_id)) WHERE m.validity=1"
419 #define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
420 #define SELECT_ARTIST_LIST "SELECT DISTINCT artist FROM "DB_TABLE_MEDIA" WHERE validity=1"
421 #define SELECT_GENRE_LIST "SELECT DISTINCT genre FROM "DB_TABLE_MEDIA" WHERE validity=1"
422 #define SELECT_COMPOSER_LIST "SELECT DISTINCT composer FROM "DB_TABLE_MEDIA" WHERE validity=1 "
423 #define SELECT_YEAR_LIST "SELECT DISTINCT year FROM "DB_TABLE_MEDIA" WHERE validity=1 "
424 #define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 "
426 #define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time FROM "FOLDER_MEDIA_JOIN
427 //#define SELECT_TAG_LIST SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN
428 //#define SELECT_PLAYLIST_LIST SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN
429 #define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
430 #define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name, thumbnail_path FROM "DB_VIEW_PLAYLIST" WHERE 1 "
431 #define SELECT_BOOKMARK_LIST "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN
433 /* Get Group Count */
434 #define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
435 #define SELECT_ARTIST_COUNT "SELECT COUNT(DISTINCT artist) FROM "DB_TABLE_MEDIA" WHERE validity=1"
436 #define SELECT_GENRE_COUNT "SELECT COUNT(DISTINCT genre) FROM "DB_TABLE_MEDIA" WHERE validity=1"
437 #define SELECT_COMPOSER_COUNT "SELECT COUNT(DISTINCT composer) FROM "DB_TABLE_MEDIA" WHERE validity=1"
438 #define SELECT_YEAR_COUNT "SELECT COUNT(DISTINCT year) FROM "DB_TABLE_MEDIA" WHERE validity=1"
439 #define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
440 //#define SELECT_TAG_COUNT "SELECT COUNT(*) FROM ("SELECT_TAG_LIST
441 //#define SELECT_PLAYLIST_COUNT "SELECT COUNT(*) FROM ("SELECT_PLAYLIST_LIST
442 #define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
443 #define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
444 #define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
445 #define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
446 /*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)*/
448 /* Get Media Count of Group */
449 #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"
450 #define SELECT_MEDIA_COUNT_FROM_MEDIA_SIMPLE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 "
451 #define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
452 #define SELECT_MEDIA_COUNT_FROM_ARTIST "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
453 #define SELECT_MEDIA_COUNT_FROM_GENRE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
454 #define SELECT_MEDIA_COUNT_FROM_COMPOSER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND composer='%q'"
455 #define SELECT_MEDIA_COUNT_FROM_YEAR "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
456 #define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP //to apply limit condition.
457 #define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL //to apply limit condition.
458 #define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
459 //#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"
460 //#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"
461 #define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
462 #define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
464 /* Get Group Info by Group ID*/
465 #define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
466 #define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
467 #define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
468 #define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
469 #define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
470 #define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
473 #define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
474 #define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'"
475 #define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d"
476 //#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')"
477 //#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')"
478 #define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%q'"
479 #define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
482 #define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
483 #define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
484 #define UPDATE_PLAYLIST_THUMBNAIL_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET thumbnail_path='%q' WHERE playlist_id=%d"
485 #define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
486 //#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d"
487 #define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d "
489 //#define SELECT_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT play_order FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d and _id=%d"
490 #define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
491 //#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT MAX(play_order) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d"
492 #define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
493 #define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d"
494 #define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d"
497 #define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
498 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
499 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
500 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s'"
503 #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"
504 #define MEDIA_IMAGE_META "media_uuid, width, height, datetaken, orientation"
505 #define SELECT_IMAGE_FROM_MEDIA "SELECT "MEDIA_IMAGE_META" FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
506 #define SELECT_AUDIO_FROM_MEDIA "SELECT "MEDIA_AV_META", samplerate, channel FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
507 #define SELECT_VIDEO_FROM_MEDIA "SELECT "MEDIA_AV_META", width, height FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
510 #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'"
511 #define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET orientation=%d WHERE media_uuid='%q'"
513 /* Get Media list of Group */
514 //#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
515 // rating, favourite, author, provider, content_name, category, location_tag, age_rating, is_drm, storage_type"
516 #define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
517 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"
519 #define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
520 #define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'"
521 #define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND path='%q'"
522 #define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d"
523 #define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'"
524 #define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL"
525 #define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
526 #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"
527 #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"
528 #define SELECT_MEDIA_PATH_BY_ID "SELECT path FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
531 #define DELETE_MEDIA_FROM_MEDIA "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
532 #define DELETE_MEDIA_FROM_MEDIA_BATCH "DELETE FROM "DB_TABLE_MEDIA" WHERE %s"
533 #define DELETE_FOLDER_FROM_FOLDER "DELETE FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%q'"
534 #define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
535 #define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
536 #define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
542 int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
547 int _content_error_capi(int type, int cotent_error);
552 int _content_query_sql(char *query_str);
557 MediaSvcHandle* _content_get_db_handle(void);
562 attribute_h _content_get_attirbute_handle(void);
567 attribute_h _content_get_alias_attirbute_handle(void);
572 void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
577 int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
582 int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
587 int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
592 int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
597 int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
602 int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
607 int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
612 int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
617 int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
622 int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
627 int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
632 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);
637 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);
642 int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count);
647 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);
651 * @brief Creates a media filter attribute handle.
652 * @details This function creates a media filter attribute handle. The handle can be
653 * used to convert to attributes of database from attributes of user.
654 * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
655 * @param[out] filter A handle to media filter attribute
656 * @return 0 on success, otherwise a negative error value.
657 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
658 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
659 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
660 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
661 * @see media_filter_attribute_destory()
664 int _media_filter_attribute_create(attribute_h *attr);
668 * @brief Add the attributes to the handle.
669 * @details This function add the attribute to handle.
670 * @param[in] filter The handle to media filter attribute
671 * @param[in] user_attr The user attribute
672 * @param[in] platform_attr The platform attribute
673 * @return 0 on success, otherwise a negative error value.
674 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
675 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
676 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
677 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
678 * @see media_filter_attribute_remove()
681 int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr);
685 * @brief Destroys a media filter attribute handle.
686 * @details The function frees all resources related to the media filter attribute handle. The filter attribute
687 * handle no longer can be used to perform any operation. A new handle
688 * has to be created before the next usage.
690 * @param[in] filter The handle to media filter attribute
691 * @return 0 on success, otherwise a negative error value.
692 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
693 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
694 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
695 * @see media_filter_create()
698 int _media_filter_attribute_destory(attribute_h attr);
702 * @brief Replace to platform attributes from user attributes.
703 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
704 * @param[in] filter The handle to media filter attribute
705 * @param[in] user_attr The user attribute
706 * @param[in] platform_attr The platform attribute
707 * @return 0 on success, otherwise a negative error value.
708 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
709 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
710 * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
711 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
712 * @see media_filter_attribute_create()
713 * @see media_filter_attribute_destory()
716 int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
721 * @brief Replace to platform attributes from user attributes.
722 * @details This function replace to platform attributes from user attributes to generate the WHERE clause
723 * @param[in] filter The handle to media filter attribute
724 * @param[in] attr The attribute
725 * @param[in] generated_option The handle to generated option
726 * @return 0 on success, otherwise a negative error value.
727 * @retval #MEDIA_CONTENT_ERROR_NONE Successful
728 * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
729 * @retval #MEDIA_CONTENT_ERROR_DB_FAILED Filed DB
730 * @retval #MEDIA_CONTENT_ERROR_PERMISSION_DENIED Permission denied
731 * @see media_filter_attribute_create()
732 * @see media_filter_attribute_destory()
736 int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
738 #define FONT_COLOR_RESET "\033[0m"
739 #define FONT_COLOR_RED "\033[31m"
740 #define FONT_COLOR_GREEN "\033[32m"
741 #define FONT_COLOR_YELLOW "\033[33m"
742 #define FONT_COLOR_BLUE "\033[34m"
743 #define FONT_COLOR_PURPLE "\033[35m"
744 #define FONT_COLOR_CYAN "\033[36m"
745 #define FONT_COLOR_GRAY "\033[37m"
747 #define media_content_gettid() syscall(__NR_gettid)
749 #define media_content_retv_if(expr, val) do { \
751 LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
756 #define media_content_debug(fmt, arg...) do { \
757 LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg); \
760 #define media_content_info(fmt, arg...) do { \
761 LOGD(FONT_COLOR_GREEN"[%d]"fmt"", media_content_gettid() ,##arg); \
764 #define media_content_error(fmt, arg...) do { \
765 LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg); \
768 #define media_content_debug_func() do { \
769 LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid()); \
776 #endif /* __cplusplus */
777 #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/