SET(SRCS
src/visual/media-svc-db.c
src/visual/media-svc-db-util.c
- src/visual/media-svc-util.c
+ src/visual/visual-svc-util.c
src/visual/media-svc-api.c
src/visual/media-svc-thumb.c
uuid/unparse.c
uuid/uuid_time.c
- src/common/media-info.c
- src/common/media-info-util.c
- src/common/media-info-debug.c
+ src/common/media-svc.c
+ src/common/media-svc-util.c
+ src/common/media-svc-debug.c
)
SET(HASH_SRCS
#TARGET_LINK_LIBRARIES(audio_test ${pkgs_LDFLAGS} ${MEDIASERVICE-LIB} )
#INSTALL(TARGETS audio_test DESTINATION ${BINDIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc.h DESTINATION include/media-service)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-error.h DESTINATION include/media-service)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/minfo-api.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/minfo-types.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/visual-svc-error.h DESTINATION include/media-service)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/visual-svc.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/visual-svc-types.h DESTINATION include/media-service/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc-error.h DESTINATION include/media-service)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc.h DESTINATION include/media-service/)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/audio-svc-types.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info-error.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-info-types.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-error.h DESTINATION include/media-service/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-types.h DESTINATION include/media-service/)
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/image/thumb_default.png DESTINATION /opt/data/gallery-beat)
#!/bin/sh
export ARCH=target
-export TET_INSTALL_PATH=/usr/bin/tetware/TETware # tetware root path
+export TET_INSTALL_PATH=/mnt/nfs/tetware/TETware # tetware root path
export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
export PATH=$TET_TARGET_PATH/bin:$PATH
export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
TS1=utc_audio_svc_add_item_to_playlist_func\r
TS2=utc_audio_svc_add_playlist_func\r
TS3=utc_audio_svc_check_duplicate_insertion_in_playlist_func\r
-TS4=utc_audio_svc_close_func\r
+#TS4=utc_audio_svc_close_func\r
TS5=utc_audio_svc_get_playlist_func\r
TS7=utc_audio_svc_count_group_item_func\r
TS8=utc_audio_svc_count_list_item_func\r
TS31=utc_audio_svc_list_item_get_val_func\r
TS32=utc_audio_svc_list_item_new_func\r
TS34=utc_audio_svc_move_item_func\r
-TS35=utc_audio_svc_open_func\r
+#TS35=utc_audio_svc_open_func\r
TS36=utc_audio_svc_playlist_free_func\r
TS37=utc_audio_svc_playlist_get_item_func\r
TS38=utc_audio_svc_playlist_get_val_func\r
TS56=utc_audio_svc_check_item_exist_func\r
TS57=utc_audio_svc_get_playlist_id_by_playlist_name_func\r
\r
-LIBS = `pkg-config --libs libmedia-info`\r
-LIBS +=-L/usr/lib/:/usr/lib/pkgconfig\r
+LIBS = `pkg-config --libs libmedia-service`\r
LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o\r
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s\r
-LIBS +=-L$(TET_ROOT)/lib/tet3/ -lapi_s\r
+LIBS +=-L$(TET_ROOT)/lib/tet3/ -ltcm_s\r
+LIBS +=-lapi_s\r
LIBS +=utc_audio_svc_common.o\r
\r
-INCS = -I. `pkg-config --cflags libmedia-info`\r
+INCS = -I. `pkg-config --cflags libmedia-service`\r
INCS += -I$(TET_ROOT)/inc/tet3\r
INCS += -I/usr/include\r
\r
/utc/audio/utc_audio_svc_add_item_to_playlist_func
/utc/audio/utc_audio_svc_add_playlist_func
/utc/audio/utc_audio_svc_check_duplicate_insertion_in_playlist_func
-/utc/audio/utc_audio_svc_close_func
/utc/audio/utc_audio_svc_count_group_item_func
/utc/audio/utc_audio_svc_count_list_item_func
/utc/audio/utc_audio_svc_count_playlist_by_name_func
/utc/audio/utc_audio_svc_list_item_get_val_func
/utc/audio/utc_audio_svc_list_item_new_func
/utc/audio/utc_audio_svc_move_item_func
-/utc/audio/utc_audio_svc_open_func
/utc/audio/utc_audio_svc_playlist_free_func
/utc/audio/utc_audio_svc_playlist_get_item_func
/utc/audio/utc_audio_svc_playlist_get_val_func
dts_fail("get_item_audio_id","fail to get audio_id.");\r
}\r
\r
- ret = audio_svc_add_item_to_playlist(playlist_id, audio_id);\r
+ ret = audio_svc_add_item_to_playlist(db_handle, playlist_id, audio_id);\r
dts_check_eq("audio_svc_add_item_to_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to add item to playlist.");\r
\r
}\r
int plst_index = -1;\r
char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
\r
- ret = audio_svc_add_item_to_playlist(plst_index, audio_id);\r
+ ret = audio_svc_add_item_to_playlist(db_handle, plst_index, audio_id);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_add_item_to_playlist","abnormal condition test for invalid parameter.");\r
const char *playlist_name = "plst_test_00";\r
int playlist_id = 0;\r
\r
- ret = audio_svc_add_playlist(playlist_name, &playlist_id);\r
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);\r
dts_check_eq("audio_svc_add_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to insert playlist.");\r
\r
}\r
{ \r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_add_playlist(NULL, NULL);\r
+ ret = audio_svc_add_playlist(db_handle, NULL, NULL);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("get_item_audio_id","fail to get audio_id.");\r
}\r
\r
- ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_id, audio_id, &count);\r
+ ret = audio_svc_check_duplicate_insertion_in_playlist(db_handle, playlist_id, audio_id, &count);\r
dts_check_eq("audio_svc_check_duplicate_insertion_in_playlist", ret, AUDIO_SVC_ERROR_NONE, "unable to check duplicate insertion.");\r
\r
}\r
int playlist_id = 1;\r
char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
\r
- ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_id, audio_id, NULL);\r
+ ret = audio_svc_check_duplicate_insertion_in_playlist(db_handle, playlist_id, audio_id, NULL);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_check_duplicate_insertion_in_playlist","abnormal condition test for invalid parameter.");\r
{
int ret = AUDIO_SVC_ERROR_NONE;
- ret = audio_svc_check_item_exist(DEFAULT_FILE);
+ ret = audio_svc_check_item_exist(db_handle, DEFAULT_FILE);
if(ret == AUDIO_SVC_ERROR_INVALID_PARAMETER)
{
dts_fail("audio_svc_check_item_exist","fail to check item.");
{
int ret = AUDIO_SVC_ERROR_NONE;
- ret = audio_svc_check_item_exist(NULL);
+ ret = audio_svc_check_item_exist(db_handle, NULL);
if (ret == AUDIO_SVC_ERROR_INVALID_PARAMETER)
{
dts_pass("audio_svc_check_item_exist","abnormal condition test for invalid path parameter.");
return FALSE;\r
}\r
\r
- ret = audio_svc_get_item_by_path(DEFAULT_FILE, item);\r
+ ret = audio_svc_get_item_by_path(db_handle, DEFAULT_FILE, item);\r
if(ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_item_free(item);\r
return FALSE;\r
}\r
\r
- _strncpy_safe(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
+ strncpy(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
\r
ret = audio_svc_item_free(item);\r
if(ret != AUDIO_SVC_ERROR_NONE)\r
return FALSE;\r
}\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_count_playlist","unable to get playlist.");\r
}\r
\r
//get all the playlists in db.\r
- ret = audio_svc_get_playlist(\r
+ ret = audio_svc_get_playlist(db_handle, \r
NULL, //filter_string,\r
NULL, //filter_string2,\r
0, //offset,\r
int ret = AUDIO_SVC_ERROR_NONE;\r
audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;\r
\r
- ret = audio_svc_check_item_exist(DEFAULT_FILE);\r
+ ret = audio_svc_check_item_exist(db_handle, DEFAULT_FILE);\r
if(ret != AUDIO_SVC_ERROR_NONE)\r
{\r
- ret = audio_svc_insert_item(storage, DEFAULT_FILE, AUDIO_SVC_CATEGORY_MUSIC);\r
+ ret = audio_svc_insert_item(db_handle, storage, DEFAULT_FILE, AUDIO_SVC_CATEGORY_MUSIC);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_insert_item","fail to insert item.");\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_check_item_exist(TEST_FILE);\r
+ ret = audio_svc_check_item_exist(db_handle, TEST_FILE);\r
if(ret != AUDIO_SVC_ERROR_NONE)\r
{\r
copy_file(DEFAULT_FILE, TEST_FILE);\r
}\r
else\r
{\r
- ret = audio_svc_delete_item_by_path(TEST_FILE);\r
+ ret = audio_svc_delete_item_by_path(db_handle, TEST_FILE);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_delete_item_by_path","fail to delete item.");\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_count_playlist","unable to get playlist.");\r
if(count < 1)\r
{\r
int playlist_id = 0;\r
- ret = audio_svc_add_playlist("plst_test", &playlist_id);\r
+ ret = audio_svc_add_playlist(db_handle, "plst_test", &playlist_id);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_add_playlist","fail to add playlist");\r
return FALSE;\r
}\r
\r
- ret = audio_svc_count_playlist( "", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_count_playlist","unable to get playlist.");\r
return FALSE;\r
}\r
\r
- ret = audio_svc_check_duplicate_insertion_in_playlist(playlist_idx, audio_id, &count);\r
+ ret = audio_svc_check_duplicate_insertion_in_playlist(db_handle, playlist_idx, audio_id, &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_count_playlist","unable to get playlist.");\r
\r
if(count < 1)\r
{\r
- ret = audio_svc_add_item_to_playlist(playlist_idx, audio_id);\r
+ ret = audio_svc_add_item_to_playlist(db_handle, playlist_idx, audio_id);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_message("audio_svc_add_item_to_playlist","unable to audio_svc_add_item_to_playlist.");\r
}\r
\r
*playlist_id = playlist_idx;\r
- _strncpy_safe(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
+ strncpy(audio_id_val, audio_id, AUDIO_SVC_UUID_SIZE+1);\r
\r
return TRUE;\r
}\r
*/
/**
-* @file uts_mmf_player_common.h
+* @file uts_audio_svc_common.h
* @author
-* @brief This is the implementaion file for the test case of mmfplayer_common
+* @brief This is the implementaion file for the test case of Audio in libmedia-service
* @version Initial Creation Version 0.1
* @date 2010-09-13
*/
#define __UTS_AUDIO_SVC_COMMON_H_
#include <audio-svc.h>
-#include <audio-svc-error.h>
+#include <media-svc.h>
#include <string.h>
#include <tet_api.h>
#include <unistd.h>
-#include <glib.h>
#include <stdbool.h>
#define MAX_STRING_LEN 256
#define UTC_MM_LOG(fmt, args...) tet_printf("[%s(L%d)]:"fmt"\n", __FUNCTION__, __LINE__, ##args)
+MediaSvcHandle * db_handle;
+
#define UTC_AUDIO_SVC_OPEN() \
do \
{ \
int ret = AUDIO_SVC_ERROR_NONE; \
- ret = audio_svc_open(); \
+ ret = media_svc_connect(&db_handle); \
if (ret != AUDIO_SVC_ERROR_NONE) \
{ \
- dts_fail("audio_svc_open", "fail to open music db"); \
+ dts_fail("media_svc_connect", "fail to open music db"); \
} \
} \
while(0);
do \
{ \
int ret = AUDIO_SVC_ERROR_NONE; \
- ret = audio_svc_close(); \
+ ret = media_svc_disconnect(db_handle); \
if (ret != AUDIO_SVC_ERROR_NONE) \
{ \
- dts_fail("audio_svc_close", "fail to close music db"); \
+ dts_fail("media_svc_disconnect", "fail to close music db"); \
} \
} \
while(0);
-#define DEFAULT_FILE "/opt/media/Sounds and music/Music/Over the horizon.mp3"
-#define TEST_FILE "/opt/media/Sounds and music/test.mp3"
+#define DEFAULT_FILE "/opt/media/Music/Over the horizon.mp3"
+#define TEST_FILE "/opt/media/Music/test.mp3"
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
bool get_item_audio_id(char * audio_id_val);
bool get_playlist_id(int * playlist_id);
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);\r
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);\r
dts_check_eq("audio_svc_count_group_item", ret, AUDIO_SVC_ERROR_NONE, "failed to get groups.");\r
\r
}\r
{ \r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, NULL, "", "", "", &count);\r
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ARTIST_ALBUM, NULL, "", "", "", &count);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
dts_check_eq("audio_svc_count_list_item", ret, AUDIO_SVC_ERROR_NONE, "failed to count items.");\r
\r
}\r
void utc_audio_svc_count_list_item_func_02()\r
{ \r
int ret = AUDIO_SVC_ERROR_NONE;\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", NULL);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", NULL);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_playlist_by_name("plst 001", &count);\r
+ ret = audio_svc_count_playlist_by_name(db_handle, "plst 001", &count);\r
dts_check_eq("audio_svc_count_playlist_by_name", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlists count.");\r
\r
}\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_playlist_by_name(NULL, &count);\r
+ ret = audio_svc_count_playlist_by_name(db_handle, NULL, &count);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int count = -1;\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
dts_check_eq("audio_svc_count_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlists count.");\r
\r
}\r
void utc_audio_svc_count_playlist_func_02()\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
- ret = audio_svc_count_playlist("", "", NULL);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", NULL);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_create_table();\r
+ ret = audio_svc_create_table(db_handle);\r
dts_check_eq("audio_svc_create_table", ret, AUDIO_SVC_ERROR_NONE, "unable to create music phone table.");\r
\r
}\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);\r
+ ret = audio_svc_delete_all(db_handle, AUDIO_SVC_STORAGE_PHONE);\r
dts_check_eq("audio_svc_delete_all", ret, AUDIO_SVC_ERROR_NONE, "failed to get groups.");\r
\r
}\r
{ \r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_delete_all(100);\r
+ ret = audio_svc_delete_all(db_handle, 100);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;
audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
- ret = audio_svc_delete_invalid_items(storage);
+ ret = audio_svc_delete_invalid_items(db_handle, storage);
dts_check_eq("audio_svc_delete_invalid_items", ret, AUDIO_SVC_ERROR_NONE, "failed to delete invalid items.");
}
int ret = AUDIO_SVC_ERROR_NONE;
audio_svc_storage_type_e storage = 3;
- ret = audio_svc_delete_invalid_items(storage);
+ ret = audio_svc_delete_invalid_items(db_handle, storage);
if (ret != AUDIO_SVC_ERROR_NONE)
{
dts_pass("audio_svc_delete_invalid_items","abnormal condition test for invalid storage parameter.");
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_delete_item_by_path(DEFAULT_FILE);\r
+ ret = audio_svc_delete_item_by_path(db_handle, DEFAULT_FILE);\r
dts_check_eq("audio_svc_delete_item_by_path", ret, AUDIO_SVC_ERROR_NONE, "failed to delete item by path.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
const char * path = NULL;\r
\r
- ret = audio_svc_delete_item_by_path(path);\r
+ ret = audio_svc_delete_item_by_path(db_handle, path);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("get_playlist_id","fail to get playlist id.");\r
}\r
\r
- ret = audio_svc_delete_playlist(playlist_id);\r
+ ret = audio_svc_delete_playlist(db_handle, playlist_id);\r
dts_check_eq("audio_svc_delete_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to delete playlist.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int playlist_id = -1;\r
\r
- ret = audio_svc_delete_playlist(playlist_id);\r
+ ret = audio_svc_delete_playlist(db_handle, playlist_id);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", &count);\r
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_group_item","unable to count.");\r
dts_fail("audio_svc_list_item_new","unable to new records.");\r
}\r
\r
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, count, result_records);\r
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, count, result_records);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_list_item_free(result_records);\r
int ret = AUDIO_SVC_ERROR_NONE;\r
AudioHandleType *result_records = NULL;\r
\r
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_list_item","failed to count items.");\r
dts_fail("get_item_audio_id","fail to get audio_id.");\r
}\r
\r
- ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, item);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_item_free(item);\r
AudioHandleType *item = NULL;\r
char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
\r
- ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, item);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_item_new","failed to malloc.");\r
}\r
\r
- ret = audio_svc_get_item_by_path(DEFAULT_FILE, item);\r
+ ret = audio_svc_get_item_by_path(db_handle, DEFAULT_FILE, item);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_item_free(item);\r
dts_fail("audio_svc_item_new","failed to malloc.");\r
}\r
\r
- ret = audio_svc_get_item_by_path(NULL, item);\r
+ ret = audio_svc_get_item_by_path(db_handle, NULL, item);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_item_free(item);\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_list_item","failed to count items.");\r
dts_fail("audio_svc_list_item_new","unable to make list item.");\r
}\r
\r
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, count, result_records);\r
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, count, result_records);\r
if (ret != AUDIO_SVC_ERROR_NONE) {\r
audio_svc_list_item_free(result_records);\r
dts_fail("audio_svc_get_list_item","failed to get items.");\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
AudioHandleType *result_records = NULL;\r
- ret = audio_svc_get_list_item(AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Breakaway", "", "", "", 0, ret, result_records);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("get_item_audio_id","fail to get audio_id.");\r
}\r
//retrieve the file path by track audio_id.\r
- ret = audio_svc_get_path_by_audio_id(audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);\r
+ ret = audio_svc_get_path_by_audio_id(db_handle, audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);\r
dts_check_eq("audio_svc_get_path_by_audio_id", ret, AUDIO_SVC_ERROR_NONE, "failed to get path.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
\r
- ret = audio_svc_get_path_by_audio_id(audio_id, NULL, AUDIO_SVC_PATHNAME_SIZE);\r
+ ret = audio_svc_get_path_by_audio_id(db_handle, audio_id, NULL, AUDIO_SVC_PATHNAME_SIZE);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_get_path_by_audio_id","abnormal condition test for invalid NULL parameter.");\r
dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
}\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
dts_fail("audio_svc_playlist_new","unable to create playlist.");\r
}\r
\r
- ret = audio_svc_get_playlist("", "", 0, count, result_records);\r
+ ret = audio_svc_get_playlist(db_handle, "", "", 0, count, result_records);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_playlist_free(result_records);\r
int ret = AUDIO_SVC_ERROR_NONE;\r
AudioHandleType *result_records = NULL;\r
\r
- ret = audio_svc_get_playlist( "", "", 0, ret, result_records);\r
+ ret = audio_svc_get_playlist(db_handle, "", "", 0, ret, result_records);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("check_default_playlist_exist","fail to check default playlist.");
}
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret != AUDIO_SVC_ERROR_NONE)
{
dts_fail("audio_svc_count_playlists","unable to get playlist.");
}
//get all the playlists in db.
- ret = audio_svc_get_playlist(
+ ret = audio_svc_get_playlist(db_handle,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
dts_fail("audio_svc_playlists_get_val","unable to get name of playlist.");
}
- ret = audio_svc_get_playlist_id_by_playlist_name(p, &playlist_id);
+ ret = audio_svc_get_playlist_id_by_playlist_name(db_handle, p, &playlist_id);
if (ret != AUDIO_SVC_ERROR_NONE)
{
audio_svc_playlist_free(playlists);
int ret = AUDIO_SVC_ERROR_NONE;
int playlist_id = -1;
- ret = audio_svc_get_playlist_id_by_playlist_name(NULL, &playlist_id);
+ ret = audio_svc_get_playlist_id_by_playlist_name(db_handle, NULL, &playlist_id);
if (ret != AUDIO_SVC_ERROR_NONE)
{
dts_pass("audio_svc_get_playlist_id_by_playlist_name","abnormal condition test for invalid playlist name parameter.");
dts_fail("get_playlist_id","fail to get playlist id.");\r
}\r
\r
- ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+ ret = audio_svc_get_playlist_name_by_playlist_id(db_handle, playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
dts_check_eq("audio_svc_get_playlist_name_by_playlist_id", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlist name.");\r
\r
}\r
char playlist_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
int playlist_id = -1;\r
\r
- ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+ ret = audio_svc_get_playlist_name_by_playlist_id(db_handle, playlist_id, playlist_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_get_playlist_name_by_playlist_id","abnormal condition test for invalid NULL parameter.");\r
const char orig_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = "plst_test";\r
char unique_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
\r
- ret = audio_svc_get_unique_playlist_name(orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+ ret = audio_svc_get_unique_playlist_name(db_handle, orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
dts_check_eq("audio_svc_get_unique_playlist_name", ret, AUDIO_SVC_ERROR_NONE, "failed to get playlist name.");\r
\r
}\r
char *orig_name = NULL;\r
char unique_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};\r
\r
- ret = audio_svc_get_unique_playlist_name(orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
+ ret = audio_svc_get_unique_playlist_name(db_handle, orig_name, unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_get_unique_playlist_name","abnormal condition test for invalid NULL parameter.");\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_delete_item_by_path(DEFAULT_FILE);\r
+ ret = audio_svc_delete_item_by_path(db_handle, DEFAULT_FILE);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_delete_item_by_path","failed to delete item by path.");\r
}\r
\r
- ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, DEFAULT_FILE, category);\r
+ ret = audio_svc_insert_item(db_handle, AUDIO_SVC_STORAGE_PHONE, DEFAULT_FILE, category);\r
dts_check_eq("audio_svc_insert_item", ret, AUDIO_SVC_ERROR_NONE, "failed to insert item.");\r
\r
}\r
const char *path = NULL; // invalid value\r
int category = AUDIO_SVC_CATEGORY_MUSIC;\r
\r
- ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category);\r
+ ret = audio_svc_insert_item(db_handle, AUDIO_SVC_STORAGE_PHONE, path, category);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_list_item","unable to get count.");\r
}\r
\r
//get all tracks from db.\r
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,\r
NULL, //type_string,\r
NULL, //type_string2,\r
NULL, //filter_string,\r
dts_fail("audio_svc_list_item_get_val","unable to get count.");\r
}\r
\r
- ret = audio_svc_get_item_by_audio_id(audio_id, item);\r
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, item);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
audio_svc_list_item_free(tracks);\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_list_item","unable to get count.");\r
}\r
\r
//get the all tracks item.\r
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,\r
NULL, //type_string,\r
NULL, //type_string2,\r
NULL, //filter_string,\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_list_item","unable to get count.");\r
}\r
\r
//get the all track items.\r
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,\r
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,\r
NULL, //type_string,\r
NULL, //type_string2,\r
NULL, //filter_string,\r
dts_fail("check_default_item_exist","fail to check default item.");\r
}\r
\r
- ret = audio_svc_move_item(storage, DEFAULT_FILE, storage, TEST_FILE);\r
+ ret = audio_svc_move_item(db_handle, storage, DEFAULT_FILE, storage, TEST_FILE);\r
dts_check_eq("audio_svc_move_item", ret, AUDIO_SVC_ERROR_NONE, "failed to move item.");\r
\r
}\r
audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;\r
const char *src_path = NULL;\r
\r
- ret = audio_svc_move_item(storage, src_path, storage, TEST_FILE);\r
+ ret = audio_svc_move_item(db_handle, storage, src_path, storage, TEST_FILE);\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
}\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
dts_fail("audio_svc_playlist_new","unable to make list item."); \r
}\r
\r
- ret = audio_svc_get_playlist(\r
+ ret = audio_svc_get_playlist(db_handle, \r
NULL, //filter_string,\r
NULL, //filter_string2,\r
0, //offset,\r
dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
}\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
}\r
\r
//get all the playlists in db.\r
- ret = audio_svc_get_playlist(\r
+ ret = audio_svc_get_playlist(db_handle, \r
NULL, //filter_string,\r
NULL, //filter_string2,\r
0, //offset,\r
dts_fail("check_default_playlist_exist","fail to check default playlist.");\r
}\r
\r
- ret = audio_svc_count_playlist("", "", &count);\r
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_fail("audio_svc_count_playlist","unable to get playlist.");\r
}\r
\r
//get all the playlists.\r
- ret = audio_svc_get_playlist(\r
+ ret = audio_svc_get_playlist(db_handle, \r
NULL, //filter_string,\r
NULL, //filter_string2,\r
0, //offset,\r
dts_fail("get_item_audio_id","fail to get audio_id.");\r
}\r
\r
- ret = audio_svc_refresh_metadata(audio_id);\r
+ ret = audio_svc_refresh_metadata(db_handle, audio_id);\r
dts_check_eq("audio_svc_refresh_metadata", ret, AUDIO_SVC_ERROR_NONE, "failed to refresh metadata.");\r
\r
}\r
{\r
int ret = AUDIO_SVC_ERROR_NONE;\r
\r
- ret = audio_svc_refresh_metadata(NULL);\r
+ ret = audio_svc_refresh_metadata(db_handle, NULL);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_playlist_set_val","abnormal condition test for invalid audio_id parameter.");\r
dts_fail("check_playlist_has_item","fail to check_playlist_has_item.");\r
}\r
\r
- ret = audio_svc_remove_item_from_playlist_by_audio_id(playlist_id, audio_id);\r
+ ret = audio_svc_remove_item_from_playlist_by_audio_id(db_handle, playlist_id, audio_id);\r
dts_check_eq("audio_svc_remove_item_from_playlist", ret, AUDIO_SVC_ERROR_NONE, "failed to remove item.");\r
\r
}\r
char * audio_id = "550e8400-e29b-41d4-a716-446655440000";\r
int playlist_id = -1;\r
\r
- ret = audio_svc_remove_item_from_playlist_by_audio_id(playlist_id, audio_id);\r
+ ret = audio_svc_remove_item_from_playlist_by_audio_id(db_handle, playlist_id, audio_id);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_remove_item_from_playlist","abnormal condition test for invalid playlist index parameter.");\r
int storage = AUDIO_SVC_STORAGE_PHONE;\r
int valid = 1;\r
\r
- ret = audio_svc_set_db_valid(storage, valid);\r
+ ret = audio_svc_set_db_valid(db_handle, storage, valid);\r
dts_check_eq("audio_svc_set_db_valid", ret, AUDIO_SVC_ERROR_NONE, "failed to set db valid.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int valid = 1;\r
\r
- ret = audio_svc_set_db_valid(100, valid);\r
+ ret = audio_svc_set_db_valid(db_handle, 100, valid);\r
\r
\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int valid = 1;\r
\r
- ret = audio_svc_set_item_valid(DEFAULT_FILE, valid);\r
+ ret = audio_svc_set_item_valid(db_handle, DEFAULT_FILE, valid);\r
dts_check_eq("audio_svc_set_item_valid", ret, AUDIO_SVC_ERROR_NONE, "failed to set item valid.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int valid = 1;\r
\r
- ret = audio_svc_set_item_valid(NULL, valid);\r
+ ret = audio_svc_set_item_valid(db_handle, NULL, valid);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_set_item_valid","abnormal condition test for invalid path parameter.");\r
dts_fail("get_playlist_id","fail to get playlist id.");\r
}\r
\r
- ret = audio_svc_update_playlist_name(playlist_id, "new name");\r
+ ret = audio_svc_update_playlist_name(db_handle, playlist_id, "new name");\r
dts_check_eq("audio_svc_update_playlist_name", ret, AUDIO_SVC_ERROR_NONE, "failed to update playlist name.");\r
\r
}\r
int ret = AUDIO_SVC_ERROR_NONE;\r
int playlist_id = 1;\r
\r
- ret = audio_svc_update_playlist_name(playlist_id, NULL);\r
+ ret = audio_svc_update_playlist_name(db_handle, playlist_id, NULL);\r
if (ret != AUDIO_SVC_ERROR_NONE)\r
{\r
dts_pass("audio_svc_update_playlist_name","abnormal condition test for invalid NULL parameter.");\r
CXX=gcc -Wall\r
endif\r
\r
-TS10=utc_minfo_finalize_func\r
TS11=utc_minfo_destroy_mtype_item_func\r
TS13=utc_minfo_get_bookmark_list_func\r
TS14=utc_minfo_get_cluster_cnt_func\r
TS22=utc_minfo_get_item_list_func\r
TS25=utc_minfo_get_meta_info_func\r
TS26=utc_minfo_get_thumb_path_func\r
-TS27=utc_minfo_init_func\r
TS28=utc_minfo_move_media_func\r
TS29=utc_minfo_mv_media_func\r
TS30=utc_minfo_update_cluster_name_func\r
TS49=utc_minfo_get_cluster_fullpath_by_id_func\r
\r
\r
-LIBS = `pkg-config --libs libmedia-info`\r
-LIBS +=-L/usr/lib/:/usr/lib/pkgconfig\r
+LIBS = `pkg-config --libs libmedia-service`\r
LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o\r
LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s\r
-LIBS +=-L$(TET_ROOT)/lib/tet3/ -lapi_s\r
+LIBS +=-lapi_s\r
\r
-INCS = -I. `pkg-config --cflags libmedia-info`\r
+INCS = -I. `pkg-config --cflags libmedia-service`\r
INCS += -I$(TET_ROOT)/inc/tet3\r
INCS += -I/usr/include\r
\r
CC += $(CFLAGS)\r
LDFLAGS = $(LIBS)\r
\r
-all : $(TS10) $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS27) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
+all : $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
\r
$(TS1): $(TS1).c\r
$(CC) -o $(TS1) $(TS1).c $(LDFLAGS)\r
$(TS9): $(TS9).c\r
$(CC) -o $(TS9) $(TS9).c $(LDFLAGS)\r
\r
-$(TS10): $(TS10).c\r
- $(CC) -o $(TS10) $(TS10).c $(LDFLAGS)\r
-\r
$(TS11): $(TS11).c\r
$(CC) -o $(TS11) $(TS11).c $(LDFLAGS)\r
\r
$(TS26): $(TS26).c\r
$(CC) -o $(TS26) $(TS26).c $(LDFLAGS)\r
\r
-$(TS27): $(TS27).c\r
- $(CC) -o $(TS27) $(TS27).c $(LDFLAGS)\r
-\r
$(TS28): $(TS28).c\r
$(CC) -o $(TS28) $(TS28).c $(LDFLAGS)\r
\r
$(CC) -o $(TS49) $(TS49).c $(LDFLAGS)\r
\r
clean:\r
- rm -rf *~ *.o $(TS10) $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS27) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
+ rm -rf *~ *.o $(TS10) $(TS11) $(TS12) $(TS13) $(TS14) $(TS15) $(TS16) $(TS17) $(TS18) $(TS19) $(TS20) $(TS21) $(TS22) $(TS23) $(TS24) $(TS25) $(TS26) $(TS28) $(TS29) $(TS30) $(TS31) $(TS32) $(TS33) $(TS34) $(TS35) $(TS36) $(TS37) $(TS38) $(TS39) $(TS40) $(TS41) $(TS42) $(TS43) $(TS44) $(TS45) $(TS46) $(TS47) $(TS48) $(TS49)\r
\r
\r
-\r
-/utc/visual/utc_minfo_init_func\r
-/utc/visual/utc_minfo_bookmark_func\r
-/utc/visual/utc_minfo_cluster_func\r
-/utc/visual/utc_minfo_media_func\r
-/utc/visual/utc_minfo_tag_func\r
-/utc/visual/utc_minfo_delete_invalid_media_records_func\r
-/utc/visual/utc_minfo_destroy_mtype_item_func\r
-/utc/visual/utc_minfo_get_bookmark_list_func\r
-/utc/visual/utc_minfo_get_cluster_cnt_func\r
-/utc/visual/utc_minfo_get_cluster_cover_func\r
-/utc/visual/utc_minfo_get_cluster_func\r
-/utc/visual/utc_minfo_get_cluster_id_by_url_func\r
-/utc/visual/utc_minfo_get_cluster_list_func\r
-/utc/visual/utc_minfo_get_cluster_lock_status_func\r
-/utc/visual/utc_minfo_get_cluster_name_by_id_func\r
-/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func\r
-/utc/visual/utc_minfo_get_geo_item_list_func\r
-/utc/visual/utc_minfo_get_item_cnt_func\r
-/utc/visual/utc_minfo_get_item_func\r
-/utc/visual/utc_minfo_get_item_list_func\r
-/utc/visual/utc_minfo_get_all_item_list_func\r
-/utc/visual/utc_minfo_get_meta_info_func\r
-/utc/visual/utc_minfo_get_media_list_by_tagname_func\r
-/utc/visual/utc_minfo_set_cluster_lock_status_func\r
-/utc/visual/utc_minfo_set_db_valid_func\r
-/utc/visual/utc_minfo_update_cluster_name_func\r
-/utc/visual/utc_minfo_update_favorite_by_media_id_func\r
-/utc/visual/utc_minfo_update_media_favorite_func\r
-/utc/visual/utc_minfo_update_media_name_func\r
-/utc/visual/utc_minfo_update_video_meta_info_int_func\r
-/utc/visual/utc_minfo_get_thumb_path_func\r
-/utc/visual/utc_minfo_get_thumb_path_for_video_func\r
-/utc/visual/utc_minfo_get_media_path_func\r
-/utc/visual/utc_minfo_get_tag_list_by_media_id_func\r
-/utc/visual/utc_minfo_move_media_func\r
-/utc/visual/utc_minfo_mv_media_func\r
-/utc/visual/utc_minfo_finalize_func\r
+/utc/visual/utc_minfo_bookmark_func
+/utc/visual/utc_minfo_cluster_func
+/utc/visual/utc_minfo_media_func
+/utc/visual/utc_minfo_tag_func
+/utc/visual/utc_minfo_delete_invalid_media_records_func
+/utc/visual/utc_minfo_destroy_mtype_item_func
+/utc/visual/utc_minfo_get_bookmark_list_func
+/utc/visual/utc_minfo_get_media_list_by_tagname_func
+/utc/visual/utc_minfo_get_cluster_cnt_func
+/utc/visual/utc_minfo_get_cluster_cover_func
+/utc/visual/utc_minfo_get_cluster_func
+/utc/visual/utc_minfo_get_cluster_id_by_url_func
+/utc/visual/utc_minfo_get_cluster_list_func
+/utc/visual/utc_minfo_get_cluster_lock_status_func
+/utc/visual/utc_minfo_get_cluster_name_by_id_func
+/utc/visual/utc_minfo_get_cluster_fullpath_by_id_func
+/utc/visual/utc_minfo_get_geo_item_list_func
+/utc/visual/utc_minfo_get_item_cnt_func
+/utc/visual/utc_minfo_get_item_func
+/utc/visual/utc_minfo_get_item_list_func
+/utc/visual/utc_minfo_get_all_item_list_func
+/utc/visual/utc_minfo_get_meta_info_func
+/utc/visual/utc_minfo_set_cluster_lock_status_func
+/utc/visual/utc_minfo_set_db_valid_func
+/utc/visual/utc_minfo_update_cluster_name_func
+/utc/visual/utc_minfo_update_favorite_by_media_id_func
+/utc/visual/utc_minfo_update_media_favorite_func
+/utc/visual/utc_minfo_update_media_name_func
+/utc/visual/utc_minfo_update_video_meta_info_int_func
+/utc/visual/utc_minfo_get_thumb_path_func
+/utc/visual/utc_minfo_get_thumb_path_for_video_func
+/utc/visual/utc_minfo_get_media_path_func
+/utc/visual/utc_minfo_get_tag_list_by_media_id_func
+/utc/visual/utc_minfo_move_media_func
+/utc/visual/utc_minfo_mv_media_func
+
int ret = -1;
int position = 2346;
- const char *media_id = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
+ const char *media_id = "77b876ed-5db9-4114-82c0-d08e814b5051";
char *thumb_path = "tmp1";
- ret = minfo_add_bookmark(media_id, position, thumb_path);
+ ret = minfo_add_bookmark(handle, media_id, position, thumb_path);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to add a bookmark to a media file. error code->%d", ret);
}
*/
void utc_minfo_add_bookmark_func_02()
{
- int ret = -1;
+ int ret = -1;
- int position = 2346;
- const char *media_id = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
- char *thumb_path = NULL;
+ int position = 2346;
+ const char *media_id = "77b876ed-5db9-4114-82c0-d08e814b5051";
+ char *thumb_path = NULL;
- ret = minfo_add_bookmark(media_id,position,thumb_path);
+ ret = minfo_add_bookmark(handle, media_id,position,thumb_path);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "add a bookmark to a media file should be failed because of the media_id parameter -1.");
}
int ret = -1;
int bookmark_id = 1;
- ret = minfo_delete_bookmark(bookmark_id);
+ ret = minfo_delete_bookmark(handle, bookmark_id);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to delete a bookmark to a media file. error code->%d", ret);
}
int ret = -1;
int bookmark_id = -1;
- ret = minfo_delete_bookmark(bookmark_id);
+ ret = minfo_delete_bookmark(handle, bookmark_id);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a bookmark to a media file should be failed because of the bookmark_id parameter -1.");
{
char cluster_id[256] = {0,};
- if( minfo_get_cluster_id_by_url(url, cluster_id, sizeof(cluster_id)) < 0 )
+ if( minfo_get_cluster_id_by_url(handle, url, cluster_id, sizeof(cluster_id)) < 0 )
{
return -1;
}
void utc_minfo_add_cluster_func_01()
{
int ret = -1;
- char *cluster_url = "/opt/media/Images and videos/ForTC";
+ char *cluster_url = "/opt/media/Images/ForTC";
char cluster_id[256] = {0,};
- ret = minfo_add_cluster(cluster_url, cluster_id, sizeof(cluster_id));
+ ret = minfo_add_cluster(handle, cluster_url, cluster_id, sizeof(cluster_id));
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to add a cluser record content in folder table. error code->%d", ret);
}
char *cluster_url = NULL; /*= "/opt/media/Images/Wallpapers_1";*/
char cluster_id[256] = {0,};
- ret = minfo_add_cluster(cluster_url, cluster_id, sizeof(cluster_id));
+ ret = minfo_add_cluster(handle, cluster_url, cluster_id, sizeof(cluster_id));
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "add a cluser record content in folder table should be failed because of the cluster_url NULL.");
}
int ret = -1;
char cluster_id[256] = {0,};
- _get_id_by_url("/opt/media/Images and videos/ForTC", cluster_id);
- ret = minfo_delete_cluster(cluster_id);
+ _get_id_by_url("/opt/media/Images/ForTC", cluster_id);
+ ret = minfo_delete_cluster(handle, cluster_id);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a cluster/folder identified by folder id. error code->%d", ret);
}
int ret = -1;
const char *cluster_id = NULL;
- ret = minfo_delete_cluster(cluster_id);
+ ret = minfo_delete_cluster(handle, cluster_id);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a cluster/folder identified by folder id should be failed because of the cluster_id -1.");
}
int ret = -1;
minfo_store_type storage_type = MINFO_PHONE;
- ret = minfo_delete_invalid_media_records(storage_type );
+ ret = minfo_delete_invalid_media_records(handle, storage_type);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete invalid records. error code->%d", ret);
}
int ret = -1;
minfo_store_type storage_type = MINFO_SYSTEM;
- ret = minfo_delete_invalid_media_records(storage_type);
+ ret = minfo_delete_invalid_media_records(handle, storage_type);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "deleting invalid records should be failed because of the status is invalid.");
}
void* p = NULL;\r
\r
minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,5};\r
- ret = minfo_get_cluster_list(cluster_filter, _cluster_ite_fn, &p_list);\r
+ ret = minfo_get_cluster_list(handle, cluster_filter, _cluster_ite_fn, &p_list);\r
\r
if( ret < MB_SVC_ERROR_NONE ) {\r
dts_fail(API_NAME, "unable to get list of clusters. error code->%d", ret);\r
-/*\r
- * libmedia-service\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-\r
-/**\r
-* @file utc_minfo_get_all_item_list_func.c\r
-* @brief This is a suit of unit test cases to test minfo_get_all_item_list API function\r
-* @author \r
-* @version Initial Creation Version 0.1\r
-* @date 2010-10-10\r
-*/\r
-\r
-#include "utc_minfo_get_all_item_list_func.h"\r
-\r
-static int _ite_fn( Mitem* item, void* user_data) \r
-{\r
- GList** list = (GList**) user_data;\r
- *list = g_list_append( *list, item );\r
-\r
- return 0;\r
-}\r
-\r
-/**\r
-* @brief This tests int minfo_get_all_item_list() API with valid parameter\r
-* Get glist including Mitem members.\r
-* @par ID utc_minfo_get_all_item_list_func_01\r
-* @param [in] \r
-* @return This function returns zero on success, or negative value with error code\r
-*/\r
-void utc_minfo_get_all_item_list_func_01()\r
-{\r
- int ret = 0;\r
-\r
- GList *p_list = NULL;\r
- minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;\r
- minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};\r
-\r
- ret = minfo_get_all_item_list(cluster_type, item_filter, _ite_fn, &p_list);\r
-\r
- if (ret == MB_SVC_ERROR_DB_NO_RECORD) {\r
- dts_pass(API_NAME, "No record. This is normal operation");\r
- }\r
-\r
- dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);\r
-}\r
-\r
-\r
-/**\r
-* @brief This tests int minfo_get_all_item_list() API with invalid parameter\r
-* Get glist including Mitem members.\r
-* @par ID utc_minfo_get_all_item_list_func_02\r
-* @param [in] \r
-* @return error code on success \r
-*/\r
-void utc_minfo_get_all_item_list_func_02()\r
-{ \r
- int ret = 0;\r
-\r
- GList *p_list = NULL;\r
- minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;\r
- minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};\r
-\r
- ret = minfo_get_all_item_list(cluster_type, item_filter, NULL, &p_list);\r
- dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");\r
-}\r
-\r
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file utc_minfo_get_all_item_list_func.c
+* @brief This is a suit of unit test cases to test minfo_get_all_item_list API function
+* @author
+* @version Initial Creation Version 0.1
+* @date 2010-10-10
+*/
+
+#include "utc_minfo_get_all_item_list_func.h"
+
+static int _ite_fn( Mitem* item, void* user_data)
+{
+ GList** list = (GList**) user_data;
+ *list = g_list_append( *list, item );
+
+ return 0;
+}
+
+/**
+* @brief This tests int minfo_get_all_item_list() API with valid parameter
+* Get glist including Mitem members.
+* @par ID utc_minfo_get_all_item_list_func_01
+* @param [in]
+* @return This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_all_item_list_func_01()
+{
+ int ret = 0;
+
+ GList *p_list = NULL;
+ minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;
+ minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};
+
+ ret = minfo_get_all_item_list(handle, cluster_type, item_filter, _ite_fn, &p_list);
+
+ if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
+ dts_pass(API_NAME, "No record. This is normal operation");
+ }
+
+ dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get media records. error code->%d", ret);
+}
+
+
+/**
+* @brief This tests int minfo_get_all_item_list() API with invalid parameter
+* Get glist including Mitem members.
+* @par ID utc_minfo_get_all_item_list_func_02
+* @param [in]
+* @return error code on success
+*/
+void utc_minfo_get_all_item_list_func_02()
+{
+ int ret = 0;
+
+ GList *p_list = NULL;
+ minfo_folder_type cluster_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;
+ minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};
+
+ ret = minfo_get_all_item_list(handle, cluster_type, item_filter, NULL, &p_list);
+ dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");
+}
+
{
int ret = -1;
- const char *media_uuid = "2f08863e-52fd-eaf8-269c-3d0798e7aa0e";
+ const char *media_uuid = "77b876ed-5db9-4114-82c0-d08e814b5051";
GList *p_list = NULL;
- ret = minfo_get_bookmark_list(media_uuid, _minfo_bm_ite_fn, &p_list);
+ ret = minfo_get_bookmark_list(handle, media_uuid, _minfo_bm_ite_fn, &p_list);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
dts_pass(API_NAME, "No record. This is normal operation");
const char *media_uuid = NULL;
GList *p_list = NULL;
- ret = minfo_get_bookmark_list(media_uuid, NULL, &p_list);
+ ret = minfo_get_bookmark_list(handle, media_uuid, NULL, &p_list);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get all of bookmark for a media content should be failed because of the p_list non-NULL.");
}
int cnt = 0;
minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
- ret = minfo_get_cluster_cnt(cluster_filter, &cnt);
+ ret = minfo_get_cluster_cnt(handle, cluster_filter, &cnt);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get count of media clusters. error code->%d", ret);
}
int *cnt = NULL;
minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
- ret = minfo_get_cluster_cnt(cluster_filter, cnt);
+ ret = minfo_get_cluster_cnt(handle, cluster_filter, cnt);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting count of media clusters should be failed because of the item_filter parameter.");
}
#include "utc_minfo_get_cluster_cover_func.h"
-static int _cover_ite_fn( char* thumb_path, void* user_data)
+static int _cover_ite_fn(const char* thumb_path, void* user_data)
{
GList** list = (GList**) user_data;
- *list = g_list_append( *list, thumb_path );
+ *list = g_list_append( *list, (char *)thumb_path );
return 0;
}
GList *p_list = NULL;
int img_cnt = 5;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
- ret = minfo_get_cluster_cover(cluster_uuid, img_cnt, _cover_ite_fn, &p_list);
+ ret = minfo_get_cluster_cover(handle, cluster_uuid, img_cnt, _cover_ite_fn, &p_list);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get cover of a cluster/folder. error code->%d", ret);
}
int img_cnt = 5;
const char *cluster_uuid = NULL;
- ret = minfo_get_cluster_cover(cluster_uuid, img_cnt, NULL, &p_list);
+ ret = minfo_get_cluster_cover(handle, cluster_uuid, img_cnt, NULL, &p_list);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get cover of a cluster/folder should be failed because of the p_list non-NULL.");
}
void utc_minfo_get_cluster_fullpath_by_id_func_01()
{
int ret = -1;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
int size = 256;
char fullpath[256] = {'\0'};
- ret = minfo_get_cluster_fullpath_by_id(cluster_uuid, fullpath, size);
+ ret = minfo_get_cluster_fullpath_by_id(handle, cluster_uuid, fullpath, size);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get cluster fullpath by id. error code->%d", ret);
}
int size = 256;
char fullpath[256] = {'\0'};
- ret = minfo_get_cluster_fullpath_by_id(cluster_uuid, fullpath, size);
+ ret = minfo_get_cluster_fullpath_by_id(handle, cluster_uuid, fullpath, size);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Getting cluster fullpath by id should be failed because the passed status is NULL.");
}
int ret = -1;
Mcluster *mc = NULL;
- char *cluster_url = "/opt/media/Images and videos/Wallpapers";
+ char *cluster_url = "/opt/media/Images/Wallpapers";
- ret = minfo_get_cluster(cluster_url, 0, &mc);
+ ret = minfo_get_cluster(handle, cluster_url, 0, &mc);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get a cluster/folder record from folder table with Mcluster type. error code->%d", ret);
}
Mcluster *mc = NULL;
char *cluster_url = NULL; /*= "/opt/media/Images/Wallpapers";*/
- ret = minfo_get_cluster(cluster_url, 0, &mc);
+ ret = minfo_get_cluster(NULL, cluster_url, 0, &mc);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get a cluster/folder record from folder table with Mcluster type should be failed because of mc NULL.");
}
int ret = -1;
char cluster_uuid[256] = {0,};
- char *folder_full_path = "/opt/media/Images and videos/Wallpapers";
- ret = minfo_get_cluster_id_by_url(folder_full_path, cluster_uuid, sizeof(cluster_uuid));
+ char *folder_full_path = "/opt/media/Images/Wallpapers";
+ ret = minfo_get_cluster_id_by_url(handle, folder_full_path, cluster_uuid, sizeof(cluster_uuid));
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get folder id using it's full name. error code->%d", ret);
char *cluster_uuid = NULL;
char *folder_full_path = NULL; /*= "/opt/media/Images/Wallpapers";*/
- ret = minfo_get_cluster_id_by_url(folder_full_path, cluster_uuid, sizeof(cluster_uuid));
+ ret = minfo_get_cluster_id_by_url(handle, folder_full_path, cluster_uuid, sizeof(cluster_uuid));
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"get folder id using it's full name should be failed because of the folder_full_path parameter NULL.");
}
-/*\r
- * libmedia-service\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-\r
-/**\r
-* @file utc_minfo_get_cluster_list_func.c\r
-* @brief This is a suit of unit test cases to test minfo_get_cluster_list API function\r
-* @author \r
-* @version Initial Creation Version 0.1\r
-* @date 2010-10-13\r
-*/\r
-\r
-#include "utc_minfo_get_cluster_list_func.h"\r
-\r
-static int _cluster_ite_fn( Mcluster* cluster, void* user_data)\r
-{\r
- GList** list = (GList**) user_data;\r
- *list = g_list_append( *list, cluster );\r
- return 0;\r
-}\r
-\r
-\r
-/**\r
-* @brief This tests int minfo_get_cluster_list() API with valid parameter\r
-* Get glist including media clusters.\r
-* @par ID utc_minfo_get_cluster_list_func_01\r
-* @param [in] \r
-* @return This function returns zero on success, or negative value with error code\r
-*/\r
-void utc_minfo_get_cluster_list_func_01()\r
-{\r
- int ret = -1;\r
-\r
- GList *p_list = NULL;\r
-\r
- minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};\r
- ret = minfo_get_cluster_list(cluster_filter, _cluster_ite_fn, &p_list);\r
- \r
- dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get glist including media clusters. error code->%d", ret);\r
-}\r
-\r
-\r
-/**\r
-* @brief This tests int minfo_get_cluster_list() API with invalid parameter\r
-* Get glist including media clusters.\r
-* @par ID utc_minfo_get_cluster_list_func_02\r
-* @param [in] \r
-* @return error code on success \r
-*/\r
-void utc_minfo_get_cluster_list_func_02()\r
-{ \r
- int ret = -1;\r
-\r
- GList *p_list = NULL;\r
-\r
- minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};\r
- ret = minfo_get_cluster_list(cluster_filter, NULL, &p_list);\r
- \r
- dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting glist including media clusters should be failed because of the item_filter parameter.");\r
-}\r
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file utc_minfo_get_cluster_list_func.c
+* @brief This is a suit of unit test cases to test minfo_get_cluster_list API function
+* @author
+* @version Initial Creation Version 0.1
+* @date 2010-10-13
+*/
+
+#include "utc_minfo_get_cluster_list_func.h"
+
+static int _cluster_ite_fn( Mcluster* cluster, void* user_data)
+{
+ GList** list = (GList**) user_data;
+ *list = g_list_append( *list, cluster );
+ return 0;
+}
+
+
+/**
+* @brief This tests int minfo_get_cluster_list() API with valid parameter
+* Get glist including media clusters.
+* @par ID utc_minfo_get_cluster_list_func_01
+* @param [in]
+* @return This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_cluster_list_func_01()
+{
+ int ret = -1;
+
+ GList *p_list = NULL;
+
+ minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
+ ret = minfo_get_cluster_list(handle, cluster_filter, _cluster_ite_fn, &p_list);
+
+ dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get glist including media clusters. error code->%d", ret);
+}
+
+
+/**
+* @brief This tests int minfo_get_cluster_list() API with invalid parameter
+* Get glist including media clusters.
+* @par ID utc_minfo_get_cluster_list_func_02
+* @param [in]
+* @return error code on success
+*/
+void utc_minfo_get_cluster_list_func_02()
+{
+ int ret = -1;
+
+ GList *p_list = NULL;
+
+ minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
+ ret = minfo_get_cluster_list(handle, cluster_filter, NULL, &p_list);
+
+ dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting glist including media clusters should be failed because of the item_filter parameter.");
+}
{
int ret = -1;
int status = 0;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
- ret = minfo_get_cluster_lock_status(cluster_uuid, &status);
+ ret = minfo_get_cluster_lock_status(handle, cluster_uuid, &status);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to varify password to lock/unlock. error code->%d", ret);
}
const char *cluster_uuid = NULL;
int status = 0;
- ret = minfo_get_cluster_lock_status(cluster_uuid, &status);
+ ret = minfo_get_cluster_lock_status(handle, cluster_uuid, &status);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Get status for lock should be failed because the passed status is NULL.");
}
void utc_minfo_get_cluster_name_by_id_func_01()
{
int ret = -1;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
int size = 256;
char cluster_name[256] = {'\0'};
- ret = minfo_get_cluster_name_by_id(cluster_uuid, cluster_name, size);
+ ret = minfo_get_cluster_name_by_id(handle, cluster_uuid, cluster_name, size);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get cluster name by id. error code->%d", ret);
}
int size = 256;
char cluster_name[256] = {'\0'};
- ret = minfo_get_cluster_name_by_id(cluster_uuid, cluster_name, size);
+ ret = minfo_get_cluster_name_by_id(handle, cluster_uuid, cluster_name, size);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Getting cluster name by id should be failed because the passed status is NULL.");
}
{
int ret = -1;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
int min_longitude = 120.0;
int max_longitude = 123.0;
int min_latitude = 19.0;
//minfo_store_type store_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;
minfo_store_type store_type = MINFO_CLUSTER_TYPE_ALL;
- ret = minfo_get_geo_item_list(cluster_uuid,
+ ret = minfo_get_geo_item_list(handle,
+ cluster_uuid,
store_type,
filter,
min_longitude,
minfo_item_filter filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,true,MINFO_MEDIA_FAV_ALL};
minfo_store_type store_type = MINFO_CLUSTER_TYPE_ALL;
- ret = minfo_get_geo_item_list(cluster_uuid,
+ ret = minfo_get_geo_item_list(handle,
+ cluster_uuid,
store_type,
filter,
min_longitude,
void utc_minfo_get_item_cnt_func_01()
{
int ret = 0;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
int cnt = 0;
minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,true};
- ret = minfo_get_item_cnt(cluster_uuid, item_filter, &cnt);
+ ret = minfo_get_item_cnt(handle, cluster_uuid, item_filter, &cnt);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
dts_pass(API_NAME, "No record. This is normal operation");
int *cnt = NULL;
minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,true};
- ret = minfo_get_item_cnt(cluster_uuid, item_filter, cnt);
+ ret = minfo_get_item_cnt(handle, cluster_uuid, item_filter, cnt);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "getting media records should be failed because of the item_filter parameter.");
}
-/*\r
- * libmedia-service\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- */\r
-\r
-/**\r
-* @file utc_minfo_get_item_func.c\r
-* @brief This is a suit of unit test cases to test minfo_get_item API function\r
-* @author \r
-* @version Initial Creation Version 0.1\r
-* @date 2010-10-13\r
-*/\r
-\r
-#include "utc_minfo_get_item_func.h"\r
-\r
-\r
-/**\r
-* @brief This tests int minfo_get_item() API with valid parameter\r
-* get a item record from media table with Mitem type.\r
-* @par ID utc_minfo_get_item_func_01\r
-* @param [in] \r
-* @return This function returns zero on success, or negative value with error code\r
-*/\r
-void utc_minfo_get_item_func_01()\r
-{\r
- int ret = -1;\r
- \r
- Mitem *mi = NULL;\r
- char* file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
-\r
- ret = minfo_get_item(file_url, &mi);\r
-\r
- dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get a item record from media table with Mitem type . error code->%d", ret);\r
-}\r
-\r
-\r
-/**\r
-* @brief This tests int minfo_get_item() API with invalid parameter\r
-* get a item record from media table with Mitem type.\r
-* @par ID utc_minfo_get_item_func_02\r
-* @param [in] \r
-* @return error code on success \r
-*/\r
-void utc_minfo_get_item_func_02()\r
-{\r
- int ret = -1;\r
- \r
- Mitem *mi = NULL;\r
- char* file_url = NULL;/*= "/opt/media/Images/Wallpapers/Home_01.png";*/\r
-\r
- ret = minfo_get_item(file_url, &mi);\r
- \r
- dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get a item record from media table with Mitem type should be failed because of the file_url NULL.");\r
-\r
-}\r
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file utc_minfo_get_item_func.c
+* @brief This is a suit of unit test cases to test minfo_get_item API function
+* @author
+* @version Initial Creation Version 0.1
+* @date 2010-10-13
+*/
+
+#include "utc_minfo_get_item_func.h"
+
+
+/**
+* @brief This tests int minfo_get_item() API with valid parameter
+* get a item record from media table with Mitem type.
+* @par ID utc_minfo_get_item_func_01
+* @param [in]
+* @return This function returns zero on success, or negative value with error code
+*/
+void utc_minfo_get_item_func_01()
+{
+ int ret = -1;
+
+ Mitem *mi = NULL;
+ char* file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
+
+ ret = minfo_get_item(handle, file_url, &mi);
+
+ dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get a item record from media table with Mitem type . error code->%d", ret);
+}
+
+
+/**
+* @brief This tests int minfo_get_item() API with invalid parameter
+* get a item record from media table with Mitem type.
+* @par ID utc_minfo_get_item_func_02
+* @param [in]
+* @return error code on success
+*/
+void utc_minfo_get_item_func_02()
+{
+ int ret = -1;
+
+ Mitem *mi = NULL;
+ char* file_url = NULL;/*= "/opt/media/Images/Wallpapers/Home_01.jpg";*/
+
+ ret = minfo_get_item(handle, file_url, &mi);
+
+ dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get a item record from media table with Mitem type should be failed because of the file_url NULL.");
+
+}
void utc_minfo_get_item_list_func_01()
{
int ret = 0;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
GList *p_list = NULL;
minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true, MINFO_MEDIA_FAV_ALL};
- ret = minfo_get_item_list(cluster_uuid, item_filter, _ite_fn, &p_list);
+ ret = minfo_get_item_list(handle, cluster_uuid, item_filter, _ite_fn, &p_list);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
dts_pass(API_NAME, "No record. This is normal operation");
GList *p_list = NULL;
minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,0,5,true,MINFO_MEDIA_FAV_ALL};
- ret = minfo_get_item_list(cluster_uuid, item_filter, NULL, &p_list);
+ ret = minfo_get_item_list(handle, cluster_uuid, item_filter, NULL, &p_list);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");
}
int ret = 0;
const char* tag = "Family";
GList *p_list = NULL;
- ret = minfo_get_media_list_by_tagname(tag, FALSE, _ite_fn, &p_list);
+ ret = minfo_get_media_list_by_tagname(handle, tag, FALSE, _ite_fn, &p_list);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
dts_pass(API_NAME, "No record. This is normal operation");
int ret = 0;
const char* tag = "Family";
GList *p_list = NULL;
- ret = minfo_get_media_list_by_tagname(tag, FALSE, NULL, &p_list);
+ ret = minfo_get_media_list_by_tagname(handle, tag, FALSE, NULL, &p_list);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting media records should be failed because of the item_filter parameter.");
}
{
int ret = -1;
Mmeta* mt = NULL;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
- ret = minfo_get_meta_info(media_uuid, &mt);
+ ret = minfo_get_meta_info(handle, media_uuid, &mt);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to get meta record of media Mitem. error code->%d", ret);
minfo_destroy_mtype_item(mt);
Mmeta* mt = NULL;
const char *media_uuid = NULL;
- ret = minfo_get_meta_info(media_uuid, &mt);
+ ret = minfo_get_meta_info(handle, media_uuid, &mt);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting meta record of media Mitem should be failed because of the media_id parameter.");
}
+
void utc_minfo_get_tag_list_by_media_id_func_01()
{
int ret = 0;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
GList *p_list = NULL;
- ret = minfo_get_tag_list_by_media_id( media_uuid, _ite_fn, &p_list);
+ ret = minfo_get_tag_list_by_media_id(handle, media_uuid, _ite_fn, &p_list);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
dts_pass(API_NAME, "No record. This is normal operation");
int ret = 0;
const char *media_uuid = NULL;
GList *p_list = NULL;
- ret = minfo_get_tag_list_by_media_id( media_uuid, NULL, &p_list);
+ ret = minfo_get_tag_list_by_media_id(handle, media_uuid, NULL, &p_list);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"getting tag list should be failed because of the item_filter parameter.");
}
int size = 256;\r
\r
char thumb_path_for_video[256] = {'\0'};\r
- char *file_url = "/opt/media/Images and videos/My video clips/Helicopter.mp4";\r
+ char *file_url = "/opt/media/Videos/Helicopter.mp4";\r
\r
- ret = minfo_get_thumb_path_for_video(file_url,thumb_path_for_video, size);\r
+ ret = minfo_get_thumb_path_for_video(handle, file_url,thumb_path_for_video, size);\r
\r
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get thumbnail pathname for a media content. error code->%d", ret);\r
}\r
int size = 20;\r
\r
char thumb_path_for_video[256] = {'\0'};\r
- char *file_url = NULL;/* = "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+ char *file_url = NULL;\r
\r
- ret = minfo_get_thumb_path_for_video(file_url,thumb_path_for_video, size);\r
+ ret = minfo_get_thumb_path_for_video(handle, file_url,thumb_path_for_video, size);\r
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get thumbnail pathname for a media content should be failed because of the file_url NULL.");\r
}\r
int size = 256;\r
\r
char thumb_path[256] = {'\0'};\r
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";\r
+ char *file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";\r
\r
- ret = minfo_get_thumb_path(file_url,thumb_path, size);\r
+ ret = minfo_get_thumb_path(handle, file_url,thumb_path, size);\r
\r
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to get thumbnail pathname for a media content. error code->%d", ret);\r
}\r
int size = 20;\r
\r
char thumb_path[256] = {'\0'};\r
- char *file_url = NULL;/* = "/opt/media/Images/Wallpapers/Home_01.png";*/\r
+ char *file_url = NULL;/* = "/opt/media/Images/Wallpapers/Home_01.jpg";*/\r
\r
- ret = minfo_get_thumb_path(file_url,thumb_path, size);\r
+ ret = minfo_get_thumb_path(handle, file_url,thumb_path, size);\r
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "get thumbnail pathname for a media content should be failed because of the file_url NULL.");\r
}\r
int ret;
Mitem* item = NULL;
- ret = minfo_get_item( url, &item );
+ ret = minfo_get_item(handle, url, &item );
if( ret < 0 ) {
dts_message(API_NAME, "minfo_get_item fail");
return -1;
void utc_minfo_add_media_func_01()
{
int err = -1;
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.jpg";
int type = 1;
- err = minfo_add_media(file_url, type);
+ err = minfo_add_media(handle, file_url, type);
dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Add a media content to media table. error code->%d", err);
}
void utc_minfo_add_media_func_02()
{
int err = -1;
- char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
+ char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.jpg";*/
int type = 1;
- err = minfo_add_media(file_url, type);
+ err = minfo_add_media(handle, file_url, type);
dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Add a media content to media table should be failed because of the file_url NULL.");
}
void utc_minfo_copy_media_func_01()
{
int err = -1;
- char *old_file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
- char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";
+ char *old_file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
+ char *new_file_url = "/opt/media/Images/Wallpapers/Home_default_1.jpg";
int type = 1;
- err = minfo_copy_media(old_file_url, new_file_url, type);
+ err = minfo_copy_media(handle, old_file_url, new_file_url, type);
dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Copy a media content from media table.. error code->%d", err);
void utc_minfo_copy_media_func_02()
{
int err = -1;
- char *old_file_url = NULL; /*= "/opt/media/Images and videos/Wallpapers/Home_default.png";*/
- char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_1.png";
+ char *old_file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_default.jpg";*/
+ char *new_file_url = "/opt/media/Images/Wallpapers/Home_default_1.jpg";
int type = 1;
- err = minfo_copy_media(old_file_url, new_file_url, type);
+ err = minfo_copy_media(handle, old_file_url, new_file_url, type);
dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE, "Copy a media content from media table should be failed because of the file_url NULL.");
}
{
int ret = -1;
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+ char *file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
char src_media_uuid[256] = {0,};
char src_cluster_uuid[256] = {0,};
- char *dst_cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ char *dst_cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
Mitem* item = NULL;
- ret = minfo_get_item( file_url, &item );
+ ret = minfo_get_item(handle, file_url, &item );
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail( API_NAME, "unable to get a media content from media table. error code->%d", ret);
minfo_destroy_mtype_item(item);
- ret = minfo_cp_media(src_media_uuid, dst_cluster_uuid);
+ ret = minfo_cp_media(handle, src_media_uuid, dst_cluster_uuid);
if (ret < MB_SVC_ERROR_NONE)
{
minfo_item_filter item_filter = {MINFO_ITEM_ALL,MINFO_MEDIA_SORT_BY_NONE,-1,-1,false,false};
Mitem* dest_item = NULL;
- ret = minfo_get_item_list(dst_cluster_uuid, item_filter, _ite_fn, &p_list);
+ ret = minfo_get_item_list(handle, dst_cluster_uuid, item_filter, _ite_fn, &p_list);
if (ret < MB_SVC_ERROR_NONE)
{
int len = g_list_length( p_list );
dest_item = (Mitem*)g_list_nth_data(p_list, len-1);
- ret = minfo_delete_media_id( dest_item->uuid );
+ ret = minfo_delete_media_id(handle, dest_item->uuid );
if (ret < MB_SVC_ERROR_NONE)
{
char *src_media_uuid = NULL;
char *dst_cluster_uuid = NULL;
- ret = minfo_cp_media(src_media_uuid, dst_cluster_uuid);
+ ret = minfo_cp_media(handle, src_media_uuid, dst_cluster_uuid);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"copy a record identified by media id to destination folder identified by folder id should be failed because of the src_media_id -1.");
}
void utc_minfo_delete_media_func_01()
{
int err = -1;
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_01.png";
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.jpg";
- err = minfo_delete_media(file_url);
+ err = minfo_delete_media(handle, file_url);
dts_check_ge(API_NAME, err, MB_SVC_ERROR_NONE, "unable to Add a media content to media table. error code->%d", err);
}
void utc_minfo_delete_media_func_02()
{
int err = -1;
- char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
+ char *file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.jpg";*/
- err = minfo_delete_media(file_url);
+ err = minfo_delete_media(handle, file_url);
dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Delete a media content from media table should be failed because of the file_url NULL.");
}
int ret = -1;
char media_uuid[256] = {0,};
- _get_id_by_url("/opt/media/Images and videos/Wallpapers/Home_default_1.png", media_uuid);
- ret = minfo_delete_media_id(media_uuid);
+ _get_id_by_url("/opt/media/Images/Wallpapers/Home_default_1.jpg", media_uuid);
+ ret = minfo_delete_media_id(handle, media_uuid);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a record identified by media id from 'media' table. error code->%d", ret);
}
int ret = -1;
char *media_uuid = NULL;
- ret = minfo_delete_media_id(media_uuid);
+ ret = minfo_delete_media_id(handle, media_uuid);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "delete a record identified by media id from 'media' table should be failed because of the media_id -1.");
}
void utc_minfo_move_media_func_01()
{
int err = -1;
- char *old_file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
- char *new_file_url = "/opt/media/Images and videos/Wallpapers/Home_default_2.png";
+ char *old_file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
+ char *new_file_url = "/opt/media/Images/Wallpapers/Home_default_2.jpg";
int type = 1;
- err = minfo_move_media(old_file_url, new_file_url, type);
+ err = minfo_move_media(handle, old_file_url, new_file_url, type);
if (err < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to Move a media content from media table. error code->%d", err);
}
- err = minfo_move_media(new_file_url, old_file_url, type);
+ err = minfo_move_media(handle, new_file_url, old_file_url, type);
if (err < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to Move a media content from media table. error code->%d", err);
void utc_minfo_move_media_func_02()
{
int err = -1;
- char *old_file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.png";*/
- char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+ char *old_file_url = NULL; /*= "/opt/media/Images/Wallpapers/Home_01.jpg";*/
+ char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.jpg";
int type = 1;
- err = minfo_move_media(old_file_url, new_file_url, type);
+ err = minfo_move_media(handle, old_file_url, new_file_url, type);
dts_check_lt(API_NAME, err, MB_SVC_ERROR_NONE,"Move a media content from media table should be failed because of the file_url NULL.");
}
{
int ret = -1;
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+ char *file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
char src_media_uuid[256] = {0,};
char src_cluster_uuid[256] = {0,};
- char *dst_cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ char *dst_cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
+
Mitem* item = NULL;
- ret = minfo_get_item( file_url, &item );
+ ret = minfo_get_item(handle, file_url, &item );
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
strncpy(src_media_uuid, item->uuid, sizeof(src_media_uuid));
strncpy(src_cluster_uuid, item->cluster_uuid, sizeof(src_cluster_uuid));
- ret = minfo_mv_media(src_media_uuid, dst_cluster_uuid);
+ ret = minfo_mv_media(handle, src_media_uuid, dst_cluster_uuid);
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "failed to move a record identified by media id to destination folder identified by folder id. error code->%d", ret);
}
- ret = minfo_mv_media(src_media_uuid, src_cluster_uuid);
+ ret = minfo_mv_media(handle, src_media_uuid, src_cluster_uuid);
if (ret < MB_SVC_ERROR_NONE)
{
char *src_media_uuid = NULL;
char *dst_cluster_uuid = NULL;
- ret = minfo_mv_media(src_media_uuid, dst_cluster_uuid);
+ ret = minfo_mv_media(handle, src_media_uuid, dst_cluster_uuid);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"move a record identified by media id to destination folder identified by folder id should be failed because of the src_media_id -1.");
}
void utc_minfo_set_cluster_lock_status_func_01()
{
int ret = -1;
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";
int status = 1;
- ret = minfo_set_cluster_lock_status(cluster_uuid, status);
+ ret = minfo_set_cluster_lock_status(handle, cluster_uuid, status);
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to set status to lock the album. error code->%d", ret);
}
- ret = minfo_set_cluster_lock_status(cluster_uuid, 0);
+ ret = minfo_set_cluster_lock_status(handle, cluster_uuid, 0);
if (ret < MB_SVC_ERROR_NONE)
{
const char *cluster_uuid = NULL;
int status = 2;
- ret = minfo_set_cluster_lock_status(cluster_uuid, status);
+ ret = minfo_set_cluster_lock_status(handle, cluster_uuid, status);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Setting lock status to the album should be failed because of the status is invalid.");
}
minfo_store_type storage_type = MINFO_PHONE;
- ret = minfo_set_db_valid(storage_type, valid);
+ ret = minfo_set_db_valid(handle, storage_type, valid);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to set value of valid. error code->%d", ret);
}
minfo_store_type storage_type = MINFO_PHONE;
- ret = minfo_set_db_valid(storage_type, valid);
+ ret = minfo_set_db_valid(handle, storage_type, valid);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Setting value of valid should be failed because of the status is invalid.");
}
{
int ret = -1;
const char *tag = "Family";
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
- ret = minfo_add_tag(media_uuid, tag);
+ ret = minfo_add_tag(handle, media_uuid, tag);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to add a tag. error code->%d", ret);
}
void utc_minfo_add_tag_func_02()
{
int ret = -1;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
const char *tag = NULL;
- ret = minfo_add_tag(media_uuid, tag);
+ ret = minfo_add_tag(handle, media_uuid, tag);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "Adding a tag should be failed because of the cluster_url NULL.");
}
void utc_minfo_delete_tag_func_01()
{
int ret = -1;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
const char *tag = "Family";
- ret = minfo_delete_tag(media_uuid, tag);
+ ret = minfo_delete_tag(handle, media_uuid, tag);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "failed to delete a tag. error code->%d", ret);
}
void utc_minfo_delete_tag_func_02()
{
int ret = -1;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
const char *tag = NULL;
- ret = minfo_delete_tag(media_uuid, tag);
+ ret = minfo_delete_tag(handle, media_uuid, tag);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "deleting a tag should be failed because of the cluster_id -1.");
}
{\r
int ret = -1;\r
\r
- const char *cluster_uuid = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";\r
+ const char *cluster_uuid = "8ac1df34-efa8-4143-a47e-5b6f4bac8c96";\r
char *new_name = "newfolder";\r
char origin_name[256];\r
memset( origin_name, 0x00, 256 );\r
\r
- ret = minfo_get_cluster_name_by_id(cluster_uuid, origin_name, 256); \r
+ ret = minfo_get_cluster_name_by_id(handle, cluster_uuid, origin_name, 256); \r
if (ret < MB_SVC_ERROR_NONE)\r
{\r
dts_fail(API_NAME, "unable to get a cluster name. error code->%d", ret);\r
}\r
\r
- ret = minfo_update_cluster_name(cluster_uuid,new_name);\r
+ ret = minfo_update_cluster_name(handle, cluster_uuid,new_name);\r
\r
if (ret < MB_SVC_ERROR_NONE)\r
{\r
dts_fail(API_NAME, "unable to get a cluster name. error code->%d", ret);\r
}\r
\r
- ret = minfo_update_cluster_name(cluster_uuid, origin_name);\r
+ ret = minfo_update_cluster_name(handle, cluster_uuid, origin_name);\r
\r
if (ret < MB_SVC_ERROR_NONE)\r
{\r
const char *cluster_uuid = NULL;\r
char *new_name = NULL; /*= "newfolder";*/\r
\r
- ret = minfo_update_cluster_name(cluster_uuid, new_name);\r
+ ret = minfo_update_cluster_name(handle, cluster_uuid, new_name);\r
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Update a cluster name should be failed because of the new_name parameter NULL.");\r
\r
}\r
{
int ret = -1;
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";
int favorite = 0;
- ret = minfo_update_media_favorite(media_uuid, favorite);
+ ret = minfo_update_media_favorite(handle, media_uuid, favorite);
dts_check_ge(API_NAME, ret, MB_SVC_ERROR_NONE, "unable to update favorite field for media file. error code->%d", ret);
}
const char *media_uuid = NULL;
int favorite = 2;
- ret = minfo_update_media_favorite(media_uuid, favorite);
+ ret = minfo_update_media_favorite(handle, media_uuid, favorite);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "update favorite field for media file should be failed because of the media_id parameter -1.");
}
void utc_minfo_update_media_favorite_func_01()\r
{\r
int ret = -1;\r
- const char *media_uuid = "12ca468c-994d-f62c-7229-a361c3a6c2a1";\r
+ const char *media_uuid = "aa33f347-988b-41f4-8a53-9df24ea86bc4";\r
int favorite_level = 1;\r
\r
- ret = minfo_update_media_favorite(media_uuid, favorite_level);\r
+ ret = minfo_update_media_favorite(handle, media_uuid, favorite_level);\r
\r
if (ret < MB_SVC_ERROR_NONE)\r
{\r
dts_fail(API_NAME, "unable to update 'favorite' feild of a media content in media table. error code->%d", ret);\r
}\r
\r
- ret = minfo_update_media_favorite(media_uuid, 0);\r
+ ret = minfo_update_media_favorite(handle, media_uuid, 0);\r
\r
if (ret < MB_SVC_ERROR_NONE)\r
{\r
const char *media_uuid = NULL;\r
int favorite_level = 1;\r
\r
- ret = minfo_update_media_favorite(media_uuid, favorite_level);\r
+ ret = minfo_update_media_favorite(handle, media_uuid, favorite_level);\r
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE, "update 'favorite' feild of a media content in media table should be failed because of the new_name NULL.");\r
}\r
void utc_minfo_update_media_name_func_01()
{
int ret = -1;
- char *file_url = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+ char *file_url = "/opt/media/Images/Wallpapers/Home_default.jpg";
char origin_name[256];
- char *new_name = "Home_01.png";
+ char *new_name = "Home_01.jpg";
Mitem* item = NULL;
memset( origin_name, 0x00, 256 );
- ret = minfo_get_item( file_url, &item );
+ ret = minfo_get_item(handle, file_url, &item );
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
if( item ) {
strncpy( origin_name, item->display_name, sizeof( origin_name ) );
- ret = minfo_update_media_name(item->uuid, new_name);
+ ret = minfo_update_media_name(handle, item->uuid, new_name);
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to Rename a media content from media table. error code->%d", ret);
}
- ret = minfo_update_media_name(item->uuid, origin_name);
+ ret = minfo_update_media_name(handle, item->uuid, origin_name);
if (ret < MB_SVC_ERROR_NONE)
{
{
int ret = -1;
const char *media_uuid = NULL;
- char *new_name = NULL;/*= "Home_01.png";*/
+ char *new_name = NULL;/*= "Home_01.jpg";*/
- ret = minfo_update_media_name(media_uuid, new_name);
+ ret = minfo_update_media_name(handle, media_uuid, new_name);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"Rename a media content from media table should be failed because of the new_name NULL.");
}
void utc_minfo_update_video_meta_info_int_func_01()
{
int ret = -1;
- char *file_url = "/opt/media/Images and videos/My video clips/Helicopter.mp4";
+ char *file_url = "/opt/media/Videos/Helicopter.mp4";
char origin_name[256];
Mitem* item = NULL;
memset( origin_name, 0x00, 256 );
- ret = minfo_get_item( file_url, &item );
+ ret = minfo_get_item(handle, file_url, &item);
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to get a media content from media table. error code->%d", ret);
if( item ) {
strncpy( origin_name, item->display_name, sizeof( origin_name ) );
- ret = minfo_update_video_meta_info_int(item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 3000);
+ ret = minfo_update_video_meta_info_int(handle, item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 3000);
if (ret < MB_SVC_ERROR_NONE)
{
dts_fail(API_NAME, "unable to update a media content from media table. error code->%d", ret);
}
- ret = minfo_update_video_meta_info_int(item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 0);
+ ret = minfo_update_video_meta_info_int(handle, item->uuid, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, 0);
if (ret < MB_SVC_ERROR_NONE)
{
const char *media_uuid = NULL;
minfo_video_meta_field_t meta_field = MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED;
- ret = minfo_update_video_meta_info_int(media_uuid, meta_field, 3000);
+ ret = minfo_update_video_meta_info_int(handle, media_uuid, meta_field, 3000);
dts_check_lt(API_NAME, ret, MB_SVC_ERROR_NONE,"update a media content from media table should be failed because of the new_name NULL.");
}
* @date 2010-10-13
*/
-#ifndef __UTS_MINFO_SVC_COMMON_H_
-#define __UTS_MINFO_SVC_COMMON_H_
+#ifndef __UTS_VISUAL_SVC_COMMON_H_
+#define __UTS_VISUAL_SVC_COMMON_H_
#include <media-svc.h>
+#include <visual-svc.h>
#include <string.h>
#include <tet_api.h>
#include <unistd.h>
#define MAX_STRING_LEN 256
#define UTC_MM_LOG(fmt, args...) tet_printf("[%s(L%d)]:"fmt"\n", __FUNCTION__, __LINE__, ##args)
-#define API_NAME "libmedia-info"
+#define API_NAME "libmedia-service"
-#define UTC_MINFO_INIT() \
+MediaSvcHandle *handle;
+
+#define UTC_MEDIA_SVC_CONNECT() \
do \
{ \
int ret = 0; \
- ret = minfo_init(); \
+ ret = media_svc_connect(&handle); \
if (ret < MB_SVC_ERROR_NONE) \
{ \
- UTC_MM_LOG( "unable to open media db. error code->%d", ret); \
+ UTC_MM_LOG( "unable to connect to media db. error code->%d", ret); \
tet_result(TET_FAIL); \
return; \
} \
} \
while(0);
-#define UTC_MINFO_FINALIZE() \
+#define UTC_MEDIA_SVC_DISCONNECT() \
do \
{ \
int ret = 0; \
- ret = minfo_finalize(); \
+ ret = media_svc_disconnect(handle); \
if (ret < MB_SVC_ERROR_NONE) \
{ \
- UTC_MM_LOG( "unable to close media db. error code->%d", ret); \
+ UTC_MM_LOG( "unable to disconnect. error code->%d", ret); \
tet_result(TET_FAIL); \
return; \
} \
void startup()
{
- UTC_MINFO_INIT()
+ UTC_MEDIA_SVC_CONNECT()
}
void cleanup()
{
- UTC_MINFO_FINALIZE()
+ UTC_MEDIA_SVC_DISCONNECT()
}
-#endif //__UTS_MINFO_SVC_COMMON_H_
+#endif //__UTS_VISUAL_SVC_COMMON_H_
+libmedia-service (0.2.0-3) unstable; urgency=low
+
+ * Change that makes user managing db handle
+ * Add DB field : size in visual_media, genre in video_meta
+ * Code cleanup and fix some bugs
+ * Git : pkgs/l/libmedia-service
+ * Tag : libmedia-service_0.2.0-3
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 10 Feb 2011 17:30:00 +0900
+
libmedia-service (0.2.0-2) unstable; urgency=low
* Remove libmedia-thumbnail dependancy
#define _AUDIO_SVC_H_
#include <stddef.h>
+#include "media-svc-types.h"
#include "audio-svc-types.h"
+#include "audio-svc-error.h"
#ifdef __cplusplus
extern "C" {
/**
- * audio_svc_open:\n
- * Open audio service library. This is the function that an user who wants to use music-service calls first.
- * This function connects with the music database and initialize efreet mime libary.
- *
- * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
- * Please refer 'audio-svc-types.h' to know the exact meaning of the error.
- * @see audio_svc_close
- * @pre None.
- * @post call audio_svc_close() to close music database
- * @remark The database name is "/opt/dbspace/.music.db".
- * @par example
- * @code
-
-#include <audio-svc.h>
-
-void open_music_db()
-{
- int ret = AUDIO_SVC_ERROR_NONE;
- // open music database
- ret = audio_svc_open();
- // open failed
- if (ret < 0)
- {
- printf( "Cannot open music db. error code->%d", ret);
- return;
- }
-
- return;
-}
-
- * @endcode
- */
-int audio_svc_open(void);
-
-
-/**
- * audio_svc_close:\n
- * Close audio service library. This is the function need to call before close the application.
- * This function disconnects with the music database and shutdown the efreet mime libary.
- *
- * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
- * Please refer 'audio-svc-types.h' to know the exact meaning of the error.
- * @see audio_svc_open
- * @pre music database already is opened.
- * @post None
- * @remark memory free before you call this function to close database.
- * @par example
- * @code
-
-#include <audio-svc.h>
-
-void close_music_db()
-{
- int ret = AUDIO_SVC_ERROR_NONE;
- // close music database
- ret = audio_svc_close();
- // close failed
- if (ret < 0)
- {
- printf( "unable to close music db. error code->%d", ret);
- return;
- }
-
- return;
-}
-
- * @endcode
- */
-int audio_svc_close(void);
-
-
-/**
* audio_svc_create_table:\n
* Create the tables in music database. File manager service need to call this function before it register media data into
* music database. In all music database consists of 5 tables, music table for Phone tracks, music table for MMC tracks,
#include <audio-svc.h>
-void create_music_table()
+void create_music_table(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
// create muisc tables of phone type
- ret = audio_svc_create_table();
+ ret = audio_svc_create_table(db_handle);
if (ret < 0)
{
printf( "unable to create table. error code->%d", ret);
* @endcode
*/
-int audio_svc_create_table(void);
+int audio_svc_create_table(MediaSvcHandle *handle);
/**
* audio_svc_set_db_valid:\n
#include <audio-svc.h>
-void set_db_valid(bool valid)
+void set_db_valid(MediaSvcHandle *db_handle, bool valid)
{
int ret = AUDIO_SVC_ERROR_NONE;
//set the validation of tracks in MMC storage in db.
- ret = audio_svc_set_db_valid(AUDIO_SVC_STORAGE_MMC, valid);
+ ret = audio_svc_set_db_valid(db_handle, AUDIO_SVC_STORAGE_MMC, valid);
if (ret < 0)
{
printf( "failed to set db invalid. error code->%d", ret);
* @endcode
*/
-int audio_svc_set_db_valid(audio_svc_storage_type_e storage_type, int valid);
+int audio_svc_set_db_valid(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type, int valid);
/**
* audio_svc_delete_all:\n
#include <audio-svc.h>
-void delete_all()
+void delete_all(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
// delete all the tracks in phone storage.
- ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);
+ ret = audio_svc_delete_all(db_handle, AUDIO_SVC_STORAGE_PHONE);
if (ret < 0)
{
printf( "failed to delete phone storage. error code->%d", ret);
* @endcode
*/
-int audio_svc_delete_all(audio_svc_storage_type_e storage_type);
+int audio_svc_delete_all(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type);
/** @} */
#include <audio-svc.h>
- void get_group_count()
+ void get_group_count(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
// count the groups by artist
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ARTIST, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get groups. error code->%d", ret);
* @endcode
*/
-int audio_svc_count_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);
+int audio_svc_count_group_item(MediaSvcHandle *handle, audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);
/**
#include <audio-svc.h>
-void get_groups()
+void get_groups(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
//count the albms with name "Unplugged"
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of groups. error code->%d", ret);
if(count > 0)
{
// allocate the result records with count
- ret = audio_svc_group_item_new(&handle, count);
+ ret = audio_svc_group_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
return;
}
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, ret, handle);
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, ret, audio_handle);
if (ret < 0)
{
printf( "failed to get groups. error code->%d", ret);
}
- audio_svc_group_item_free(handle);
+ audio_svc_group_item_free(audio_handle);
}
else
{
* @endcode
*/
-int audio_svc_get_group_item(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, AudioHandleType *result_records);
+int audio_svc_get_group_item(MediaSvcHandle *handle, audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, AudioHandleType *result_records);
/**
void group_item_new()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//allocate the memory of type group item with count
- ret = audio_svc_group_item_new(&handle, count);
+ ret = audio_svc_group_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
void group_item_free()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//allocate the memory of type group item with count
- ret = audio_svc_group_item_new(&handle, count);
+ ret = audio_svc_group_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free the list item memory.
- ret = audio_svc_group_item_free(handle);
+ ret = audio_svc_group_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_group_item_get_value()
+void get_group_item_get_value(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of groups. error code->%d", ret);
if(count > 0)
{
// allocate the result records with count
- ret = audio_svc_group_item_new(&handle, count);
+ ret = audio_svc_group_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
return;
}
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, handle);
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, audio_handle);
if (ret < 0)
{
printf( "failed to get groups. error code->%d", ret);
- audio_svc_group_item_free(handle);
+ audio_svc_group_item_free(audio_handle);
return;
}
}
if (ret < 0)
{
printf( "failed to get group items. error code->%d", ret);
- audio_svc_group_item_free(handle);
+ audio_svc_group_item_free(audio_handle);
return;
}
}
- ret = audio_svc_group_item_free(handle);
+ ret = audio_svc_group_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_group_item()
+void get_group_item(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
AudioHandleType *item = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of groups. error code->%d", ret);
if(count > 0)
{
// allocate the result records with count
- ret = audio_svc_group_item_new(&handle, count);
+ ret = audio_svc_group_item_new(&audio_handle, count);
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, handle);
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, "Unplugged", "", "", "", 0, count, audio_handle);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
if (ret < 0)
{
printf( "failed to get groups. error code->%d", ret);
- audio_svc_group_item_free(handle);
+ audio_svc_group_item_free(audio_handle);
return;
}
}
return;
}
- ret = audio_svc_group_item_get(handle,0, &item);
+ ret = audio_svc_group_item_get(audio_handle,0, &item);
if (ret < 0)
{
printf( "failed to get group item. error code->%d", ret);
return;
}
- ret = audio_svc_group_item_free(handle);
+ ret = audio_svc_group_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_item_count()
+void get_item_count(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
// get the count of all tracks in db.
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
* @endcode
*/
-int audio_svc_count_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);
+int audio_svc_count_list_item(MediaSvcHandle *handle, audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);
/**
#include <audio-svc.h>
-void get_track_item()
+void get_track_item(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = -1;
// get the count of all tracks
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
if(count > 0)
{
// allocate result records
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
// get items
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, ret, handle);
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", 0, ret, audio_handle);
if (ret < 0)
{
printf( "failed to get items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
}
else
{
* @endcode
*/
-int audio_svc_get_list_item(audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *track);
+int audio_svc_get_list_item(MediaSvcHandle *handle, audio_svc_track_type_e item_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *track);
/**
void list_item_new()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//allocate the memory of type list item with count
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
void list_item_free()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//allocate the memory of type list item with count
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free the list item memory.
- ret = audio_svc_list_item_free(handle);
+ ret = audio_svc_list_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_list_item_get_value()
+void get_list_item_get_value(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
return;
}
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get the all track items.
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,
NULL, //type_string,
NULL, //type_string2,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows,
- handle
+ audio_handle
);
if (ret < 0)
{
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
int duration = 0;
int size = 0;
- ret = audio_svc_list_item_get_val(handle, i ,
+ ret = audio_svc_list_item_get_val(audio_handle, i ,
AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size,
AUDIO_SVC_LIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
AUDIO_SVC_LIST_ITEM_TITLE, &title, &size,
if (ret < 0)
{
printf( "failed to get list items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
}
- ret = audio_svc_list_item_free(handle);
+ ret = audio_svc_list_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_svc_item()
+void get_svc_item(MediaSvcHandle *db_handle)
{
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
AudioHandleType *item = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
int count = 0;
int i = 0
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
return;
}
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get the all tracks item.
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,
NULL, //type_string,
NULL, //type_string2,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows,
- handle
+ audio_handle
);
if (ret < 0)
{
printf( "failed to get items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
char *audio_id = NULL;
int size = 0;
//get the list item with index "i"
- ret = audio_svc_list_item_get(handle, i, &item);
+ ret = audio_svc_list_item_get(audio_handle, i, &item);
if (ret < 0)
{
printf( "failed to get list items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
if (ret < 0)
{
printf( "failed to get list items value. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
}
void new_svc_item()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
//create the svc item object.
- ret = audio_svc_item_new(&handle);
+ ret = audio_svc_item_new(&audio_handle);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
void free_svc_item()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
//create svc item object, object number is count.
- ret = audio_svc_item_new(&handle);
+ ret = audio_svc_item_new(&audio_handle);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free the svc item object.
- ret = audio_svc_item_free(handle);
+ ret = audio_svc_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_svc_item_value()
+void get_svc_item_value(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType*handle = NULL;
+ AudioHandleType *audio_handle = NULL;
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
return;
}
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get all tracks from db.
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,
NULL, //type_string,
NULL, //type_string2,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //count,
- handle
+ audio_handle
);
if (ret < 0)
{
printf( "failed to get items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
int size = 0;
char *audio_id = NULL, *title = NULL, *album = NULL, *artist = NULL, *thumbname = NULL;
//get the track audio_id with index "i" in handle array.
- ret = audio_svc_list_item_get_val(handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+ ret = audio_svc_list_item_get_val(audio_handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
if (ret < 0)
{
printf( "failed to get list items. error code->%d", ret);
audio_svc_item_free(item);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
- ret = audio_svc_get_item_by_audio_id(audio_id, item);
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, item);
if (ret < 0)
{
printf( "failed to get items. error code->%d", ret);
audio_svc_item_free(item);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
{
printf( "failed to get item value. error code->%d", ret);
audio_svc_item_free(item);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
}
return;
}
- ret = audio_svc_list_item_free(handle);
+ ret = audio_svc_list_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
void new_search_item()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
//create the search item object.
- ret = audio_svc_search_item_new(&handle, 10);
+ ret = audio_svc_search_item_new(&audio_handle, 10);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
* @code
#include <audio-svc.h>
-void test_audio_svc_list_by_search()
+void test_audio_svc_list_by_search(MediaSvcHandle *db_handle)
{
int offset = 0, count = 10, i = 0;
const char *str = "Sa";
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
- err = audio_svc_search_item_new(&handle, count);
+ err = audio_svc_search_item_new(&audio_handle, count);
if (err < 0) {
printf("audio_svc_search_item_new failed:%d\n", err);
return err;
}
- err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+ err = audio_svc_list_by_search(db_handle, audio_handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
if (err != AUDIO_SVC_ERROR_NONE) {
mediainfo_dbg("Fail to get items : %d", err);
for (i = 0; i < count; i++) {
AudioHandleType *item = NULL;
- err = audio_svc_search_item_get(handle, i, &item);
+ err = audio_svc_search_item_get(audio_handle, i, &item);
char *audio_id = NULL, *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
int size = 0;
if (err < 0) {
}
}
- audio_svc_search_item_free(handle);
+ audio_svc_search_item_free(audio_handle);
}
void free_search_item()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
//create search item object, object number is count.
- ret = audio_svc_search_item_new(&handle, 10);
+ ret = audio_svc_search_item_new(&audio_handle, 10);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free the search item object.
- ret = audio_svc_search_item_free(handle);
+ ret = audio_svc_search_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
int audio_svc_search_item_free(AudioHandleType *record);
-int audio_svc_insert_item_start(int data_cnt);
-int audio_svc_insert_item_end(void);
+int audio_svc_insert_item_start(MediaSvcHandle *handle, int data_cnt);
+int audio_svc_insert_item_end(MediaSvcHandle *handle);
/**
* audio_svc_insert_item:\n
* Register music track into DB. The "Category" property is defined by file manager service, and Only
* "MUSIC" type tracks can be listed in music app.
* This function extract the metadata of track then insert it into the database.
+ * You can use this API with audio_svc_insert_item_start and audio_svc_insert_item_end
+ * when you try to insert lots of items to DB to enhance performance.
*
* @param[in] storage_type Information for storage type
* @param[in] path Information for file path
* @param[in] category Information for file category, defined by file manager.
* @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
* Please refer 'audio-svc-error.h' to know the exact meaning of the error.
- * @see None
+ * @see audio_svc_insert_item_start, audio_svc_insert_item_end, audio_svc_insert_item_immediately
+ * @remark None
+ * @pre music table is already created
+ * @post None
+ * @par example
+ * @code
+
+ #include <audio-svc.h>
+
+void insert_item_to_db(MediaSvcHandle *db_handle)
+{
+ int ret = AUDIO_SVC_ERROR_NONE;
+ const char *path = "/opt/media/Sounds/Music/Layla.mp3";
+ int category = AUDIO_SVC_CATEGORY_MUSIC;
+ // insert a track into music db
+ ret = audio_svc_insert_item(db_handle, AUDIO_SVC_STORAGE_PHONE, path, category);
+
+ if (ret < 0)
+ {
+ printf( "unable to insert item, error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+int audio_svc_insert_item(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type, const char *path, audio_svc_category_type_e category);
+
+
+/**
+ * audio_svc_insert_item_immediately:\n
+ * Register music track into DB. The "Category" property is defined by file manager service, and Only
+ * "MUSIC" type tracks can be listed in music app.
+ * This function extract the metadata of track then insert it into the database.
+ * You can use this API when just insert one item to db or have to insert item to db immediately.
+ * If you shold insert lots of items to db, it's better to use audio_svc_insert_item_start, audio_svc_insert_item, audio_svc_insert_item_end
+ *
+ * @param[in] storage_type Information for storage type
+ * @param[in] path Information for file path
+ * @param[in] category Information for file category, defined by file manager.
+ * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ * Please refer 'audio-svc-error.h' to know the exact meaning of the error.
+ * @see audio_svc_insert_item
* @remark None
* @pre music table is already created
* @post None
#include <audio-svc.h>
-void insert_item_to_db()
+void insert_item_to_db(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char *path = "/opt/media/Sounds/Music/Layla.mp3";
int category = AUDIO_SVC_CATEGORY_MUSIC;
// insert a track into music db
- ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, category);
+ ret = audio_svc_insert_item(db_handle, AUDIO_SVC_STORAGE_PHONE, path, category);
if (ret < 0)
{
* @endcode
*/
-int audio_svc_insert_item(audio_svc_storage_type_e storage_type, const char *path, audio_svc_category_type_e category);
-int audio_svc_move_item_start(int data_cnt);
-int audio_svc_move_item_end(void);
+int audio_svc_insert_item_immediately(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type, const char *path, audio_svc_category_type_e category);
+
+int audio_svc_move_item_start(MediaSvcHandle *handle, int data_cnt);
+int audio_svc_move_item_end(MediaSvcHandle *handle);
/**
#include <audio-svc.h>
- void move_item()
+ void move_item(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
const char *dest_path = "/opt/media/Sounds/BeyondSamsung.mp3";
const char *src_path = "/opt/media/Sounds/Music/BeyondSamsung.mp3";
// move the track to dest path
- ret = audio_svc_move_item(storage, src_path, storage, dest_path);
+ ret = audio_svc_move_item(db_handle, storage, src_path, storage, dest_path);
if (ret < 0)
{
* @endcode
*/
-int audio_svc_move_item(audio_svc_storage_type_e src_storage, const char *src_path, audio_svc_storage_type_e dest_storage, const char *dest_path);
+int audio_svc_move_item(MediaSvcHandle *handle, audio_svc_storage_type_e src_storage, const char *src_path, audio_svc_storage_type_e dest_storage, const char *dest_path);
/**
#include <audio-svc.h>
- void delete_item_by_path()
+ void delete_item_by_path(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
// delete music item by path
- ret = audio_svc_delete_item_by_path("test.mp3");
+ ret = audio_svc_delete_item_by_path(handle, "test.mp3");
if (ret < 0)
{
printf("failed to delete item by path. error code->%d", ret);
* @endcode
*/
-int audio_svc_delete_item_by_path(const char *path);
+int audio_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path);
/**
#include <audio-svc.h>
-void delete_all()
+void delete_all(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
audio_svc_storage_type_e storage = AUDIO_SVC_STORAGE_PHONE;
// delete all invalid item in phone storage.
- ret = audio_svc_delete_invalid_items(storage);
+ ret = audio_svc_delete_invalid_items(db_handle, storage);
if (ret < 0)
{
printf( "failed to delete invalid item. error code->%d", ret);
* @endcode
*/
-int audio_svc_delete_invalid_items(audio_svc_storage_type_e storage);
+int audio_svc_delete_invalid_items(MediaSvcHandle *handle, audio_svc_storage_type_e storage);
-int audio_svc_set_item_valid_start(int data_cnt);
-int audio_svc_set_item_valid_end(void);
+int audio_svc_set_item_valid_start(MediaSvcHandle *handle, int data_cnt);
+int audio_svc_set_item_valid_end(MediaSvcHandle *handle);
/**
* audio_svc_set_item_valid:\n
#include <audio-svc.h>
-void set_item_valid()
+void set_item_valid(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
//set the track with "audio_id" in MMC storage to be valid.
- ret = audio_svc_set_item_valid(test_path, true);
+ ret = audio_svc_set_item_valid(db_handle, test_path, true);
if (ret < 0)
{
printf( "failed to set item valid. error code->%d", ret);
* @endcode
*/
-int audio_svc_set_item_valid(const char *path, int valid);
+int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid);
/**
#include <audio-svc.h>
- void get_item_by_audio_id()
+ void get_item_by_audio_id(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
char audio_id[AUDIO_SVC_UUID_SIZE+1] = "550e8400-e29b-41d4-a716-446655440000";
- ret = audio_svc_item_new(&handle);
+ ret = audio_svc_item_new(&audio_handle);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
// retrieve the music item by audio_id.
- ret = audio_svc_get_item_by_audio_id(audio_id, handle);
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, audio_handle);
if (ret < 0)
{
printf("failed to get item by audio_id. error code->%d", ret);
- audio_svc_item_free(handle);
+ audio_svc_item_free(audio_handle);
return;
}
//free the music item
- ret = audio_svc_item_free(handle);
+ ret = audio_svc_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_item_by_audio_id(const char *audio_id, AudioHandleType *item_handle);
+int audio_svc_get_item_by_audio_id(MediaSvcHandle *handle, const char *audio_id, AudioHandleType *item_handle);
/**
#include <audio-svc.h>
-void get_item_by_path()
+void get_item_by_path(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char *path = "/opt/media/Sounds/Music/Layla.mp3";
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
- ret = audio_svc_item_new(&handle);
+ ret = audio_svc_item_new(&audio_handle);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
// retrieve the music item by file path.
- ret = audio_svc_get_item_by_path(path, handle);
+ ret = audio_svc_get_item_by_path(db_handle, path, audio_handle);
if (ret < 0)
{
printf("failed to get item by path. error code->%d", ret);
- audio_svc_item_free(handle);
+ audio_svc_item_free(audio_handle);
return;
}
//free the music item
- ret = audio_svc_item_free(handle);
+ ret = audio_svc_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_item_by_path(const char *path, AudioHandleType *item_handle);
+int audio_svc_get_item_by_path(MediaSvcHandle *handle, const char *path, AudioHandleType *item_handle);
/**
#include <audio-svc.h>
-void check_item_Exist()
+void check_item_Exist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char *path = "/opt/media/Sounds/Music/The Last Laugh.mp3";
//check item exist
- ret = audio_svc_check_item_exist(path);
+ ret = audio_svc_check_item_exist(db_handle, path);
if (ret < 0)
{
printf("Item not found");
* @endcode
*/
-int audio_svc_check_item_exist(const char *path);
+int audio_svc_check_item_exist(MediaSvcHandle *handle, const char *path);
/**
*
#include <audio-svc.h>
-char * get_path_by_audio_id (const char *audio_id)
+char * get_path_by_audio_id (MediaSvcHandle *db_handle, const char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
char pathname[AUDIO_SVC_PATHNAME_SIZE] = {0,};
//retrieve the file path by track audio_id.
- ret = audio_svc_get_path_by_audio_id(audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);
+ ret = audio_svc_get_path_by_audio_id(db_handle, audio_id, pathname, AUDIO_SVC_PATHNAME_SIZE);
if (ret < 0)
{
printf( "failed to get path. error code->%d", ret);
}
* @endcode
*/
-int audio_svc_get_path_by_audio_id(const char *audio_id, char *path, size_t max_path_length);
+int audio_svc_get_path_by_audio_id(MediaSvcHandle *handle, const char *audio_id, char *path, size_t max_path_length);
/**
*
#include <audio-svc.h>
-int get_audio_id_by_path ()
+int get_audio_id_by_path (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
char audio_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
//retrieve the file path by track audio_id.
- ret = audio_svc_get_audio_id_by_path(test_path, audio_id, AUDIO_SVC_UUID_SIZE);
+ ret = audio_svc_get_audio_id_by_path(db_handle, test_path, audio_id, AUDIO_SVC_UUID_SIZE);
if (ret < 0)
{
printf( "failed to get audio_id. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_audio_id_by_path(const char *path, char *audio_id, size_t max_audio_id_length);
+int audio_svc_get_audio_id_by_path(MediaSvcHandle *handle, const char *path, char *audio_id, size_t max_audio_id_length);
/**
* audio_svc_get_thumbnail_path_by_path:\n
*
#include <audio-svc.h>
-int get_thumbnail_path_by_path ()
+int get_thumbnail_path_by_path (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
const char * test_path = "/opt/media/Sounds/Music/Layla.mp3";
char thumb_path[AUDIO_SVC_PATHNAME_SIZE] = {0};
//retrieve the thumbnail path by track path.
- ret = audio_svc_get_thumbnail_path_by_path(test_path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
+ ret = audio_svc_get_thumbnail_path_by_path(db_handle, test_path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
if (ret < 0)
{
printf( "failed to get thumbnail_path. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path, size_t max_thumb_path_length);
+int audio_svc_get_thumbnail_path_by_path(MediaSvcHandle *handle, const char *path, char *thumb_path, size_t max_thumb_path_length);
/**
#include <audio-svc.h>
-void update_svc_item()
+void update_svc_item(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 0;
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
return;
}
- ret = audio_svc_list_item_new(&handle, count);
+ ret = audio_svc_list_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get all tracks from db.
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,
NULL, //type_string,
NULL, //type_string2,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //count,
- handle
+ audio_handle
);
if (ret < 0)
{
printf( "failed to get service list items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
{
char *audio_id = NULL;
int size = 0;
- ret = audio_svc_list_item_get_val(handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
+ ret = audio_svc_list_item_get_val(audio_handle, i, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
if (ret < 0)
{
printf( "failed to get list items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
- ret = audio_svc_update_item_metadata(audio_id,
+ ret = audio_svc_update_item_metadata(db_handle, audio_id,
AUDIO_SVC_TRACK_DATA_PLAYED_COUNT, 5,
AUDIO_SVC_TRACK_DATA_PLAYED_TIME, 5,
AUDIO_SVC_TRACK_DATA_ADDED_TIME, 5,
if (ret < 0)
{
printf( "failed to update items. error code->%d", ret);
- audio_svc_list_item_free(handle);
+ audio_svc_list_item_free(audio_handle);
return;
}
}
- ret = audio_svc_list_item_free(handle);
+ ret = audio_svc_list_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
* @endcode
*/
-int audio_svc_update_item_metadata(const char *audio_id, audio_svc_track_data_type_e first_field_name, ...);
+int audio_svc_update_item_metadata(MediaSvcHandle *handle, const char *audio_id, audio_svc_track_data_type_e first_field_name, ...);
/**
#include <audio-svc.h>
void
-refresh_drm_metadata()
+refresh_drm_metadata(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
- ret = audio_svc_refresh_metadata(test_audio_id);
+ ret = audio_svc_refresh_metadata(db_handle, test_audio_id);
if (ret < 0)
{
printf( "failed to refresh metadata. error code->%d", ret);
* @endcode
*/
-int audio_svc_refresh_metadata(const char *audio_id);
+int audio_svc_refresh_metadata(MediaSvcHandle *handle, const char *audio_id);
/** @} */
#include <audio-svc.h>
-void get_playlist_count()
+void get_playlist_count(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
// get the count of all playlist in db.
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlists. error code->%d", ret);
* @endcode
*/
-int audio_svc_count_playlist(const char *filter_string, const char *filter_string2, int *count);
+int audio_svc_count_playlist(MediaSvcHandle *handle, const char *filter_string, const char *filter_string2, int *count);
/**
#include <audio-svc.h>
-void get_playlists()
+void get_playlists(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
// get the count of all playlist in db.
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlists. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
return;
}
- ret = audio_svc_get_playlist("", "", 0, count, handle);
+ ret = audio_svc_get_playlist(db_handle, "", "", 0, count, audio_handle);
if (ret < 0)
{
printf( "failed to get playlists. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
- ret = audio_svc_playlist_free(handle);
+ ret = audio_svc_playlist_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_playlist(const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlists);
+int audio_svc_get_playlist(MediaSvcHandle *handle, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlists);
/**
void new_playlist()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//create playlists
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
void free_playlist()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//create playlist object, object number is "count".
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free playlist object
- ret = audio_svc_playlist_free(handle);
+ ret = audio_svc_playlist_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_playlist_value()
+void get_playlist_value(MediaSvcHandle *db_handle)
{
- AudioHandleType*handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
int i = 0;
int count = 0;
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get all the playlists in db.
- ret = audio_svc_get_playlist(
+ ret = audio_svc_get_playlist(db_handle,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //count
- handle);
+ audio_handle);
if (ret < 0)
{
printf( "failed to get playlist. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
for (i = 0; i < count; i++) {
char *p = NULL;
- int plst_id;
+ int playlist_id = -1;
int size;
//get the playlist id and playlist name of each playlist
- ret = audio_svc_playlist_get_val(handle, i, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
+ ret = audio_svc_playlist_get_val(audio_handle, i, AUDIO_SVC_PLAYLIST_ID, &playlist_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
if (ret < 0)
{
printf( "failed to get playlist attribute value. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
}
- ret = audio_svc_playlist_free(handle);
+ ret = audio_svc_playlist_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void set_playlist_value()
+void set_playlist_value(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
char *p = NULL;
- int plst_id = 0;
+ int playlist_id = -1;
int size = AUDIO_SVC_METADATA_LEN_MAX;
int i = 0;
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get all the playlists.
- ret = audio_svc_get_playlist(
+ ret = audio_svc_get_playlist(db_handle,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows
- handle);
+ audio_handle);
if (ret < 0)
{
printf( "failed to get playlist. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
//set the name of first playlist to "playlist_test_name"
- ret = audio_svc_playlist_set_val(handle, i, AUDIO_SVC_PLAYLIST_NAME, "playlist_test_name", size, -1);
+ ret = audio_svc_playlist_set_val(audio_handle, i, AUDIO_SVC_PLAYLIST_NAME, "playlist_test_name", size, -1);
if (ret < 0)
{
printf( "failed to set playlist attribute value. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
- ret = audio_svc_playlist_free(handle);
+ ret = audio_svc_playlist_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_playlist_item()
+void get_playlist_item(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType*handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 0;
int i = 0;
- ret = audio_svc_count_playlist("", "", &count);
+ ret = audio_svc_count_playlist(db_handle, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_new(&handle, count);
+ ret = audio_svc_playlist_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
return;
}
- ret = audio_svc_get_playlist(
+ ret = audio_svc_get_playlist(db_handle,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows
- handle);
+ audio_handle);
if (ret < 0)
{
printf( "failed to get playlist. error code->%d", ret);
for (i = 0; i < count; i++) {
char *p = NULL;
- int plst_id;
- int size;
+ int playlist_id = -1;
+ int size = 0;
AudioHandleType *plst = NULL;
//get the playlist object with index "i"
- ret = audio_svc_playlist_get_item(handle, i, &plst);
+ ret = audio_svc_playlist_get_item(audio_handle, i, &plst);
if (ret < 0)
{
printf( "failed to get playlist item. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
//get the id and name of playlist object.
- ret = audio_svc_playlist_get_val(plst, 0, AUDIO_SVC_PLAYLIST_ID, &plst_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
+ ret = audio_svc_playlist_get_val(plst, 0, AUDIO_SVC_PLAYLIST_ID, &playlist_id, AUDIO_SVC_PLAYLIST_NAME, &p, &size, -1);
if (ret < 0)
{
printf( "failed to get playlist attribute value. error code->%d", ret);
- audio_svc_playlist_free(handle);
+ audio_svc_playlist_free(audio_handle);
return;
}
}
- ret = audio_svc_playlist_free(handle);
+ ret = audio_svc_playlist_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_playlist_item_count()
+void get_playlist_item_count(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
int playlist_id = 1;
// get the count of all tracks in db.
- ret = audio_svc_count_playlist_item(playlist_id, "", "", &count);
+ ret = audio_svc_count_playlist_item(db_handle, playlist_id, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist items. error code->%d", ret);
* @endcode
*/
-int audio_svc_count_playlist_item(int playlist_id, const char *filter_string, const char *filter_string2, int *count);
+int audio_svc_count_playlist_item(MediaSvcHandle *handle, int playlist_id, const char *filter_string, const char *filter_string2, int *count);
/**
#include <audio-svc.h>
-void get_track_item()
+void get_track_item(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = -1;
int playlist_id = 1;
// get the count of all tracks in db.
- ret = audio_svc_count_playlist_item(playlist_id, "", "", &count);
+ ret = audio_svc_count_playlist_item(db_handle, playlist_id, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist items. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_item_new(&handle, count);
+ ret = audio_svc_playlist_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get the playlist items.
- ret = audio_svc_get_playlist_item(plst_id,
+ ret = audio_svc_get_playlist_item(db_handle, playlist_id,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows,
- handle
+ audio_handle
);
if (ret < 0)
{
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
* @endcode
*/
-int audio_svc_get_playlist_item(int playlist_id, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlist_item);
+int audio_svc_get_playlist_item(MediaSvcHandle *handle, int playlist_id, const char *filter_string, const char *filter_string2, int offset, int rows, AudioHandleType *playlist_item);
/**
#include <audio-svc.h>
-void playlist_item_new()
+void playlist_item_new(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 0;
+ int playlist_id = 1;
- ret = audio_svc_count_playlist_item(AUDIO_SVC_TRACK_ALL, "", "", &count);
+ ret = audio_svc_count_playlist_item(db_handle, playlist_id, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of items. error code->%d", ret);
}
//allocate the memory of type list item with count
- ret = audio_svc_playlist_item_new(&handle, count);
+ ret = audio_svc_playlist_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
void playlist_item_free()
{
int ret = AUDIO_SVC_ERROR_NONE;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int count = 5;
//allocate the memory of type list item with count
- ret = audio_svc_playlist_item_new(&handle, count);
+ ret = audio_svc_playlist_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//free the list item memory.
- ret = audio_svc_playlist_item_free(handle);
+ ret = audio_svc_playlist_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_playlist_item_get_value()
+void get_playlist_item_get_value(MediaSvcHandle *db_handle)
{
int count = 0;
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = 1;
+ int playlist_id = 1;
- ret = audio_svc_count_playlist_item(plst_id, "", "", &count);
+ ret = audio_svc_count_playlist_item(db_handle, playlist_id, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist items. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_item_new(&handle, count);
+ ret = audio_svc_playlist_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get the playlist items.
- ret = audio_svc_get_playlist_item(plst_id,
+ ret = audio_svc_get_playlist_item(db_handle, playlist_id,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows,
- handle
+ audio_handle
);
if (ret < 0)
{
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
int size = 0;
int play_order = 0;
- ret = audio_svc_playlist_item_get_val(handle, i ,
+ ret = audio_svc_playlist_item_get_val(audio_handle, i ,
AUDIO_SVC_PLAYLIST_ITEM_UID, &uid,
AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID, &audio_id, &size,
AUDIO_SVC_PLAYLIST_ITEM_THUMBNAIL_PATH, &thumbname, &size,
if (ret < 0)
{
printf( "failed to get playlist items. error code->%d", ret);
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
}
- ret = audio_svc_playlist_item_free(handle);
+ ret = audio_svc_playlist_item_free(audio_handle);
if (ret < 0)
{
printf( "failed to free handle. error code->%d", ret);
#include <audio-svc.h>
-void get_playlist_item()
+void get_playlist_item(MediaSvcHandle *db_handle)
{
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
AudioHandleType *item = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
int count = 0;
- int i = 0
+ int i = 0;
+ int playlist_id = 1;
- ret = audio_svc_count_playlist_item(plst_id, "", "", &count);
+ ret = audio_svc_count_playlist_item(db_handle, playlist_id, "", "", &count);
if (ret < 0)
{
printf( "failed to get count of playlist items. error code->%d", ret);
return;
}
- ret = audio_svc_playlist_item_new(&handle, count);
+ ret = audio_svc_playlist_item_new(&audio_handle, count);
if (ret < 0)
{
printf( "failed to allocate handle. error code->%d", ret);
}
//get the playlist items.
- ret = audio_svc_get_playlist_item(plst_id,
+ ret = audio_svc_get_playlist_item(db_handle, playlist_id,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
count, //rows,
- handle
+ audio_handle
);
if (ret < 0)
{
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
char *audio_id = NULL;
int size = 0;
//get the playlist item with index "i"
- ret = audio_svc_playlist_item_get(handle, i, &item);
+ ret = audio_svc_playlist_item_get(audio_handle, i, &item);
if (ret < 0)
{
printf( "failed to get playlistlist items. error code->%d", ret);
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
if (ret < 0)
{
printf( "failed to get playlist items value. error code->%d", ret);
- audio_svc_playlist_item_free(handle);
+ audio_svc_playlist_item_free(audio_handle);
return;
}
}
#include <audio-svc.h>
- void add_playlist()
+ void add_playlist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
// add playlist with name "plst_test_001"
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
return;
}
// printf the playlist index
- printf("playlist index is %d", plst_id);
+ printf("playlist index is %d", playlist_id);
return;
}
* @endcode
*/
-int audio_svc_add_playlist(const char *playlist_name, int *playlist_id);
+int audio_svc_add_playlist(MediaSvcHandle *handle, const char *playlist_name, int *playlist_id);
/**
#include <audio-svc.h>
-void delete_playlist()
+void delete_playlist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
//append a playlist with name "plst_test_001" into db.
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
printf( "failed to add playlist. error code->%d", ret);
}
//delete the playlist "plst_test_001"
- ret = audio_svc_delete_playlist(plst_id);
+ ret = audio_svc_delete_playlist(db_handle, playlist_id);
if (ret < 0)
{
printf( "failed to delete playlist. error code->%d", ret);
* @endcode
*/
-int audio_svc_delete_playlist(int playlist_id);
+int audio_svc_delete_playlist(MediaSvcHandle *handle, int playlist_id);
/**
#include <audio-svc.h>
-void add_item_to_playlist()
+void add_item_to_playlist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
// append a playlist with name "plst_test_001"
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
printf( "failed to add playlist. error code->%d", ret);
}
// append a track with test_audio_id into playlist "plst_test_001"
- ret = audio_svc_add_item_to_playlist(plst_id, test_audio_id);
+ ret = audio_svc_add_item_to_playlist(db_handle, playlist_id, test_audio_id);
if (ret < 0)
{
printf( "failed to add item to playlist. error code->%d", ret);
* @endcode
*/
-int audio_svc_add_item_to_playlist(int playlist_id, const char *audio_id);
+int audio_svc_add_item_to_playlist(MediaSvcHandle *handle, int playlist_id, const char *audio_id);
/**
#include <audio-svc.h>
- void remove_item_from_playlist()
+ void remove_item_from_playlist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
int test_uid = 50;
//append playlist "plst_test_001" into db.
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
printf( "failed to add playlist. error code->%d", ret);
}
//remove music item with uid "50" from playlist "plst_test_001"
- ret = audio_svc_remove_item_from_playlist_by_uid(plst_id, test_uid);
+ ret = audio_svc_remove_item_from_playlist_by_uid(db_handle, playlist_id, test_uid);
if (ret < 0)
{
printf( "failed to remove item to playlist. error code->%d", ret);
* @endcode
*/
-int audio_svc_remove_item_from_playlist_by_uid(int playlist_id, int uid);
+int audio_svc_remove_item_from_playlist_by_uid(MediaSvcHandle *handle, int playlist_id, int uid);
/**
#include <audio-svc.h>
- void remove_item_from_playlist()
+ void remove_item_from_playlist(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
char * test_audio_id = "550e8400-e29b-41d4-a716-446655440000";
//append playlist "plst_test_001" into db.
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
printf( "failed to add playlist. error code->%d", ret);
}
//remove music item with uid "50" from playlist "plst_test_001"
- ret = audio_svc_remove_item_from_playlist_by_audio_id(plst_id, test_audio_id);
+ ret = audio_svc_remove_item_from_playlist_by_audio_id(db_handle, playlist_id, test_audio_id);
if (ret < 0)
{
printf( "failed to remove item to playlist. error code->%d", ret);
* @endcode
*/
-int audio_svc_remove_item_from_playlist_by_audio_id(int playlist_id, const char *audio_id);
+int audio_svc_remove_item_from_playlist_by_audio_id(MediaSvcHandle *handle, int playlist_id, const char *audio_id);
/**
#include <audio-svc.h>
-gchar* get_new_playlist_name (void)
+gchar* get_new_playlist_name (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
char unique_name[24] = "\0";
//get a unique playlist name, based on "My playlist"
- ret = audio_svc_get_unique_playlist_name("My playlist", unique_name, 24);
+ ret = audio_svc_get_unique_playlist_name(db_handle, "My playlist", unique_name, 24);
if (ret < 0)
{
printf( "failed to get unique playlist name. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_unique_playlist_name(const char* orig_name, char *unique_name, size_t max_unique_name_length);
+int audio_svc_get_unique_playlist_name(MediaSvcHandle *handle, const char* orig_name, char *unique_name, size_t max_unique_name_length);
/**
*
#include <audio-svc.h>
-char * get_playlist_name_by_playlist_id (int playlist_id)
+char * get_playlist_name_by_playlist_id (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
char playlist_name[AUDIO_SVC_PATHNAME_SIZE] = {0,};
+ int playlist_id = 1;
//get the playlist name by playlist id "playlist_id"
- ret = audio_svc_get_playlist_name_by_playlist_id(playlist_id, playlist_name, AUDIO_SVC_PATHNAME_SIZE);
+ ret = audio_svc_get_playlist_name_by_playlist_id(db_handle, playlist_id, playlist_name, AUDIO_SVC_PATHNAME_SIZE);
if (ret < 0)
{
printf( "failed to get playlist name. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_playlist_name_by_playlist_id(int playlist_id, char *playlist_name, size_t max_playlist_name_length);
+int audio_svc_get_playlist_name_by_playlist_id(MediaSvcHandle *handle, int playlist_id, char *playlist_name, size_t max_playlist_name_length);
/**
#include <audio-svc.h>
-int get_playlist_id (void)
+int get_playlist_id (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int playlist_id = 0;
//get a playlist index.
- ret = audio_svc_get_playlist_id_by_playlist_name("My playlist", &playlist_id);
+ ret = audio_svc_get_playlist_id_by_playlist_name(db_handle, "My playlist", &playlist_id);
if (ret < 0)
{
printf( "failed to get playlist index. error code->%d", ret);
* @endcode
*/
-int audio_svc_get_playlist_id_by_playlist_name(const char *playlist_name, int *playlist_id);
+int audio_svc_get_playlist_id_by_playlist_name(MediaSvcHandle *handle, const char *playlist_name, int *playlist_id);
/**
#include <audio-svc.h>
void
-update_playlist_name()
+update_playlist_name(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- int plst_id = -1;
+ int playlist_id = -1;
const char *playlist_name = "plst_test_001";
//append a playlist "plst_test_001" into db.
- ret = audio_svc_add_playlist(playlist_name, &plst_id);
+ ret = audio_svc_add_playlist(db_handle, playlist_name, &playlist_id);
if (ret < 0)
{
printf( "failed to add playlist. error code->%d", ret);
}
//rename playlist name to "plst_test_002"
- ret = audio_svc_update_playlist_name(plst_id, "plst_test_002");
+ ret = audio_svc_update_playlist_name(db_handle, playlist_id, "plst_test_002");
if (ret < 0)
{
printf( "failed to update playlist name. error code->%d", ret);
* @endcode
*/
-int audio_svc_update_playlist_name(int playlist_id, const char *new_playlist_name);
+int audio_svc_update_playlist_name(MediaSvcHandle *handle, int playlist_id, const char *new_playlist_name);
/**
#include <audio-svc.h>
-void update_playlist_order()
+void update_playlist_order(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int playlist_id = 1;
int new_play_order = 5;
//update the item index in playlist
- ret = audio_svc_update_playlist_item_play_order(playlist_id, uid, new_play_order);
+ ret = audio_svc_update_playlist_item_play_order(db_handle, playlist_id, uid, new_play_order);
if (ret < 0)
{
printf( "failed to update play order. error code->%d", ret);
* @endcode
*/
-int audio_svc_update_playlist_item_play_order(int playlist_id, int uid, int new_play_order);
+int audio_svc_update_playlist_item_play_order(MediaSvcHandle *handle, int playlist_id, int uid, int new_play_order);
/**
#include <audio-svc.h>
int
-get_playlist_count(void)
+get_playlist_count(MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
const char *playlist_name = "plst_test_001";
//get the count of playlists whose name are "plst_test_001"
- ret = audio_svc_count_playlist_by_name(playlist_name, &count);
+ ret = audio_svc_count_playlist_by_name(db_handle, playlist_name, &count);
if (ret < 0)
{
printf( "failed to get count of playlist . error code->%d", ret);
* @endcode
*/
-int audio_svc_count_playlist_by_name(const char* playlist_name, int*count);
+int audio_svc_count_playlist_by_name(MediaSvcHandle *handle, const char* playlist_name, int*count);
/**
#include <audio-svc.h>
-bool check_item_exist (gint plst_id, gint key_id)
+bool check_item_exist (MediaSvcHandle *db_handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
+ int playlist_id = 1;
char *audio_id = "550e8400-e29b-41d4-a716-446655440000";
- //get the count of music track with audio_id in playlist "plst_id"
- ret = audio_svc_check_duplicate_insertion_in_playlist(plst_id, audio_id, &count);
+ //get the count of music track with audio_id in playlist "playlist_id"
+ ret = audio_svc_check_duplicate_insertion_in_playlist(db_handle, playlist_id, audio_id, &count);
if (ret < 0)
{
if(count > 0)
* @endcode
*/
-int audio_svc_check_duplicate_insertion_in_playlist(int playlist_id, const char *audio_id, int * count);
+int audio_svc_check_duplicate_insertion_in_playlist(MediaSvcHandle *handle, int playlist_id, const char *audio_id, int * count);
/**
* audio_svc_list_by_search:\n
* This function takes a variable number of arguments, the arguments format is pair of atrribute index and attribute value.
* The last parameter should be "-1", which tell the compiler that the arguments list is over.
*
- * @param[in] handle The handle for search
+ * @param[in] record The handle for search
* @param[in] order_field field to order
* Please refer 'audio-svc-types.h', and see the enum audio_svc_search_order_e
* @param[in] offset offset of list to be searched
#include <audio-svc.h>
-void test_audio_svc_list_by_search()
+void test_audio_svc_list_by_search(MediaSvcHandle *db_handle)
{
int offset = 0, count = 10, i = 0;
const char *str = "Sa";
- AudioHandleType *handle = NULL;
+ AudioHandleType *audio_handle = NULL;
- err = audio_svc_search_item_new(&handle, count);
+ err = audio_svc_search_item_new(&audio_handle, count);
if (err < 0) {
printf("audio_svc_search_item_new failed:%d\n", err);
return err;
}
- err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+ err = audio_svc_list_by_search(db_handle, audio_handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
if (err != AUDIO_SVC_ERROR_NONE) {
mediainfo_dbg("Fail to get items : %d", err);
for (i = 0; i < count; i++) {
AudioHandleType *item = NULL;
- err = audio_svc_search_item_get(handle, i, &item);
+ err = audio_svc_search_item_get(audio_handle, i, &item);
char *audio_id = NULL, *title = NULL, *artist = NULL, *pathname = NULL, *album = NULL;
int size = 0;
if (err < 0) {
}
}
- audio_svc_search_item_free(handle);
+ audio_svc_search_item_free(audio_handle);
}
* @endcode
*/
-int audio_svc_list_by_search(AudioHandleType *handle,
+int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
audio_svc_search_order_e order_field,
int offset,
int count,
*
*/
-/**
- * This file defines the error code of media service
- *
- * @file media-svc-error.h
- * @author Hyunjun Ko <zzoon.ko@samsung.com>
- * @version 1.0
- * @brief This file defines the error code of media service
- */
-/**
-* @ingroup MINFO_SVC_API
-* @defgroup MEDIA_SVC_ERROR Media service error code table
-* @{
-*/
#ifndef _MEDIA_SVC_ERROR_H_
#define _MEDIA_SVC_ERROR_H_
+/**
+ @addtogroup MEDIA_SVC
+ @{
+ * @file media-svc-error.h
+ * @brief This file defines error codes for media service.
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-//Error types definition
-#define MB_SVC_ERROR_NONE 0 /**< base */
-#define MB_SVC_ERROR_INVALID_PARAMETER -1 /**< invalid parameter(s) */
-#define MB_SVC_ERROR_INVALID_MEDIA -2 /**< invalid or unknown media */
-#define MB_SVC_ERROR_FILE_NOT_EXSITED -3 /**< file doesn't exist */
-#define MB_SVC_ERROR_DIR_NOT_EXSITED -4 /**< folder doesn't exist */
-
-#define MB_SVC_ERROR_FILE_IO -11 /**< file I/O error */
-#define MB_SVC_ERROR_OUT_OF_MEMORY -12 /**< memory allocation error*/
-
-#define MB_SVC_ERROR_CREATE_THUMBNAIL -101 /**< create thumbnail */
-#define MB_SVC_ERROR_COPY_THUMBNAIL -102 /**< copy thumbnail */
-#define MB_SVC_ERROR_MOVE_THUMBNAIL -103 /**< move thumbnail */
+ */
-#define MB_SVC_ERROR_DB_CONNECT -201 /**< connect DB error */
-#define MB_SVC_ERROR_DB_DISCONNECT -202 /**< disconnect DB error */
-#define MB_SVC_ERROR_DB_CREATE_TABLE -203 /**< create table error */
-#define MB_SVC_ERROR_DB_NO_RECORD -204 /**< No record */
-#define MB_SVC_ERROR_DB_OUT_OF_RANGE -205 /**< DB out of table records range*/
-#define MB_SVC_ERROR_DB_INTERNAL -206 /**< internal db error */
+/**
+ @defgroup MEDIA_SVC_COMMON Global data structure and error code
+ @{
-#define MB_SVC_ERROR_NOT_IMPLEMENTED -997 /**< Not implemented */
-#define MB_SVC_ERROR_INTERNAL -998 /**< internal error */
-#define MB_SVC_ERROR_UNKNOWN -999 /**< Unknown error */
+ @par
+ type definition and error code
+ */
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#define MEDIA_INFO_ERROR_NONE 0 /**< No Error */
+
+#define MEDIA_INFO_ERROR_INVALID_PARAMETER -1 /**< Invalid parameter */
+#define MEDIA_INFO_ERROR_INVALID_MEDIA -2 /**< Invalid media */
+#define MEDIA_INFO_ERROR_INVALID_FILE_FORMAT -3 /**< Invalid file format */
+#define MEDIA_INFO_ERROR_INVALID_PATH -4 /**< Invalid file path */
+#define MEDIA_INFO_ERROR_OUT_OF_MEMORY -5 /**< Out of memory */
+#define MEDIA_INFO_ERROR_OUT_OF_STORAGE -6 /**< Out of storage */
+#define MEDIA_INFO_ERROR_INSERT_FAIL -7 /**< Insert failed */
+#define MEDIA_INFO_ERROR_DRM_INSERT_FAIL -8 /**< DRM file insert failed */
+
+#define MEDIA_INFO_ERROR_ITEM_NOT_FOUND -11 /**< Item not found */
+#define MEDIA_INFO_ERROR_FILE_NOT_FOUND -12 /**< File not found */
+#define MEDIA_INFO_ERROR_APPEND_ITEM_FAILED -13 /**< Append item failed */
+#define MEDIA_INFO_ERROR_REMOVE_ITEM_FAILED -14 /**< Remove item failed */
+#define MEDIA_INFO_ERROR_GET_ITEM_FAILED -15 /**< Get item failed */
+#define MEDIA_INFO_ERROR_REMOVE_FILE_FAILED -16 /**< Remove file failed */
+#define MEDIA_INFO_ERROR_EXTRACT_FAILED -17 /**< Extract Failed */
+#define MEDIA_INFO_ERROR_MAKE_PLAYLIST_NAME_FAILED -18 /**< fail to make new playlist name */
+
+#define MEDIA_INFO_ERROR_DATABASE_CONNECT -100 /**< DB connect error */
+#define MEDIA_INFO_ERROR_DATABASE_DISCONNECT -101 /**< DB disconnect error */
+#define MEDIA_INFO_ERROR_DATABASE_QUERY -104 /**< DB query error */
+#define MEDIA_INFO_ERROR_DATABASE_TABLE_OPEN -105 /**< DB table open error */
+#define MEDIA_INFO_ERROR_DATABASE_INVALID -106 /**< DB invalid error */
+#define MEDIA_INFO_ERROR_DATABASE_INTERNAL -107 /**< DB internal error */
+
+#define MEDIA_INFO_ERROR_SOCKET_CONN -201 /**< Socket connect error */
+#define MEDIA_INFO_ERROR_SOCKET_MSG -202 /**< Socket message error */
+#define MEDIA_INFO_ERROR_SOCKET_SEND -203 /**< Socket send error */
+#define MEDIA_INFO_ERROR_SOCKET_RECEIVE -204 /**< Socket receive error */
+#define MEDIA_INFO_ERROR_SOCKET_RECEIVE_TIMEOUT -205 /**< Socket time out */
+
+#define MEDIA_INFO_ERROR_INTERNAL -998 /**< Internal error */
+#define MEDIA_INFO_ERROR_UNKNOWN -999 /**< Unknown error */
+#define MEDIA_INFO_ERROR_NOT_IMPLEMENTED -200 /**< Not implemented */
+/**
+ @}
+*/
/**
-* @}
+ @}
*/
#endif /*_MEDIA_SVC_ERROR_H_*/
-
-
-
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_SVC_TYPES_H_
+#define _MEDIA_SVC_TYPES_H_
+
+#ifndef DEPRECATED_API
+# define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+typedef void MediaSvcHandle; /**< Handle */
+
+#endif /*_MEDIA_SVC_TYPES_H_*/
*/
-/**
- * This file is main header file of media service.
- *
- * @file media-svc.h
- * @author Hyunjun Ko <zzoon.ko@samsung.com>
- * @version 1.0
- * @brief This file is main header file of media service.
+
+#ifndef _MEDIA_SVC_H_
+#define _MEDIA_SVC_H_
+
+#include "media-svc-types.h"
+#include "media-svc-error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ @defgroup MEDIA_SVC Media Information Service
+ @{
+ * @file media-svc.h
+ * @brief This file defines API's for media service.
+ * @version 1.0
*/
+/**
+ @defgroup MEDIA_SVC_API Media Database API
+ @{
-#ifndef _MEDIA_SERVICE_H_
-#define _MEDIA_SERVICE_H_
+ @par
+ manage the service database.
+ */
+#if 0
/**
- * @addtogroup MEDIA_SVC media-svc
- * @{
+ * mediainfo_open:
+ * Open media information service library. This is the function that an user who wants to use media information service calls first.
+ * This function connects to the media database.
+ *
+ * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-info-error.h' to know the exact meaning of the error.
+ * @see mediainfo_close
+ * @pre None.
+ * @post call mediainfo_close() to close the media database
+ * @remark The database name is "/opt/dbspace/.media.db".
+ * @par example
+ * @code
+
+#include <media-info.h>
+
+void open_media_db()
+{
+ int ret = MEDIA_INFO_ERROR_NONE;
+ // open media database
+ ret = mediainfo_open();
+ // open failed
+ if (ret < 0)
+ {
+ printf( "Cannot open media db. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
*/
+int mediainfo_open(void);
+/**
+ * mediainfo_close:
+ * Open media information service library. This is the function that an user who wants to finalize media information service calls before closing the application.
+ * This function disconnects to the media database.
+ *
+ * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-info-error.h' to know the exact meaning of the error.
+ * @see mediainfo_open
+ * @pre None.
+ * @post call mediainfo_open() to open the media database
+ * @remark The database name is "/opt/dbspace/.media.db".
+ * @par example
+ * @code
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+#include <media-info.h>
-#include "media-svc-error.h"
-#include "minfo-types.h"
+void close_media_db()
+{
+ int ret = MEDIA_INFO_ERROR_NONE;
+ // close media database
+ ret = mediainfo_close();
+ // close failed
+ if (ret < 0)
+ {
+ printf( "Cannot close media db. error code->%d", ret);
+ return;
+ }
-#include "minfo-api.h"
+ return;
+}
+ * @endcode
+ */
+int mediainfo_close(void);
+#endif
+/**
+ * media_svc_connect:
+ * Connect to the media database. This is the function that an user who wants to get a handle to access the media database.
+ * This function connects to the media database.
+ *
+ * @param handle [out] Handle to access database.
+ * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-info-error.h' to know the exact meaning of the error.
+ * @see media_svc_disconnect
+ * @pre None.
+ * @post call media_svc_connect to connect to the media database
+ * @remark The database name is "/opt/dbspace/.media.db".
+ * @par example
+ * @code
-#ifdef __cplusplus
+#include <media-info.h>
+
+void connect_media_db()
+{
+ int ret = MEDIA_INFO_ERROR_NONE;
+ MediaSvcHandle* my_handle = NULL;
+
+ // connect to the media database
+ ret = media_svc_connect(&my_handle);
+
+ if (ret < 0)
+ {
+ printf("Fatal error to connect DB\n");
+ return;
+ }
+
+ return;
}
-#endif /* __cplusplus */
+
+ * @endcode
+ */
+int media_svc_connect(MediaSvcHandle **handle);
+
/**
- * @}
+ * media_svc_disconnect:
+ * Disconnect to the media database. This is the function that an user who wants to disconnect the media database.
+ * This function disconnects to the media database.
+ *
+ * @param handle [out] Handle to access database.
+ * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-info-error.h' to know the exact meaning of the error.
+ * @see media_svc_connect
+ * @pre None.
+ * @post call media_svc_disconnect to disconnect to the media database
+ * @remark The database name is "/opt/dbspace/.media.db".
+ * @par example
+ * @code
+
+#include <media-info.h>
+
+void disconnect_media_db()
+{
+ int ret = MEDIA_INFO_ERROR_NONE;
+ MediaSvcHandle* my_handle = NULL;
+
+ // connect to the media database
+ ret = media_svc_connect(&my_handle);
+
+ if (ret < 0)
+ {
+ printf("Fatal error to connect DB\n");
+ return;
+ }
+
+ //
+ // Do something using my_handle
+ //
+
+
+ ret = media_svc_disconnect(my_handle);
+ if (ret < 0)
+ {
+ printf("Fatal error to disconnect DB\n");
+ }
+
+ return;
+}
+
+ * @endcode
*/
+int media_svc_disconnect(MediaSvcHandle *handle);
-#endif /*_MEDIA_SERVICE_H_*/
+/** @} */
+
+/**
+ @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*_MEDIA_SVC_H_*/
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines the error code of media service
+ *
+ * @file visual-svc-error.h
+ * @author Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version 1.0
+ * @brief This file defines the error code of media service
+ */
+
+/**
+* @ingroup VISUAL_SVC_API
+* @defgroup VISUAL_SVC_ERROR Media service error code table
+* @{
+*/
+
+#ifndef _VISUAL_SVC_ERROR_H_
+#define _VISUAL_SVC_ERROR_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+//Error types definition
+#define MB_SVC_ERROR_NONE 0 /**< base */
+#define MB_SVC_ERROR_INVALID_PARAMETER -1 /**< invalid parameter(s) */
+#define MB_SVC_ERROR_INVALID_MEDIA -2 /**< invalid or unknown media */
+#define MB_SVC_ERROR_FILE_NOT_EXSITED -3 /**< file doesn't exist */
+#define MB_SVC_ERROR_DIR_NOT_EXSITED -4 /**< folder doesn't exist */
+
+#define MB_SVC_ERROR_FILE_IO -11 /**< file I/O error */
+#define MB_SVC_ERROR_OUT_OF_MEMORY -12 /**< memory allocation error*/
+
+#define MB_SVC_ERROR_CREATE_THUMBNAIL -101 /**< create thumbnail */
+#define MB_SVC_ERROR_COPY_THUMBNAIL -102 /**< copy thumbnail */
+#define MB_SVC_ERROR_MOVE_THUMBNAIL -103 /**< move thumbnail */
+
+#define MB_SVC_ERROR_DB_CONNECT -201 /**< connect DB error */
+#define MB_SVC_ERROR_DB_DISCONNECT -202 /**< disconnect DB error */
+#define MB_SVC_ERROR_DB_CREATE_TABLE -203 /**< create table error */
+#define MB_SVC_ERROR_DB_NO_RECORD -204 /**< No record */
+#define MB_SVC_ERROR_DB_OUT_OF_RANGE -205 /**< DB out of table records range*/
+#define MB_SVC_ERROR_DB_INTERNAL -206 /**< internal db error */
+
+#define MB_SVC_ERROR_NOT_IMPLEMENTED -997 /**< Not implemented */
+#define MB_SVC_ERROR_INTERNAL -998 /**< internal error */
+#define MB_SVC_ERROR_UNKNOWN -999 /**< Unknown error */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @}
+*/
+
+#endif /*_VISUAL_SVC_ERROR_H_*/
+
+
+
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines structure for minfo part.
+ *
+ * @file visual-svc-types.h
+ * @author Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version 1.0
+ * @brief none
+ */
+
+
+ /**
+ * @ingroup VISUAL_SVC_API
+ * @defgroup VISUAL_SVC_TYPES minfo types
+ * @{
+ */
+
+#ifndef _VISUAL_SVC_TYPES_H_
+#define _VISUAL_SVC_TYPES_H_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef EXPORT_API
+# define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef DEPRECATED_API
+# define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+
+//(un)favoriate item
+#define MB_SVC_DEFAULT 0
+#define MB_SVC_FAVORITE 1 //favorite item
+
+#define MINFO_DEFAULT_GPS 1000.00
+
+
+/**
+ *@enum minfo_file_type
+ * Enumerations of minfo file type
+ */
+
+typedef enum {
+ MINFO_ITEM_NONE = 0x00000000, /**< none */
+ MINFO_ITEM_IMAGE = 0x00000001, /**< image files */
+ MINFO_ITEM_VIDEO = 0x00000002, /**< video files */
+ MINFO_ITEM_ALL = 0x00000008, /**< all the supported media types */
+}minfo_file_type;
+
+/**
+ * @enum minfo_folder_type
+ * Enumerations of folder(cluster/album) type
+ */
+typedef enum {
+ MINFO_CLUSTER_TYPE_ALL, /**< All type of media */
+ MINFO_CLUSTER_TYPE_LOCAL_ALL, /**< lcoal both phone and mmc */
+ MINFO_CLUSTER_TYPE_LOCAL_PHONE, /**< lcoal phone only */
+ MINFO_CLUSTER_TYPE_LOCAL_MMC, /**< lcoal mmc only */
+ MINFO_CLUSTER_TYPE_WEB, /**< web album */
+ MINFO_CLUSTER_TYPE_STREAMING, /**< streaming album */
+ MINFO_CLUSTER_TYPE_MAX, /**< Max value*/
+} minfo_folder_type;
+
+/**
+* @enum minfo_media_favorite_type
+* Enumerations of favorite of getting media item list.
+*/
+typedef enum{
+ MINFO_MEDIA_FAV_ALL, /**< Includes all favorite and unfavorite media */
+ MINFO_MEDIA_FAV_ONLY, /**< Includes only favorite media */
+ MINFO_MEDIA_UNFAV_ONLY, /**< Includes only unfavorite media */
+}minfo_media_favorite_type;
+
+/**
+* @enum minfo_media_sort_type
+* Enumerations of sort of getting media item list.
+*/
+typedef enum{
+ MINFO_MEDIA_SORT_BY_NONE, /**< No Sort */
+ MINFO_MEDIA_SORT_BY_NAME_DESC, /**< Sort by display name descending */
+ MINFO_MEDIA_SORT_BY_NAME_ASC, /**< Sort by display name ascending */
+ MINFO_MEDIA_SORT_BY_DATE_DESC, /**< Sort by modified_date descending */
+ MINFO_MEDIA_SORT_BY_DATE_ASC, /**< Sort by modified_date ascending */
+}minfo_media_sort_type;
+
+/**
+* @enum minfo_folder_sort_type
+* Enumerations of sort of getting folder item list.
+*/
+typedef enum{
+ MINFO_CLUSTER_SORT_BY_NONE, /**< No Sort */
+ MINFO_CLUSTER_SORT_BY_NAME_DESC, /**< Sort by display name descending */
+ MINFO_CLUSTER_SORT_BY_NAME_ASC, /**< Sort by display name ascending */
+ MINFO_CLUSTER_SORT_BY_DATE_DESC, /**< Sort by modified_date descending */
+ MINFO_CLUSTER_SORT_BY_DATE_ASC, /**< Sort by modified_date ascending */
+}minfo_folder_sort_type;
+
+/**
+* @enum minfo_store_type
+* Enumerations of store type.
+*/
+
+typedef enum
+{
+ MINFO_PHONE, /**< Stored only in phone */
+ MINFO_MMC, /**< Stored only in MMC */
+ MINFO_WEB, /**< Stored only in web album */
+ MINFO_WEB_STREAMING, /**< Stored only in web streaming album */
+ MINFO_SYSTEM, /**< Stored in ALL*/
+} minfo_store_type;
+
+/**
+ * @enum minfo_image_meta_field_t
+ * Enumerations for image_meta field name.
+ */
+typedef enum {
+ MINFO_IMAGE_META_LONGITUDE, /**< image meta longitude(double) field */
+ MINFO_IMAGE_META_LATITUDE, /**< image meta latitude(double) field */
+ MINFO_IMAGE_META_DESCRIPTION, /**< image meta description(string) field */
+ MINFO_IMAGE_META_WIDTH, /**< image meta width(int) field */
+ MINFO_IMAGE_META_HEIGHT, /**< image meta height(int) field */
+ MINFO_IMAGE_META_ORIENTATION, /**< image meta orientation(int) field */
+ MINFO_VIDEO_META_DATE_TAKEN, /**< image meta datetaken(int) field */
+} minfo_image_meta_field_t;
+
+/**
+ * @enum minfo_video_meta_field_t
+ * Enumerations for video_meta field name.
+ */
+typedef enum {
+ MINFO_VIDEO_META_ID, /**< media medta ID field */
+ MINFO_VIDEO_META_MEDIA_ID, /**< media medta ID field */
+ MINFO_VIDEO_META_ALBUM, /**< medta album field */
+ MINFO_VIDEO_META_ARTIST, /**< medta artist field */
+ MINFO_VIDEO_META_TITLE, /**< medta title field */
+ MINFO_VIDEO_META_GENRE, /**< medta genre field */
+ MINFO_VIDEO_META_DESCRIPTION, /**< medta description field */
+ MINFO_VIDEO_META_YOUTUBE_CATEGORY, /**< medta youtube cat field */
+ MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, /**< medta bookmark field */
+ MINFO_VIDEO_META_DURATION, /**< medta duration field */
+ MINFO_VIDEO_META_LONGISTUDE, /**< medta longistude field */
+ MINFO_VIDEO_META_LATITUDE, /**< medta latitude field */
+} minfo_video_meta_field_t;
+
+/**
+ * @enum minfo_search_field_t
+ * Enumerations for field to search
+ */
+typedef enum {
+ MINFO_SEARCH_BY_NAME = 0x00000001, /**< media display name field */
+ MINFO_SEARCH_BY_PATH = 0x00000002, /**< media path field */
+ MINFO_SEARCH_BY_HTTP_URL = 0x00000004, /**< media http url field */
+ MINFO_SEARCH_MAX = 0x00000008, /**< maximum */
+} minfo_search_field_t;
+
+/**
+* @struct minfo_item_filter
+* This structure defines filter of minfo item.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1,
+* so there are some limitation on start_pos and end_pos.
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+ minfo_file_type file_type; /**< Image, Video */
+ minfo_media_sort_type sort_type; /**< sort type */
+ int start_pos; /**< first item index, start from 0*/
+ int end_pos; /**< last item index */
+ bool with_meta; /**< include image_meta or video_meta */
+ int favorite; /**< favourite */
+}minfo_item_filter;
+
+/**
+* @struct minfo_cluster_filter
+* This structure defines filter of minfo cluster.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1,
+* so there are some limitation on start_pos and end_pos
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+ minfo_folder_type cluster_type; /**< Local/Web/Streaming */
+ minfo_folder_sort_type sort_type; /**< sort type */
+ int start_pos; /**< first item index, start from 0 */
+ int end_pos; /**< last item index*/
+}minfo_cluster_filter;
+
+/**
+* @struct minfo_tag_filter
+* This structure defines filter of minfo tag.
+* it assumes that there are (n) records matching filter, the valid index range is from 0 to n-1,
+* so there are some limitation on start_pos and end_pos.
+* start_pos, if equals -1, it gets all records, end_pos is meaningless,
+* start_pos it can't set to be bigger than (n-1), its valid range is 0 to (n-2).
+* end_pos, if equals -1, it gets continuous record from start_pos until last item,
+* end_pos, if bigger than n-1, it's meaningless and automatically regarded as (n-1).
+*
+*/
+
+typedef struct {
+ minfo_file_type file_type; /**< Image, Video */
+ int start_pos; /**< first item index, start from 0*/
+ int end_pos; /**< last item index */
+ bool with_meta; /**< include image_meta or video_meta */
+}minfo_tag_filter;
+
+/**
+* @struct _Mcluster
+* This structure defines _Mcluster, same with Mcluster
+*/
+
+typedef struct _Mcluster
+{
+ int gtype; /**< self-defination type */
+
+ /*< public >*/
+ //unsigned int _id; /**< cluster id */
+ char *uuid; /**< UUID */
+ char *thumb_url; /**< thumbnail full path */
+ time_t mtime; /**< modified time */
+ int type; /**< type */
+ char *display_name; /**< cluster name */
+ int count; /**< content count */
+ int sns_type; /**< web account type */
+ char *account_id; /**< web account */
+ int lock_status; /**< status for album lock */
+ char *web_album_id; /**< web album id */
+ void* _reserved; /**< reserved */
+}Mcluster;
+
+/**
+* @struct _Mvideo
+* This structure defines _Mvideo, same with Mvideo
+*/
+
+typedef struct _Mvideo
+{
+ int gtype;
+
+ char *album_name; /**< album name */
+ char *artist_name; /**< artist name */
+ char *title; /**< title */
+ char *genre; /**< genre */
+ unsigned int last_played_pos; /**< last played position */
+ unsigned int duration; /**< duration */
+ char *web_category; /**< web category */
+ GList* bookmarks; /**< bookmark info */
+ void* _reserved; /**< reserved */
+}Mvideo;
+
+/**
+* @struct _Mimage
+* This structure defines _Mimage, same with Mimage
+*/
+
+typedef struct _Mimage
+{
+ int gtype;
+
+ int orientation; /**< orientation */
+ void* _reserved; /**< reserved */
+
+}Mimage;
+
+
+/**
+* @struct _Mmeta
+* This structure defines _Mmeta, same with Mmeta
+*/
+
+typedef struct _Mmeta
+{
+ int gtype;
+
+ //int item_id; /**< media id */
+ char *media_uuid; /**< media UUID */
+ int type; /**< type */
+ char *description; /**< description */
+ double longitude; /**< longitude */
+ double latitude; /**< latitude */
+
+ int width; /**< width */
+ int height; /**< height */
+ int datetaken; /**< datetaken */
+
+ union
+ {
+ Mimage* image_info; /**< image info */
+ Mvideo* video_info; /**< video info */
+ };
+ void* _reserved; /**< reserve */
+}Mmeta;
+
+/**
+* @struct _Mitem
+* This structure defines _Mitem, same with Mitem
+*/
+
+typedef struct _Mitem
+{
+ int gtype;
+
+ //unsigned int _id; /**< item id */
+ char *uuid; /**< UUID */
+ int type; /**< file type */
+ char *thumb_url; /**< thumbnail full path */
+ char *file_url; /**< file full path */
+ time_t mtime; /**< modified time */
+ char *ext; /**< ext */
+ //unsigned int cluster_id; /**< cluster id */
+ char *cluster_uuid; /**< cluster UUID */
+ char *display_name; /**< item name */
+ int rate; /**< favorite level */
+ int size;
+ Mmeta* meta_info; /**< image or video info */
+ void *_reserved; /**< reserved */
+}Mitem;
+
+
+/**
+* @struct _Mbookmark
+* This structure defines _Mbookmark, same with Mbookmark
+*/
+typedef struct _Mbookmark
+{
+ int gtype; /**< self-defination type */
+
+ unsigned int _id; /**< bookmark id */
+ //unsigned int media_id; /**< media id */
+ char *media_uuid; /**< media UUID */
+ unsigned int position; /**< marked time */
+ char *thumb_url; /**< thumnail full path */
+}Mbookmark;
+
+/**
+* @struct _Mtag
+* This structure defines _Mtag, same with Mtag
+*/
+typedef struct _Mtag
+{
+ int gtype; /**< self-defination type */
+
+ unsigned int _id; /**< tag id */
+ //unsigned int media_id; /**< media id */
+ char *media_uuid; /**< media UUID */
+ char *tag_name; /**< tag name*/
+ int count; /**< count of media content included into a tag*/
+ void *_reserved; /**< reserved */
+}Mtag;
+
+
+typedef int (*minfo_cluster_ite_cb)( Mcluster *cluster, void *user_data );
+typedef int (*minfo_item_ite_cb)( Mitem *item, void *user_data );
+typedef int (*minfo_bm_ite_cb)( Mbookmark *bookmark, void *user_data );
+typedef int (*minfo_cover_ite_cb)( const char *thumb_path, void *user_data );
+typedef int (*minfo_tag_ite_cb)( Mtag *_tag_, void *user_data );
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+/**
+* @}
+*/
+
+#endif /*_VISUAL_SVC_TYPES_H_*/
+
+
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _VISUAL_SVC_H_
+#define _VISUAL_SVC_H_
+
+/**
+ * This file defines minfo apis for media service..
+ *
+ * @file visual-svc.h
+ * @author Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version 1.0
+ * @brief This file defines apis for visual media service.
+ */
+
+#include "media-svc-types.h"
+#include "visual-svc-types.h"
+#include "visual-svc-error.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ @mainpage VISUAL_SVC
+
+ @par
+ This document provides necessary visual media information for developers who are
+ going to implement gallery application and ug-imageviewer or other
+ 3rd party applications.
+ */
+
+/**
+ * @ingroup MEDIA_SVC
+ @defgroup VISUAL_SVC_API Media Service
+ @{
+
+ @par
+ Call Directly.
+ */
+
+
+/**
+ * minfo_get_item_list
+ * This function gets mitem list, which include all or portion of a cluster or folder specified by
+ * @p cluster_id. @p filter could specify some filter conditions, like, type of got items, sort by type,
+ * start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * Menawhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] the folder id in which media files are in. if the parameter is NULL, then query all folders.
+ * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
+ * when free list, it need free every item first and then free list itself.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mitem_ite_cb(Mitem *item, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ //append an item to linked list.
+ *list = g_list_append(*list, item);
+ }
+
+ void test_minfo_get_item_list(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int img_cnt = 0;
+ GList *p_list = NULL;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
+ //get a set of items
+ ret = minfo_get_item_list(mb_svc_handle, cluster_id, item_filter, mitem_ite_cb, &p_list);
+
+ if(ret< 0) {
+ printf("minfo_get_item_list error\n");
+ return;
+ }
+ }
+ * @endcode
+
+ */
+
+int
+minfo_get_item_list(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * minfo_get_all_item_list
+ * This function gets mitem list, which include all or portion of a or many clusters or folders specified by
+ * @p cluster_type. @p filter could specify some filter conditions, like, type of got items, sort by type,
+ * start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * Meanwhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_type [in] the folder type which specify media files belong to.
+ * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
+ * when free list, it need free every item first and then free list itself.
+ * @see minfo_get_item_list.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mitem_ite_cb(Mitem *item, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ //append an item to linked list.
+ *list = g_list_append(*list, item);
+ }
+
+ void test_minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int img_cnt = 0;
+ GList *p_list = NULL;
+
+ minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,3,10,true,true};
+ //get a set of items, which all reside on local storage, including MMC and phone.
+ ret = minfo_get_all_item_list(mb_svc_handle, MINFO_CLUSTER_TYPE_LOCAL_ALL, item_filter, mitem_ite_cb, &p_list);
+
+ if(ret< 0) {
+ printf("minfo_get_item_list error\n");
+ return;
+ }
+ }
+ * @endcode
+
+ */
+
+int
+minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle, const minfo_folder_type cluster_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * minfo_get_item_list_search
+ * This function gets mitem list, which is searched by string specified by user.
+ * @p search_field is a field to want to search. @p search_str could specify string to search.
+ * Menawhile data of each mitem instance mainly derive from media table record. However meta data
+ * is composed of video_meta or image_meta record.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param search_field [in] A field to want search. Please refer the enum type minfo_search_field_t in 'minfo-types.h'.
+ * @param search_str [in] A string to search.
+ * @param folder_type [in] the folder type which specify media files belong to.
+ * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+
+ * @return This function returns 0 on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks type of data memeber of list is pointer to the structure type 'Mitem'
+ * when free list, it need free every item first and then free list itself.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mitem_ite_cb(Mitem *item, void *user_data)
+ {
+ GList **list = (GList **)user_data;
+ //append an item to linked list.
+ *list = g_list_append(*list, item);
+ }
+
+ void test_minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ GList *p_list = NULL;
+ const char *search_str = "Hiphop";
+ minfo_search_field_t search_field = MINFO_SEARCH_BY_NAME;
+ minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_ALL;
+
+ minfo_item_filter item_filter = {MINFO_ITEM_VIDEO, MINFO_MEDIA_SORT_BY_NAME_ASC, 0, 9, false, MINFO_MEDIA_FAV_ALL};
+
+ ret = minfo_get_item_list_search(mb_svc_handle, search_field, search_str, folder_type, item_filter, mitem_ite_cb, &p_list);
+
+ if (ret< 0) {
+ printf("minfo_get_item_list_search error\n");
+ return;
+ }
+ }
+ * @endcode
+
+ */
+
+int
+minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle, minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, const minfo_item_filter filter, minfo_item_ite_cb func, void *user_data);
+
+/**
+ * minfo_get_all_item_cnt
+ * This function gets count of all records in media table. This function returns the count of all items, which are unlocked excluding web media.
+ *
+ * @param cnt [out] returned value, count of all records
+ * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+
+ #include <media-svc.h>
+
+ void test_minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int cnt = 0;
+
+ ret = minfo_get_all_item_cnt(mb_svc_handle, &cnt);
+ if(ret< 0) {
+ printf("minfo_get_all_item_cnt error\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+DEPRECATED_API int
+minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt);
+
+/**
+ * minfo_get_all_item_conut
+ * This function gets count of all records in the specific storage.
+ * User can specify folder type like MINFO_CLUSTER_TYPE_ALL, MINFO_CLUSTER_TYPE_LOCAL_PHONE, etc.
+ * Please refer 'visual-svc-types.h' to know what folder type exists.
+ * This function returns the count of all items, which are unlocked.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param folder_type [in] folder type
+ * @param file_type [in] file type
+ * @param fav_type [in] favortie type
+ * @param cnt [out] returned value, count of all records
+ * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_get_all_item_conut(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = -1;
+ int cnt = 0;
+ minfo_folder_type folder_type = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
+ minfo_file_type file_type = MINFO_ITEM_ALL;
+ minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ALL;
+
+ ret = minfo_get_all_item_conut(mb_svc_handle, folder_type, file_type, fav_type, &cnt);
+ if(ret< 0) {
+ printf("minfo_get_all_item_cnt error\n");
+ return;
+ }
+}
+* @endcode
+*/
+
+EXPORT_API int minfo_get_all_item_count(
+ MediaSvcHandle *mb_svc_handle,
+ minfo_folder_type folder_type,
+ minfo_file_type file_type,
+ minfo_media_favorite_type fav_type,
+ int *cnt);
+
+/**
+ * minfo_get_item_cnt
+ * This function gets count of matched records in media table with the specified @p filter, which
+ * specify some filter conditions, like, type of got items, sort by type, start and end positions
+ * of items, including meta data or not, whether just get the favorites, etc.
+ * The detail structure type of @p filter, could refer to the defination 'minfo_item_filter'
+ * in header file, minfo-types.h.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
+ * @param filter [in] the filter to specify some filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, whether just get the favorites, etc.
+ * @param cnt [out] returned value, count of matched records
+
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks list contains a set of full path string of cover file.
+ * @see minfo_get_item_list.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ minfo_item_filter item_filter = {MINFO_ITEM_VIDEO,MINFO_MEDIA_SORT_BY_DATE_ASC,-1,10,true,true};
+
+ //get count of a set of items.
+ ret = minfo_get_item_cnt(mb_svc_handle, cluster_id, item_filter, &cnt);
+ if(ret< 0) {
+ printf("test_minfo_get_item_cnt error\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const minfo_item_filter filter, int *cnt);
+
+
+/**
+ * minfo_get_cluster_cnt
+ * This function gets count of matched records from folder table with the specified @p filter, which
+ * specify some filter conditions, like, type of got clusters, sort by type, start and end positions
+ * of clusters, etc. The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
+ * in header file, minfo-types.h.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
+ * @param cnt [out] returned value, count of matched records
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_get_cluster_list.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,-1,10};
+
+ //get the count of items which is owned by a cluster.
+ ret = minfo_get_cluster_cnt(mb_svc_handle, cluster_filter, &cnt);
+ if(ret< 0) {
+ printf("test_minfo_get_cluster_cnt error\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, int *cnt);
+
+
+/**
+ * minfo_get_cluster_list
+ * This function gets Mcluster instances list. Data of each instance is composed of the matched records from folder table
+ * with the @p filter, which specify some filter conditions, like, type of got clusters, sort by type, start and end positions
+ * The detail structure type of @p filter, could refer to the defination 'minfo_cluster_filter'
+ * in header file, minfo-types.h.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param filter [in] filter to specify some filter conditions, like, type of got clusters, sort by type, start and end positions of clusters
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks item type in list is pointer to structure mcluster
+ * when free list, it need free every item first and then free list itself.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mcluster_ite_cb(Mcluster *cluster, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, cluster);
+ }
+
+ void test_minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int i;
+ int img_cnt;
+ GList *p_list = NULL;
+ Mcluster* cluster = NULL;
+
+ //get a linked list which include all of clusters based on a specified filter.
+ minfo_cluster_filter cluster_filter ={MINFO_CLUSTER_TYPE_ALL,MINFO_CLUSTER_SORT_BY_NONE,0,10};
+
+ ret = minfo_get_cluster_list(mb_svc_handle, cluster_filter, mcluster_ite_cb, &p_list);
+
+ if( ret < 0) {
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, minfo_cluster_ite_cb func, void *user_data);
+
+
+/**
+ * minfo_get_meta_info
+ * This function gets matched 'Mmeta' instances. Data of the instance is composed of the matched media record from
+ * 'video_meta'/'image_meta' table, when finish using the Mmeta instance, should call API, minfo_mmeta_destroy to
+ * destroy this created instance.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] specified _id field in media table record
+ * @param meta [out] pointer to pointer of matched Mmeta instance
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks after using meta, it must be freed.
+ * @see None
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_meta_info(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ Mmeta* mt = NULL;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //get a matched meta data.
+ ret = minfo_get_meta_info(mb_svc_handle, media_id, &mt);
+ if( ret < 0) {
+ printf("minfo_get_meta_info failed\n");
+ return ret;
+ }
+ minfo_mmeta_destroy(mt);
+ }
+
+ * @endcode
+ */
+
+int
+minfo_get_meta_info(MediaSvcHandle *mb_svc_handle, const char *media_id, Mmeta** meta);
+
+/**
+ * minfo_update_image_meta_info_int
+ * This function will update the corresponding field's value in database 'image_meta' table, this will be decided by the
+ * @p meta_field, whose type is 'minfo_image_meta_field_t', and indicate which field will be replaced by the value of int type
+ * pointered to by @p updated_value.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] specified _id field in media table record
+ * @param meta_field [in] the enum value indicate which field of database table will be updated
+ * @param updated_value [in] value of int, which will replace the original value in database image meta table
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks after using meta, it must be freed.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int width = 640;
+ int height = 480;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ // update image meta's 'width and height' member
+ ret = minfo_update_image_meta_info_int(mb_svc_handle, media_id, MINFO_IMAGE_META_WIDTH, width, MINFO_IMAGE_META_HEIGHT, height);
+ if( ret < 0) {
+ printf("minfo_update_image_meta_info_int failed\n");
+ return;
+ }
+ }
+
+ * @endcode
+ */
+
+EXPORT_API int
+minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id,
+ minfo_image_meta_field_t meta_field,
+ const int updated_value,
+ ...);
+
+/**
+ * minfo_update_video_meta_info_int
+ * This function will update the corresponding field's value in database 'video_meta' table, this will be decided by the
+ * @p meta_field, whose type is 'minfo_video_meta_field_t', and indicate which field will be replaced by the value of int type
+ * pointered to by @p updated_value.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] specified _id field in media table record
+ * @param meta_field [in] the enum value indicate which field of database table will be updated
+ * @param updated_value [in] value of int, which will replace the original value in database video meta table
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks after using meta, it must be freed.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int _value = 876;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //update video meta's 'last_played_time' member
+ ret = minfo_update_video_meta_info_int(mb_svc_handle, media_id, MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED, _value);
+
+ if( ret < 0) {
+ printf("minfo_update_video_meta_info_int failed\n");
+ return;
+ }
+ }
+
+ * @endcode
+ */
+
+int
+minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_video_meta_field_t meta_field, const int updated_value);
+
+
+/**
+* minfo_destroy_mtype_item
+* This function free an type instantiated object, whose type may be any one recognized by media-svc, these type
+* will include Mitem, Mimage, Mvideo, Mmeta, Mcluster, etc. In this function, it will check the concrete type for the
+* @p item, and then decide which free function will really be called.
+*
+* @return This function returns 0 on success, and negativa value on failure.
+* @param item [in] the input parameter, inlcuding the instanciated object.
+* @exception None.
+* @remarks This function is general one, it will be able to destroy any recognized instantiated object
+* by media-svc, so when you create or get an instantiated object from media-svc, and then
+* call this function to free it.
+* @see None
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_destroy_mtype_item(void)
+ {
+ int ret = -1;
+ Mitem *mi = NULL;
+
+ char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+ ret = minfo_get_item(file_url, &mi);
+
+ //destroy an item whose type is 'Mitem'.
+ ret = minfo_destroy_mtype_item(mi);
+
+ if( ret < 0) {
+ return ret;
+ }
+
+ }
+ * @endcode
+*/
+
+int
+minfo_destroy_mtype_item(void* item);
+
+
+/**
+ * minfo_add_media_start
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+ Or updates file information in these tables if the file is updated
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param trans_count [in] count of trasaction user wants
+ * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_add_media_end, minfo_add_media_batch
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
+ {
+ int err = -1, i;
+
+ err = minfo_add_media_start(mb_svc_handle, 100);
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+ }
+
+ err = minfo_add_media_end(mb_svc_handle);
+ if( err < 0) {
+ printf("minfo_add_media_end failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_add_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
+
+
+/**
+ * minfo_add_media_batch
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+ Or updates file information in these tables if the file is updated
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] the local file full path
+ * @param type [in] the file type, maybe it's video file or image file
+ * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_add_media_start, minfo_add_media_end
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
+ {
+ int err = -1, i;
+
+ err = minfo_add_media_start(mb_svc_handle, 100);
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+
+ for (i = 0; i < 100; i++) {
+ err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+ }
+
+ err = minfo_add_media_end(mb_svc_handle);
+ if( err < 0) {
+ printf("minfo_add_media_end failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_add_media_batch(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
+
+/**
+ * minfo_add_media_end
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+ Or updates file information in these tables if the file is updated
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_add_media_start, minfo_add_media_batch
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_add_media_batch(MediaSvcHandle *mb_svc_handle)
+ {
+ int err = -1, i;
+
+ err = minfo_add_media_start(100);
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ err = minfo_add_media_batch(mb_svc_handle, image_files[i], MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+ }
+
+ err = minfo_add_media_end();
+ if( err < 0) {
+ printf("minfo_add_media_end failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_add_media_end(MediaSvcHandle *mb_svc_handle);
+
+/**
+ * minfo_add_media
+ * This function inserts new media file information into media table,video_meta table/image_meta table.
+ Or updates file information in these tables if the file is updated
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] the local file full path
+ * @param type [in] the file type, maybe it's video file or image file
+ * @return This function returns 0/positive on success, or negative value with error code. (0 : added, 1: updated, 2: skipped )
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_delete_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_add_media(MediaSvcHandle *mb_svc_handle)
+ {
+ int err = -1;
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+ //add a new media content whose url is 'file_url'.
+ err = minfo_add_media(mb_svc_handle, file_url, MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_add_media failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+
+int
+minfo_add_media(MediaSvcHandle *mb_svc_handle, const char* file_url, minfo_file_type content_type);
+
+
+
+/**
+ * minfo_delete_media
+ * This function deletes matched media table record, video_meta/image_meta record. After that, if the folder which this file is in is empty, then delete the folder record.
+ * When user actually delete a media file in file system, he/she should call this function to delete the corresponding record in 'media' table, meanwhile it may delete the
+ * folder record in 'folder' table if this folder will not include any media content.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] matched local file full path
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_add_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_delete_media(void)
+ {
+ int ret = -1;
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+ //delete a media reord from 'media' table.
+ ret= minfo_delete_media(file_url);
+
+ if( ret < 0) {
+ printf("minfo_delete_media failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_delete_media(MediaSvcHandle *mb_svc_handle, const char* file_url);
+
+
+
+/**
+ * minfo_move_media
+ * This function moves the media file to another place. When user actually move a media file ( @p old_file_url )in file system to the destination
+ * pathname ( @p new_file_url ), he/she need to call this function to move the record of 'media' table. Meanwhile user is responsible for identifying
+ * the file's type, like image, video, etc.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param old_file_url [in] old local file full path of the media file
+ * @param new_file_url [in] new local file full path of the media file
+ * @param type [in] media file type,maybe vidoe or image
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_mv_media, minfo_copy_media, minfo_update_media_name.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_move_media(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char* old_file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+ char* new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+
+ //move an item to a specified location.
+ ret = minfo_move_media(mb_svc_handle, old_file_url, new_file_url, MINFO_ITEM_IMAGE);
+
+ if( ret < 0) {
+ printf("minfo_move_media failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_move_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
+
+/**
+ * minfo_move_media_start
+ * This function starts to move multiple media files
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param trans_count [in] count of trasaction user wants
+ * @return This function returns 0/positive on success, or negative value with error code.
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_move_media_end, minfo_move_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_move_media_batch(MediaSvcHandle *mb_svc_handle)
+ {
+ int err = -1, i;
+
+ err = minfo_move_media_start(mb_svc_handle, 100);
+ if( err < 0) {
+ printf("minfo_move_media_start failed\n");
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_move_media failed\n");
+ return;
+ }
+ }
+
+ err = minfo_move_media_end(mb_svc_handle);
+ if( err < 0) {
+ printf("minfo_move_media_end failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_move_media_start(MediaSvcHandle *mb_svc_handle, int trans_count);
+
+
+
+/**
+ * minfo_move_media_end
+ * This function ends to move multiple media files
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @return This function returns 0/positive on success, or negative value with error code.
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_add_move_start, minfo_move_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_move_media_batch(void)
+ {
+ int err = -1, i;
+
+ err = minfo_move_media_start(mb_svc_handle, 100);
+ if( err < 0) {
+ printf("minfo_add_media_start failed\n");
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ err = minfo_move_media(mb_svc_handle, src_image_file_path[i], dst_image_file_path[i], MINFO_ITEM_IMAGE);
+
+ if( err < 0) {
+ printf("minfo_move_media failed\n");
+ return;
+ }
+ }
+
+ err = minfo_move_media_end(mb_svc_handle);
+ if( err < 0) {
+ printf("minfo_move_media_end failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_move_media_end(MediaSvcHandle *mb_svc_handle);
+
+
+/**
+ * minfo_copy_media
+ * This function copies the media file to another place. User should pass the full pathnames for these parameters, @p old_file_url and @ new_file_url
+ * respectively. The @p old_file_url indicate the original full pathname of this media content, and @ new_file_url indicate the destination full pathname of
+ * the copied file.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param old_file_url [in] old local file full path of the media file
+ * @param new_file_url [in] new local file full path of the media file
+ * @param type [in] media file type, maybe vidoe or image
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks This function will not return the thumbnail pathname of new media file, user could get this new thumnail file using the function, minfo_get_thumb_path.
+ * @see minfo_cp_media, minfo_update_media_name, minfo_move_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_copy_media(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret =-1;
+
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+ char *new_file_url = "/opt/media/Images/Wallpapers/Home_01_1.png";
+
+ //copy a media file to other location whos name is specified by 'new_file_url'.
+ ret = minfo_copy_media(mb_svc_handle, old_file_url, new_file_url, file_type);
+ if( ret < 0) {
+ printf("minfo_copy_media failed\n");
+ return;
+ }
+
+ }
+ * @endcode
+ */
+
+int
+minfo_copy_media(MediaSvcHandle *mb_svc_handle, const char* old_file_url, const char *new_file_url, minfo_file_type content_type);
+
+
+/**
+ * minfo_update_media_name
+ * This function rename a image or video file. Here this function will assume the folder name of
+ * file whose name is changed keep unchanged. That is, this file which is changed name still is located in the same folder.
+ * This function actually call sqlite3
+ * UPDATE %s SET ... WHERE _id = _id;
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] the id of specified media file
+ * @param new_name [in] new name of the media file
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_move_media, minfo_copy_media.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_media_name(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //update media name
+ ret = minfo_update_media_name(mb_svc_handle, media_id, new_name);
+ if( ret < 0) {
+ printf("test_minfo_update_media_name failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_update_media_name(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* new_name);
+
+/**
+ * minfo_update_media_thumb
+ * This function updates a thumbpath of the media in DB.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] the id of specified media file
+ * @param thumb_path [in] new thumbnail path of the media file
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see None
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ const char *thumb_path = "/opt/media/test.jpg";
+
+ //update thumbnail path
+ ret = minfo_update_media_thumb(mb_svc_handle, media_id, thumb_path);
+ if( ret < 0) {
+ printf("minfo_update_media_thumb failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* thumb_path);
+
+/**
+ * minfo_update_media_favorite
+ * This function updates favorite field of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE,
+ * In Gallery application or ug-imageviewer, user could want to set a media file as favorite or unfovarite, so he/she could call
+ * this API to do it.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] Unique id of the media file
+ * @param favorite_level [in] new favorite_level of the media file, indicate whether this media content is favorite or unfavorite.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //update an item's favorite record
+ ret = minfo_update_media_favorite(mb_svc_handle, media_id, favorite_level);
+
+ if( ret < 0) {
+ printf("minfo_update_media_favorite failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle, const char *media_id, const int favorite_level);
+
+
+/**
+ * minfo_update_media_date
+ * This function updates modified date of image or video file in 'media' table. This function actually call the Sqlite3 UPDATE.
+ * In Gallery application or ug-imageviewer, user could want to set moedified date of a media, so he/she could call this API to do it.
+ * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] Unique id of the media file
+ * @param modified_date [in] date to modify, which is a type of time_t
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_media_date(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ time_t today;
+ time(&today);
+
+ //update an item's date record
+ ret = minfo_update_media_date(mb_svc_handle, media_id, today);
+ if( ret < 0) {
+ printf("minfo_update_media_date failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id, time_t modified_date);
+
+
+/**
+ * minfo_add_cluster
+ * This function adds new local folder. This function could be called when user want to add a Album(local folder)
+ * in Gallery application. This function actually call the sqlite INSERT statement to insert the record in folder
+ * table. Meanwhile it will return new added local folder's ID to @p id.
+ * Sqlie3 statement looks like this, INSERT INTO folder (...);
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_url [in] the local directory of added folder, it should be full pathname of local folder
+ * @param id [out] id of the added folder, this function will return a unique ID to calling application
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_delete_cluster
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_add_cluster(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char *cluster_url = "/opt/media/Images/Wallpapers";
+ char cluster_id[256];
+
+ //add a new cluster whose url is 'cluster_url'.
+ ret = minfo_add_cluster(mb_svc_handle, cluster_url, cluster_id, sizeof(cluster_id));
+ if( ret < 0) {
+ printf("minfo_add_cluster failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_add_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, char *id, int max_length);
+
+
+/**
+ * minfo_check_cluster_exist
+ * This function checks to exist the cluster in media database by its path.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param path [in] the local directory to check if it exists, it should be full pathname of local folder
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_check_item_exist
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char *cluster_url = "/opt/media/Images/Wallpapers";
+
+ //check if the cluster exists by path.
+ ret = minfo_check_cluster_exist(mb_svc_handle, cluster_url);
+ if( ret < 0) {
+ printf("minfo_check_cluster_exist failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle, const char *path);
+
+/**
+ * minfo_check_item_exist
+ * This function checks to exist the media in media database by its path.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param path [in] the local media path to check if it exists, it should be full pathname.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks if invoke this function with same input parameter, it fails
+ * @see minfo_check_cluster_exist
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_check_item_exist(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char *media_url = "/opt/media/Images/Wallpapers/Wallpaper1.jpg";
+
+ //check if the item exists by path.
+ ret = minfo_check_item_exist(mb_svc_handle, media_url);
+ if( ret < 0) {
+ printf("minfo_check_item_exist failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_check_item_exist(MediaSvcHandle *mb_svc_handle, const char *path);
+
+/**
+ * minfo_get_item_by_id
+ * This function gets mitem information. When user could get the unique ID of a media content, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
+ * of this structute, could refer to the header, minfo-item.h.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] the local file media id
+ * @param mitem [out] the returned data structure whose type is Mitem.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks when invoking this function, *mitem must equals NULL, and
+ * the @p media_id should be valid ID, if it is invalid, like -1 or 0, this
+ * function will return @p mitem whose content is NULL. If normally, @p mitem must be freed with minfo_mitem_destroy.
+ * @see minfo_get_item.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ Mitem *mi = NULL;
+
+ //get an item based on its media ID.
+ ret = minfo_get_item_by_id(mb_svc_handle, media_id, &mi);
+ if(ret < 0) {
+ return;
+ }
+
+ minfo_destroy_mtype_item(mi);
+ }
+ * @endcode
+ */
+
+int
+minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, Mitem **mitem);
+
+
+/**
+ * minfo_get_item
+ * This function gets mitem information. When user could get the full pathname of a media content, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, media content's pathname, etc. The detail defination
+ * of this structute, could refer to the header, minfo-item.h.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] the local file full pathname
+ * @param mitem [out] the returned data structure whose type is Mitem.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks when invoking this function, *mitem must equals NULL, and
+ * after using mitem, it must be freed with minfo_mitem_destroy.
+ * @see minfo_get_item_by_id.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_item(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ Mitem *mi = NULL;
+ char* file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+ //get an item based on its url.
+ ret = minfo_get_item(mb_svc_handle, file_url, &mi);
+ if(ret < 0) {
+ return;
+ }
+
+ minfo_destroy_mtype_item(mi);
+ }
+ * @endcode
+ */
+
+int
+minfo_get_item(MediaSvcHandle *mb_svc_handle, const char* file_url, Mitem **mitem);
+
+/**
+ * minfo_get_item_by_http_url
+ * This function gets mitem information. When user could get the http url of a media content, which is downloaded from web, he/she
+ * could get the detail information with the type 'Mitem', which include the below feilds, like, item's unique id,
+ * media content type, media content's thumbnail name, etc. The detail defination
+ * of this structute, could refer to the header, minfo_item/minfo-item.h.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param http_url [in] the http url of a media, which is downloaded from web.
+ * @param mitem [out] the returned data structure whose type is Mitem.
+ * @return This function returns 0 on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks when invoking this function, *mitem must equals NULL, and
+ * after using mitem, it must be freed with minfo_mitem_destroy.
+ * @see minfo_get_item_by_id, minfo_get_item
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ Mitem *mi = NULL;
+ char* http_url = "http://picasa.com/myaccount/Home_01.png";
+
+ //get an item based on its http url.
+ ret = minfo_get_item_by_http_url(mb_svc_handle, http_url, &mi);
+ if(ret < 0) {
+ return;
+ }
+
+ minfo_destroy_mtype_item(mi);
+ }
+ * @endcode
+ */
+
+int
+minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle, const char* http_url, Mitem **mitem);
+
+
+/**
+* minfo_get_cluster
+* This function gets mcluster information by folder full path or cluster id when user could not know exact url of cluster. When user could get full path of a folder, he/she
+* could get the detail information with the type 'Mcluster' about this cluster/local folder, the type 'Mcluster'
+* mainly include folder/cluster ID, display name, count of included media content, etc. The detail defination
+* of this type could refer to the herder file, minfo-cluster.h.
+*
+* @return This function returns 0 on success, or negative value with error code.
+* @param mb_svc_handle [in] the handle of DB
+* @param cluster_url [in] local folder full path, it indicate which folder user want to get it's detail information
+* @param cluster_id [in] the cluster ID which indentify a cluster
+* @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
+* @exception None.
+* @remarks when user could not know exact url of a cluster, he/she could choose alternative way he/she pass cluster id to this function, so that
+* this function still could get the wanted cluster.
+* when invoking this function, *mcluster must equals NULL, and
+* after using mitem, it must be freed with minfo_mcluster_destroy.
+* @see minfo_mcluster_destroy
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ Mcluster *mc = NULL;
+ char *cluster_url = "/opt/media/Images/Wallpapers";
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //get a cluster using cluster's url.
+ ret = minfo_get_cluster(mb_svc_handle, cluster_url, cluster_id, &mc);
+ if(ret < 0) {
+ printf("minfo_get_cluster fail: %d \n", ret);
+ return;
+ }
+
+ printf("minfo_get_cluster: %s \n", mc->display_name);
+ minfo_mcluster_destroy(mc);
+ }
+* @endcode
+*/
+
+int
+minfo_get_cluster(MediaSvcHandle *mb_svc_handle, const char* cluster_url, const char *cluster_id, Mcluster **mcluster);
+
+
+/**
+ * minfo_get_cluster_cover
+ * This function gets thumbnail path of cover files by cluster id. This function could get the cover of a cluster
+ * or folder which may include first several items' thumbnails, maybe 5 or other number, user could specify it
+ * using @p img_cnt.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] the folder id in which media files are in. if the parameter is -1, then query all folders.
+ * @param img_cnt [in] the count of cover thumbnails
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an thumbnail path has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of thumbnail path. It is passed to the iterative callback.
+ *
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks type of item is pointer to char*,
+ * when free list, needn't free every string.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int cover_ite_cb(char *thumb_path, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, thumb_path);
+ }
+
+ void test_minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ GList *p_list = NULL;
+ int img_cnt = 5;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //get the cover of a cluster.
+ ret = minfo_get_cluster_cover(mb_svc_handle, cluster_id, img_cnt, cover_ite_cb, &p_list);
+ if(ret< 0) {
+ printf("test_minfo_get_cluster_cover error\n");
+ return;
+ }
+ }
+
+ * @endcode
+ */
+
+int
+minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const int img_cnt, minfo_cover_ite_cb func, void *user_data);
+
+
+/**
+ * minfo_get_bookmark_list
+ * This function gets the type 'Mbookmark' instances list. Data of each this type instance is
+ * composed of the matched record indentified by the media id from 'video_bookmark' table.
+ * The type 'Mbookmark' mainly include the these information, like, bookmark id, media id,
+ * marked time, corresponding thumbnail pathanme, etc.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] media_id field of video_bookmark table record
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] User's data structure to contain items of the type Mbookmark. It is passed to the iterative callback.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks member data in list is pointer to structure Mbookmark,
+ * when free list, it need free every item first and then free list itself.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mbookmark_ite_cb(Mbookmark *bm, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, bm);
+ }
+
+ void test_minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ GList *p_list = NULL;
+
+ //get a linked list which will include all of bookmarks of a media file.
+ ret = minfo_get_bookmark_list(mb_svc_handle, media_id, mbookmar_ite_cb, &p_list);
+ if( ret < 0) {
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_bm_ite_cb func, void *user_data);
+
+
+/**
+ * minfo_get_geo_item_list
+ * This function gets the type 'Mitem' instances list. Data of each instance is composed of the matched record identified
+ * by @p filter from 'media' table. Except that the got items pass the criterion of @p filter, they should position where the longitude
+ * is between @p min_longitude and @p max_longitude, and the latitude is between @p min_latitude and @p max_latitude.
+* This function gets 'Mitem' list matched with latitude, longitude, filter and cluster id.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] indicate the value, 'fold_id' field in 'media' table record
+ * @param filter [in] specified filter to get matched media record
+ * @param store_filter [in] specified storage filter to get matched media record
+ * @param min_longitude [in] minimum value of 'longitude' field in 'vidoe_meta'/'image_meta' table
+ * @param max_longitude [in] maximum value of longitude field in 'vidoe_meta'/'image_meta' table
+ * @param min_latitude [in] minimum value of 'latitude' field in 'video_meta'/'image_meta' record
+ * @param max_latitude [in] maximum value of 'latitude' field in 'video_meta'/'image_meta' record
+ * @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param user_data [out] user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks item type in list is pointer to structure Mitem,
+ * when free list, it need free every item first and then free list itself.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ int mitem_ite_cb(Mitem *item, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, item);
+ }
+
+ void test_minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ int min_longitude = 120.0;
+ int max_longitude = 123.0;
+ int min_latitude = 19.0;
+ int max_latitude = 24.0;
+ GList *p_list = NULL;
+
+ //get a linked list which include a set of items based on their location.
+ ret = minfo_get_geo_item_list(mb_svc_handle,
+ cluster_id,
+ store_filter,
+ filter,
+ min_longitude,
+ max_longitude,
+ min_latitude,
+ max_latitude,
+ mitem_ite_cb,
+ &p_list);
+ if( ret < 0) {
+ printf("minfo_get_geo_item_list failed\n");
+ return;
+ }
+ }
+ * @endcode
+ */
+
+int
+minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ minfo_folder_type store_filter,
+ minfo_item_filter filter,
+ double min_longitude,
+ double max_longitude,
+ double min_latitude,
+ double max_latitude,
+ minfo_item_ite_cb func,
+ void *user_data);
+
+
+
+/**
+ * minfo_get_thumb_path
+ * This function gets thumbnail path of specified image file. When user could get the full pathname of a image content.
+ * He/She wants to get the thumbnail file corresponding to the image content identified by the @p file_url.
+ * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] local file full path, identify a media record in 'media' table
+ * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
+ * @param max_thumb_path [in] The max length of the returned thumbnail path
+ *
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks one file full path always matches one thumbnail path,
+ here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
+ * @see minfo_get_thumb_path_for_video.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char thumb_path[256] = {'\0'};
+ char *file_url = "/opt/media/Images/Wallpapers/Home_01.png";
+
+ //get thumbnail pathname of an item.
+ ret = minfo_get_thumb_path(mb_svc_handle, file_url, thumb_path, sizeof(thumb_path));
+ if( ret < 0) {
+ printf("minfo_get_thumb_path failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
+
+/**
+ * minfo_get_thumb_path_for_video
+ * This function gets thumbnail path of specified video file. When user could get the full pathname of a video content.
+ * He/She wants to get the thumbnail file corresponding to the video content identified by the @p file_url.
+ * User is responsible for allocating the memory for @p thumb_path so that this function could fill up the thumbnail pathname to it.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param file_url [in] local file full path, identify a media record in 'media' table
+ * @param thumb_path [out] the returned thumbnail path of specified file, user is responsible for allocating memory for it first
+ * @param max_thumb_path [in] The max length of the returned thumbnail path
+ *
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks one file full path always matches one thumbnail path,
+ here, it returns thumbnail path , but maybe thumbnail file doesn't exist, return NULL.
+ * @see minfo_get_thumb_path.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char thumb_path[256] = {'\0'};
+ char *file_url = "/opt/media/Images and videos/My video clip/Helicopter.mp4";
+
+ //get thumbnail pathname of an item.
+ ret = minfo_get_thumb_path_for_video(mb_svc_handle, file_url,thumb_path, sizeof(thumb_path));
+ if( ret < 0) {
+ printf("minfo_get_thumb_path_for_video failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle, const char* file_url, char* thumb_path, size_t max_thumb_path);
+
+/**
+ * minfo_delete_media_id
+ * This function deletes matched record identified by the @p media_id from 'media' table , 'video_meta'/'image_meta' record.
+ * After that, if the folder which this deleted file is in becomes empty, then delete the folder record from 'folder' table, too.
+ * In order that user could successfully delete the corresponding record from 'media' table, he/she should be able to the correct _id
+ * of media content before it.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] represent the value, media '_id' in 'media' table record
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_delete_media.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_delete_media_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //delete an item according to its ID.
+ ret = minfo_delete_media_id(mb_svc_handle, media_id);
+ if( ret < 0) {
+ printf("test_minfo_delete_media_id failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_delete_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id);
+
+/**
+ * minfo_delete_all_media_records:\n
+ * This function delete all media records in a type of storage like phone or MMC.
+ * This function is always used for MMC card insert/inject operation, in file manager service library.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param storage_type [in] information for storage type
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None
+ * @pre None
+ * @post None
+ * @remark None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = MB_SVC_ERROR_NONE;
+
+ //delete all media records in MMC storage in db.
+ ret = minfo_delete_all_media_records(mb_svc_handle, MINFO_MMC);
+ if (ret < 0) {
+ printf( "failed to delete items. error code->%d", ret);
+ return;
+ }
+ }
+
+ * @endcode
+ */
+
+int
+minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
+
+/**
+ * minfo_cp_media
+ * This function copies specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the copied media file
+ * is identified by it's media id. Compared to API, minfo_copy_media, the different is , this function copy a media content to specified folder,
+ * according to the media content id and the destination folder's id, however the function, minfo_copy_media, copy a media content to specified folder
+ * according to the media file's full pathname and folder's full name.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
+ * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder' table
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks This function will implement the same functionality as minfo_copy_media.
+ * @see minfo_copy_media
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_cp_media(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //copy the a media file whose ID is specified by, 'src_media_id', to a cluster.
+ ret = minfo_cp_media(mb_svc_handle, src_media_id, dst_cluster_id);
+ if( ret < 0) {
+ printf("minfo_cp_media failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_cp_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
+
+
+
+/**
+ * minfo_mv_media
+ * This function moves specified media file to another folder, which is identified by the folder id, @p dst_cluster_id. Meanwhile the moved media file
+ * is identified by it's media id. Compared to API, minfo_move_media, the difference is that this function moves a media content to specified folder,
+ * according to the media content id and the destination folder's id, however the function, minfo_move_media, move a media content to specified folder
+ * according to the media file's full pathname and folder's full name.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param src_media_id [in] id of the source media file, it's value is from '_id' field of the 'media' table
+ * @param dst_cluster_id [in] id of the destination folder, it's value is from '_id' field of the 'folder'
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see minfo_move_media.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_mv_media(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *src_media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ const char *dst_cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //move an item to specified cluster.
+ ret = minfo_mv_media(mb_svc_handle, src_media_id, dst_cluster_id);
+ if( ret < 0) {
+ printf("minfo_mv_media failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+
+int
+minfo_mv_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
+
+
+
+/**
+ * minfo_delete_cluster
+ * This function deletes specified cluster, which is identified by the @p cluster_id. When user launch Gallery and in edit 'Albums' mode, if he/she
+ * want to delete a cluster/folder, so call this function to do it. When delete a cluster/folder, the media-svc will not only delete the record in 'folder' table,
+ * but delete all of records in 'media' table which are located in this folder, meanwhile delete the corresponding records in 'video_bookmark' table, etc.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] cluster id, to indicate the deleted folder/cluster
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks delete all releated contents in cluster together with cluster
+ * like all media files, image/video meta,bookmark information.
+ * @see minfo_add_cluster
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+
+ #include <media-svc.h>
+
+ void test_minfo_delete_cluster(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //delete a cluster record, meanwhile this function will delete all of items owned by this cluster.
+ ret = minfo_delete_cluster(mb_svc_handle, cluster_id);
+ if( ret < 0) {
+ printf("minfo_delete_cluster failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_delete_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
+
+
+
+/**
+ * minfo_update_cluster_name
+ * This function updates the specified cluster name using @p new_name, which just indicate the new folder name. User could
+ * call this function, when he/she wants to change some folder/cluster name. This really update the corresponding record in
+ * 'folder' table.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] cluster id, this value is from the '_id' field of 'folder' table
+ * @param new_name [in] new cluster name
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+
+ void test_minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ char *new_name = "newfolder";
+
+ //update a cluster's name
+ ret = minfo_update_cluster_name(mb_svc_handle, cluster_id,new_name);
+ if( ret < 0) {
+ printf("minfo_update_cluster_name failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* new_name);
+
+/**
+ * minfo_update_cluster_date
+ * This function updates the specified cluster modified date using @p modified_date, which just indicate the new modified date. User could
+ * call this function, when he/she wants to change some clsuter's modified date. This really update the corresponding record in the DB
+ * @param mb_svc_handle [in] the handle of DB
+ * @param cluster_id [in] cluster id, this value is the identifier of the cluster
+ * @param modified_date [in] date to modify, which is a type of time_t
+ * @return This function returns zero(MB_SVC_ERROR_BASE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @remarks None.
+ * @see None.
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+ #include <media-svc.h>
+ #include <time.h>
+
+ void test_minfo_update_cluster_date(void)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ time_t today;
+ time(&today);
+
+ //update a cluster's name
+ ret = minfo_update_cluster_date(cluster_id, today);
+
+ if( ret < 0) {
+ printf("minfo_update_cluster_date failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_update_cluster_date(MediaSvcHandle *mb_svc_handle, const char *cluster_id, time_t modified_date);
+
+
+
+/**
+ * minfo_add_bookmark
+ * This function inserts new bookmark record into 'video_bookmark' table. The inserted data should include marked time of video content, @p position
+ * and @p thumb_path, current extracted thumbnail file in marked time, etc. User should use @p media_id to identify the
+ * video content, so that add bookmark to it.
+ * @param mb_svc_handle [in] the handle of DB
+ * @param media_id [in] media file id, uniquely identify the media content
+ * @param position [in] marked time of the media file
+ * @param thumb_path [in] the extracted thumbnail path for this marked time
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks if add same input parameters twice, it fails
+ * @see minfo_delete_bookmark
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+
+ #include <media-svc.h>
+
+ void test_minfo_add_bookmark(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int position = 2346;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ char *thumb_path = "tmp1";
+
+ //add a bookmark which include position, thumbnail, etc. to an item.
+ ret = minfo_add_bookmark(mb_svc_handle, media_id,position,thumb_path);
+ if( ret < 0) {
+ printf("minfo_add_bookmark failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+
+int
+minfo_add_bookmark(MediaSvcHandle *mb_svc_handle, const char *media_id, const int position, const char* thumb_path);
+
+
+/**
+ * minfo_delete_bookmark
+ * This function deletes specified bookmark record from 'video_bookmark' table, the deleted bookmark should be identified by @p bookmark_id.
+ * This function actually call the sqlite3 statement,
+ * "DELETE FROM video_bookmark WHERE _id = bookmark_id; "
+ * In gallery or ug-imageviewer, user could get a linked list bookmark for some media file, so he/she could delete one of them using @p bookmark_id.
+ *
+ * @param mb_svc_handle [in] the handle of DB
+ * @param bookmark_id [in] _id field in video_bookmark table.
+ * @return This function returns 0 on success, or negative value with error code.
+ * @remarks user should give a correct bookmark ID to successfully delete it.
+ * @see minfo_add_bookmark
+ * @pre None
+ * @post None
+ * @par example
+ * @code
+
+
+ #include <media-svc.h>
+
+ void test_minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int bookmark_id = 1;
+
+ //delete a bookmark record in 'video_bookmark' table.
+ ret = minfo_delete_bookmark(mb_svc_handle, bookmark_id);
+
+ if( ret < 0) {
+ printf("minfo_delete_bookmark failed\n");
+ return;
+ }
+ }
+* @endcode
+ */
+
+int
+minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle, const int bookmark_id);
+
+
+
+
+/**
+* minfo_get_cluster_id_by_url
+* This function gets some folder's full path. This will be called when user want to know what one folder's unique
+* ID is.
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param mb_svc_handle [in] the handle of DB
+* @param url [in] folder path
+* @param cluster_id [out] folder ID
+* @exception None.
+* @remarks None.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ char cluster_id[256] = {0,};
+ char *url = "/opt/media/Images/Wallpapers";
+
+ //get cluster's ID using cluster's url.
+ ret = minfo_get_cluster_id_by_url(url, cluster_id, sizeof(mb_svc_handle, cluster_id));
+ if( ret < 0) {
+ printf("test_minfo_get_cluster_id_by_url failed\n");
+ return;
+ }
+ }
+* @endcode
+*/
+int
+minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle, const char* url, char* cluster_id, int max_length);
+
+
+/**
+* minfo_get_cluster_name_by_id
+* This function gets folder's name. This will be called when user want to know what one folder's name
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] mb_svc_handle the handle of DB
+* @param[in] cluster_id folder ID
+* @param[out] cluster_name folder name
+* @param[in] max_length The max length of the returned folder name.
+* @exception None.
+* @remarks None.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ char *cluster_name[1024];
+
+ //get cluster's name using cluster's id.
+ ret = minfo_get_cluster_name_by_id(mb_svc_handle, cluster_id, cluster_name, sizeof(cluster_name));
+
+ if( ret < 0) {
+ printf("test_minfo_get_cluster_name_by_id failed\n");
+ return;
+ } else {
+ printf("cluster name is %s\n", cluster_name);
+ return;
+ }
+ }
+* @endcode
+*/
+int
+minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *cluster_name, int max_length );
+
+/**
+* minfo_get_cluster_fullpath_by_id
+* This function gets folder's full path. This will be called when user want to know what one folder's full path.
+* User should specify the maximum length of the @p folder_path, so as to avoid over flow of the string.
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] mb_svc_handle the handle of DB
+* @param[in] cluster_id folder ID
+* @param[out] folder_path folder path name
+* @param[in] max_length specify the maximum length of @p folder_path.
+* @exception None.
+* @remarks None.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ char *folder_path[1024];
+
+ //get cluster's path name using cluster's id.
+ ret = minfo_get_cluster_fullpath_by_id(mb_svc_handle, cluster_id, folder_path, sizeof(folder_path));
+
+ if( ret < 0) {
+ printf("test_minfo_get_cluster_fullpath_by_id failed\n");
+ return;
+ } else {
+ printf("path name is %s\n", cluster_name);
+ return;
+ }
+ }
+* @endcode
+*/
+
+int
+minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *folder_path, int max_length);
+
+
+
+/**
+* minfo_set_cluster_lock_status
+* @fn int minfo_set_cluster_lock_status( int cluster_id, int lock_status );
+* This function set status for lock to DB. This will be called when user want to set to lock an album.
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] mb_svc_handle the handle of DB
+* @param[in] cluster_id folder ID
+* @param[in] lock_status status for lock to be saved ( 0 : unlock, 1 : lock )
+* @exception None.
+* @remarks None.
+* @see minfo_get_cluster_lock_status.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ int status = 1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //set s cluster lock status.
+ ret = minfo_set_cluster_lock_status(mb_svc_handle, cluster_id, status);
+
+ if( ret < 0) {
+ printf("test_minfo_set_cluster_lock_status failed\n");
+ return;
+ }
+ }
+* @endcode
+*/
+
+int
+minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int lock_status);
+
+/**
+* minfo_get_cluster_lock_status
+* @fn int minfo_get_cluster_lock_status( int cluster_id, int *lock_status );
+* This function gets status for lock from DB. This will be called when user want to get lock status for an album.
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] mb_svc_handle the handle of DB
+* @param[in] cluster_id folder ID
+* @param[out] lock_status status for cuurent lock status
+* @exception None.
+* @remarks None.
+* @see minfo_set_cluster_lock_status.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+ int status = -1;
+
+ //get a cluster's status.
+ ret = minfo_get_cluster_lock_status(mb_svc_handle, cluster_id, &status);
+
+ if( ret < 0) {
+ printf("test_minfo_get_cluster_lock_status failed\n");
+ return;
+ } else {
+ print("Current status : %d\n", status);
+ return;
+ }
+ }
+* @endcode
+*/
+
+int
+minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int *lock_status );
+
+/**
+* @fn int minfo_get_media_path( minfo_store_type storage_type, char* media_path, size_t max_media_path);
+* This function gets the path of media. This will be called when user want to get path of direcotry containing media in device.
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] storage_type store type, which means type of device containg media.
+* @param[out] media_path path of media
+* @param[in] max_media_path The max length of the returned media_path.
+* @exception None.
+* @remarks None.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_media_path(void)
+ {
+ int ret = -1;
+ char media_path[256] = {'\0'};
+
+ //get media's fullpath.
+ ret = minfo_get_media_path(MINFO_PHONE, media_path, sizeof(media_path));
+
+ if( ret < 0) {
+ printf("minfo_get_media_path failed\n");
+ return;
+ } else {
+ print("The returned path : %s\n", media_path);
+ return;
+ }
+ }
+* @endcode
+*/
+
+int
+minfo_get_media_path(minfo_store_type storage_type, char* media_path, size_t max_media_path );
+
+
+/**
+ * minfo_set_db_valid
+ * This function set whether all the media contents in a type of storage are valid, like phone or MMC.
+ * Actually media service will filter all the media contents query from database by the media validation.
+ * This function is always used for MMC card insert/inject operation, in file manager service library.
+ * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] storage_type information for storage type
+ * @param[in] valid whether the track item is valid.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_delete_invalid_media_records.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void set_db_valid(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ bool valid = TRUE;
+
+ //set the validation of medias in MMC storage in db.
+ ret = minfo_set_db_valid(mb_svc_handle, MINFO_MMC, valid);
+ if (ret < 0) {
+ printf( "failed to set db invalid. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int minfo_set_db_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid);
+
+/**
+ * minfo_set_item_valid_start
+ * This function set whether the media content in a type of storage is valid, like phone or MMC.
+ * Actually media service will filter all the media contents query from database by the media validation.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] trans_count count of trasaction user wants
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_set_item_valid, minfo_set_item_valid_end
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
+{
+ int i;
+ int ret = MB_SVC_ERROR_NONE;
+ bool valid = TRUE;
+
+ ret = minfo_set_item_valid_start(mb_svc_handle, 100);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_start failed. error code->%d", ret);
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ //set the validation of a media in MMC storage in db.
+ ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
+ if (ret < 0) {
+ printf( "failed to set item valid. error code->%d", ret);
+ return;
+ }
+ }
+
+ ret = minfo_set_item_valid_end(mb_svc_handle);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_end failed. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int minfo_set_item_valid_start(MediaSvcHandle *mb_svc_handle, int trans_count);
+
+
+/**
+ * minfo_set_item_valid_end
+ * This function set whether the media content in a type of storage is valid, like phone or MMC.
+ * Actually media service will filter all the media contents query from database by the media validation.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_set_item_valid_start, minfo_set_item_valid
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
+{
+ int i;
+ int ret = MB_SVC_ERROR_NONE;
+ bool valid = TRUE;
+
+ ret = minfo_set_item_valid_start(mb_svc_handle, 100);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_start failed. error code->%d", ret);
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ //set the validation of a media in MMC storage in db.
+ ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
+ if (ret < 0) {
+ printf( "failed to set item valid. error code->%d", ret);
+ return;
+ }
+ }
+
+ ret = minfo_set_item_valid_end(mb_svc_handle);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_end failed. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+int minfo_set_item_valid_end(MediaSvcHandle *mb_svc_handle);
+
+
+/**
+ * minfo_set_item_valid
+ * This function set whether the media content in a type of storage is valid, like phone or MMC.
+ * Actually media service will filter all the media contents query from database by the media validation.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] storage_type information for storage type
+ * @param[in] full_path The path of the media
+ * @param[in] valid whether the track item is valid.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_set_item_valid_start, minfo_set_item_valid_end
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void set_item_valid_batch(MediaSvcHandle *mb_svc_handle)
+{
+ int i;
+ int ret = MB_SVC_ERROR_NONE;
+ bool valid = TRUE;
+
+ ret = minfo_set_item_valid_start(mb_svc_handle, 100);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_start failed. error code->%d", ret);
+ return;
+ }
+
+ for (i = 0; i < 200; i++) {
+ //set the validation of a media in MMC storage in db.
+ ret = minfo_set_item_valid(mb_svc_handle, MINFO_MMC, image_files[i], valid);
+ if (ret < 0) {
+ printf( "failed to set item valid. error code->%d", ret);
+ return;
+ }
+ }
+
+ ret = minfo_set_item_valid_end(mb_svc_handle);
+ if (ret < 0) {
+ printf( "minfo_set_item_valid_end failed. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+
+int minfo_set_item_valid(MediaSvcHandle *mb_svc_handle,
+ const minfo_store_type storage_type,
+ const char *full_path,
+ int valid);
+
+
+/**
+ * minfo_delete_invalid_media_records
+ * This function delete all of invalid media records in a type of storage are valid, like phone or MMC.
+ * Actually media service will filter all the media contents query from database by the media validation.
+ * This function is always used for MMC card insert/inject operation, in file manager service library.
+ * When inject a MMC card, the media records for MMC are not deleted really, but are set to be invalid.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] storage_type information for storage type
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_set_db_valid.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+
+ //delete the invalid media records in MMC storage in db.
+ ret = minfo_delete_invalid_media_records(mb_svc_handle, MINFO_MMC);
+ if (ret < 0) {
+ printf( "failed to delete invalid items. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
+
+/**
+ * minfo_delete_tag
+ * This function could delete a tag or some member of the tag in 'media_tag' table in database. When user pass @p media_id not equal
+ * to -1, the tag will be deleted, otherwise some member of the tag will be deleted. Whatever cases, user should pass the correct tag name with
+ * @p tag_name to successfully delete.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] media_id identify a media item with this ID
+ * @param[in] tag_name name of deleted tag
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void delete_a_tag(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+
+ //delete all tag records in 'media_tag' in db, whose tag name is 'test_tag'.
+ ret = minfo_delete_tag(mb_svc_handle, -1, "test tag");
+ if (ret < 0) {
+ printf( "failed to delete a tag record. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_delete_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
+
+
+/**
+ * minfo_rename_tag:
+ * This function could rename a tag_name to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
+ * tag name, @p dst_tag_name which is new tag name replacing @p src_tagname. This function will check whether the new tag name, @p dst_tag_name, has
+ * existed in 'media_tag' table. If yes, this function will item by item replace old tag name, if no, this function will directly update old tag name to new tag name.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] src_tagname identify original tag name
+ * @param[in] dst_tag_name new tag name.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_rename_tag(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+
+ //rename all tag records with new tag name 'test_tag2'.
+ ret = minfo_rename_tag(mb_svc_handle, "test tag1", "test tag2");
+ if (ret < 0) {
+ printf( "failed to rename tag records. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_rename_tag(MediaSvcHandle *mb_svc_handle, const char* src_tagname, const char* dst_tag_name);
+
+/**
+ * minfo_rename_tag_by_id:
+ * This function could rename a tag_name for some tag record to another tag_name in 'media_tag' table in database. User need to pass @p src_tagname which indicate original
+ * tag name, @p media_id which combine with the @p src_tagname to indentify one tag record, @p dst_tag_name which is new tag name replacing @p src_tagname.
+ * This function will check whether the new tag name with @p media_id has existed in 'media_tag' table. If yes, this function will delete old tag record, if no, this function will directly
+ * update old tag record to new tag record.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] media_id identify original tag record with @p src_tagname
+ * @param[in] src_tagname identify original tag record with @p media_id
+ * @param[in] dst_tag_name new tag name.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+
+ //rename some tag record with new tag name 'test_tag2'.
+ ret = minfo_rename_tag_by_id(mb_svc_handle, media_id, "test tag1", "test tag2");
+ if (ret < 0) {
+ printf( "failed to rename tag records. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* src_tagname, const char* dst_tag_name);
+
+
+
+
+/**
+ * minfo_add_tag:
+ * This function could add a new tag into 'media_tag' table in database. When user create a new tag and will
+ * not add any media item to it, he/she should set @p media_id as 0. When user create a new tag and want to add
+ * some media items to it, he/she should do a loop to insert them into 'media_tag' table in database, meanwhile
+ * should fill up @p media_id and @p tag_name with appropriate values.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] media_id identify a media item with this ID
+ * @param[in] tag_name name of new added tag
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void add_a_tag(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+
+ //add a tag record in 'media_tag' in db, and not add any media item to it.
+ ret = minfo_add_tag(mb_svc_handle, NULL, "test tag");
+ if (ret < 0)
+ {
+ printf( "failed to add a tag record. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_add_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* tag_name);
+
+/**
+ * minfo_get_media_list_by_tagname:
+ * This function could get a media items' list who are included to the same tag according to tag name .
+ * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
+ * no if FALSE.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] tag_name tag name
+ * @param[in] with_meta indicate whether want to get meta data of media item
+ * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+int mitem_ite_cb(Mitem *item, void *user_data)
+{
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, item);
+}
+
+
+void get_media_list_tag_name(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ GList *p_list = NULL;
+
+ //get a media items' list who are included to the same tag with 'test tag'.
+ ret = minfo_get_media_list_by_tagname(mb_svc_handle, "test tag", FALSE, mitem_ite_cb, &p_list);
+ if (ret < 0) {
+ printf( "failed to get a media items' list. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_get_media_list_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, bool with_meta, minfo_item_ite_cb func, void* user_data );
+
+/**
+ * minfo_get_media_list_by_tagname_with_filter:
+ * This function could get a media items' list who are included to the same tag according to tag name and filter.
+ * User could dictate whether he/she hope to get meta data of media item with @p with_meta. Yes if TRUE,
+ * no if FALSE.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] tag_name tag name
+ * @param[in] filter the filter to specify some tag filter conditions, like, type of got items, sort by type, start and end positions of items, including meta data or not, etc.
+ * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param[out] user_data user's data structure to contain items of the type Mitem. It is passed to the iterative callback.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+int mitem_ite_cb(Mitem *item, void *user_data)
+{
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, item);
+}
+
+
+void get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ GList *p_list = NULL;
+ minfo_tag_filter filter;
+
+ filter.start_pos = 0;
+ filter.end_pos = 3;
+ filter.file_type = MINFO_ITEM_ALL;
+ filter.with_meta = FALSE;
+
+ //get a media items' list who are included to the same tag with 'test tag'.
+ ret = minfo_get_media_list_by_tagname_with_filter(mb_svc_handle, "test tag", filter, mitem_ite_cb, &p_list);
+ if (ret < 0) {
+ printf( "failed to get a media items' list. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle, const char* tag_name, minfo_tag_filter filter, minfo_item_ite_cb func, void* user_data );
+
+/**
+ * minfo_get_media_count_by_tagname:
+ * This function could get count of media items, which are included to the same tag according to tag name .
+ * User could dictate whether he/she hope to get count of media items.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] tag_name tag name
+ * @param[out] count count of media items
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ int count = 0;
+
+ //get count of media items, which are included to the same tag with 'test tag'.
+ ret = minfo_get_media_count_by_tagname(mb_svc_handle, "test tag", &count);
+ if (ret < 0) {
+ printf( "failed to get a media items' list. error code->%d", ret);
+ } else {
+ printf( "Count is %d\n", count );
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name, int* count );
+
+/**
+ * minfo_get_tag_list_by_media_id:
+ * This function could get a tags' list whose memeber is Mtag type. User should pass @p media_id to indicate which
+ * media item will be searched. Also he/she should define a callback function to be called by this function.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] media_id identify a media item with ID
+ * @param[in] func Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+ * @param[out] user_data user's data structure to contain items of the type Mtag. It is passed to the iterative callback.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_set_db_valid.
+ * @pre None
+ * @post None
+ * @remark None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+int mtag_ite_cb(Mtag *i_tag, void *user_data)
+{
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, item);
+}
+
+
+void get_tag_list_media_id(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ const char *media_id = "b6a4f4ac-26ea-458c-a228-9aef7f70349d";
+ GList *p_list = NULL;
+
+ //get a tags' list which include the same media item and it's media_id is b6a4f4ac-26ea-458c-a228-9aef7f70349d.
+ ret = minfo_get_tag_list_by_media_id(mb_svc_handle, media_id, mtag_ite_cb, &p_list);
+ if (ret < 0) {
+ printf( "failed to get a tags' list. error code->%d", ret);
+ return;
+ }
+}
+
+ * @endcode
+ */
+
+int
+minfo_get_tag_list_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_tag_ite_cb func, void* user_data);
+
+/**
+ * minfo_add_web_cluster
+ * This function could add a web album through specifying it's @p name, @p account_id. After adding a web
+ * album, this function will return @p id.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] sns_type sns type, like, facebook, flickr, etc.
+ * @param[in] name new added web album's name.
+ * @param[in] account_id account ID.
+ * @param[out] id return album's id.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_add_web_cluster_album_id.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+
+void add_web_cluster(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ char cluster_id[256] = {0,};
+
+ //add a web album.
+ ret = minfo_add_web_cluster(mb_svc_handle, 1, "web_album", "1", cluster_id, sizeof(cluster_id));
+ if (ret < 0) {
+ printf( "failed to add a web album. error code->%d", ret);
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_add_web_cluster(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name,const char *account_id, char* id, int max_length);
+
+
+/**
+ * minfo_add_web_cluster_album_id
+ * This function could add a web album through specifying it's @p name, @p account_id, @p album_id. After adding a web
+ * album, this function will return @p id.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] sns_type sns type, like, facebook, flickr, etc.
+ * @param[in] name new added web album's name.
+ * @param[in] account_id account ID.
+ * @param[in] album_id web album id
+ * @param[out] id return album's id.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see minfo_add_web_cluster.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+
+void add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ char cluster_id[256] = {0,};
+
+ //add a web album.
+ ret = minfo_add_web_cluster_album_id(mb_svc_handle, 1, "web_album", "1", "1", cluster_id, sizeof(cluster_id));
+ if (ret < 0) {
+ printf( "failed to add a web album. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name, const char *account_id, const char *album_id, char *id, int max_length);
+
+/**
+ * minfo_delete_web_cluster
+ * This function could delete a web album through specifying @p cluster_id. After deleteing a web
+ * album, the application will not be able to get this web album displaying.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] cluster_id cluster ID identifying a web album.
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void delete_web_cluster(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //delete a web album.
+ ret = minfo_delete_web_cluster(mb_svc_handle, cluster_id);
+ if (ret < 0) {
+ printf( "failed to delete a web album. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_delete_web_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id);
+
+/**
+* minfo_get_web_cluster_by_web_account_id
+* This function gets list of mcluster by web account id. User could get the detail information with
+* the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
+* count of included media content, etc. The detail defination of this type could refer to the herder file, minfo_item/minfo-cluster.h.
+*
+* @return This function returns 0 on success, or negative value with error code.
+* Please refer 'media-svc-error.h' to know the exact meaning of the error.
+* @param mb_svc_handle [in] the handle of DB
+* @param web_account_id [in] the web account ID which indentify a cluster
+* @param func [in] Iterative callback implemented by a user. This callback is called when an item has to be inserted to user's list.
+* @param user_data [out] user's data structure to contain items of the type Mcluster. It is passed to the iterative callback.
+* @exception None.
+* @remarks User could pass web account id to this function, so that
+* this function still could get the wanted list of clusters
+* when invoking this function.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+
+ #include <media-svc.h>
+ int mcluster_ite_cb(Mcluster *cluster, void *user_data)
+ {
+ GList** list = (GList**)user_data;
+ *list = g_list_append(*list, cluster);
+ }
+
+ void test_minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ const char* account_id = "user";
+ GList *p_list = NULL;
+
+ //get a web cluster using account id.
+ ret = minfo_get_web_cluster_by_web_account_id(mb_svc_handle, account_id, mcluster_ite_cb, &p_list);
+ if(ret < 0) {
+ printf("minfo_get_web_cluster_by_web_account_id fail: %d \n", ret);
+ return;
+ }
+ }
+* @endcode
+*/
+
+int
+minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle, const char* web_account_id, minfo_cluster_ite_cb func, void *user_data);
+
+/**
+* minfo_get_web_cluster_web_album_id
+* This function gets mcluster information by web cluster id. User could get the detail information with
+* the type 'Mcluster' about this cluster, the type 'Mcluster' mainly include folder/cluster ID, display name,
+* count of included media content, etc. The detail defination of this type could refer to the herder file, minfo-cluster.h.
+*
+* @return This function returns 0 on success, or negative value with error code.
+* @param mb_svc_handle [in] the handle of DB
+* @param cluster_id [in] the cluster ID which indentify a cluster
+* @param mcluster [out] mcluster to be returned, which is a 'Mcluster' type
+* @exception None.
+* @remarks User could pass cluster id to this function, so that
+* this function still could get the wanted cluster.
+* when invoking this function, *mcluster must equals NULL, and
+* after using mitem, it must be freed with minfo_destroy_mtype_item.
+* @see None.
+* @pre None
+* @post None
+* @par example
+* @code
+
+ #include <media-svc.h>
+
+ void test_minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle)
+ {
+ int ret = -1;
+ Mcluster *mc = NULL;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //get a cluster using cluster's id.
+ ret = minfo_get_web_cluster_web_album_id(mb_svc_handle, cluster_id, &mc);
+ if(ret < 0) {
+ printf("minfo_get_web_cluster_web_album_id fail: %d \n", ret);
+ return;
+ }
+
+ minfo_destroy_mtype_item(mc);
+ }
+* @endcode
+*/
+
+int
+minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle, const char *web_album_id, Mcluster **mcluster);
+
+/**
+ * minfo_add_web_media
+ * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name
+ * @p thumb_path. If failed to add it to web album, this function will return an error code.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] cluster_id specify cluster id to indentify a web album.
+ * @param[in] http_url web media's url.
+ * @param[in] file_name file name.
+ * @param[in] thumb_path thumbnail full path of this web media
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remarks None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+void test_minfo_add_web_media(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //add a web media to a web album.
+ ret = minfo_add_web_media(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", "thumbnail path");
+ if (ret < 0) {
+ printf( "failed to add to a web album. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+DEPRECATED_API int
+minfo_add_web_media(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, const char* thumb_path);
+
+/**
+ * minfo_add_web_media_with_type
+ * This function could add a web media to web album specified by @p cluster_id, in addition, user need to pass @p http_url, @p file_name, @p content_type,
+ * @p thumb_path. If failed to add it to web album, this function will return an error code.
+ *
+ * @param[in] mb_svc_handle the handle of DB
+ * @param[in] cluster_id specify cluster id to indentify a web album.
+ * @param[in] http_url web media's url.
+ * @param[in] file_name file name.
+ * @param[in] content_type type of the media.
+ * @param[in] thumb_path thumbnail full path of this web media
+ * @return This function returns zero(MB_SVC_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-svc-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None
+ * @post None
+ * @remark None
+ * @par example
+ * @code
+
+#include <media-svc.h>
+
+
+void test_minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle)
+{
+ int ret = MB_SVC_ERROR_NONE;
+ const char *cluster_id = "51298053-feb7-4261-a1c8-26b05a6e0ae0";
+
+ //add a web media to a web album.
+ ret = minfo_add_web_media_with_type(mb_svc_handle, cluster_id, "http://user/specifying/address", "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
+ if (ret < 0) {
+ printf( "failed to add to a web album. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+
+int
+minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* http_url, const char* file_name, minfo_file_type content_type, const char* thumb_path);
+
+/**
+ @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+
+
+
+#endif /*_VISUAL_SVC_H_*/
+
+
* File name is changed to media-svc-hash.c
*/
-#include "media-svc-error.h"
#include "md5.h"
#include <string.h>
#include <alloca.h>
+#include "media-svc-hash.h"
+#include "visual-svc-error.h"
static const char ACCEPTABLE_URI_CHARS[96] = {
--- /dev/null
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _MEDIA_SVC_HASH_
+#define _MEDIA_SVC_HASH_
+
+int mb_svc_generate_hash_code(const char *origin_path, char *hash_code, int max_length);
+
+#endif /*MEDIA_SVC_HASH_*/
+
#include "audio-svc-debug.h"
#include "audio-svc-error.h"
#include "audio-svc-db-utils.h"
-#include "media-info-util.h"
+#include "media-svc-util.h"
int _audio_svc_sql_busy_handler(void *pData, int count)
{
return 100 - count;
}
-int _audio_svc_sql_query(const char *sql_str)
+int _audio_svc_sql_query(sqlite3 *handle, const char *sql_str)
{
int err = -1;
char *zErrMsg = NULL;
audio_svc_debug("SQL = [%s]", sql_str);
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_error("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
err = sqlite3_exec(handle, sql_str, NULL, NULL, &zErrMsg);
if (SQLITE_OK != err) {
return err;
}
-int _audio_svc_sql_query_list(GList **query_list)
+int _audio_svc_sql_query_list(sqlite3 *handle, GList **query_list)
{
int i = 0;
int length = g_list_length(*query_list);
for (i = 0; i < length; i++) {
sql = (char*)g_list_nth_data(*query_list, i);
if(sql != NULL) {
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
sql = NULL;
if (err != SQLITE_OK) {
}
-int _audio_svc_sql_prepare_to_step(const char *sql_str, sqlite3_stmt** stmt)
+int _audio_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt)
{
int err = -1;
audio_svc_debug("[SQL query] : %s", sql_str);
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_error("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
err = sqlite3_prepare_v2(handle, sql_str, -1, stmt, NULL);
sqlite3_free((char *)sql_str);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_sql_begin_trans(void)
+int _audio_svc_sql_begin_trans(sqlite3 *handle)
{
char *err_msg = NULL;
audio_svc_debug("========_audio_svc_sql_begin_trans");
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
-
if (handle == NULL) {
audio_svc_error("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (SQLITE_OK != sqlite3_exec(handle, "BEGIN IMMEDIATE;", NULL, NULL, &err_msg)) {
audio_svc_error("Error:failed to begin transaction: error=%s", err_msg);
sqlite3_free(err_msg);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_sql_end_trans(void)
+int _audio_svc_sql_end_trans(sqlite3 *handle)
{
char *err_msg = NULL;
audio_svc_debug("========_audio_svc_sql_end_trans");
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
-
if (handle == NULL) {
audio_svc_error("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (SQLITE_OK != sqlite3_exec(handle, "COMMIT;", NULL, NULL, &err_msg)) {
audio_svc_error("Error:failed to end transaction: error=%s", err_msg);
sqlite3_free(err_msg);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_sql_rollback_trans(void)
+int _audio_svc_sql_rollback_trans(sqlite3 *handle)
{
char *err_msg = NULL;
audio_svc_debug("========_audio_svc_sql_rollback_trans");
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_error("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (SQLITE_OK != sqlite3_exec(handle, "ROLLBACK;", NULL, NULL, &err_msg)) {
audio_svc_error("Error:failed to rollback transaction: error=%s", err_msg);
sqlite3_free(err_msg);
#include <glib.h>
#include <sys/stat.h>
-#include "media-info-util.h"
+#include "media-svc-util.h"
#include "audio-svc-error.h"
#include "audio-svc-music-table.h"
#include "audio-svc-playlist-table.h"
#define AUDIO_SVC_COLLATE_NOCASE "COLLATE NOCASE"
static const char *g_audio_svc_music_fields =
- "audio_id, path, thumbnail_path, title, album, artist, genre, author, year,\
-copyright, description, format, bitrate,track_num,duration, rating, played_count, last_played_time, added_time, modified_date, size, category, valid, folder_id, storage_type";
+ "audio_uuid, path, thumbnail_path, title, album, artist, genre, author, year,\
+copyright, description, format, bitrate,track_num,duration, rating, played_count, last_played_time, added_time, modified_date, size, category, valid, folder_uuid, storage_type";
static __thread GList *g_audio_svc_item_valid_query_list = NULL;
static __thread GList *g_audio_svc_move_item_query_list = NULL;
static __thread GList *g_audio_svc_insert_item_query_list = NULL;
-static int __audio_svc_create_music_db_table();
-static void __audio_svc_get_next_record(audio_svc_audio_item_s *item,
- sqlite3_stmt *stmt);
-static int
-__audio_svc_count_invalid_records_with_thumbnail(audio_svc_storage_type_e
- storage_type);
-static int __audio_svc_count_records_with_thumbnail(audio_svc_storage_type_e
- storage_type);
-static int
-__audio_svc_get_invalid_records_with_thumbnail(audio_svc_storage_type_e
- storage_type, int count,
- mp_thumbnailpath_record_t *
- thumb_path);
-static int __audio_svc_get_records_with_thumbnail(audio_svc_storage_type_e
- storage_type, int count,
- mp_thumbnailpath_record_t *
- thumb_path);
+static int __audio_svc_create_music_db_table(sqlite3 *handle);
+static void __audio_svc_get_next_record(audio_svc_audio_item_s *item, sqlite3_stmt *stmt);
+static int __audio_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e storage_type);
+static int __audio_svc_count_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e storage_type);
+static int __audio_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e storage_type, int count, mp_thumbnailpath_record_t * thumb_path);
+static int __audio_svc_get_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e storage_type, int count, mp_thumbnailpath_record_t * thumb_path);
-static int __audio_svc_create_music_db_table(void)
+static int __audio_svc_create_music_db_table(sqlite3 *handle)
{
int err = -1;
char *sql = sqlite3_mprintf("create table if not exists %s (\
- audio_id text primary key, \
+ audio_uuid text primary key, \
path text unique, \
thumbnail_path text, \
title text, \
size integer default 0, \
category INTEGER default 0, \
valid integer default 0, \
- folder_id TEXT NOT NULL, \
+ folder_uuid TEXT NOT NULL, \
storage_type integer, \
favourite integer default 0, \
content_type integer default %d);",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CONTENT_TYPE);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to create db table (%d)", err);
static void __audio_svc_get_next_record(audio_svc_audio_item_s *item,
sqlite3_stmt *stmt)
{
- _strncpy_safe(item->audio_id,
- (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_AUDIO_ID), sizeof(item->audio_id));
+ _strncpy_safe(item->audio_uuid,
+ (const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_AUDIO_ID), sizeof(item->audio_uuid));
_strncpy_safe(item->pathname,
(const char *)sqlite3_column_text(stmt, AUDIO_SVC_AUDIO_INFO_PATH), sizeof(item->pathname));
_strncpy_safe(item->thumbname,
}
static int
-__audio_svc_count_invalid_records_with_thumbnail(audio_svc_storage_type_e
+__audio_svc_count_invalid_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e
storage_type)
{
int ret = AUDIO_SVC_ERROR_NONE;
("select count(*) from %s where valid=0 and storage_type=%d and thumbnail_path is not null",
AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
}
-static int __audio_svc_count_records_with_thumbnail(audio_svc_storage_type_e
+static int __audio_svc_count_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e
storage_type)
{
int ret = AUDIO_SVC_ERROR_NONE;
("select count(*) from %s where storage_type=%d and thumbnail_path is not null",
AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
}
static int
-__audio_svc_get_invalid_records_with_thumbnail(audio_svc_storage_type_e
+__audio_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e
storage_type, int count,
mp_thumbnailpath_record_t *
thumb_path)
int err = -1;
int idx = 0;
sqlite3_stmt *sql_stmt = NULL;
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
char *sql =
sqlite3_mprintf
("select thumbnail_path from %s where valid=0 and storage_type=%d and thumbnail_path is not null",
return AUDIO_SVC_ERROR_NONE;
}
-static int __audio_svc_get_records_with_thumbnail(audio_svc_storage_type_e
+static int __audio_svc_get_records_with_thumbnail(sqlite3 *handle, audio_svc_storage_type_e
storage_type, int count,
mp_thumbnailpath_record_t *
thumb_path)
int err = -1;
int idx = 0;
sqlite3_stmt *sql_stmt = NULL;
-
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
char *sql =
sqlite3_mprintf
("select thumbnail_path from %s where storage_type=%d and thumbnail_path is not null",
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_create_music_table(void)
+int _audio_svc_create_music_table(sqlite3 *handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- ret = __audio_svc_create_music_db_table();
+ ret = __audio_svc_create_music_db_table(handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_truncate_music_table(audio_svc_storage_type_e storage_type)
+int _audio_svc_truncate_music_table(sqlite3 *handle, audio_svc_storage_type_e storage_type)
{
int idx = 0;
mp_thumbnailpath_record_t *thumbpath_record = NULL;
int invalid_count = 0;
int ret = AUDIO_SVC_ERROR_NONE;
- invalid_count = __audio_svc_count_records_with_thumbnail(storage_type);
+ invalid_count = __audio_svc_count_records_with_thumbnail(handle, storage_type);
audio_svc_debug("invalid count: %d\n", invalid_count);
if (invalid_count > 0) {
memset(thumbpath_record, 0,
sizeof(mp_thumbnailpath_record_t) * invalid_count);
- ret =
- __audio_svc_get_records_with_thumbnail(storage_type,
- invalid_count,
- thumbpath_record);
+ ret = __audio_svc_get_records_with_thumbnail(handle, storage_type, invalid_count, thumbpath_record);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("error when get thumbnail record");
SAFE_FREE(thumbpath_record);
char *sql =
sqlite3_mprintf("delete from %s where storage_type=%d",
AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to truncate table (%d)", err);
for (idx = 0; idx < invalid_count; idx++) {
if (strlen(thumbpath_record[idx].thumbnail_path) > 0) {
- ret =
- _audio_svc_check_and_remove_thumbnail
- (thumbpath_record[idx].thumbnail_path);
+ ret = _audio_svc_check_and_remove_thumbnail(handle, thumbpath_record[idx].thumbnail_path);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
("error _audio_svc_check_and_remove_thumbnail");
}
-int _audio_svc_create_folder_table(void)
+int _audio_svc_create_folder_table(sqlite3 *handle)
{
int err = -1;
char *sql = sqlite3_mprintf("create table if not exists %s (\
- _id text primary key, \
+ folder_uuid text primary key, \
path text,\
folder_name text,\
storage_type integer,\
modified_date integer default 0);", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("error while create folder table");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_folder(audio_svc_storage_type_e storage_type, const char *folder_id)
+int _audio_svc_delete_folder(sqlite3 *handle, audio_svc_storage_type_e storage_type, const char *folder_id)
{
int err = -1;
char *sql = NULL;
if ((storage_type == AUDIO_SVC_STORAGE_MMC) && (folder_id == NULL)) { /* when mmc card removed. */
sql = sqlite3_mprintf("delete from %s where storage_type=%d",
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, storage_type);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_debug("It failed to delete item (%d)", err);
}
} else {
sql =
- sqlite3_mprintf("delete from %s where _id='%q'",
+ sqlite3_mprintf("delete from %s where folder_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_debug("It failed to delete item (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_insert_item_with_data(audio_svc_audio_item_s *item, bool stack_query)
+int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *item, bool stack_query)
{
int err = -1;
int ret = AUDIO_SVC_ERROR_NONE;
int year = -1;
char *audio_id = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (item == NULL) {
audio_svc_error("Invalid handle");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
sizeof(item->audio.year));
}
- ret = _audio_svc_get_and_append_folder_id_by_path(item->pathname, item->storage_type, folder_id);
+ ret = _audio_svc_get_and_append_folder_id_by_path(handle, item->pathname, item->storage_type, folder_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
char *sql =
audio_svc_debug("query : %s", sql);
if(!stack_query) {
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to insert music record");
_audio_svc_sql_query_add(&g_audio_svc_insert_item_query_list, &sql);
}
- //item->audio_id = sqlite3_last_insert_rowid(handle);
+ //item->audio_uuid = sqlite3_last_insert_rowid(handle);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_select_music_record_by_audio_id(const char *audio_id,
+int _audio_svc_select_music_record_by_audio_id(sqlite3 *handle, const char *audio_id,
audio_svc_audio_item_s *item)
{
int ret = AUDIO_SVC_ERROR_NONE;
char *sql =
sqlite3_mprintf
- ("select * from %s where audio_id='%q' and valid=1 and category=%d",
+ ("select * from %s where audio_uuid='%q' and valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO, audio_id, AUDIO_SVC_CATEGORY_MUSIC);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("error when _audio_svc_select_music_record_by_audio_id. ret = [%d]", ret);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_select_music_record_by_path(const char *path,
+int _audio_svc_select_music_record_by_path(sqlite3 *handle, const char *path,
audio_svc_audio_item_s *item)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- /* hjkim, 110211, remove category condition for the sound files */
+
char *sql =
sqlite3_mprintf("select * from %s where valid=1 and path='%q' ",
AUDIO_SVC_DB_TABLE_AUDIO, path);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_music_record_by_audio_id(const char *audio_id)
+int _audio_svc_delete_music_record_by_audio_id(sqlite3 *handle, const char *audio_id)
{
int err = -1;
- /* hjkim, 110211, remove category condition for the sound files */
char *sql =
- sqlite3_mprintf("delete from %s where valid=1 and audio_id='%q'",
+ sqlite3_mprintf("delete from %s where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, audio_id);
- err = _audio_svc_sql_query(sql);
+
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to delete item (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_metadata_in_music_record(const char *audio_id,
+int _audio_svc_update_metadata_in_music_record(sqlite3 *handle, const char *audio_id,
audio_svc_audio_item_s *item)
{
int err = -1;
char *sql =
sqlite3_mprintf
("update %s set thumbnail_path='%q',title='%q',album='%q',artist='%q',arist_seq='%q' ,genre='%q',author='%q',\
- year=%d,copyright='%q',description='%q',format='%q',track_num=%d,duration=%d,bitrate=%d where valid=1 and audio_id='%q'",
+ year=%d,copyright='%q',description='%q',format='%q',track_num=%d,duration=%d,bitrate=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO,
item->thumbname,
item->audio.title,
item->audio.track, item->audio.duration, item->audio.bitrate,
audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update metadata (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_path_in_music_record(const char *src_path,
+int _audio_svc_update_path_in_music_record(sqlite3 *handle, const char *src_path,
const char *path, const char *title)
{
char *sql = NULL;
AUDIO_SVC_DB_TABLE_AUDIO, path, src_path);
}
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update metadata (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_path_and_storage_in_music_record(const char *src_path, const char *path, audio_svc_storage_type_e storage_type)
+int _audio_svc_update_path_and_storage_in_music_record(sqlite3 *handle, const char *src_path, const char *path, audio_svc_storage_type_e storage_type)
{
int err = -1;
char *sql = sqlite3_mprintf("update %s set path='%q', storage_type=%d where valid=1 and path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, path, storage_type, src_path);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update metadata (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_folder_id_in_music_record(const char *path, const char *folder_id)
+int _audio_svc_update_folder_id_in_music_record(sqlite3 *handle, const char *path, const char *folder_id)
{
int err = -1;
- char *sql = sqlite3_mprintf("update %s set folder_id='%q' where path='%q'",
+ char *sql = sqlite3_mprintf("update %s set folder_uuid='%q' where path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, folder_id, path);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update metadata (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_thumb_path_in_music_record(const char *file_path,
+int _audio_svc_update_thumb_path_in_music_record(sqlite3 *handle, const char *file_path,
const char *path)
{
int err = -1;
("update %s set thumbnail_path='%q' where valid=1 and path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, path, file_path);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update thumb path (%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_rating_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_rating_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
int rated_time = -1;
char *sql =
sqlite3_mprintf
- ("update %s set rating=%d, rated_time=%d where valid=1 and audio_id='%q'",
+ ("update %s set rating=%d, rated_time=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, rated_time, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_debug("To update rating is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_playtime_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_playtime_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set last_played_time=%d where valid=1 and audio_id='%q'",
+ ("update %s set last_played_time=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update last_played_time is failed(%d)",
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_playcount_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_playcount_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set played_count=%d where valid=1 and audio_id='%q'",
+ ("update %s set played_count=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update played count is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_addtime_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_addtime_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set added_time=%d where valid=1 and audio_id='%q'",
+ ("update %s set added_time=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update added_time is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_track_num_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_track_num_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set track_num=%d where valid=1 and audio_id='%q'",
+ ("update %s set track_num=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("update track num is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_album_rating_in_music_record(const char *audio_id,
+int _audio_svc_update_album_rating_in_music_record(sqlite3 *handle, const char *audio_id,
int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set album_rating=%d where valid=1 and audio_id='%q'",
+ ("update %s set album_rating=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("update album_rating is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_year_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_year_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set year=%d where valid=1 and audio_id='%q'",
+ ("update %s set year=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("update year is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_title_in_music_record(const char *audio_id,
+int _audio_svc_update_title_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set title='%q' where valid=1 and audio_id='%q'",
+ ("update %s set title='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update title is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_artist_in_music_record(const char *audio_id,
+int _audio_svc_update_artist_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set artist='%q' where valid=1 and audio_id='%q'",
+ ("update %s set artist='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update artist is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_album_in_music_record(const char *audio_id,
+int _audio_svc_update_album_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set album='%q' where valid=1 and audio_id='%q'",
+ ("update %s set album='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update album is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_genre_in_music_record(const char *audio_id,
+int _audio_svc_update_genre_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set genre='%q' where valid=1 and audio_id='%q'",
+ ("update %s set genre='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update genre is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_author_in_music_record(const char *audio_id,
+int _audio_svc_update_author_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set author='%q' where valid=1 and audio_id='%q'",
+ ("update %s set author='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update author is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_description_in_music_record(const char *audio_id,
+int _audio_svc_update_description_in_music_record(sqlite3 *handle, const char *audio_id,
const char *changed_value)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("update %s set description='%q' where valid=1 and audio_id='%q'",
+ ("update %s set description='%q' where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update description is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_favourite_in_music_record(const char *audio_id, int changed_value)
+int _audio_svc_update_favourite_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value)
{
int err = -1;
- char *sql = sqlite3_mprintf("update %s set favourite=%d where valid=1 and audio_id='%q'",
+ char *sql = sqlite3_mprintf("update %s set favourite=%d where valid=1 and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, changed_value, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("update album_rating is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_count_music_group_records(audio_svc_group_type_e group_type,
+int _audio_svc_count_music_group_records(sqlite3 *handle, audio_svc_group_type_e group_type,
const char *limit_string1,
const char *limit_string2,
const char *filter_string,
int text_bind = 1;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (filter_string) {
if (strlen(filter_string) > 0) {
snprintf(filter_query, sizeof(filter_query), "%%%s%%",
case AUDIO_SVC_GROUP_BY_FOLDER:
{
snprintf(query, sizeof(query),
- "select count(distinct folder_id) from %s where valid=1 and category=%d",
+ "select count(distinct folder_uuid) from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
/*FIX ME. if filter_mode exist. */
if (filter_mode) {
snprintf(query, sizeof(query),
- "select count(distinct a.folder_id) from %s a inner join %s b on a.folder_id = b._id \
+ "select count(distinct a.folder_uuid) from %s a inner join %s b on a.folder_uuid=b.folder_uuid \
where a.valid=1 and a.category=%d and b.path like ?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
}
}
-int _audio_svc_get_music_group_records(audio_svc_group_type_e group_type,
+int _audio_svc_get_music_group_records(sqlite3 *handle, audio_svc_group_type_e group_type,
const char *limit_string1,
const char *limit_string2,
const char *filter_string,
int idx = 0;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (filter_string) {
if (strlen(filter_string) > 0) {
snprintf(filter_query, sizeof(filter_query), "%%%s%%",
case AUDIO_SVC_GROUP_BY_ALBUM:
{
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
case AUDIO_SVC_GROUP_BY_ARTIST:
{
snprintf(query, sizeof(query),
- "select artist, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+ "select artist, min(audio_uuid), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
{
if (limit_string1 && strlen(limit_string1) > 0) {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and artist=?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
} else {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and artist is null",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
}
case AUDIO_SVC_GROUP_BY_GENRE:
{
snprintf(query, sizeof(query),
- "select genre, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+ "select genre, min(audio_uuid), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
case AUDIO_SVC_GROUP_BY_FOLDER:
{
snprintf(query, sizeof(query),
- "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
- from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d",
+ "select b.folder_name, min(a.audio_uuid), (b.path), (a.thumbnail_path), (a.album_rating) \
+ from %s as a inner join %s b on a.folder_uuid=b.folder_uuid where a.valid=1 and a.category=%d",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
if (filter_mode) {
snprintf(query, sizeof(query),
- "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
- from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d and b.path like ?",
+ "select b.folder_name, min(a.audio_uuid), (b.path), (a.thumbnail_path), (a.album_rating) \
+ from %s as a inner join %s b on a.folder_uuid=b.folder_uuid where a.valid=1 and a.category=%d and b.path like ?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
}
if (filter_mode2) {
snprintf(query, sizeof(query),
- "select b.folder_name, min(a.audio_id), (b.path), (a.thumbnail_path), (a.album_rating) \
- from %s as a inner join %s b on a.folder_id = b._id where a.valid=1 and a.category=%d and b.path like ? and b.path like ?",
+ "select b.folder_name, min(a.audio_uuid), (b.path), (a.thumbnail_path), (a.album_rating) \
+ from %s as a inner join %s b on a.folder_uuid=b.folder_uuid where a.valid=1 and a.category=%d and b.path like ? and b.path like ?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_CATEGORY_MUSIC);
}
snprintf(tail_query, sizeof(tail_query),
- " group by a.folder_id order by b.folder_name %s, b.path %s limit %d,%d",
+ " group by a.folder_uuid order by b.folder_name %s, b.path %s limit %d,%d",
AUDIO_SVC_COLLATE_NOCASE, AUDIO_SVC_COLLATE_NOCASE, offset, rows);
g_strlcat(query, tail_query, sizeof(query));
}
case AUDIO_SVC_GROUP_BY_YEAR:
{
snprintf(query, sizeof(query),
- "select year, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+ "select year, min(audio_uuid), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
case AUDIO_SVC_GROUP_BY_COMPOSER:
{
snprintf(query, sizeof(query),
- "select author, min(audio_id), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
+ "select author, min(audio_uuid), album, thumbnail_path, album_rating from %s where valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
{
if (limit_string1 && strlen(limit_string1) > 0) {
snprintf(query, sizeof(query),
- "select artist, min(audio_id), album, thumbnail_path, album_rating \
+ "select artist, min(audio_uuid), album, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre=?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
} else {
snprintf(query, sizeof(query),
- "select artist, min(audio_id), album, thumbnail_path, album_rating \
+ "select artist, min(audio_uuid), album, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre is null",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
}
{
if (limit_string1 && strlen(limit_string1) > 0) {
snprintf(query, sizeof(query),
- "select distinct album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select distinct album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre=?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
} else {
snprintf(query, sizeof(query),
- "select distinct album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select distinct album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre is null",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
}
if (limit_string1 && strlen(limit_string1) > 0) {
if (limit_string2 && strlen(limit_string2) > 0) {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre=? and artist=?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
} else {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre=? and artist is null",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
}
} else {
if (limit_string2 && strlen(limit_string2) > 0) {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre is null and artist=?",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
} else {
snprintf(query, sizeof(query),
- "select album, min(audio_id), artist, thumbnail_path, album_rating \
+ "select album, min(audio_uuid), artist, thumbnail_path, album_rating \
from %s where valid=1 and category=%d and genre is null and artist is null",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC);
}
}
-int _audio_svc_count_music_track_records(audio_svc_track_type_e track_type,
+int _audio_svc_count_music_track_records(sqlite3 *handle, audio_svc_track_type_e track_type,
const char *type_string,
const char *type_string2,
const char *filter_string,
int text_bind = 1;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (filter_string) {
if (strlen(filter_string) > 0) {
snprintf(filter_query, sizeof(filter_query), "%%%s%%",
case AUDIO_SVC_TRACK_BY_FOLDER:
if (type_string && strlen(type_string) > 0) {
snprintf(query, sizeof(query),
- "select count(*) from %s where valid=1 and category=%d and folder_id=(select _id from %s where path = ?)",
+ "select count(*) from %s where valid=1 and category=%d and folder_uuid=(select folder_uuid from %s where path = ?)",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC,
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
} else {
snprintf(query, sizeof(query),
- "select count(*) from %s where valid=1 and category=%d and folder_id is null",
+ "select count(*) from %s where valid=1 and category=%d and folder_uuid is null",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
}
case AUDIO_SVC_TRACK_BY_PLAYLIST:
{
snprintf(query, sizeof(query),
- "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d",
+ "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
AUDIO_SVC_DB_TABLE_AUDIO, (int)type_string,
AUDIO_SVC_CATEGORY_MUSIC);
}
-int _audio_svc_get_music_track_records(audio_svc_track_type_e track_type,
+int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e track_type,
const char *type_string,
const char *type_string2,
const char *filter_string,
{
char query[AUDIO_SVC_QUERY_SIZE] = { 0 };
char *result_field =
- "audio_id, path, thumbnail_path, title, artist, duration, rating";
+ "audio_uuid, path, thumbnail_path, title, artist, duration, rating";
char tail_query[70] = { 0 };
char filter_query[AUDIO_SVC_METADATA_LEN_MAX + 5] = { 0 };
int idx = 0;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
+#endif
#define filter_condition(filter_mode, filter_mode2, query) \
if ((filter_mode)) g_strlcat((query), " and title like ?", sizeof((query))); \
if ((filter_mode2)) g_strlcat((query), " and title like ?", sizeof((query)));
case AUDIO_SVC_TRACK_BY_ARTIST:
{
-/*hjkim, 110822, UX changed. query album info to sort by album and title.*/
if (type_string && strlen(type_string) > 0) {
snprintf(query, sizeof(query),
"select %s, album from %s where valid=1 and category=%d and artist=?",
{
if (type_string && strlen(type_string) > 0) {
snprintf(query, sizeof(query),
- "select %s from %s where valid=1 and category=%d and folder_id=(select _id from %s where path = ?)",
+ "select %s from %s where valid=1 and category=%d and folder_uuid=(select folder_uuid from %s where path = ?)",
result_field, AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC,
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER);
} else {
snprintf(query, sizeof(query),
- "select %s from %s where valid=1 and category=%d and folder_id is null",
+ "select %s from %s where valid=1 and category=%d and folder_uuid is null",
result_field, AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_CATEGORY_MUSIC);
}
case AUDIO_SVC_TRACK_BY_PLAYLIST:
{
char *result_field_for_playlist =
- "b.audio_id, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating";
+ "b.audio_uuid, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating";
len =
snprintf(query, sizeof(query),
- "select %s from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d ",
+ "select %s from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d ",
result_field_for_playlist,
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
AUDIO_SVC_DB_TABLE_AUDIO, (int)type_string,
}
while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
- _strncpy_safe(track[idx].audio_id,
- (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_id));
+ _strncpy_safe(track[idx].audio_uuid,
+ (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_uuid));
_strncpy_safe(track[idx].pathname,
(const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_PATHNAME), sizeof(track[idx].pathname));
_strncpy_safe(track[idx].thumbnail_path,
(const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_LIST_ITEM_ARTIST), sizeof(track[idx].artist));
track[idx].duration = sqlite3_column_int(sql_stmt, AUDIO_SVC_LIST_ITEM_DURATION);
track[idx].rating = sqlite3_column_int(sql_stmt, AUDIO_SVC_LIST_ITEM_RATING);
- audio_svc_debug ("Index : %d : audio_id = %s, title = %s, pathname = %s, duration = %d",
- idx, track[idx].audio_id, track[idx].title, track[idx].pathname, track[idx].duration);
+ audio_svc_debug ("Index : %d : audio_uuid = %s, title = %s, pathname = %s, duration = %d",
+ idx, track[idx].audio_uuid, track[idx].title, track[idx].pathname, track[idx].duration);
idx++;
}
}
-int _audio_svc_delete_music_track_groups(audio_svc_group_type_e group_type,
+int _audio_svc_delete_music_track_groups(sqlite3 *handle, audio_svc_group_type_e group_type,
const char *type_string)
{
int err = -1;
case AUDIO_SVC_GROUP_BY_FOLDER:
sql =
sqlite3_mprintf
- ("delete from %s where folder_id=(select _id from %s where path = '%q') and valid=1 and category=%d",
+ ("delete from %s where folder_uuid=(select folder_uuid from %s where path = '%q') and valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER,
type_string, AUDIO_SVC_CATEGORY_MUSIC);
break;
audio_svc_debug("query (%s)", sql);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To delete group is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_search_audio_id_by_path(const char *path, char *audio_id)
+int _audio_svc_search_audio_id_by_path(sqlite3 *handle, const char *path, char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
*audio_id = -1;
char *sql =
sqlite3_mprintf
- ("select audio_id from %s where valid=1 and category=%d and path='%q'",
+ ("select audio_uuid from %s where valid=1 and category=%d and path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_CATEGORY_MUSIC, path);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
}
-int _audio_svc_update_valid_of_music_records(audio_svc_storage_type_e
+int _audio_svc_update_valid_of_music_records(sqlite3 *handle, audio_svc_storage_type_e
storage_type, int valid)
{
audio_svc_debug("storage_type: %d", storage_type);
char *sql =
sqlite3_mprintf("update %s set valid = %d where storage_type = %d",
AUDIO_SVC_DB_TABLE_AUDIO, valid, storage_type);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To set all items as invalid is failed(%d)",
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_count_record_with_path(const char *path)
+int _audio_svc_count_record_with_path(sqlite3 *handle, const char *path)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_mprintf("select count(*) from %s where path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, path);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
}
-int _audio_svc_delete_invalid_music_records(audio_svc_storage_type_e
+int _audio_svc_delete_invalid_music_records(sqlite3 *handle, audio_svc_storage_type_e
storage_type)
{
int idx = 0;
int invalid_count = 0;
int ret = AUDIO_SVC_ERROR_NONE;
- invalid_count = __audio_svc_count_invalid_records_with_thumbnail(storage_type);
+ invalid_count = __audio_svc_count_invalid_records_with_thumbnail(handle, storage_type);
audio_svc_debug("invalid count: %d\n", invalid_count);
if (invalid_count > 0) {
}
memset(thumbpath_record, 0, sizeof(mp_thumbnailpath_record_t) * invalid_count);
- ret = __audio_svc_get_invalid_records_with_thumbnail(storage_type, invalid_count, thumbpath_record);
+ ret = __audio_svc_get_invalid_records_with_thumbnail(handle, storage_type, invalid_count, thumbpath_record);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("error when get thumbnail record");
SAFE_FREE(thumbpath_record);
}
char *sql = sqlite3_mprintf("delete from %s where valid = 0 and storage_type=%d", AUDIO_SVC_DB_TABLE_AUDIO, storage_type);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To delete invalid items is failed(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_valid_in_music_record(const char *path, int valid)
+int _audio_svc_update_valid_in_music_record(sqlite3 *handle, const char *path, int valid)
{
int err = -1;
char *sql = sqlite3_mprintf("update %s set valid=%d where path= '%q'",
AUDIO_SVC_DB_TABLE_AUDIO, valid, path);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("To update item as valid is failed(%d)", err);
}
-int _audio_svc_update_valid_in_music_record_query_add(const char *path, int valid)
+int _audio_svc_update_valid_in_music_record_query_add(sqlite3 *handle, const char *path, int valid)
{
char *sql = sqlite3_mprintf("update %s set valid=%d where path= '%q'",
AUDIO_SVC_DB_TABLE_AUDIO, valid, path);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_move_item_query_add(const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id)
+int _audio_svc_move_item_query_add(sqlite3 *handle, const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id)
{
char *sql = NULL;
sql = sqlite3_mprintf("update %s set path='%q', storage_type=%d where valid=1 and path='%q'",
audio_svc_debug("SQL = [%s]", sql);
_audio_svc_sql_query_add(&g_audio_svc_move_item_query_list, &sql);
- sql = sqlite3_mprintf("update %s set folder_id='%q' where path='%q'",
+ sql = sqlite3_mprintf("update %s set folder_uuid='%q' where path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, folder_id, path);
audio_svc_debug("SQL = [%s]", sql);
}
//call this API after beginning transaction. this API do sqlite_exec for the g_audio_svc_sqli_query_list.
-int _audio_svc_list_query_do(audio_svc_query_type_e query_type)
+int _audio_svc_list_query_do(sqlite3 *handle, audio_svc_query_type_e query_type)
{
int ret = AUDIO_SVC_ERROR_NONE;
- ret = _audio_svc_sql_begin_trans();
+ ret = _audio_svc_sql_begin_trans(handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (query_type == AUDIO_SVC_QUERY_SET_ITEM_VALID)
- ret = _audio_svc_sql_query_list(&g_audio_svc_item_valid_query_list);
+ ret = _audio_svc_sql_query_list(handle, &g_audio_svc_item_valid_query_list);
else if (query_type == AUDIO_SVC_QUERY_MOVE_ITEM)
- ret = _audio_svc_sql_query_list(&g_audio_svc_move_item_query_list);
+ ret = _audio_svc_sql_query_list(handle, &g_audio_svc_move_item_query_list);
else if (query_type == AUDIO_SVC_QUERY_INSERT_ITEM)
- ret = _audio_svc_sql_query_list(&g_audio_svc_insert_item_query_list);
+ ret = _audio_svc_sql_query_list(handle, &g_audio_svc_insert_item_query_list);
else
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("_audio_svc_list_query_do failed. start rollback");
- _audio_svc_sql_rollback_trans();
+ _audio_svc_sql_rollback_trans(handle);
return ret;
}
- ret = _audio_svc_sql_end_trans();
+ ret = _audio_svc_sql_end_trans(handle);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- _audio_svc_sql_rollback_trans();
+ _audio_svc_sql_rollback_trans(handle);
return ret;
}
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_path(const char *audio_id, char *path)
+int _audio_svc_get_path(sqlite3 *handle, const char *audio_id, char *path)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql =
sqlite3_mprintf
- ("select path from %s where audio_id='%q' and valid=1 and category=%d",
+ ("select path from %s where audio_uuid='%q' and valid=1 and category=%d",
AUDIO_SVC_DB_TABLE_AUDIO, audio_id, AUDIO_SVC_CATEGORY_MUSIC);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("error when _audio_svc_get_path. ret = [%d]",
}
-int _audio_svc_get_and_append_folder_id_by_path(const char *path, audio_svc_storage_type_e storage_type, char *folder_id)
+int _audio_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *path, audio_svc_storage_type_e storage_type, char *folder_id)
{
char *path_name = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
path_name = g_path_get_dirname(path);
- ret = _audio_svc_get_folder_id_by_foldername(path_name, folder_id);
+ ret = _audio_svc_get_folder_id_by_foldername(handle, path_name, folder_id);
if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
char *folder_name = NULL;
folder_name = g_path_get_basename(path_name);
folder_modified_date = _audio_svc_get_file_dir_modified_date(path_name);
- ret = _audio_svc_append_audio_folder(storage_type, folder_uuid, path_name, folder_name, folder_modified_date);
+ ret = _audio_svc_append_audio_folder(handle, storage_type, folder_uuid, path_name, folder_name, folder_modified_date);
SAFE_FREE(folder_name);
_strncpy_safe(folder_id, folder_uuid, AUDIO_SVC_UUID_SIZE+1);
}
return ret;
}
-int _audio_svc_get_folder_id_by_foldername(const char *folder_name, char *folder_id)
+int _audio_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- char *sql = sqlite3_mprintf("SELECT _id FROM %s WHERE path = '%q';", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_name);
+ char *sql = sqlite3_mprintf("SELECT folder_uuid FROM %s WHERE path = '%q';", AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_name);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
return ret;
}
-int _audio_svc_append_audio_folder(audio_svc_storage_type_e storage_type,
+int _audio_svc_append_audio_folder(sqlite3 *handle, audio_svc_storage_type_e storage_type,
const char *folder_id, const char *path_name, const char *folder_name, int modified_date)
{
int err = -1;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
- char *sql = sqlite3_mprintf("insert into %s (_id, path, folder_name, storage_type, modified_date) values ('%q', '%q', '%q', '%d', '%d'); ",
+#endif
+ char *sql = sqlite3_mprintf("insert into %s (folder_uuid, path, folder_name, storage_type, modified_date) values ('%q', '%q', '%q', '%d', '%d'); ",
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id, path_name, folder_name, storage_type, modified_date);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to insert albums");
}
/* handle by one items. */
-int _audio_svc_check_and_update_folder_table(const char *path_name)
+int _audio_svc_check_and_update_folder_table(sqlite3 *handle, const char *path_name)
{
int err = -1;
char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
return AUDIO_SVC_ERROR_INTERNAL;
}
- ret = _audio_svc_get_folder_id_by_foldername(folder_path_name, folder_id);
+ ret = _audio_svc_get_folder_id_by_foldername(handle, folder_path_name, folder_id);
SAFE_FREE(folder_path_name);
if(ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
char *sql =
sqlite3_mprintf
- ("delete from %s where _id='%q' and ((SELECT count(*) FROM %s WHERE folder_id='%q')=0);",
+ ("delete from %s where folder_uuid='%q' and ((SELECT count(*) FROM %s WHERE folder_uuid='%q')=0);",
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, folder_id,
AUDIO_SVC_DB_TABLE_AUDIO, folder_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to delete audio_folder item");
}
/* batch processing */
-int _audio_svc_update_folder_table(void)
+int _audio_svc_update_folder_table(sqlite3 *handle)
{
int err = -1;
char *sql = NULL;
sql =
sqlite3_mprintf
- ("delete from %s where _id IN (select _id FROM %s where _id NOT IN (select folder_id from %s))",
+ ("delete from %s where folder_uuid IN (select folder_uuid FROM %s where folder_uuid NOT IN (select folder_uuid from %s))",
AUDIO_SVC_DB_TABLE_AUDIO_FOLDER, AUDIO_SVC_DB_TABLE_AUDIO_FOLDER,
AUDIO_SVC_DB_TABLE_AUDIO);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to delete audio_folder item");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_check_and_update_albums_table(const char *album)
+int _audio_svc_check_and_update_albums_table(sqlite3 *handle, const char *album)
{
int err = -1;
char *sql = NULL;
if(!STRING_VALID(album)) {
sql = sqlite3_mprintf("delete from %s where album_id NOT IN (SELECT album_id FROM %s);",
AUDIO_SVC_DB_TABLE_ALBUMS, AUDIO_SVC_DB_TABLE_AUDIO);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to update albums table");
} else {
sql = sqlite3_mprintf("delete from %s where album='%q' and ((SELECT count(*) FROM %s WHERE album='%q')=0);",
AUDIO_SVC_DB_TABLE_ALBUMS, album, AUDIO_SVC_DB_TABLE_AUDIO, album);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("failed to update albums table");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path)
+int _audio_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumb_path)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- /* hjkim, 110211, remove category condition for the sound files */
+
char *sql =
sqlite3_mprintf
("select thumbnail_path from %s where valid=1 and path='%q' ",
AUDIO_SVC_DB_TABLE_AUDIO, path);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-char *_audio_svc_get_thumbnail_path_by_album_id(int album_id)
+char *_audio_svc_get_thumbnail_path_by_album_id(sqlite3 *handle, int album_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
sqlite3_mprintf("select _data from %s where album_id=%d",
AUDIO_SVC_DB_TABLE_ALBUM_ART, album_id);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return g_strdup(thumbnail_path);
}
-int _audio_svc_check_and_remove_thumbnail(const char *thumbnail_path)
+int _audio_svc_check_and_remove_thumbnail(sqlite3 *handle, const char *thumbnail_path)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
sqlite3_mprintf("select count(*) from %s where thumbnail_path='%q'",
AUDIO_SVC_DB_TABLE_AUDIO, thumbnail_path);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
("error when _audio_svc_check_and_remove_thumbnail. err = [%d]",
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_list_search(audio_svc_audio_item_s *item,
+int _audio_svc_list_search(sqlite3 *handle, audio_svc_audio_item_s *item,
char *where_query,
audio_svc_search_order_e order_field,
int offset,
char order_str[AUDIO_SVC_QUERY_SIZE] = { 0 };
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
snprintf(query, sizeof(query), "SELECT * FROM audio_media WHERE %s", where_query);
audio_svc_debug("");
*/
#include <glib.h>
-#include "media-info-util.h"
+#include "media-svc-util.h"
#include "audio-svc-error.h"
#include "audio-svc-playlist-table.h"
#include "audio-svc-debug.h"
#define AUDIO_SVC_ORDER_BY_PLAYLIST_NAME "ORDER BY name COLLATE NOCASE"
-static int __audio_svc_create_playlist_db_table(void);
-static int __audio_svc_create_playlist_item_db_table(void);
-static int __audio_svc_delete_playlist_item_records_by_playlist_id(int
- playlist_id);
+static int __audio_svc_create_playlist_db_table(sqlite3 *handle);
+static int __audio_svc_create_playlist_item_db_table(sqlite3 *handle);
+static int __audio_svc_delete_playlist_item_records_by_playlist_id(sqlite3 *handle, int playlist_id);
-static int __audio_svc_create_playlist_db_table(void)
+static int __audio_svc_create_playlist_db_table(sqlite3 *handle)
{
int err = -1;
- /* hjkim, 110125, make name to unique */
char *sql = sqlite3_mprintf("create table if not exists %s (\
_id INTEGER PRIMARY KEY, \
name TEXT NOT NULL UNIQUE\
);", AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to create playlist table (%d)", err);
/* when memory card is removed, the items in the memory card is displayed in grey out when selecting playlist item view.
If same memory card is inserted again, they are handled as same as other phone items in the playlist view. */
-static int __audio_svc_create_playlist_item_db_table(void)
+static int __audio_svc_create_playlist_item_db_table(sqlite3 *handle)
{
int err = -1;
char *sql = NULL;
sql = sqlite3_mprintf("create table if not exists %s (\
_id INTEGER primary key autoincrement, \
playlist_id INTEGER NOT NULL,\
- audio_id TEXT NOT NULL,\
+ audio_uuid TEXT NOT NULL,\
play_order INTEGER NOT NULL\
);", AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to create playlist item table (%d)",
}
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
- /* hjkim, 111020, add trigger to remove item from audio_playlists_map when item remove */
+ /* add trigger to remove item from audio_playlists_map when item remove */
sql =
sqlite3_mprintf
- ("CREATE TRIGGER IF NOT EXISTS audio_playlists_map_cleanup_1 DELETE ON %s BEGIN DELETE FROM %s WHERE audio_id = old.audio_id;END;",
+ ("CREATE TRIGGER IF NOT EXISTS audio_playlists_map_cleanup_1 DELETE ON %s BEGIN DELETE FROM %s WHERE audio_uuid=old.audio_uuid;END;",
AUDIO_SVC_DB_TABLE_AUDIO, AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("error while create TRIGGER albumart_cleanup1");
}
/* when deleting a playlist, all items included in the playlist should be removed together */
-static int __audio_svc_delete_playlist_item_records_by_playlist_id(int
- playlist_id)
+static int __audio_svc_delete_playlist_item_records_by_playlist_id(sqlite3 *handle, int playlist_id)
{
int err = -1;
char *sql = sqlite3_mprintf("delete from %s where playlist_id = %d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
playlist_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to delete items by playlist index");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_create_playlist_table(void)
+int _audio_svc_create_playlist_table(sqlite3 *handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
- ret = __audio_svc_create_playlist_db_table();
+ ret = __audio_svc_create_playlist_db_table(handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = __audio_svc_create_playlist_item_db_table();
+ ret = __audio_svc_create_playlist_item_db_table(handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_truncate_playlist_table(void)
+int _audio_svc_truncate_playlist_table(sqlite3 *handle)
{
int err = -1;
char *sql = sqlite3_mprintf("delete from %s",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_debug("It failed to truncate playlist table", err);
sql =
sqlite3_mprintf("delete from %s",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to truncate playlist item table",
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_insert_playlist_record(const char *playlist_name,
+int _audio_svc_insert_playlist_record(sqlite3 *handle, const char *playlist_name,
int *playlist_id)
{
int err = -1;
sqlite3_mprintf("select max(_id) from %s",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS, plist_idx,
playlist_name);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to insert playlist(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_playlist_record(int playlist_id)
+int _audio_svc_delete_playlist_record(sqlite3 *handle, int playlist_id)
{
int err = -1;
char *sql = sqlite3_mprintf("delete from %s where _id=%d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
playlist_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to delete playlist(%d)", err);
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
- return
- __audio_svc_delete_playlist_item_records_by_playlist_id
- (playlist_id);
+ return __audio_svc_delete_playlist_item_records_by_playlist_id(handle, playlist_id);
}
-int _audio_svc_update_playlist_record_by_name(int playlist_id,
+int _audio_svc_update_playlist_record_by_name(sqlite3 *handle, int playlist_id,
const char *new_playlist_name)
{
int err = -1;
char *sql = sqlite3_mprintf("update %s set name='%q' where _id=%d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
new_playlist_name, playlist_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update playlist name(%d)", err);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_count_playlist_records(const char *filter_string,
+int _audio_svc_count_playlist_records(sqlite3 *handle, const char *filter_string,
const char *filter_string2, int *count)
{
int err = -1;
bool filter_mode2 = FALSE;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
const char *filter_1 = " where name like ?";
const char *filter_2 = " and name like ?";
if (filter_string) {
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_playlist_records(int offset, int rows,
+int _audio_svc_get_playlist_records(sqlite3 *handle, int offset, int rows,
const char *filter_string,
const char *filter_string2,
audio_svc_playlist_s *playlists)
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (filter_string) {
if (strlen(filter_string) > 0) {
filter_mode = TRUE;
SQLITE3_FINALIZE(sql_stmt);
- /* hjkim, 110303, add query to get thumbnail_path of playlists */
+ /* add query to get thumbnail_path of playlists */
for (idx_1 = 0; idx_1 < idx; idx_1++) {
char *sql =
sqlite3_mprintf
- ("select thumbnail_path from %s where audio_id= \
- (select audio_id from %s where playlist_id=%d and \
- play_order=(select min(a.play_order) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d))",
+ ("select thumbnail_path from %s where audio_uuid= \
+ (select audio_uuid from %s where playlist_id=%d and \
+ play_order=(select min(a.play_order) from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d))",
AUDIO_SVC_DB_TABLE_AUDIO,
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
playlists[idx_1].playlist_id,
AUDIO_SVC_DB_TABLE_AUDIO, playlists[idx_1].playlist_id,
AUDIO_SVC_CATEGORY_MUSIC);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
audio_svc_debug("No item in playlist");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_count_playlist_item_records(int playlist_id,
+int _audio_svc_count_playlist_item_records(sqlite3 *handle, int playlist_id,
const char *filter_string,
const char *filter_string2,
int *count)
int text_bind = 1;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
if (filter_string) {
if (strlen(filter_string) > 0) {
snprintf(filter_query, sizeof(filter_query), "%%%s%%",
}
snprintf(query, sizeof(query),
- "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d",
+ "select count(*) from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
AUDIO_SVC_DB_TABLE_AUDIO, playlist_id,
AUDIO_SVC_CATEGORY_MUSIC);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_playlist_item_records(int playlist_id,
+int _audio_svc_get_playlist_item_records(sqlite3 *handle, int playlist_id,
const char *filter_string,
const char *filter_string2, int offset,
int rows,
int idx = 0;
sqlite3_stmt *sql_stmt = NULL;
+#if 0
sqlite3 *handle = _media_info_get_proper_handle();
if (handle == NULL) {
audio_svc_debug("handle is NULL");
return AUDIO_SVC_ERROR_DB_INTERNAL;
}
-
+#endif
filter_mode = STRING_VALID(filter_string);
filter_mode2 = STRING_VALID(filter_string2);
}
char *result_field_for_playlist =
- "a._id, b.audio_id, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating, a.play_order";
+ "a._id, b.audio_uuid, b.path, b.thumbnail_path, b.title, b.artist, b.duration, b.rating, a.play_order";
len =
snprintf(query, sizeof(query),
- "select %s from %s a, %s b where a.playlist_id=%d and b.audio_id=a.audio_id and b.valid=1 and b.category=%d ",
+ "select %s from %s a, %s b where a.playlist_id=%d and b.audio_uuid=a.audio_uuid and b.valid=1 and b.category=%d ",
result_field_for_playlist,
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
AUDIO_SVC_DB_TABLE_AUDIO, playlist_id,
while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
track[idx].u_id =
sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_UID);
- _strncpy_safe(track[idx].audio_id,
- (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_id));
+ _strncpy_safe(track[idx].audio_uuid,
+ (const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_AUDIO_ID), sizeof(track[idx].audio_uuid));
_strncpy_safe(track[idx].pathname,
(const char *)sqlite3_column_text(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_PATHNAME), sizeof(track[idx].pathname));
_strncpy_safe(track[idx].thumbnail_path,
track[idx].rating = sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_RATING);
track[idx].play_order = sqlite3_column_int(sql_stmt, AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER);
- audio_svc_debug("u_id = %d, audio_id = %s, title = %s, pathname = %s, duration = %d, play_order = %d",
- track[idx].u_id, track[idx].audio_id, track[idx].title, track[idx].pathname, track[idx].duration, track[idx].play_order);
+ audio_svc_debug("u_id = %d, audio_uuid = %s, title = %s, pathname = %s, duration = %d, play_order = %d",
+ track[idx].u_id, track[idx].audio_uuid, track[idx].title, track[idx].pathname, track[idx].duration, track[idx].play_order);
idx++;
}
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_count_playlist_records_by_name(const char *playlist_name,
+int _audio_svc_count_playlist_records_by_name(sqlite3 *handle, const char *playlist_name,
int *count)
{
int ret = AUDIO_SVC_ERROR_NONE;
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
playlist_name);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_playlist_id_by_name(const char *playlist_name,
- int *playlist_id)
+int _audio_svc_get_playlist_id_by_name(sqlite3 *handle, const char *playlist_name, int *playlist_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
playlist_name);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_audio_id_by_uid(int uid, char *audio_id)
+int _audio_svc_get_audio_id_by_uid(sqlite3 *handle, int uid, char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- char *sql = sqlite3_mprintf("select audio_id from %s where _id=%d",
+ char *sql = sqlite3_mprintf("select audio_uuid from %s where _id=%d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, uid);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error("error when _audio_svc_get_audio_id_by_uid. ret = [%d]", ret);
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_get_playlist_name_by_playlist_id(int playlist_id,
- char *playlist_name)
+int _audio_svc_get_playlist_name_by_playlist_id(sqlite3 *handle, int playlist_id, char *playlist_name)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS,
playlist_id);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_insert_playlist_item_record(int playlist_id, const char *audio_id)
+int _audio_svc_insert_playlist_item_record(sqlite3 *handle, int playlist_id, const char *audio_id)
{
int err = -1;
int ret = AUDIO_SVC_ERROR_NONE;
("select max(play_order) from %s where playlist_id = %d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
++play_order;
/* insert the new record */
- sql = sqlite3_mprintf("insert into %s ( playlist_id, audio_id, play_order) values (%d, '%q', %d)",
+ sql = sqlite3_mprintf("insert into %s ( playlist_id, audio_uuid, play_order) values (%d, '%q', %d)",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id, play_order);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error(" It failed to insert item to playlist");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_check_duplication_records_in_playlist(int playlist_id,
+int _audio_svc_check_duplication_records_in_playlist(sqlite3 *handle, int playlist_id,
const char *audio_id, int *count)
{
int ret = AUDIO_SVC_ERROR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql =
sqlite3_mprintf
- ("select count(*) from %s where playlist_id=%d and audio_id='%q'",
+ ("select count(*) from %s where playlist_id=%d and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id);
- ret = _audio_svc_sql_prepare_to_step(sql, &sql_stmt);
+ ret = _audio_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != AUDIO_SVC_ERROR_NONE) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(int playlist_id, const char *audio_id)
+int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(sqlite3 *handle, int playlist_id, const char *audio_id)
{
int err = -1;
char *sql =
sqlite3_mprintf
- ("delete from %s where playlist_id=%d and audio_id='%q'",
+ ("delete from %s where playlist_id=%d and audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id, audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(int playlist_id,
- int uid)
+int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(sqlite3 *handle, int playlist_id, int uid)
{
int err = -1;
char *sql =
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, playlist_id,
uid);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_delete_playlist_item_records_by_audio_id(const char *audio_id)
+int _audio_svc_delete_playlist_item_records_by_audio_id(sqlite3 *handle, const char *audio_id)
{
int err = -1;
- char *sql = sqlite3_mprintf("delete from %s where audio_id='%q'",
+ char *sql = sqlite3_mprintf("delete from %s where audio_uuid='%q'",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP,
audio_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to delete items by audio_id");
return AUDIO_SVC_ERROR_NONE;
}
-int _audio_svc_update_item_play_order(int playlist_id, int uid,
- int new_play_order)
+int _audio_svc_update_item_play_order(sqlite3 *handle, int playlist_id, int uid, int new_play_order)
{
int err = -1;
char *sql =
("update %s set play_order=%d where _id=%d and playlist_id = %d",
AUDIO_SVC_DB_TABLE_AUDIO_PLAYLISTS_MAP, new_play_order, uid,
playlist_id);
- err = _audio_svc_sql_query(sql);
+ err = _audio_svc_sql_query(handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
audio_svc_error("It failed to update play order");
#include <sys/time.h>
#include <sys/vfs.h>
#include <ctype.h>
-
#include <dirent.h>
-
#include <glib.h>
#include <glib/gstdio.h>
#include <drm-service-types.h>
#include <drm-service.h>
-
#include <mm_file.h>
-#include "media-info-util.h"
#include "audio-svc-debug.h"
#include "audio-svc-error.h"
#include "audio-svc-utils.h"
#include "audio-svc.h"
#include "audio-svc-types-priv.h"
-#include "md5_hash.h"
+#include "media-svc-hash.h"
#define AUDIO_SVC_PARENTAL_RATING_LEN 20
#define AUDIO_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/
}
/* extract thumbnail image */
- /*hm2007.kim 100122 - remove thumbnail extract routine while db creating.*/
+ /* remove thumbnail extract routine while db creating.*/
#if 0
album_id = _audio_svc_get_album_id(item->audio.album);
if (album_id < 0) {
return AUDIO_SVC_ERROR_INTERNAL;
}
- /* hjkim, 101112, in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
+ /* in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */
_strncpy_safe(item->audio.album, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.album));
_strncpy_safe(item->audio.artist, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.artist));
_strncpy_safe(item->audio.genre, AUDIO_SVC_TAG_UNKNOWN, sizeof(item->audio.genre));
#include <stdarg.h>
#include <db-util.h>
-#include "media-info-env.h"
-#include "media-info-util.h"
+#include "media-svc-env.h"
+#include "media-svc-util.h"
#include "audio-svc.h"
#include "audio-svc-error.h"
#include "audio-svc-debug.h"
static __thread int g_audio_svc_insert_item_data_cnt = 1;
static __thread int g_audio_svc_insert_item_cur_data_cnt = 0;
+#if 0
+/**
+ * audio_svc_open:\n
+ * Open audio service library. This is the function that an user who wants to use music-service calls first.
+ * This function connects with the music database and initialize efreet mime libary.
+ *
+ * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ * Please refer 'audio-svc-types.h' to know the exact meaning of the error.
+ * @see audio_svc_close
+ * @pre None.
+ * @post call audio_svc_close() to close music database
+ * @remark The database name is "/opt/dbspace/.music.db".
+ * @par example
+ * @code
+
+#include <audio-svc.h>
+
+void open_music_db()
+{
+ int ret = AUDIO_SVC_ERROR_NONE;
+ // open music database
+ ret = audio_svc_open();
+ // open failed
+ if (ret < 0)
+ {
+ printf( "Cannot open music db. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+int audio_svc_open(void);
+
+
+/**
+ * audio_svc_close:\n
+ * Close audio service library. This is the function need to call before close the application.
+ * This function disconnects with the music database and shutdown the efreet mime libary.
+ *
+ * @return This function returns zero(AUDIO_SVC_ERROR_NONE) on success, or negative value with error code.\n
+ * Please refer 'audio-svc-types.h' to know the exact meaning of the error.
+ * @see audio_svc_open
+ * @pre music database already is opened.
+ * @post None
+ * @remark memory free before you call this function to close database.
+ * @par example
+ * @code
+
+#include <audio-svc.h>
+
+void close_music_db()
+{
+ int ret = AUDIO_SVC_ERROR_NONE;
+ // close music database
+ ret = audio_svc_close();
+ // close failed
+ if (ret < 0)
+ {
+ printf( "unable to close music db. error code->%d", ret);
+ return;
+ }
+
+ return;
+}
+
+ * @endcode
+ */
+int audio_svc_close(void);
int audio_svc_open(void)
{
audio_svc_debug("audio_svc_close succeed");
return ret;
}
-
-int audio_svc_create_table(void)
+#endif
+int audio_svc_create_table(MediaSvcHandle *handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
- ret = _audio_svc_create_music_table();
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _audio_svc_create_music_table(db_handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_create_playlist_table();
+ ret = _audio_svc_create_playlist_table(db_handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_create_folder_table();
+ ret = _audio_svc_create_folder_table(db_handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_delete_all(audio_svc_storage_type_e storage_type)
+int audio_svc_delete_all(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type)
{
char * dirpath = NULL;
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (storage_type != AUDIO_SVC_STORAGE_PHONE
&& storage_type != AUDIO_SVC_STORAGE_MMC) {
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- ret = _audio_svc_truncate_music_table(storage_type);
+ ret = _audio_svc_truncate_music_table(db_handle, storage_type);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
/* 20111110, make each thumbnail */
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
/* update folder table */
- ret = _audio_svc_delete_folder(storage_type, NULL);
+ ret = _audio_svc_delete_folder(db_handle, storage_type, NULL);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
#if 0
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_insert_item_start(int data_cnt)
+int audio_svc_insert_item_start(MediaSvcHandle *handle, int data_cnt)
{
- audio_svc_debug("Transaction data count : [%d]", data_cnt);
+ audio_svc_debug("Transaction data count : [%d]", data_cnt);
+
+ if(handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if(data_cnt < 1) {
audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_insert_item_end(void)
+int audio_svc_insert_item_end(MediaSvcHandle *handle)
{
audio_svc_debug_func();
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (g_audio_svc_insert_item_cur_data_cnt > 0) {
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_INSERT_ITEM);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_INSERT_ITEM);
}
g_audio_svc_insert_item_data_cnt = 1;
return ret;
}
-int audio_svc_insert_item(audio_svc_storage_type_e storage_type,
+int audio_svc_insert_item(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type,
const char *path, audio_svc_category_type_e category)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (storage_type != AUDIO_SVC_STORAGE_PHONE
&& storage_type != AUDIO_SVC_STORAGE_MMC) {
if (g_audio_svc_insert_item_data_cnt == 1) {
- return _audio_svc_insert_item_with_data(&item, FALSE);
+ return _audio_svc_insert_item_with_data(db_handle, &item, FALSE);
}
else if(g_audio_svc_insert_item_cur_data_cnt < (g_audio_svc_insert_item_data_cnt - 1)) {
- ret = _audio_svc_insert_item_with_data(&item, TRUE);
+ ret = _audio_svc_insert_item_with_data(db_handle, &item, TRUE);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
g_audio_svc_insert_item_cur_data_cnt ++;
}
else if (g_audio_svc_insert_item_cur_data_cnt == (g_audio_svc_insert_item_data_cnt - 1)) {
- ret = _audio_svc_insert_item_with_data(&item, TRUE);
+ ret = _audio_svc_insert_item_with_data(db_handle, &item, TRUE);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_INSERT_ITEM);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_INSERT_ITEM);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
g_audio_svc_insert_item_cur_data_cnt = 0;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_get_item_by_path(const char *path, AudioHandleType * item_handle)
+int audio_svc_insert_item_immediately(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type,
+ const char *path, audio_svc_category_type_e category)
+{
+ int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (storage_type != AUDIO_SVC_STORAGE_PHONE
+ && storage_type != AUDIO_SVC_STORAGE_MMC) {
+ audio_svc_error("storage type is incorrect(%d)", storage_type);
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!STRING_VALID(path)) {
+ audio_svc_error("path is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ audio_svc_debug("storage[%d], path[%s], category[%d]", storage_type, path, category);
+
+ if ((category != AUDIO_SVC_CATEGORY_MUSIC)
+ && (category != AUDIO_SVC_CATEGORY_SOUND)) {
+ audio_svc_error("invalid category condition");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ audio_svc_audio_item_s item;
+ memset(&item, 0, sizeof(audio_svc_audio_item_s));
+
+ item.category = category;
+ item.time_added = time(NULL);
+
+ ret = _audio_svc_extract_metadata_audio(storage_type, path, &item);
+ audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
+
+ return _audio_svc_insert_item_with_data(db_handle, &item, FALSE);
+}
+
+int audio_svc_get_item_by_path(MediaSvcHandle *handle, const char *path, AudioHandleType * item_handle)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(path)) {
audio_svc_error("file path is null");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
memset(item, 0, sizeof(audio_svc_audio_item_s));
- return _audio_svc_select_music_record_by_path(path, item);
+ return _audio_svc_select_music_record_by_path(db_handle, path, item);
}
-int audio_svc_get_item_by_audio_id(const char *audio_id, AudioHandleType *item_handle)
+int audio_svc_get_item_by_audio_id(MediaSvcHandle *handle, const char *audio_id, AudioHandleType *item_handle)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(audio_id)) {
audio_svc_error("invalid audio_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
memset(item, 0, sizeof(audio_svc_audio_item_s));
- return _audio_svc_select_music_record_by_audio_id(audio_id, item);
+ return _audio_svc_select_music_record_by_audio_id(db_handle, audio_id, item);
}
-int audio_svc_delete_item_by_path(const char *path)
+int audio_svc_delete_item_by_path(MediaSvcHandle *handle, const char *path)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!STRING_VALID(path)) {
audio_svc_error("file path is null");
audio_svc_audio_item_s item;
memset(&item, 0, sizeof(audio_svc_audio_item_s));
- ret = _audio_svc_select_music_record_by_path(path, &item);
+ ret = _audio_svc_select_music_record_by_path(db_handle, path, &item);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_delete_music_record_by_audio_id(item.audio_id);
+ ret = _audio_svc_delete_music_record_by_audio_id(db_handle, item.audio_uuid);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_delete_playlist_item_records_by_audio_id(item.audio_id);
+ ret = _audio_svc_delete_playlist_item_records_by_audio_id(db_handle, item.audio_uuid);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_check_and_update_folder_table(path);
+ ret = _audio_svc_check_and_update_folder_table(db_handle, path);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
#if 0
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_move_item_start(int data_cnt)
+int audio_svc_move_item_start(MediaSvcHandle *handle, int data_cnt)
{
audio_svc_debug("Transaction data count : [%d]", data_cnt);
+ if(handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if(data_cnt < 1) {
audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_move_item_end(void)
+int audio_svc_move_item_end(MediaSvcHandle *handle)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
audio_svc_debug_func();
if (g_audio_svc_move_item_cur_data_cnt > 0) {
g_audio_svc_move_item_data_cnt = 1;
g_audio_svc_move_item_cur_data_cnt = 0;
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_MOVE_ITEM);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_MOVE_ITEM);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
}
g_audio_svc_move_item_data_cnt = 1;
g_audio_svc_move_item_cur_data_cnt = 0;
- ret = _audio_svc_update_folder_table();
+ ret = _audio_svc_update_folder_table(db_handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return AUDIO_SVC_ERROR_NONE;
//old db was separated into phone and mmc table.
//so when src_storage and dest_storage is not same, then need to remove old one and insert new one
//since audio_id in mmc table is started with over 5000001 . but don't need to do like this anymore.
-int audio_svc_move_item(audio_svc_storage_type_e src_storage,
+int audio_svc_move_item(MediaSvcHandle *handle, audio_svc_storage_type_e src_storage,
const char *src_path,
audio_svc_storage_type_e dest_storage,
const char *dest_path)
char folder_id[AUDIO_SVC_UUID_SIZE+1] = {0,};
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(src_path)) {
audio_svc_error("src_path is null");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
if (g_audio_svc_move_item_data_cnt == 1) {
/* update path and storage type*/
- ret = _audio_svc_update_path_and_storage_in_music_record(src_path, dest_path, dest_storage);
+ ret = _audio_svc_update_path_and_storage_in_music_record(db_handle, src_path, dest_path, dest_storage);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
/* get folder_id */
- ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+ ret = _audio_svc_get_and_append_folder_id_by_path(db_handle, dest_path, dest_storage, folder_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
/* update folder_id */
- ret = _audio_svc_update_folder_id_in_music_record(dest_path, folder_id);
+ ret = _audio_svc_update_folder_id_in_music_record(db_handle, dest_path, folder_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
/* remove old folder path */
- ret = _audio_svc_check_and_update_folder_table(src_path);
+ ret = _audio_svc_check_and_update_folder_table(db_handle, src_path);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
}
else if (g_audio_svc_move_item_cur_data_cnt < (g_audio_svc_move_item_data_cnt - 1)) {
- ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+ ret = _audio_svc_get_and_append_folder_id_by_path(db_handle, dest_path, dest_storage, folder_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_move_item_query_add(src_path, dest_path, dest_storage, folder_id);
+ ret = _audio_svc_move_item_query_add(db_handle, src_path, dest_path, dest_storage, folder_id);
g_audio_svc_move_item_cur_data_cnt ++;
}
else if (g_audio_svc_move_item_cur_data_cnt == (g_audio_svc_move_item_data_cnt - 1)) {
- ret = _audio_svc_get_and_append_folder_id_by_path(dest_path, dest_storage, folder_id);
+ ret = _audio_svc_get_and_append_folder_id_by_path(db_handle, dest_path, dest_storage, folder_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_move_item_query_add(src_path, dest_path, dest_storage, folder_id);
+ ret = _audio_svc_move_item_query_add(db_handle, src_path, dest_path, dest_storage, folder_id);
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_MOVE_ITEM);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_MOVE_ITEM);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
g_audio_svc_move_item_cur_data_cnt = 0;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_refresh_metadata(const char *audio_id)
+int audio_svc_refresh_metadata(MediaSvcHandle *handle, const char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!STRING_VALID(audio_id)) {
audio_svc_error("invalid audio_id");
audio_svc_audio_item_s item;
memset(&item, 0, sizeof(audio_svc_audio_item_s));
- ret = _audio_svc_select_music_record_by_audio_id(audio_id, &item);
+ ret = _audio_svc_select_music_record_by_audio_id(db_handle, audio_id, &item);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (item.audio.duration > 0) {
ret = _audio_svc_extract_metadata_audio(item.storage_type, item.pathname, &item);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- return _audio_svc_update_metadata_in_music_record(audio_id, &item);
+ return _audio_svc_update_metadata_in_music_record(db_handle, audio_id, &item);
}
-int audio_svc_count_group_item(audio_svc_group_type_e group_type,
+int audio_svc_count_group_item(MediaSvcHandle *handle, audio_svc_group_type_e group_type,
const char *limit_string1,
const char *limit_string2,
const char *filter_string,
const char *filter_string2, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (group_type < AUDIO_SVC_GROUP_BY_ALBUM
|| group_type > AUDIO_SVC_GROUP_BY_COMPOSER) {
audio_svc_error("group type is wrong : %d", group_type);
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_count_music_group_records(group_type, limit_string1,
+ return _audio_svc_count_music_group_records(db_handle, group_type, limit_string1,
limit_string2,
filter_string,
filter_string2, count);
}
-int audio_svc_get_group_item(audio_svc_group_type_e group_type,
+int audio_svc_get_group_item(MediaSvcHandle *handle, audio_svc_group_type_e group_type,
const char *limit_string1,
const char *limit_string2,
const char *filter_string,
const char *filter_string2, int offset, int rows,
AudioHandleType *result_records)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
audio_svc_group_item_s *result_groups =
(audio_svc_group_item_s *) result_records;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_get_music_group_records(group_type, limit_string1,
+ return _audio_svc_get_music_group_records(db_handle, group_type, limit_string1,
limit_string2, filter_string,
filter_string2, offset, rows,
result_groups);
}
-int audio_svc_count_list_item(audio_svc_track_type_e item_type,
+int audio_svc_count_list_item(MediaSvcHandle *handle, audio_svc_track_type_e item_type,
const char *type_string, const char *type_string2,
const char *filter_string,
const char *filter_string2, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (item_type < AUDIO_SVC_TRACK_ALL
|| item_type > AUDIO_SVC_TRACK_BY_PLAYLIST) {
audio_svc_error("item type is wrong : %d", item_type);
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_count_music_track_records(item_type, type_string,
+ return _audio_svc_count_music_track_records(db_handle, item_type, type_string,
type_string2, filter_string,
filter_string2, count);
}
-int audio_svc_get_list_item(audio_svc_track_type_e item_type,
+int audio_svc_get_list_item(MediaSvcHandle *handle, audio_svc_track_type_e item_type,
const char *type_string, const char *type_string2,
const char *filter_string,
const char *filter_string2, int offset, int rows,
AudioHandleType *track)
{
audio_svc_list_item_s *result_track = (audio_svc_list_item_s *) track;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (item_type < AUDIO_SVC_TRACK_ALL
|| item_type > AUDIO_SVC_TRACK_BY_PLAYLIST) {
memset(result_track, 0, sizeof(audio_svc_list_item_s) * rows);
- return _audio_svc_get_music_track_records(item_type, type_string,
+ return _audio_svc_get_music_track_records(db_handle, item_type, type_string,
type_string2, filter_string,
filter_string2, offset, rows,
result_track);
}
-int audio_svc_get_audio_id_by_path(const char *path, char *audio_id, size_t max_audio_id_length)
+int audio_svc_get_audio_id_by_path(MediaSvcHandle *handle, const char *path, char *audio_id, size_t max_audio_id_length)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(path)) {
audio_svc_error("file path is null");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_search_audio_id_by_path(path, audio_id);
+ return _audio_svc_search_audio_id_by_path(db_handle, path, audio_id);
}
-int audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path,
+int audio_svc_get_thumbnail_path_by_path(MediaSvcHandle *handle, const char *path, char *thumb_path,
size_t max_thumb_path_length)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(path)) {
audio_svc_error("file path is null");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_get_thumbnail_path_by_path(path, thumb_path);
+ return _audio_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
}
-int audio_svc_add_playlist(const char *playlist_name, int *playlist_id)
+int audio_svc_add_playlist(MediaSvcHandle *handle, const char *playlist_name, int *playlist_id)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(playlist_name)) {
audio_svc_error("invalid playlist_name");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_insert_playlist_record(playlist_name, playlist_id);
+ return _audio_svc_insert_playlist_record(db_handle, playlist_name, playlist_id);
}
-int audio_svc_delete_playlist(int playlist_id)
+int audio_svc_delete_playlist(MediaSvcHandle *handle, int playlist_id)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_delete_playlist_record(playlist_id);
+ return _audio_svc_delete_playlist_record(db_handle, playlist_id);
}
-int audio_svc_update_playlist_name(int playlist_id,
+int audio_svc_update_playlist_name(MediaSvcHandle *handle, int playlist_id,
const char *new_playlist_name)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_update_playlist_record_by_name(playlist_id,
+ return _audio_svc_update_playlist_record_by_name(db_handle, playlist_id,
new_playlist_name);
}
-int audio_svc_count_playlist(const char *filter_string,
+int audio_svc_count_playlist(MediaSvcHandle *handle, const char *filter_string,
const char *filter_string2, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (count == NULL) {
audio_svc_error("invalid count condition");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_count_playlist_records(filter_string, filter_string2,
+ return _audio_svc_count_playlist_records(db_handle, filter_string, filter_string2,
count);
}
-int audio_svc_get_playlist(const char *filter_string,
+int audio_svc_get_playlist(MediaSvcHandle *handle, const char *filter_string,
const char *filter_string2, int offset, int rows,
AudioHandleType *playlists)
{
- audio_svc_playlist_s *ret_playlists =
- (audio_svc_playlist_s *) playlists;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ audio_svc_playlist_s *ret_playlists = (audio_svc_playlist_s *) playlists;
if (offset < 0 || rows <= 0) {
audio_svc_error("offset(%d) or row value(%d) is wrong", offset,
rows);
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_get_playlist_records(offset, rows, filter_string,
+ return _audio_svc_get_playlist_records(db_handle, offset, rows, filter_string,
filter_string2, ret_playlists);
}
-int audio_svc_count_playlist_item(int playlist_id, const char *filter_string,
+int audio_svc_count_playlist_item(MediaSvcHandle *handle, int playlist_id, const char *filter_string,
const char *filter_string2, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_count_playlist_item_records(playlist_id,
+ return _audio_svc_count_playlist_item_records(db_handle, playlist_id,
filter_string,
filter_string2, count);
}
-int audio_svc_get_playlist_item(int playlist_id, const char *filter_string,
+int audio_svc_get_playlist_item(MediaSvcHandle *handle, int playlist_id, const char *filter_string,
const char *filter_string2, int offset,
int rows, AudioHandleType *playlist_item)
{
- audio_svc_playlist_item_s *ret_playlist_item =
- (audio_svc_playlist_item_s *) playlist_item;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ audio_svc_playlist_item_s *ret_playlist_item = (audio_svc_playlist_item_s *) playlist_item;
if (offset < 0 || rows <= 0) {
audio_svc_error("offset(%d) or row value(%d) is wrong", offset,
memset(ret_playlist_item, 0, sizeof(audio_svc_playlist_item_s) * rows);
- return _audio_svc_get_playlist_item_records(playlist_id, filter_string,
+ return _audio_svc_get_playlist_item_records(db_handle, playlist_id, filter_string,
filter_string2, offset,
rows, ret_playlist_item);
}
-int audio_svc_get_playlist_id_by_playlist_name(const char *playlist_name,
+int audio_svc_get_playlist_id_by_playlist_name(MediaSvcHandle *handle, const char *playlist_name,
int *playlist_id)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(playlist_name)) {
audio_svc_error("invalid playlist_name");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_get_playlist_id_by_name(playlist_name, playlist_id);
+ return _audio_svc_get_playlist_id_by_name(db_handle, playlist_name, playlist_id);
}
-int audio_svc_get_playlist_name_by_playlist_id(int playlist_id,
+int audio_svc_get_playlist_name_by_playlist_id(MediaSvcHandle *handle, int playlist_id,
char *playlist_name,
size_t max_playlist_name_length)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_get_playlist_name_by_playlist_id(playlist_id,
+ return _audio_svc_get_playlist_name_by_playlist_id(db_handle, playlist_id,
playlist_name);
}
-int audio_svc_count_playlist_by_name(const char *playlist_name, int *count)
+int audio_svc_count_playlist_by_name(MediaSvcHandle *handle, const char *playlist_name, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(playlist_name)) {
audio_svc_error("invalid playlist_name");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_count_playlist_records_by_name(playlist_name, count);
+ return _audio_svc_count_playlist_records_by_name(db_handle, playlist_name, count);
}
-int audio_svc_get_unique_playlist_name(const char *orig_name, char *unique_name,
+int audio_svc_get_unique_playlist_name(MediaSvcHandle *handle, const char *orig_name, char *unique_name,
size_t max_unique_name_length)
{
int ret = AUDIO_SVC_ERROR_NONE;
int count = -1;
char playlist_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = { 0 };
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!STRING_VALID(orig_name)) {
audio_svc_error("orig_name is NULL");
}
snprintf(playlist_name, sizeof(playlist_name), "%s_001", orig_name);
- ret = audio_svc_count_playlist_by_name(playlist_name, &count);
+ ret = audio_svc_count_playlist_by_name(db_handle, playlist_name, &count);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (count > 0) {
count = -1;
snprintf(unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE,
"%s_%.3d", orig_name, i + 1);
- ret =
- audio_svc_count_playlist_by_name(unique_name,
- &count);
+ ret = audio_svc_count_playlist_by_name(db_handle, unique_name, &count);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (count == 0) {
return AUDIO_SVC_ERROR_MAKE_PLAYLIST_NAME_FAILED;
} else {
- snprintf(unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE, "%s_%.3d", orig_name, 1); /* hjkim, 101006, return My playlist_001 */
+ snprintf(unique_name, AUDIO_SVC_PLAYLIST_NAME_SIZE, "%s_%.3d", orig_name, 1);
return AUDIO_SVC_ERROR_NONE;
}
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_add_item_to_playlist(int playlist_id, const char *audio_id)
+int audio_svc_add_item_to_playlist(MediaSvcHandle *handle, int playlist_id, const char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
-
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist idx");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- ret = _audio_svc_insert_playlist_item_record(playlist_id, audio_id);
+ ret = _audio_svc_insert_playlist_item_record(db_handle, playlist_id, audio_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
- ret = _audio_svc_update_favourite_in_music_record(audio_id, 1);
+ ret = _audio_svc_update_favourite_in_music_record(db_handle, audio_id, 1);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
}
return ret;
}
-int audio_svc_check_duplicate_insertion_in_playlist(int playlist_id,
+int audio_svc_check_duplicate_insertion_in_playlist(MediaSvcHandle *handle, int playlist_id,
const char *audio_id, int *count)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist idx");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_check_duplication_records_in_playlist(playlist_id, audio_id, count);
+ return _audio_svc_check_duplication_records_in_playlist(db_handle, playlist_id, audio_id, count);
}
-int audio_svc_update_playlist_item_play_order(int playlist_id, int uid,
+int audio_svc_update_playlist_item_play_order(MediaSvcHandle *handle, int playlist_id, int uid,
int new_play_order)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_update_item_play_order(playlist_id, uid,
- new_play_order);
+ return _audio_svc_update_item_play_order(db_handle, playlist_id, uid, new_play_order);
}
-int audio_svc_remove_item_from_playlist_by_uid(int playlist_id, int uid)
+int audio_svc_remove_item_from_playlist_by_uid(MediaSvcHandle *handle, int playlist_id, int uid)
{
int ret = AUDIO_SVC_ERROR_NONE;
char audio_id[AUDIO_SVC_UUID_SIZE + 1] = {0, };
-
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist idx");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
- ret = _audio_svc_get_audio_id_by_uid(uid, audio_id);
+ ret = _audio_svc_get_audio_id_by_uid(db_handle, uid, audio_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_update_favourite_in_music_record(audio_id, 0);
+ ret = _audio_svc_update_favourite_in_music_record(db_handle, audio_id, 0);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
}
- ret = _audio_svc_delete_playlist_item_record_from_playlist_by_uid(playlist_id, uid);
+ ret = _audio_svc_delete_playlist_item_record_from_playlist_by_uid(db_handle, playlist_id, uid);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return ret;
}
-int audio_svc_remove_item_from_playlist_by_audio_id(int playlist_id,
+int audio_svc_remove_item_from_playlist_by_audio_id(MediaSvcHandle *handle, int playlist_id,
const char *audio_id)
{
int ret = AUDIO_SVC_ERROR_NONE;
-
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (playlist_id < 0) {
audio_svc_error("invalid playlist idx");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- ret = _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(playlist_id, audio_id);
+ ret = _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(db_handle, playlist_id, audio_id);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
if (playlist_id == AUDIO_SVC_FAVORITE_LIST_ID) {
- ret = _audio_svc_update_favourite_in_music_record(audio_id, 0);
+ ret = _audio_svc_update_favourite_in_music_record(db_handle, audio_id, 0);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
}
return ret;
}
-int audio_svc_set_db_valid(audio_svc_storage_type_e storage_type, int valid)
+int audio_svc_set_db_valid(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type, int valid)
{
audio_svc_debug("storage:%d", storage_type);
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (storage_type != AUDIO_SVC_STORAGE_PHONE
&& storage_type != AUDIO_SVC_STORAGE_MMC) {
audio_svc_debug("storage type should be phone or mmc");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- return _audio_svc_update_valid_of_music_records(storage_type, valid);
+ return _audio_svc_update_valid_of_music_records(db_handle, storage_type, valid);
}
-int audio_svc_delete_invalid_items(audio_svc_storage_type_e storage_type)
+int audio_svc_delete_invalid_items(MediaSvcHandle *handle, audio_svc_storage_type_e storage_type)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (storage_type != AUDIO_SVC_STORAGE_PHONE
&& storage_type != AUDIO_SVC_STORAGE_MMC) {
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- ret = _audio_svc_delete_invalid_music_records(storage_type);
+ ret = _audio_svc_delete_invalid_music_records(db_handle, storage_type);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
- ret = _audio_svc_update_folder_table();
+ ret = _audio_svc_update_folder_table(db_handle);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
#if 0
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_set_item_valid_start(int data_cnt)
+int audio_svc_set_item_valid_start(MediaSvcHandle *handle, int data_cnt)
{
audio_svc_debug("Transaction data count : [%d]", data_cnt);
+ if(handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if(data_cnt < 1) {
audio_svc_error("data_cnt shuld be bigger than 1. data_cnt : [%d]", data_cnt);
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_set_item_valid_end(void)
+int audio_svc_set_item_valid_end(MediaSvcHandle *handle)
{
audio_svc_debug_func();
int ret = AUDIO_SVC_ERROR_NONE;
-
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (g_audio_svc_item_valid_cur_data_cnt > 0) {
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_SET_ITEM_VALID);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_SET_ITEM_VALID);
}
return ret;
}
-int audio_svc_set_item_valid(const char *path, int valid)
+int audio_svc_set_item_valid(MediaSvcHandle *handle, const char *path, int valid)
{
int ret = AUDIO_SVC_ERROR_NONE;
-
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
audio_svc_debug("path=[%s], valid=[%d]", path, valid);
if (!STRING_VALID(path)) {
#if 0 //original code
return _audio_svc_update_valid_in_music_record(path, valid);
-#else //hjkim, 110909, stack up querys and commit it at once when query counts are same as g_audio_svc_item_valid_data_cnt
+#else //stack up querys and commit it at once when query counts are same as g_audio_svc_item_valid_data_cnt
audio_svc_debug("g_audio_svc_item_valid_data_cnt =[%d], g_audio_svc_item_valid_cur_data_cnt =[%d]",
g_audio_svc_item_valid_data_cnt , g_audio_svc_item_valid_cur_data_cnt );
if (g_audio_svc_item_valid_data_cnt == 1) {
- return _audio_svc_update_valid_in_music_record(path, valid);
+ return _audio_svc_update_valid_in_music_record(db_handle, path, valid);
} else if (g_audio_svc_item_valid_cur_data_cnt < (g_audio_svc_item_valid_data_cnt - 1)) {
- ret = _audio_svc_update_valid_in_music_record_query_add(path, valid);
+ ret = _audio_svc_update_valid_in_music_record_query_add(db_handle, path, valid);
g_audio_svc_item_valid_cur_data_cnt ++;
} else if (g_audio_svc_item_valid_cur_data_cnt == (g_audio_svc_item_valid_data_cnt - 1)) {
- ret = _audio_svc_update_valid_in_music_record_query_add(path, valid);
+ ret = _audio_svc_update_valid_in_music_record_query_add(db_handle, path, valid);
- ret = _audio_svc_list_query_do(AUDIO_SVC_QUERY_SET_ITEM_VALID);
+ ret = _audio_svc_list_query_do(db_handle, AUDIO_SVC_QUERY_SET_ITEM_VALID);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
g_audio_svc_item_valid_cur_data_cnt = 0;
#endif
}
-int audio_svc_get_path_by_audio_id(const char *audio_id, char *path,
+int audio_svc_get_path_by_audio_id(MediaSvcHandle *handle, const char *audio_id, char *path,
size_t max_path_length)
{
int ret = AUDIO_SVC_ERROR_NONE;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!STRING_VALID(audio_id)) {
audio_svc_error("invalid audio_id");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- ret = _audio_svc_get_path(audio_id, path);
+ ret = _audio_svc_get_path(db_handle, audio_id, path);
audio_svc_retv_if(ret != AUDIO_SVC_ERROR_NONE, ret);
return AUDIO_SVC_ERROR_NONE;
return ret;
}
-int audio_svc_group_item_get(AudioHandleType *record, int index,
- AudioHandleType **item)
+int audio_svc_group_item_get(AudioHandleType *record, int index, AudioHandleType **item)
{
audio_svc_group_item_s *item_arr = (audio_svc_group_item_s *) record;
{
char **val = va_arg((var_args), char **);
int *size = va_arg((var_args), int *);
- if (strlen(item[index].audio_id) == 0) {
+ if (strlen(item[index].audio_uuid) == 0) {
audio_svc_error("audio_id is NULL");
*size = 0;
ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
} else {
- *val = item[index].audio_id;
- *size = strlen(item[index].audio_id);
+ *val = item[index].audio_uuid;
+ *size = strlen(item[index].audio_uuid);
}
break;
}
return ret;
}
-int audio_svc_list_item_get(AudioHandleType *record, int index,
- AudioHandleType **item)
+int audio_svc_list_item_get(AudioHandleType *record, int index, AudioHandleType **item)
{
audio_svc_list_item_s *item_arr = (audio_svc_list_item_s *) record;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_playlist_get_item(AudioHandleType *record, int index,
- AudioHandleType **plst)
+int audio_svc_playlist_get_item(AudioHandleType *record, int index, AudioHandleType **plst)
{
if (!record) {
audio_svc_error("Invalid arguments");
{
char **val = va_arg((var_args), char **);
int *size = va_arg((var_args), int *);
- if (strlen(item[index].audio_id) == 0) {
+ if (strlen(item[index].audio_uuid) == 0) {
audio_svc_error("audio_id is NULL");
*size = 0;
ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
} else {
- *val = item[index].audio_id;
- *size = strlen(item[index].audio_id);
+ *val = item[index].audio_uuid;
+ *size = strlen(item[index].audio_uuid);
}
break;
}
return ret;
}
-int audio_svc_playlist_item_get(AudioHandleType *record, int index,
- AudioHandleType **item)
+int audio_svc_playlist_item_get(AudioHandleType *record, int index, AudioHandleType **item)
{
- audio_svc_playlist_item_s *item_arr =
- (audio_svc_playlist_item_s *) record;
+ audio_svc_playlist_item_s *item_arr = (audio_svc_playlist_item_s *) record;
if (!item_arr) {
audio_svc_error("Invalid arguments");
int count = 1;
audio_svc_debug("count is [%d]", count);
- audio_svc_audio_item_s *item =
- (audio_svc_audio_item_s *) malloc(count *
- sizeof(audio_svc_audio_item_s));
+ audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) malloc(count * sizeof(audio_svc_audio_item_s));
if (item == NULL) {
return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
}
va_list var_args;
int field_name;
audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) record;
+
audio_svc_debug_func();
if (!item) {
audio_svc_error("Invalid arguments");
{
char **val = va_arg((var_args), char **);
int *size = va_arg((var_args), int *);
- if (strlen(item->audio_id) == 0) {
+ if (strlen(item->audio_uuid) == 0) {
audio_svc_error("audio_id is NULL");
*size = 0;
ret = AUDIO_SVC_ERROR_DB_NO_RECORD;
} else {
- *size = strlen(item->audio_id);
- *val = item->audio_id;
+ *size = strlen(item->audio_uuid);
+ *val = item->audio_uuid;
}
break;
}
int audio_svc_search_item_new(AudioHandleType **record, int count)
{
audio_svc_debug("count is [%d]", count);
-
- audio_svc_audio_item_s *item =
- (audio_svc_audio_item_s *) malloc(count *
- sizeof(audio_svc_audio_item_s));
+ audio_svc_audio_item_s *item = (audio_svc_audio_item_s *) malloc(count * sizeof(audio_svc_audio_item_s));
if (item == NULL) {
return AUDIO_SVC_ERROR_OUT_OF_MEMORY;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_search_item_get(AudioHandleType *record, int index,
- AudioHandleType **item)
+int audio_svc_search_item_get(AudioHandleType *record, int index, AudioHandleType **item)
{
audio_svc_audio_item_s *item_arr = (audio_svc_audio_item_s *) record;
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_update_item_metadata(const char *audio_id,
+int audio_svc_update_item_metadata(MediaSvcHandle *handle, const char *audio_id,
audio_svc_track_data_type_e first_field_name,
...)
{
int ret = AUDIO_SVC_ERROR_NONE;
va_list var_args;
int field_name = -1;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!STRING_VALID(audio_id)) {
audio_svc_error("invalid audio_id");
audio_svc_error("play count should be positive value");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_playcount_in_music_record(audio_id, val);
+ ret = _audio_svc_update_playcount_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("play time should be positive value");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_playtime_in_music_record(audio_id, val);
+ ret = _audio_svc_update_playtime_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("added time should be positive value");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_addtime_in_music_record(audio_id, val);
+ ret = _audio_svc_update_addtime_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("rating value should be between 0 and 5");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_rating_in_music_record(audio_id, val);
+ ret = _audio_svc_update_rating_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_title_in_music_record(audio_id, val);
+ ret = _audio_svc_update_title_in_music_record(db_handle, audio_id, val);
}
break;
}
if (val == NULL) {
val = AUDIO_SVC_TAG_UNKNOWN;
}
- ret =_audio_svc_update_artist_in_music_record(audio_id, val);
+ ret =_audio_svc_update_artist_in_music_record(db_handle, audio_id, val);
}
break;
}
if (val == NULL) {
val = AUDIO_SVC_TAG_UNKNOWN;
}
- ret = _audio_svc_update_album_in_music_record(audio_id, val);
+ ret = _audio_svc_update_album_in_music_record(db_handle, audio_id, val);
}
break;
}
if (val == NULL) {
val = AUDIO_SVC_TAG_UNKNOWN;
}
- ret = _audio_svc_update_genre_in_music_record(audio_id, val);
+ ret = _audio_svc_update_genre_in_music_record(db_handle, audio_id, val);
}
break;
}
if (val == NULL) {
val = AUDIO_SVC_TAG_UNKNOWN;
}
- ret = _audio_svc_update_author_in_music_record(audio_id, val);
+ ret = _audio_svc_update_author_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("text size should be shorter than AUDIO_SVC_METADATA_LEN_MAX");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_description_in_music_record(audio_id, val);
+ ret = _audio_svc_update_description_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("year should be positive value");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_year_in_music_record(audio_id, val);
+ ret = _audio_svc_update_year_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("track number should be positive value");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_track_num_in_music_record(audio_id, val);
+ ret = _audio_svc_update_track_num_in_music_record(db_handle, audio_id, val);
}
break;
}
audio_svc_error("rating value should be between 0 and 5");
ret = AUDIO_SVC_ERROR_INVALID_PARAMETER;
} else {
- ret = _audio_svc_update_album_rating_in_music_record(audio_id, val);
+ ret = _audio_svc_update_album_rating_in_music_record(db_handle, audio_id, val);
}
break;
}
return AUDIO_SVC_ERROR_NONE;
}
-int audio_svc_check_item_exist(const char *path)
+int audio_svc_check_item_exist(MediaSvcHandle *handle, const char *path)
{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (!STRING_VALID(path)) {
audio_svc_error("path is NULL");
return AUDIO_SVC_ERROR_INVALID_PARAMETER;
}
- if (_audio_svc_count_record_with_path(path) > 0) {
+ if (_audio_svc_count_record_with_path(db_handle, path) > 0) {
audio_svc_debug("item is exist in database");
return AUDIO_SVC_ERROR_NONE;
} else {
}
-int audio_svc_list_by_search(AudioHandleType *handle,
+int audio_svc_list_by_search(MediaSvcHandle *handle, AudioHandleType *record,
audio_svc_search_order_e order_field,
int offset,
int count,
char search_str[AUDIO_SVC_METADATA_LEN_MAX] = { 0 };
char *condition_str = NULL;
- audio_svc_audio_item_s *item = (audio_svc_audio_item_s *)handle;
+ audio_svc_audio_item_s *item = (audio_svc_audio_item_s *)record;
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ if(db_handle == NULL) {
+ audio_svc_error("Handle is NULL");
+ return AUDIO_SVC_ERROR_INVALID_PARAMETER;
+ }
if (!item) {
audio_svc_error("Invalid arguments");
return AUDIO_SVC_ERROR_INTERNAL;
}
- return _audio_svc_list_search((audio_svc_audio_item_s *)handle, query_where, order_field, offset, count);
+ return _audio_svc_list_search(db_handle, item, query_where, order_field, offset, count);
}
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <time.h>
+#include <sys/time.h>
+#include "media-svc-debug.h"
+
+#ifdef _PERFORMANCE_CHECK_
+static long g_time_usec = 0L;
+#endif
+
+#ifdef _USE_LOG_FILE_
+static FILE *g_log_fp = NULL;
+static char _g_file_path[1024] = "\0";
+
+FILE *get_fp()
+{
+ return g_log_fp;
+}
+
+void mediainfo_init_file_debug()
+{
+ if (g_log_fp == NULL) {
+ snprintf(_g_file_path, sizeof(_g_file_path), "/tmp/%s",
+ "media-info");
+ if (access(_g_file_path, R_OK == 0)) {
+ remove(_g_file_path);
+ }
+
+ g_log_fp = fopen(_g_file_path, "a");
+ }
+}
+
+void mediainfo_close_file_debug()
+{
+ if (g_log_fp != NULL) {
+ fclose(g_log_fp);
+ g_log_fp = NULL;
+ }
+}
+
+#endif
+
+long mediainfo_get_debug_time(void)
+{
+#ifdef _PERFORMANCE_CHECK_
+ struct timeval time;
+ gettimeofday(&time, NULL);
+ return time.tv_sec * 1000000 + time.tv_usec;
+#else
+ return 0L;
+#endif
+}
+
+void mediainfo_reset_debug_time(void)
+{
+#ifdef _PERFORMANCE_CHECK_
+ struct timeval time;
+ gettimeofday(&time, NULL);
+ g_time_usec = time.tv_sec * 1000000 + time.tv_usec;
+#endif
+}
+
+void mediainfo_print_debug_time(char *time_string)
+{
+#ifdef _PERFORMANCE_CHECK_
+ struct timeval time;
+ double totaltime = 0.0;
+
+ gettimeofday(&time, NULL);
+ totaltime =
+ (double)(time.tv_sec * 1000000 + time.tv_usec -
+ g_time_usec) / CLOCKS_PER_SEC;
+
+ mediainfo_dbg("time [%s] : %f \n", time_string, totaltime);
+#endif
+}
+
+void
+mediainfo_print_debug_time_ex(long start, long end, const char *func_name,
+ char *time_string)
+{
+#ifdef _PERFORMANCE_CHECK_
+ double totaltime = 0.0;
+
+ totaltime = (double)(end - start) / CLOCKS_PER_SEC;
+
+ mediainfo_dbg("time [%s: %s] : %f \n", func_name, time_string,
+ totaltime);
+#endif
+}
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#if 0
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "media-svc-util.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc.h"
+#include "audio-svc.h"
+#include "audio-svc-error.h"
+#endif
+#include "uuid.h"
+
+#if 0
+static GHashTable *g_handle_table = NULL;
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int _media_info_get_thread_id()
+{
+ return syscall(__NR_gettid);
+}
+
+int _media_info_init_handle_tbl()
+{
+ pthread_mutex_lock(&mutex);
+
+ if (g_handle_table == NULL)
+ g_handle_table = g_hash_table_new(g_int_hash, g_int_equal);
+
+ pthread_mutex_unlock(&mutex);
+
+ if (g_handle_table == NULL)
+ return -1;
+ else
+ return 0;
+}
+
+int _media_info_finalize_handle_tbl()
+{
+ pthread_mutex_lock(&mutex);
+
+ if (g_handle_table != NULL) {
+ int size = g_hash_table_size(g_handle_table);
+ if (size == 0) {
+ g_hash_table_destroy(g_handle_table);
+ g_handle_table = NULL;
+ } else
+ mediainfo_dbg("handle table is not empty");
+ }
+
+ pthread_mutex_unlock(&mutex);
+
+ return 0;
+}
+
+int
+_media_info_insert_handle(int **tid_key, int tid, HandleTable ** handle_table)
+{
+ *tid_key = g_malloc(sizeof **tid_key);
+ **tid_key = tid;
+ *handle_table = g_malloc(sizeof **handle_table);
+
+ pthread_mutex_lock(&mutex);
+
+ g_hash_table_insert(g_handle_table, (gpointer) * tid_key,
+ (gpointer) * handle_table);
+
+ (*handle_table)->ref_cnt = 1;
+
+ pthread_mutex_unlock(&mutex);
+
+ return 0;
+}
+
+int _media_info_remove_handle(int tid)
+{
+ int *key = NULL;
+ HandleTable *val = NULL;
+
+ pthread_mutex_lock(&mutex);
+
+ if (!g_hash_table_lookup_extended
+ (g_handle_table, &tid, (gpointer) & key, (gpointer) & val)) {
+ pthread_mutex_unlock(&mutex);
+ return -1;
+ } else {
+ if (g_hash_table_remove(g_handle_table, (gpointer) & tid))
+ mediainfo_dbg("g_hash_table_remove done");
+ else
+ mediainfo_dbg("g_hash_table_remove fails");
+
+ if (key)
+ g_free(key);
+ if (val)
+ g_free(val);
+
+ pthread_mutex_unlock(&mutex);
+ return 0;
+ }
+}
+
+HandleTable *_media_info_search_handle(int tid)
+{
+ pthread_mutex_lock(&mutex);
+
+ HandleTable *value =
+ (HandleTable *) g_hash_table_lookup(g_handle_table,
+ (gpointer) & tid);
+
+ pthread_mutex_unlock(&mutex);
+
+ return value;
+}
+
+sqlite3 *_media_info_get_proper_handle()
+{
+ int tid = _media_info_get_thread_id();
+ HandleTable *value =
+ (HandleTable *) g_hash_table_lookup(g_handle_table,
+ (gpointer) & tid);
+
+ if (value == NULL) {
+ return NULL;
+ } else {
+ return value->handle;
+ }
+}
+void _media_info_atomic_add_counting(HandleTable *handle_table)
+{
+ pthread_mutex_lock(&mutex);
+ handle_table->ref_cnt++;
+ pthread_mutex_unlock(&mutex);
+}
+
+
+void _media_info_atomic_sub_counting(HandleTable *handle_table)
+{
+ pthread_mutex_lock(&mutex);
+ handle_table->ref_cnt--;
+ pthread_mutex_unlock(&mutex);
+}
+#endif
+char *_media_info_generate_uuid(void)
+{
+ uuid_t uuid_value;
+ static char uuid_unparsed[50];
+
+ uuid_generate(uuid_value);
+ uuid_unparse(uuid_value, uuid_unparsed);
+
+ //mediainfo_dbg("UUID : %s", uuid_unparsed);
+ return uuid_unparsed;
+}
+
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <sqlite3.h>
+#include <db-util.h>
+#include "media-svc.h"
+#include "media-svc-error.h"
+#include "media-svc-debug.h"
+#include "media-svc-env.h"
+
+
+static int __media_svc_busy_handler(void *pData, int count);
+static int __media_svc_connect_db_with_handle(sqlite3 **db_handle);
+static int __media_svc_disconnect_db_with_handle(sqlite3 *db_handle);
+
+static int __media_svc_busy_handler(void *pData, int count)
+{
+ usleep(50000);
+ mediainfo_dbg("mb_svc_busy_handler called : %d\n", count);
+
+ return 100 - count;
+}
+
+static int __media_svc_connect_db_with_handle(sqlite3 **db_handle)
+{
+ mediainfo_dbg("");
+ int err = -1;
+ err = db_util_open(MEDIA_INFO_DATABASE_NAME, db_handle,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+
+ if (SQLITE_OK != err) {
+ *db_handle = NULL;
+
+ return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+ }
+
+ /*Register busy handler*/
+ err = sqlite3_busy_handler(*db_handle, __media_svc_busy_handler, NULL);
+ if (SQLITE_OK != err) {
+ if (*db_handle) mediainfo_dbg("[sqlite] %s\n", sqlite3_errmsg(*db_handle));
+
+ db_util_close(*db_handle);
+ *db_handle = NULL;
+
+ return MEDIA_INFO_ERROR_DATABASE_CONNECT;
+ }
+
+ return MEDIA_INFO_ERROR_NONE;
+}
+
+static int __media_svc_disconnect_db_with_handle(sqlite3 *db_handle)
+{
+ mediainfo_dbg("");
+ int err = -1;
+ err = db_util_close(db_handle);
+
+ if (SQLITE_OK != err) {
+ db_handle = NULL;
+
+ return MEDIA_INFO_ERROR_DATABASE_DISCONNECT;
+ }
+
+ return MEDIA_INFO_ERROR_NONE;
+}
+
+int media_svc_connect(MediaSvcHandle **handle)
+{
+ int ret = -1;
+ sqlite3 * db_handle = NULL;
+
+ ret = __media_svc_connect_db_with_handle(&db_handle);
+
+ if ( ret < 0) {
+ return -1;
+ } else {
+ *handle = db_handle;
+ return 0;
+ }
+}
+
+int media_svc_disconnect(MediaSvcHandle *handle)
+{
+ sqlite3 * db_handle = (sqlite3 *)handle;
+
+ return __media_svc_disconnect_db_with_handle(db_handle);
+}
+
#define SQLITE3_FINALIZE(x) if(x != NULL) {sqlite3_finalize(x);}
int _audio_svc_sql_busy_handler(void *pData, int count);
-int _audio_svc_sql_query(const char *sql_str);
-int _audio_svc_sql_query_list(GList **query_list);
-int _audio_svc_sql_prepare_to_step(const char *sql_str, sqlite3_stmt** stmt);
-int _audio_svc_sql_begin_trans(void);
-int _audio_svc_sql_end_trans(void);
-int _audio_svc_sql_rollback_trans(void);
+int _audio_svc_sql_query(sqlite3 *handle, const char *sql_str);
+int _audio_svc_sql_query_list(sqlite3 *handle, GList **query_list);
+int _audio_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt** stmt);
+int _audio_svc_sql_begin_trans(sqlite3 *handle);
+int _audio_svc_sql_end_trans(sqlite3 *handle);
+int _audio_svc_sql_rollback_trans(sqlite3 *handle);
void _audio_svc_sql_query_add(GList **query_list, char **query);
void _audio_svc_sql_query_release(GList **query_list);
* @brief This file defines the functions related to DB.\r
*/\r
\r
+#include <stdbool.h>\r
+#include <sqlite3.h>\r
#include "audio-svc-types.h"\r
#include "audio-svc-types-priv.h"\r
-#include <stdbool.h>\r
\r
typedef struct{\r
char thumbnail_path[AUDIO_SVC_PATHNAME_SIZE];\r
}mp_thumbnailpath_record_t;\r
\r
-int _audio_svc_create_music_table(void);\r
-int _audio_svc_truncate_music_table(audio_svc_storage_type_e storage_type);\r
-int _audio_svc_create_folder_table(void);\r
-int _audio_svc_delete_folder(audio_svc_storage_type_e storage_type, const char *folder_id);\r
-int _audio_svc_select_music_record_by_audio_id(const char *audio_id, audio_svc_audio_item_s *item);\r
-int _audio_svc_select_music_record_by_path(const char *path, audio_svc_audio_item_s *item);\r
-int _audio_svc_delete_music_record_by_audio_id(const char *audio_id);\r
-int _audio_svc_update_metadata_in_music_record(const char *audio_id, audio_svc_audio_item_s *item);\r
-int _audio_svc_update_path_in_music_record(const char *src_path, const char *path, const char *title);\r
-int _audio_svc_update_path_and_storage_in_music_record(const char *src_path, const char *path, audio_svc_storage_type_e storage_type);\r
-int _audio_svc_update_folder_id_in_music_record(const char *path, const char *folder_id);\r
-int _audio_svc_update_thumb_path_in_music_record(const char *file_path, const char *path);\r
-int _audio_svc_update_rating_in_music_record( const char *audio_id, int changed_value);\r
-int _audio_svc_update_playtime_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_playcount_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_addtime_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_track_num_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_album_rating_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_year_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_update_title_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_artist_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_album_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_genre_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_author_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_description_in_music_record(const char *audio_id, const char * changed_value);\r
-int _audio_svc_update_favourite_in_music_record(const char *audio_id, int changed_value);\r
-int _audio_svc_count_music_group_records(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);\r
-int _audio_svc_get_music_group_records(audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_group_item_s *group);\r
-int _audio_svc_count_music_track_records(audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);\r
-int _audio_svc_get_music_track_records(audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, audio_svc_list_item_s *track);\r
-int _audio_svc_search_audio_id_by_path(const char *path, char *audio_id);\r
-int _audio_svc_update_valid_of_music_records(audio_svc_storage_type_e storage_type, int valid);\r
-int _audio_svc_count_record_with_path(const char *path);\r
-int _audio_svc_delete_invalid_music_records(audio_svc_storage_type_e storage_type);\r
-int _audio_svc_update_valid_in_music_record(const char *path, int valid);\r
-int _audio_svc_update_valid_in_music_record_query_add(const char *path, int valid);\r
-int _audio_svc_move_item_query_add(const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id);\r
-int _audio_svc_list_query_do(audio_svc_query_type_e query_type);\r
-int _audio_svc_get_path(const char *audio_id, char *path);\r
-int _audio_svc_delete_music_track_groups(audio_svc_group_type_e group_type, const char *type_string);\r
-int _audio_svc_check_and_update_folder_table(const char* path_name);\r
-int _audio_svc_check_and_update_albums_table(const char *album);\r
-int _audio_svc_insert_item_with_data(audio_svc_audio_item_s *item, bool stack_query);\r
-int _audio_svc_update_folder_table(void);\r
-int _audio_svc_get_thumbnail_path_by_path(const char *path, char *thumb_path);\r
-int _audio_svc_get_and_append_folder_id_by_path(const char *path, audio_svc_storage_type_e storage_type, char *folder_id);\r
-int _audio_svc_get_folder_id_by_foldername(const char *folder_name, char *folder_id);\r
-int _audio_svc_append_audio_folder(audio_svc_storage_type_e storage_type, const char *folder_id, const char *path_name, const char *folder_name, int modified_date);\r
-char * _audio_svc_get_thumbnail_path_by_album_id(int album_id);\r
-int _audio_svc_check_and_remove_thumbnail(const char * thumbnail_path);\r
-int _audio_svc_list_search(audio_svc_audio_item_s *item,\r
+int _audio_svc_create_music_table(sqlite3 *handle);\r
+int _audio_svc_truncate_music_table(sqlite3 *handle, audio_svc_storage_type_e storage_type);\r
+int _audio_svc_create_folder_table(sqlite3 *handle);\r
+int _audio_svc_delete_folder(sqlite3 *handle, audio_svc_storage_type_e storage_type, const char *folder_id);\r
+int _audio_svc_select_music_record_by_audio_id(sqlite3 *handle, const char *audio_id, audio_svc_audio_item_s *item);\r
+int _audio_svc_select_music_record_by_path(sqlite3 *handle, const char *path, audio_svc_audio_item_s *item);\r
+int _audio_svc_delete_music_record_by_audio_id(sqlite3 *handle, const char *audio_id);\r
+int _audio_svc_update_metadata_in_music_record(sqlite3 *handle, const char *audio_id, audio_svc_audio_item_s *item);\r
+int _audio_svc_update_path_in_music_record(sqlite3 *handle, const char *src_path, const char *path, const char *title);\r
+int _audio_svc_update_path_and_storage_in_music_record(sqlite3 *handle, const char *src_path, const char *path, audio_svc_storage_type_e storage_type);\r
+int _audio_svc_update_folder_id_in_music_record(sqlite3 *handle, const char *path, const char *folder_id);\r
+int _audio_svc_update_thumb_path_in_music_record(sqlite3 *handle, const char *file_path, const char *path);\r
+int _audio_svc_update_rating_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_playtime_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_playcount_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_addtime_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_track_num_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_album_rating_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_year_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_update_title_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_artist_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_album_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_genre_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_author_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_description_in_music_record(sqlite3 *handle, const char *audio_id, const char * changed_value);\r
+int _audio_svc_update_favourite_in_music_record(sqlite3 *handle, const char *audio_id, int changed_value);\r
+int _audio_svc_count_music_group_records(sqlite3 *handle, audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2, int *count);\r
+int _audio_svc_get_music_group_records(sqlite3 *handle, audio_svc_group_type_e group_type, const char *limit_string1, const char *limit_string2, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_group_item_s *group);\r
+int _audio_svc_count_music_track_records(sqlite3 *handle, audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int *count);\r
+int _audio_svc_get_music_track_records(sqlite3 *handle, audio_svc_track_type_e track_type, const char *type_string, const char *type_string2, const char *filter_string, const char *filter_string2, int offset, int rows, audio_svc_list_item_s *track);\r
+int _audio_svc_search_audio_id_by_path(sqlite3 *handle, const char *path, char *audio_id);\r
+int _audio_svc_update_valid_of_music_records(sqlite3 *handle, audio_svc_storage_type_e storage_type, int valid);\r
+int _audio_svc_count_record_with_path(sqlite3 *handle, const char *path);\r
+int _audio_svc_delete_invalid_music_records(sqlite3 *handle, audio_svc_storage_type_e storage_type);\r
+int _audio_svc_update_valid_in_music_record(sqlite3 *handle, const char *path, int valid);\r
+int _audio_svc_update_valid_in_music_record_query_add(sqlite3 *handle, const char *path, int valid);\r
+int _audio_svc_move_item_query_add(sqlite3 *handle, const char *src_path, const char *path, audio_svc_storage_type_e storage_type, const char *folder_id);\r
+int _audio_svc_list_query_do(sqlite3 *handle, audio_svc_query_type_e query_type);\r
+int _audio_svc_get_path(sqlite3 *handle, const char *audio_id, char *path);\r
+int _audio_svc_delete_music_track_groups(sqlite3 *handle, audio_svc_group_type_e group_type, const char *type_string);\r
+int _audio_svc_check_and_update_folder_table(sqlite3 *handle, const char* path_name);\r
+int _audio_svc_check_and_update_albums_table(sqlite3 *handle, const char *album);\r
+int _audio_svc_insert_item_with_data(sqlite3 *handle, audio_svc_audio_item_s *item, bool stack_query);\r
+int _audio_svc_update_folder_table(sqlite3 *handle);\r
+int _audio_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumb_path);\r
+int _audio_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *path, audio_svc_storage_type_e storage_type, char *folder_id);\r
+int _audio_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *folder_name, char *folder_id);\r
+int _audio_svc_append_audio_folder(sqlite3 *handle, audio_svc_storage_type_e storage_type, const char *folder_id, const char *path_name, const char *folder_name, int modified_date);\r
+char * _audio_svc_get_thumbnail_path_by_album_id(sqlite3 *handle, int album_id);\r
+int _audio_svc_check_and_remove_thumbnail(sqlite3 *handle, const char * thumbnail_path);\r
+int _audio_svc_list_search(sqlite3 *handle, audio_svc_audio_item_s *item,\r
char *where_query,\r
audio_svc_search_order_e order_field,\r
int offset,\r
* @file audio-svc-playlist-table.h
* @version 0.1
*/
-
+
+#include <sqlite3.h>
#include "audio-svc-types-priv.h"
-int _audio_svc_create_playlist_table(void);
-int _audio_svc_truncate_playlist_table(void);
+int _audio_svc_create_playlist_table(sqlite3 *handle);
+int _audio_svc_truncate_playlist_table(sqlite3 *handle);
/* playlist table */
/**
* This function inserts new playlist record into playlist table.
*/
-int _audio_svc_insert_playlist_record(const char *playlist_name, int *playlist_id);
+int _audio_svc_insert_playlist_record(sqlite3 *handle, const char *playlist_name, int *playlist_id);
/**
* This function deletes playlist record from playlist table.
*/
-int _audio_svc_delete_playlist_record(int playlist_id);
+int _audio_svc_delete_playlist_record(sqlite3 *handle, int playlist_id);
/**
* This function update playlist record with new name
*/
-int _audio_svc_update_playlist_record_by_name(int playlist_id, const char *new_playlist_name);
+int _audio_svc_update_playlist_record_by_name(sqlite3 *handle, int playlist_id, const char *new_playlist_name);
/**
* This function returns the number of total playlist records in the playlist table.
*/
-int _audio_svc_count_playlist_records(const char *filter_string, const char *filter_string2, int *count);
+int _audio_svc_count_playlist_records(sqlite3 *handle, const char *filter_string, const char *filter_string2, int *count);
/**
* This function retrieves playlist record without any condition in the playlist table.
*/
-int _audio_svc_get_playlist_records(int offset, int rows, const char *filter_string, const char *filter_string2, audio_svc_playlist_s *playlists);
+int _audio_svc_get_playlist_records(sqlite3 *handle, int offset, int rows, const char *filter_string, const char *filter_string2, audio_svc_playlist_s *playlists);
-int _audio_svc_count_playlist_item_records(int playlist_id, const char *filter_string, const char *filter_string2, int *count);
-int _audio_svc_get_playlist_item_records(int playlist_id, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_playlist_item_s *track);
+int _audio_svc_count_playlist_item_records(sqlite3 *handle, int playlist_id, const char *filter_string, const char *filter_string2, int *count);
+int _audio_svc_get_playlist_item_records(sqlite3 *handle, int playlist_id, const char *filter_string, const char *filter_string2,int offset, int rows, audio_svc_playlist_item_s *track);
/**
* This function returns the number of playlist with playlist_name.
* It is called when inserting a new playlist record to guarantee unique playlist name.
* */
-int _audio_svc_count_playlist_records_by_name(const char *playlist_name, int * count);
+int _audio_svc_count_playlist_records_by_name(sqlite3 *handle, const char *playlist_name, int * count);
/*****************************************************************/
/**
* This function inserts a new record with playlist index and audio_id into playlist item table.
*/
-int _audio_svc_insert_playlist_item_record(int playlist_id, const char *audio_id);
+int _audio_svc_insert_playlist_item_record(sqlite3 *handle, int playlist_id, const char *audio_id);
/**
* This function removes item with audio_id from playlist.
* It is possible to add a same track to a playlist several times.
* So if user tries to remove one instance of track from playlist, this function should be called.
*/
-int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(int playlist_id, const char *audio_id);
+int _audio_svc_delete_playlist_item_record_from_playlist_by_audio_id(sqlite3 *handle, int playlist_id, const char *audio_id);
/**
* When deleting a track, all instance of track will be removed from playlists
*/
-int _audio_svc_delete_playlist_item_records_by_audio_id(const char *audio_id);
-int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(int playlist_id, int uid);
-int _audio_svc_check_duplication_records_in_playlist(int playlist_id, const char *audio_id, int * count);
-int _audio_svc_get_playlist_id_by_name(const char *playlist_name, int *playlist_id);
-int _audio_svc_get_playlist_name_by_playlist_id(int playlist_id, char *playlist_name);
-int _audio_svc_get_audio_id_by_uid(int uid, char *audio_id);
-int _audio_svc_update_item_play_order(int playlist_id, int uid, int new_play_order);
+int _audio_svc_delete_playlist_item_records_by_audio_id(sqlite3 *handle, const char *audio_id);
+int _audio_svc_delete_playlist_item_record_from_playlist_by_uid(sqlite3 *handle, int playlist_id, int uid);
+int _audio_svc_check_duplication_records_in_playlist(sqlite3 *handle, int playlist_id, const char *audio_id, int * count);
+int _audio_svc_get_playlist_id_by_name(sqlite3 *handle, const char *playlist_name, int *playlist_id);
+int _audio_svc_get_playlist_name_by_playlist_id(sqlite3 *handle, int playlist_id, char *playlist_name);
+int _audio_svc_get_audio_id_by_uid(sqlite3 *handle, int uid, char *audio_id);
+int _audio_svc_update_item_play_order(sqlite3 *handle, int playlist_id, int uid, int new_play_order);
#endif /*_AUDIO_SVC_PLAYLIST_TABLE_H_*/
\ No newline at end of file
*/
typedef struct {
int storage_type; /**< Storage of media file : internal/external */
- char audio_id[AUDIO_SVC_PATHNAME_SIZE+1]; /**< Unique ID of item */
+ char audio_uuid[AUDIO_SVC_UUID_SIZE+1]; /**< Unique ID of item */
char pathname[AUDIO_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
char thumbname[AUDIO_SVC_PATHNAME_SIZE]; /**< Thumbnail image file path */
int played_count; /**< played count */
* List item search result record
*/
typedef struct{
- char audio_id[AUDIO_SVC_PATHNAME_SIZE+1]; /**< Unique ID of item */
+ char audio_uuid[AUDIO_SVC_UUID_SIZE+1]; /**< Unique ID of item */
char pathname[AUDIO_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
char title[AUDIO_SVC_METADATA_LEN_MAX]; /**< title of track */
char artist[AUDIO_SVC_METADATA_LEN_MAX]; /**< artist of track */
typedef struct{
int u_id; /**< Unique ID of playlist item*/
- char audio_id[AUDIO_SVC_PATHNAME_SIZE+1]; /**< Unique Audio ID */
+ char audio_uuid[AUDIO_SVC_UUID_SIZE+1]; /**< Unique Audio ID */
char pathname[AUDIO_SVC_PATHNAME_SIZE]; /**< Full path and file name of media file */
char title[AUDIO_SVC_METADATA_LEN_MAX]; /**< title of track */
char artist[AUDIO_SVC_METADATA_LEN_MAX]; /**< artist of track */
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_SVC_DEBUG_H_
+#define _MEDIA_SVC_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "Media-Service"
+
+#define mediainfo_dbg(fmt, arg...) LOGD("[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+
+#ifdef _USE_LOG_FILE_
+void mediainfo_init_file_debug();
+void mediainfo_close_file_debug();
+FILE* get_fp();
+#define mediainfo_file_dbg(fmt,arg...) fprintf( get_fp(), "[%s: %d] [%s]" fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+
+#endif
+
+
+#ifdef _PERFORMANCE_CHECK_
+long
+mediainfo_get_debug_time(void);
+void
+mediainfo_reset_debug_time(void);
+void
+mediainfo_print_debug_time(char* time_string);
+void
+mediainfo_print_debug_time_ex(long start, long end, const char* func_name, char* time_string);
+#endif
+
+#endif /*_MEDIA_SVC_DEBUG_H_*/
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_SVC_ENV_H_
+#define _MEDIA_SVC_ENV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MEDIA_INFO_DATABASE_NAME "/opt/dbspace/.media.db"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_SVC_ENV_H_*/
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#ifndef _MEDIA_SVC_UTIL_H_
+#define _MEDIA_SVC_UTIL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if 0
+typedef struct _handle_table {
+ int ref_cnt;
+ sqlite3* handle;
+} HandleTable;
+
+
+int
+_media_info_get_thread_id();
+
+/* To manage handles in each trhead, use GHashTable */
+int
+_media_info_init_handle_tbl();
+
+int
+_media_info_finalize_handle_tbl();
+
+int
+_media_info_insert_handle(int** tid_key, int tid, HandleTable** handle_table);
+
+int
+_media_info_remove_handle(int tid);
+
+HandleTable*
+_media_info_search_handle(int tid);
+
+sqlite3*
+_media_info_get_proper_handle();
+
+void
+_media_info_atomic_add_counting(HandleTable *handle_table);
+
+void
+_media_info_atomic_sub_counting(HandleTable *handle_table);
+#endif
+
+char *_media_info_generate_uuid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_SVC_UTIL_H_*/
#include <glib.h>
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
-* @fn int mb_svc_insert_file(char* file_full_path, mb_svc_media_type_t content_type);
+* @fn int mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, char* file_full_path, mb_svc_media_type_t content_type);
* This function insert file information into folder table, meida table, image_meta table/video_meta table and bookmark table
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_insert_file(const char* file_full_path, minfo_file_type content_type);
+mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, const char* file_full_path, minfo_file_type content_type);
/**
-* @fn int mb_svc_delete_file(char* file_full_path, mb_svc_media_type_t type);
+* @fn int mb_svc_delete_file(MediaSvcHandle *mb_svc_handle, char* file_full_path, mb_svc_media_type_t type);
* This function deletes file information from folder table,media table and related tables
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_delete_file(const char* file_full_path);
+mb_svc_delete_file(MediaSvcHandle *mb_svc_handle, const char* file_full_path);
/**
-* @fn int mb_svc_update_file(char* old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type);
+* @fn int mb_svc_update_file(MediaSvcHandle *mb_svc_handle, char* old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type);
* This function updates file information for media table, image_meta table/video_meta table
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_update_file(const char* old_file_full_path, const char *new_file_full_path, minfo_file_type content_type);
+mb_svc_update_file(MediaSvcHandle *mb_svc_handle, const char* old_file_full_path, const char *new_file_full_path, minfo_file_type content_type);
/**
-* @fn int mb_svc_rename_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
+* @fn int mb_svc_rename_file(MediaSvcHandle *mb_svc_handle, char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
* This function updates media table due to file name is changed
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_rename_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+mb_svc_rename_file(MediaSvcHandle *mb_svc_handle, const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
/**
-* @fn int mb_svc_move_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
+* @fn int mb_svc_move_file(MediaSvcHandle *mb_svc_handle, char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
* This function updates media table and folder table due to the file is moved
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_move_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+mb_svc_move_file(MediaSvcHandle *mb_svc_handle, const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
/**
-* @fn int mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+* @fn int mb_svc_move_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
* This function moves a media to destination cluster
*
* @return This function returns 0 on success, and negative value on failure.
int
-mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+mb_svc_move_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
/**
-* @fn int mb_svc_copy_file(char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
+* @fn int mb_svc_copy_file(MediaSvcHandle *mb_svc_handle, char *old_file_full_path, char *new_file_full_path, mb_svc_media_type_t type, char* thumb_path);
* This function updates folder table, media table and image_meta/video_meta table
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_copy_file(const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
+mb_svc_copy_file(MediaSvcHandle *mb_svc_handle, const char *old_file_full_path, const char *new_file_full_path, minfo_file_type content_type, char* thumb_path);
/**
-* @fn int mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+* @fn int mb_svc_copy_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
* This function copy a media to the destination cluster.
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id);
+mb_svc_copy_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id);
/**
-* @fn int mb_svc_update_cluster_name(const char *cluster_id, const char* new_name);
+* @fn int mb_svc_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* new_name);
* This function update a name of the cluster.
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_update_cluster_name(const char *cluster_id, const char* new_name);
+mb_svc_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char* new_name);
void
mb_svc_sync_files_to_db_with_path(char* dir_full_path);
int
-mb_svc_insert_items();
+mb_svc_insert_items(MediaSvcHandle *mb_svc_handle);
int
-mb_svc_insert_file_batch(const char *file_full_path, minfo_file_type content_type);
+mb_svc_move_items(MediaSvcHandle *mb_svc_handle);
+
+int
+mb_svc_insert_file_batch(MediaSvcHandle *mb_svc_handle, const char *file_full_path, minfo_file_type content_type);
+
+int
+mb_svc_move_file_batch(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_full_path,
+ const char *new_file_full_path,
+ minfo_file_type content_type,
+ char *thumb_path);
//clock_t
long mb_svc_get_clock(void);
int mb_svc_finalize();
/**
-* @fn int mb_svc_get_folder_media_list(int folder_id, int file_type, int favoriate, GList** p_record_list);
+* @fn int mb_svc_get_folder_media_list(MediaSvcHandle *mb_svc_handle, int folder_id, int file_type, int favoriate, GList** p_record_list);
* This function gets folder media list from media table via folder ID.
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_get_folder_media_list(int folder_id, minfo_file_type content_type, int favorite,GList** p_record_list);
+int mb_svc_get_folder_media_list(MediaSvcHandle *mb_svc_handle, int folder_id, minfo_file_type content_type, int favorite,GList** p_record_list);
/**
-* @fn int mb_svc_get_video_record_by_media_id(int media_id, mb_svc_video_meta_record_s* video_meta_record);
+* @fn int mb_svc_get_video_record_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, mb_svc_video_meta_record_s* video_meta_record);
* This function gets a video record from video meta table via media ID.
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_get_video_record_by_media_id(const char *media_id, mb_svc_video_meta_record_s* video_meta_record);
+int mb_svc_get_video_record_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, mb_svc_video_meta_record_s* video_meta_record);
/**
-* @fn int mb_svc_get_image_record_by_media_id(int media_id, mb_svc_image_meta_record_s* image_meta_record);
+* @fn int mb_svc_get_image_record_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, mb_svc_image_meta_record_s* image_meta_record);
* This function gets a image record from image meta table via media ID.
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_image_record_by_media_id(const char *media_id, mb_svc_image_meta_record_s* image_meta_record);
+int mb_svc_get_image_record_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, mb_svc_image_meta_record_s* image_meta_record);
/**
-* @fn int mb_svc_get_video_list(int folder_id, int favoriate, GList** p_record_list);
+* @fn int mb_svc_get_video_list(MediaSvcHandle *mb_svc_handle, int folder_id, int favoriate, GList** p_record_list);
* This function gets all the video file in some folder via folder ID.
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_video_list(int folder_id, int favorite, GList** p_record_list);
+int mb_svc_get_video_list(MediaSvcHandle *mb_svc_handle, int folder_id, int favorite, GList** p_record_list);
/**
-* @fn int mb_svc_get_folder_fullpath_by_folder_id( int folder_id, char* folder_fullpath);
+* @fn int mb_svc_get_folder_fullpath_by_folder_id(MediaSvcHandle *mb_svc_handle, int folder_id, char* folder_fullpath);
* This function gets some folder's full path.
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int
-mb_svc_get_folder_fullpath_by_folder_id(const char *folder_id, char* folder_fullpath, int max_length);
+int
+mb_svc_get_folder_fullpath_by_folder_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, char* folder_fullpath, int max_length);
/**
-* @fn int mb_svc_get_folder_id_by_full_path( const char* folder_full_path,int* folder_id, int max_length);
+* @fn int mb_svc_get_folder_id_by_full_path(MediaSvcHandle *mb_svc_handle, const char* folder_full_path,int* folder_id, int max_length);
* This function gets some folder's full path.
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_folder_id_by_full_path( const char* folder_full_path, char *folder_id, int max_length);
+mb_svc_get_folder_id_by_full_path(MediaSvcHandle *mb_svc_handle, const char* folder_full_path, char *folder_id, int max_length);
/**
-* @fn int mb_svc_get_folder_id_by_web_album_id(const char* web_album_id,int* folder_id);
+* @fn int mb_svc_get_folder_id_by_web_album_id(MediaSvcHandle *mb_svc_handle, const char* web_album_id,int* folder_id);
* This function could get folder id of a cluster, using its web album ID.
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_folder_id_by_web_album_id(const char* web_album_id, char *folder_id);
+mb_svc_get_folder_id_by_web_album_id(MediaSvcHandle *mb_svc_handle, const char* web_album_id, char *folder_id);
/**
-* @fn int mb_svc_get_media_fullpath(const char *folder_id, char* media_display_name, char* media_fullpath);
+* @fn int mb_svc_get_media_fullpath(MediaSvcHandle *mb_svc_handle, const char *folder_id, char* media_display_name, char* media_fullpath);
* This function gets some media file's full path.
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_media_fullpath(const char *folder_id, char* media_display_name, char* media_fullpath);
+int mb_svc_get_media_fullpath(MediaSvcHandle *mb_svc_handle, const char *folder_id, char* media_display_name, char* media_fullpath);
/**
-* @fn int mb_svc_get_media_image_item_list(int folder_id, int media_type, int favoriate, GList** p_item_list)
+* @fn int mb_svc_get_media_image_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, int media_type, int favoriate, GList** p_item_list)
* This function gets all the media item or image item from record of media table
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_media_image_item_list(int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
+int mb_svc_get_media_image_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
/**
-* @fn int mb_svc_get_video_item_list(int folder_id, int favoriate, GList** p_item_list)
+* @fn int mb_svc_get_video_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, int favoriate, GList** p_item_list)
* This function gets video item from record of media table
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_video_item_list(int folder_id, int favorite, GList** p_item_list);
+int mb_svc_get_video_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, int favorite, GList** p_item_list);
/**
-* @fn int mb_svc_get_media_item_list(int folder_id, int media_type, int favoriate, GList** p_item_list)
+* @fn int mb_svc_get_media_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, int media_type, int favoriate, GList** p_item_list)
* This function gets all the media item or image item or video item from record of media table
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_media_item_list(int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
+int mb_svc_get_media_item_list(MediaSvcHandle *mb_svc_handle, int folder_id, minfo_file_type content_type, int favorite, GList** p_item_list);
/**
-* @fn int mb_svc_get_all_favorite_media_item_list(int media_type, GList** p_item_list);
+* @fn int mb_svc_get_all_favorite_media_item_list(MediaSvcHandle *mb_svc_handle, int media_type, GList** p_item_list);
* This function gets all the favorite media item or image item or video item from record of media table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
int
-mb_svc_get_all_favorite_media_item_list(minfo_file_type content_type, GList** p_item_list);
+mb_svc_get_all_favorite_media_item_list(MediaSvcHandle *mb_svc_handle, minfo_file_type content_type, GList** p_item_list);
/**
-* @fn int mb_svc_get_media_record_cnt_by_folder_id (int folder_id, int* count);
+* @fn int mb_svc_get_media_record_cnt_by_folder_id (MediaSvcHandle *mb_svc_handle, int folder_id, int* count);
* This function gets record count in some folder
*
* @return This function returns record count.
*
*
*/
-int mb_svc_get_media_record_cnt_by_folder_id(int folder_id, int* count);
+int mb_svc_get_media_record_cnt_by_folder_id(MediaSvcHandle *mb_svc_handle, int folder_id, int* count);
/**
-* @fn int mb_svc_get_folder_list(GList** p_record_list);
+* @fn int mb_svc_get_folder_list(MediaSvcHandle *mb_svc_handle, GList** p_record_list);
* This function gets all the folders
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_folder_list(GList** p_record_list);
+int mb_svc_get_folder_list(MediaSvcHandle *mb_svc_handle, GList** p_record_list);
/**
-* @fn int mb_svc_get_folder_item_list(GList** p_item_list);
+* @fn int mb_svc_get_folder_item_list(MediaSvcHandle *mb_svc_handle, GList** p_item_list);
* This function gets all the folder items
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_folder_item_list(GList** p_item_list);
+int mb_svc_get_folder_item_list(MediaSvcHandle *mb_svc_handle, GList** p_item_list);
/**
-* @fn int mb_svc_get_bookmark_record_by_id(int record_id, mb_svc_bookmark_record_s* record);
+* @fn int mb_svc_get_bookmark_record_by_id(MediaSvcHandle *mb_svc_handle, int record_id, mb_svc_bookmark_record_s* record);
* This function gets the bookmark
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_bookmark_record_by_id(int record_id, mb_svc_bookmark_record_s* record);
+int mb_svc_get_bookmark_record_by_id(MediaSvcHandle *mb_svc_handle, int record_id, mb_svc_bookmark_record_s* record);
/**
-* @fn int mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record);
+* @fn int mb_svc_get_media_tag_by_id(MediaSvcHandle *mb_svc_handle, int _id, mb_svc_tag_record_s *mtag_record);
* This function gets the tag record according to its ID
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record);
+int mb_svc_get_media_tag_by_id(MediaSvcHandle *mb_svc_handle, int _id, mb_svc_tag_record_s *mtag_record);
/**
-* @fn int mb_svc_get_bookmark_record_by_media_id(int media_id, mb_svc_bookmark_record_s* bookmark_record);
+* @fn int mb_svc_get_bookmark_record_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, mb_svc_bookmark_record_s* bookmark_record);
* This function gets the bookmark
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_bookmark_record_by_media_id(int media_id, mb_svc_bookmark_record_s* bookmark_record);
+mb_svc_get_bookmark_record_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, mb_svc_bookmark_record_s* bookmark_record);
/**
-* @fn int mb_svc_get_image_list_by_location(double longitude, double latitude, GList** p_record_list);
+* @fn int mb_svc_get_image_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, GList** p_record_list);
* This function gets all the image records at some location
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_image_list_by_location(double longitude, double latitude, GList** p_record_list);
+int mb_svc_get_image_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, GList** p_record_list);
/**
-* @fn int mb_svc_get_video_list_by_location(double longitude, double latitude, GList** p_record_list);
+* @fn int mb_svc_get_video_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, GList** p_record_list);
* This function gets all the video records at some location
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_video_list_by_location(double longitude, double latitude, GList** p_record_list);
+int mb_svc_get_video_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, GList** p_record_list);
/**
-* @fn int mb_svc_get_media_item_list_by_location(double longitude, double latitude, int media_type, int favoriate, GList** p_item_list);
+* @fn int mb_svc_get_media_item_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, int media_type, int favoriate, GList** p_item_list);
* This function gets all the media item at some location
*
*
*
*/
-int mb_svc_get_media_item_list_by_location(double longitude, double latitude, minfo_file_type content_type, int favorite, GList** p_item_list);
+int mb_svc_get_media_item_list_by_location(MediaSvcHandle *mb_svc_handle, double longitude, double latitude, minfo_file_type content_type, int favorite, GList** p_item_list);
/**
-* @fn int mb_svc_get_web_streaming_record_by_folder_id(int folder_id, GList** p_record_list);
+* @fn int mb_svc_get_web_streaming_record_by_folder_id(MediaSvcHandle *mb_svc_handle, int folder_id, GList** p_record_list);
* This function gets the web streaming records list mapped to folder ID .
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_web_streaming_record_by_folder_id(int folder_id, GList** p_record_list);
+int mb_svc_get_web_streaming_record_by_folder_id(MediaSvcHandle *mb_svc_handle, int folder_id, GList** p_record_list);
/**
-* @fn int mb_svc_get_web_album_list_by_web_account(char *web_account,GList** p_record_list);
+* @fn int mb_svc_get_web_album_list_by_web_account(MediaSvcHandle *mb_svc_handle, char *web_account,GList** p_record_list);
* This function gets the web streaming records list via web account
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_web_album_list_by_web_account(char *web_account,GList** p_record_list);
+int mb_svc_get_web_album_list_by_web_account(MediaSvcHandle *mb_svc_handle, char *web_account,GList** p_record_list);
/**
-* @fn int mb_svc_get_web_streaming_item_by_web_account(char *web_account,GList** p_item_list);
+* @fn int mb_svc_get_web_streaming_item_by_web_account(MediaSvcHandle *mb_svc_handle, char *web_account,GList** p_item_list);
* This function gets the web streaming item list via web account
*
* @return This function returns 0 on success, and -1 on failure.
*
*
*/
-int mb_svc_get_web_streaming_item_by_web_account(char *web_account,GList** p_item_list);
+int mb_svc_get_web_streaming_item_by_web_account(MediaSvcHandle *mb_svc_handle, char *web_account,GList** p_item_list);
/**
-* @fn int mb_svc_update_favorite_by_media_id(const char *media_id, int favorite);
+* @fn int mb_svc_update_favorite_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite);
* This function update rate field of media record
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_update_favorite_by_media_id(const char *media_id, int favorite);
+mb_svc_update_favorite_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite);
/**
-* @fn int mb_svc_get_media_record_by_fid_name(int folder_id, char* display_name, mb_svc_media_record_s* m_record);
+* @fn int mb_svc_get_media_record_by_fid_name(MediaSvcHandle *mb_svc_handle, int folder_id, char* display_name, mb_svc_media_record_s* m_record);
* This function gets media record by folder id and file name
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_media_record_by_fid_name(const char *folder_id, const char* display_name, mb_svc_media_record_s* m_record);
+mb_svc_get_media_record_by_fid_name(MediaSvcHandle *mb_svc_handle, const char *folder_id, const char* display_name, mb_svc_media_record_s* m_record);
/**
-* @fn int mb_svc_get_folder_content_count_by_folder_id(int folder_id);
+* @fn int mb_svc_get_folder_content_count_by_folder_id(MediaSvcHandle *mb_svc_handle, int folder_id);
* This function gets matched media record count with specified folder id
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_get_folder_content_count_by_folder_id(const char *folder_id);
+mb_svc_get_folder_content_count_by_folder_id(MediaSvcHandle *mb_svc_handle, const char *folder_id);
/**
-* @fn int mb_svc_media_iter_start(int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
+* @fn int mb_svc_media_iter_start(MediaSvcHandle *mb_svc_handle, int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
* This function gets media record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_media_iter_start(int folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_media_iter_start(MediaSvcHandle *mb_svc_handle, int folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
/**
-* @fn int mb_svc_media_iter_start_new(int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
+* @fn int mb_svc_media_iter_start_new(MediaSvcHandle *mb_svc_handle, int folder_id, mb_svc_media_list_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator );
* This function gets media record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_media_iter_start_new(const char *folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_media_iter_start_new(MediaSvcHandle *mb_svc_handle, const char *folder_id, minfo_item_filter* filter, minfo_folder_type folder_type, int valid, GList* p_folder_id_list, mb_svc_iterator_s* mb_svc_iterator);
/**
-* @fn int mb_svc_media_search_iter_start(minfo_search_field_t search_field, const char *search_str, const minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator );
+* @fn int mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle, minfo_search_field_t search_field, const char *search_str, const minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator );
* This function gets media record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_media_search_iter_start(minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator);
+mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle, minfo_search_field_t search_field, const char *search_str, minfo_folder_type folder_type, minfo_item_filter filter, mb_svc_iterator_s *mb_svc_iterator);
/**
* @fn int mb_svc_media_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_media_record_s *record);
mb_svc_media_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_media_record_s *record);
/**
-* @fn int mb_svc_folder_iter_start(minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
+* @fn int mb_svc_folder_iter_start(MediaSvcHandle *mb_svc_handle, minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
* This function gets folder record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_folder_iter_start(minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_folder_iter_start(MediaSvcHandle *mb_svc_handle, minfo_cluster_filter* cluster_filter, mb_svc_iterator_s* mb_svc_iterator);
/**
* @fn int mb_svc_folder_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_folder_record_s *record);
mb_svc_iter_finish(mb_svc_iterator_s* mb_svc_iterator);
/**
-* @fn int mb_svc_get_media_record_by_id(int media_id,mb_svc_media_record_s *media_record);
+* @fn int mb_svc_get_media_record_by_id(MediaSvcHandle *mb_svc_handle, int media_id,mb_svc_media_record_s *media_record);
* This function gets media record matched with field _id
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_get_media_record_by_id(const char *media_id, mb_svc_media_record_s *media_record);
+mb_svc_get_media_record_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, mb_svc_media_record_s *media_record);
/**
-* @fn int mb_svc_get_folder_record_by_id(const char *folder_id, mb_svc_folder_record_s *folder_record);
+* @fn int mb_svc_get_folder_record_by_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, mb_svc_folder_record_s *folder_record);
* This function gets folder record matched with field _id
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_get_folder_record_by_id(const char *folder_id, mb_svc_folder_record_s *folder_record);
+mb_svc_get_folder_record_by_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, mb_svc_folder_record_s *folder_record);
/**
-* @fn int mb_svc_get_video_id_by_media_id(int media_id, int* video_id);
+* @fn int mb_svc_get_video_id_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, int* video_id);
* This function gets video record id by media_id filed in video_meta table
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_get_id_by_media_id(int media_id, char* table_name, int* video_id);
+mb_svc_get_id_by_media_id(MediaSvcHandle *mb_svc_handle, int media_id, char* table_name, int* video_id);
/**
-* @fn int mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type);
+* @fn int mb_svc_delete_folder(MediaSvcHandle *mb_svc_handle, const char *folder_id, minfo_store_type storage_type);
* This function delete folder record,matched media record,image_meta record or video_meta record and bookmark record by field "_id"
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type);
+mb_svc_delete_folder(MediaSvcHandle *mb_svc_handle, const char *folder_id, minfo_store_type storage_type);
/**
-* @fn int mb_svc_webstreaming_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+* @fn int mb_svc_webstreaming_iter_start(MediaSvcHandle *mb_svc_handle, mb_svc_iterator_s* mb_svc_iterator);
* This function gets webstreaming record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_webstreaming_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_webstreaming_iter_start(MediaSvcHandle *mb_svc_handle, mb_svc_iterator_s* mb_svc_iterator);
/**
* @fn int mb_svc_webstreaming_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_web_streaming_record_s *webstreaming_record);
/**
-* @fn int mb_svc_bookmark_iter_start(mb_svc_iterator_s* mb_svc_iterator);
+* @fn int mb_svc_bookmark_iter_start(MediaSvcHandle *mb_svc_handle, mb_svc_iterator_s* mb_svc_iterator);
* This function gets bookmark record iterator
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_bookmark_iter_start(const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_bookmark_iter_start(MediaSvcHandle *mb_svc_handle, const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
/**
mb_svc_bookmark_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_bookmark_record_s *record);
/**
-* @fn mb_svc_tag_iter_start(const char *tag_name, int media_id, mb_svc_iterator_s* mb_svc_iterator);
+* @fn mb_svc_tag_iter_start(MediaSvcHandle *mb_svc_handle, const char *tag_name, int media_id, mb_svc_iterator_s* mb_svc_iterator);
* This function gets tag record iterator, according tag_name, if any, or media_id.
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_tag_iter_start(const char *tag_name, const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_tag_iter_start(MediaSvcHandle *mb_svc_handle, const char *tag_name, const char *media_id, mb_svc_iterator_s* mb_svc_iterator);
/**
-* @fn mb_svc_tag_iter_with_filter_start(const char *tag_name, int media_id, minfo_tag_filter, filter, mb_svc_iterator_s* mb_svc_iterator);
+* @fn mb_svc_tag_iter_with_filter_start(MediaSvcHandle *mb_svc_handle, const char *tag_name, int media_id, minfo_tag_filter, filter, mb_svc_iterator_s* mb_svc_iterator);
* This function gets tag record iterator, according tag_name, if any, or media_id.
*
* @return This function returns 0 on success, and negative value on failure.
*/
int
-mb_svc_tag_iter_with_filter_start(const char *tag_name, minfo_tag_filter filter, mb_svc_iterator_s* mb_svc_iterator);
+mb_svc_tag_iter_with_filter_start(MediaSvcHandle *mb_svc_handle, const char *tag_name, minfo_tag_filter filter, mb_svc_iterator_s* mb_svc_iterator);
/**
* @fn int mb_svc_tag_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_tag_record_s *record);
mb_svc_media_id_list_by_tag_iter_next(mb_svc_iterator_s* mb_svc_iterator, mb_svc_tag_record_s *record);
int
-mb_svc_delete_record_tag(const char *tag_name, const char *media_id);
+mb_svc_delete_record_tag(MediaSvcHandle *mb_svc_handle, const char *tag_name, const char *media_id);
int
-mb_svc_rename_record_tag(const char* src_tagname, const char* dst_tag_name);
+mb_svc_rename_record_tag(MediaSvcHandle *mb_svc_handle, const char* src_tagname, const char* dst_tag_name);
int
-mb_svc_rename_record_tag_by_id(const char *media_id, const char* src_tagname, const char* dst_tag_name);
+mb_svc_rename_record_tag_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* src_tagname, const char* dst_tag_name);
int
-mb_svc_get_tagid_by_tagname(const char* tag_name);
+mb_svc_get_tagid_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tag_name);
int
-mb_svc_add_web_streaming_folder(char *folder_id);
+mb_svc_add_web_streaming_folder(MediaSvcHandle *mb_svc_handle, char *folder_id);
int
-mb_svc_get_web_streaming_folder_id();
+mb_svc_get_web_streaming_folder_id(MediaSvcHandle *mb_svc_handle);
int
-mb_svc_get_web_streaming_folder_uuid(char *folder_uuid, int max_length);
+mb_svc_get_web_streaming_folder_uuid(MediaSvcHandle *mb_svc_handle, char *folder_uuid, int max_length);
int
-mb_svc_get_media_id_by_full_path(const char* file_full_path, char *media_id);
+mb_svc_get_media_id_by_full_path(MediaSvcHandle *mb_svc_handle, const char* file_full_path, char *media_id);
int
-mb_svc_get_media_id_by_http_url(const char* http_url, char* media_id);
+mb_svc_get_media_id_by_http_url(MediaSvcHandle *mb_svc_handle, const char* http_url, char* media_id);
int
-mb_svc_get_media_record_by_full_path(const char* file_full_path, mb_svc_media_record_s* record);
+mb_svc_get_media_record_by_full_path(MediaSvcHandle *mb_svc_handle, const char* file_full_path, mb_svc_media_record_s* record);
int
-mb_svc_get_web_album_cluster_record(int sns_type, const char* name, const char *account_id, const char *album_id, mb_svc_folder_record_s* folder_record);
+mb_svc_get_web_album_cluster_record(MediaSvcHandle *mb_svc_handle, int sns_type, const char* name, const char *account_id, const char *album_id, mb_svc_folder_record_s* folder_record);
int
-mb_svc_delete_invalid_media_records(const minfo_store_type storage_type);
+mb_svc_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
int
-mb_svc_get_folder_name_by_id(const char *folder_id, char *folder_name, int max_length);
+mb_svc_get_folder_name_by_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *folder_name, int max_length);
int
-mb_svc_get_folder_list_by_web_account_id(char *web_account, GList** p_record_list);
+mb_svc_get_folder_list_by_web_account_id(MediaSvcHandle *mb_svc_handle, char *web_account, GList** p_record_list);
int
-mb_svc_geo_media_iter_start(const char *folder_id,
+mb_svc_geo_media_iter_start(MediaSvcHandle *mb_svc_handle,
+ const char *folder_id,
minfo_folder_type store_filter,
minfo_item_filter* filter,
mb_svc_iterator_s* mb_svc_iterator,
double min_latitude,
double max_latitude );
-int
-mb_svc_get_all_item_count(int *cnt);
+int mb_svc_get_all_item_count(
+ MediaSvcHandle *mb_svc_handle,
+ minfo_folder_type folder_type,
+ minfo_file_type file_type,
+ minfo_media_favorite_type fav_type,
+ int *cnt);
int
-mb_svc_get_media_count_by_tagname(const char* tagname, int* count);
+mb_svc_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char* tagname, int* count);
int
-mb_svc_delete_tagmap_by_media_id(const char *media_id);
+mb_svc_delete_tagmap_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id);
+int
+mb_svc_check_exist_by_path(MediaSvcHandle *mb_svc_handle, const char *path, const char *table_name);
+int
+mb_svc_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type);
#ifdef __cplusplus
}
#define _MEDIA_SVC_DB_UTIL_H_
#include <glib.h>
+#include "media-svc-types.h"
#ifdef __cplusplus
extern "C" {
#define MB_SVC_RECORD_DELETE_QUERY_STRING "DELETE FROM %s WHERE _id = %d;"
#define MB_SVC_TABLE_DELETE_QUERY_STRING "DELETE FROM %s ;"
#define MB_SVC_TABLE_COUNT_QUERY_STRING "SELECT count(*) FROM %s"
-#define MB_SVC_TABLE_COUNT_MEDIA "SELECT count(*) FROM %s "
+#define MB_SVC_TABLE_COUNT_BY_PATH_QUERY_STRING "SELECT count(*) FROM %s WHERE path='%q'"
-#define MB_SVC_TABLE_SELECT_BOOKMARK_BY_BID_QUERY_STRING "SELECT _id, media_uuid, marked_time, thumbnail_path FROM %s WHERE _id=%d;"
-#define MB_SVC_TABLE_SELECT_WEB_CLUSTER_RECORD_QUERY_STRING "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q';"
-#define MB_SVC_TABLE_SELECT_WEB_ALBUM_CLUSTER_RECORD_QUERY_STRING "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q' AND web_album_id = '%q';"
-#define MB_SVC_TABLE_SELECT_MEDIA_ID_BY_HTTP_URL "SELECT uuid FROM %s WHERE http_url = '%q';"
+#define MB_SVC_TABLE_SELECT_BOOKMARK_BY_BID_QUERY_STRING "SELECT _id, visual_uuid, marked_time, thumbnail_path FROM %s WHERE _id=%d;"
+#define MB_SVC_TABLE_SELECT_WEB_CLUSTER_RECORD_QUERY_STRING "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q';"
+#define MB_SVC_TABLE_SELECT_WEB_ALBUM_CLUSTER_RECORD_QUERY_STRING "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE sns_type = %d AND folder_name = '%q' AND web_account_id = '%q' AND web_album_id = '%q';"
+#define MB_SVC_TABLE_SELECT_MEDIA_ID_BY_HTTP_URL "SELECT visual_uuid FROM %s WHERE http_url = '%q';"
#define MB_SVC_UPDATE_FOLDER_PATH_TABLE "UPDATE %s SET path = REPLACE( path, '%q', '%q');"
#define MB_SVC_UPDATE_FOLDER_MODIFIED_DATE_TABLE "UPDATE %s SET modified_date = %d where path like '%q';"
#define MB_SVC_TABLE_SELECT_WEBSTREAMING_RECORD_BY_ID "SELECT _id, title, duration, url, thumb_path FROM %s WHERE _id=%d;"
#define MB_SVC_TABLE_SELECT_MEDIA_CNT_BY_TAGID "SELECT count(*) FROM %s WHERE tag_id=%d"
/* SELECT Query for uuid */
-#define MB_SVC_TABLE_SELECT_MEDIA_BY_MEDIA_UUID "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE uuid = '%s' AND valid = 1;"
-#define MB_SVC_TABLE_SELECT_FOLDER_RECORD_BY_UUID "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE uuid = '%s';"
-#define MB_SVC_TABLE_SELECT_VIDEO_BY_MUUID "SELECT _id, media_uuid, album, artist, title, description, youtube_category, last_played_time, duration, longitude, latitude, width, height, datetaken FROM %s WHERE media_uuid = '%s';"
-#define MB_SVC_TABLE_SELECT_IMAGE_BY_MUUID "SELECT _id, media_uuid, longitude, latitude, description, width, height, orientation, datetaken FROM %s WHERE media_uuid='%s';"
-#define MB_SVC_TABLE_SELECT_BOOKMARK_ALL_BY_MUUID "SELECT _id, media_uuid, marked_time, thumbnail_path FROM %s where media_uuid = '%s';"
-#define MB_SVC_TABLE_SELECT_MEDIA_BY_PATH "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE path = '%q';"
+#define MB_SVC_TABLE_SELECT_MEDIA_BY_MEDIA_UUID "SELECT visual_uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size FROM %s WHERE visual_uuid = '%s' AND valid = 1;"
+#define MB_SVC_TABLE_SELECT_FOLDER_RECORD_BY_UUID "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE folder_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_VIDEO_BY_MUUID "SELECT _id, visual_uuid, album, artist, title, genre, description, youtube_category, last_played_time, duration, longitude, latitude, width, height, datetaken FROM %s WHERE visual_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_IMAGE_BY_MUUID "SELECT _id, visual_uuid, longitude, latitude, description, width, height, orientation, datetaken FROM %s WHERE visual_uuid='%s';"
+#define MB_SVC_TABLE_SELECT_BOOKMARK_ALL_BY_MUUID "SELECT _id, visual_uuid, marked_time, thumbnail_path FROM %s where visual_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_MEDIA_BY_PATH "SELECT visual_uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size FROM %s WHERE path = '%q';"
#define MB_SVC_FOLDER_CONTENT_COUNT_BY_FUUID "SELECT count(*) FROM %s WHERE folder_uuid = '%s'"
-#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
-#define MB_SVC_TABLE_SELECT_FOLDER_URI_BY_FUUID "SELECT path, folder_name, storage_type FROM %s WHERE uuid = '%s';"
-#define MB_SVC_TABLE_SELECT_FOLDER_BY_PATH_INFO "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
-#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_ALBUM_ID_QUERY_STRING "SELECT uuid FROM %s WHERE web_album_id = '%q';"
-#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_STREAMING "SELECT uuid FROM %s WHERE storage_type = %d;"
-#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_PATH_INFO "SELECT uuid FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
-#define MB_SVC_SELECT_MEDIA_UUID_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
-#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID "SELECT folder_name FROM %s WHERE uuid = '%s';"
-#define MB_SVC_SELECT_ALL_ITEM_COUNT "select count(*) from %s as m INNER JOIN visual_folder AS f ON m.folder_uuid = f.uuid and f.lock_status=0 and m.valid=1 and f.storage_type!=2;"
-#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID "SELECT folder_name FROM %s WHERE uuid = '%s';"
-#define MB_SVC_TABLE_SELECT_FOLDER_ALL_QUERY_STRING "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s "
-#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_ID_AND_DISPLAY_NAME "SELECT uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
-#define MB_SVC_SELECT_ALL_MEDIA "SELECT m.uuid, m.path, folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url FROM %s as m INNER JOIN visual_folder AS f ON "
-#define MB_SVC_SELECT_FOLDER_BY_PATH "SELECT uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s where valid=1 and path='%q' or path like '%q';"
-#define MB_SVC_SELECT_MEDIA_ID_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
-#define MB_SVC_SELECT_INVALID_MEDIA_LIST "SELECT m.uuid, m.path, folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url FROM visual_media as m INNER JOIN visual_folder AS f ON f.uuid = m.folder_uuid and m.valid=0 and f.storage_type=%d"
+#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT visual_uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_URI_BY_FUUID "SELECT path, folder_name, storage_type FROM %s WHERE folder_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_FOLDER_BY_PATH_INFO "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_ALBUM_ID_QUERY_STRING "SELECT folder_uuid FROM %s WHERE web_album_id = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_WEB_STREAMING "SELECT folder_uuid FROM %s WHERE storage_type = %d;"
+#define MB_SVC_TABLE_SELECT_FOLDER_UUID_BY_PATH_INFO "SELECT folder_uuid FROM %s WHERE path = '%q' AND folder_name = '%q' AND storage_type = %d;"
+#define MB_SVC_SELECT_MEDIA_UUID_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT visual_uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID "SELECT folder_name FROM %s WHERE folder_uuid = '%s';"
+//#define MB_SVC_SELECT_ALL_ITEM_COUNT "select count(*) from %s as m INNER JOIN visual_folder AS f ON m.folder_uuid = f.folder_uuid and f.lock_status=0 and m.valid=1 and f.storage_type!=2;"
+#define MB_SVC_SELECT_ALL_ITEM_COUNT "select count(*) from %s as m INNER JOIN visual_folder AS f ON m.folder_uuid = f.folder_uuid and f.lock_status=0 and m.valid=1 and %s %s %s;"
+#define MB_SVC_TABLE_SELECT_FOLDER_NAME_BY_UUID "SELECT folder_name FROM %s WHERE folder_uuid = '%s';"
+#define MB_SVC_TABLE_SELECT_FOLDER_ALL_QUERY_STRING "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s "
+#define MB_SVC_SELECT_MEDIA_RECORD_BY_FOLDER_ID_AND_DISPLAY_NAME "SELECT visual_uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_SELECT_ALL_MEDIA "SELECT m.visual_uuid, m.path, m.folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url, size FROM %s as m INNER JOIN visual_folder AS f ON "
+#define MB_SVC_SELECT_FOLDER_BY_PATH "SELECT folder_uuid, path, folder_name, modified_date, web_account_id, storage_type, sns_type, lock_status, web_album_id FROM %s where valid=1 and path='%q' or path like '%q';"
+#define MB_SVC_SELECT_MEDIA_ID_BY_FOLDER_UUID_AND_DISPLAY_NAME "SELECT visual_uuid FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
+#define MB_SVC_SELECT_INVALID_MEDIA_LIST "SELECT m.visual_uuid, m.path, m.folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url, size FROM visual_media as m INNER JOIN visual_folder AS f ON f.folder_uuid = m.folder_uuid and m.valid=0 and f.storage_type=%d"
+#define MB_SVC_SELECT_ALL_MEDIA_LIST_BY_STORAGE "SELECT m.visual_uuid, m.path, m.folder_uuid, display_name, content_type, rating, m.modified_date, thumbnail_path, http_url, size FROM visual_media as m INNER JOIN visual_folder AS f ON f.folder_uuid = m.folder_uuid and f.storage_type=%d"
-#define MB_SVC_TABLE_SELECT_GEO_LIST "SELECT a.uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url from ( SELECT m.uuid, path, folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, valid FROM %s AS m INNER JOIN ( SELECT media_uuid from image_meta where longitude between %f and %f and latitude between %f and %f union select media_uuid from video_meta where longitude between %f and %f and latitude between %f and %f) AS meta ON meta.media_uuid = m.uuid ) a, (select uuid, lock_status from visual_folder where valid=1 %s ) b where a.folder_uuid = b.uuid and a.valid=1 "
+#define MB_SVC_TABLE_SELECT_GEO_LIST "SELECT a.visual_uuid, path, a.folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size from ( SELECT m.visual_uuid, path, m.folder_uuid, display_name, content_type, rating, modified_date, thumbnail_path, http_url, size, valid FROM %s AS m INNER JOIN ( SELECT visual_uuid from image_meta where longitude between %f and %f and latitude between %f and %f union select visual_uuid from video_meta where longitude between %f and %f and latitude between %f and %f) AS meta ON meta.visual_uuid = m.visual_uuid ) a, (select folder_uuid, lock_status from visual_folder where valid=1 %s ) b where a.folder_uuid = b.folder_uuid and a.valid=1 "
-#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT t._id, tm.media_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT t._id, tm.visual_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select visual_uuid, tag_id from visual_tag_map ) tm, ( select visual_uuid, folder_uuid from visual_media) m, ( select folder_uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.visual_uuid = tm.visual_uuid and m.folder_uuid = f.folder_uuid and f.lock_status=%d;"
-#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_WITH_LOCK_STATUS "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d UNION SELECT _id, tag_name from visual_tag ORDER BY tag_name ASC;"
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_WITH_LOCK_STATUS "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select visual_uuid, tag_id from visual_tag_map ) tm, ( select visual_uuid, folder_uuid from visual_media) m, ( select folder_uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.visual_uuid = tm.visual_uuid and m.folder_uuid = f.folder_uuid and f.lock_status=%d UNION SELECT _id, tag_name from visual_tag ORDER BY tag_name ASC;"
-#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_MEDIA_ID_WITH_LOCK_STATUS "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map where media_uuid='%s') tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_MEDIA_ID_WITH_LOCK_STATUS "select t._id, t.tag_name from ( select _id, tag_name from visual_tag ORDER BY tag_name ASC ) t, ( select visual_uuid, tag_id from visual_tag_map where visual_uuid='%s') tm, ( select visual_uuid, folder_uuid from visual_media) m, ( select folder_uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.visual_uuid = tm.visual_uuid and m.folder_uuid = f.folder_uuid and f.lock_status=%d;"
-#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS_AND_FILTER "SELECT t._id, tm.media_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid, content_type from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d %s ;"
+#define MB_SVC_TABLE_SELECT_TAG_ALL_QUERY_STRING_BY_TAG_NAME_WITH_LOCK_STATUS_AND_FILTER "SELECT t._id, tm.visual_uuid from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select visual_uuid, tag_id from visual_tag_map ) tm, ( select visual_uuid, folder_uuid, content_type from visual_media) m, ( select folder_uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.visual_uuid = tm.visual_uuid and m.folder_uuid = f.folder_uuid and f.lock_status=%d %s ;"
-#define MB_SVC_TABLE_SELECT_COUNT_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT count(*) from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=%d;"
+#define MB_SVC_TABLE_SELECT_COUNT_BY_TAG_NAME_WITH_LOCK_STATUS "SELECT count(*) from ( select _id, tag_name from visual_tag WHERE tag_name='%s' ORDER BY tag_name ASC ) t, ( select visual_uuid, tag_id from visual_tag_map ) tm, ( select visual_uuid, folder_uuid from visual_media) m, ( select folder_uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.visual_uuid = tm.visual_uuid and m.folder_uuid = f.folder_uuid and f.lock_status=%d;"
/* UPDATE Query for uuid */
-#define MB_SVC_UPDATE_VIDEO_META_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%f, %s=%f, %s=%d, %s=%d, %s=%d WHERE _id = %d;"
+#define MB_SVC_UPDATE_VIDEO_META_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%f, %s=%f, %s=%d, %s=%d, %s=%d WHERE _id = %d;"
#define MB_SVC_UPDATE_IMAGE_META_TABLE "UPDATE %s SET %s='%q', %s=%f, %s=%f, %s='%q', %s=%d, %s=%d, %s=%d, %s=%d WHERE _id = %d;"
-#define MB_SVC_UPDATE_MEDIA_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%d, %s='%q', %s='%q' WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_MEDIA_THUMB_PATH "UPDATE %s SET thumbnail_path = '%q' WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID "UPDATE %s SET rating = %d WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_MEDIA_DATE_BY_ID "UPDATE %s SET modified_date = %d WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_FOLDER_ALBUM_STATUS "UPDATE %s SET lock_status = ? WHERE uuid = ?;"
-#define MB_SVC_UPDATE_VALID_BY_UUID "UPDATE %s SET valid = %d WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_FOLDER_TABLE "UPDATE %s SET %s='%q', %s='%q', %s=%d, %s='%q', %s=%d, %s=%d, %s=%d WHERE uuid = '%s';"
-#define MB_SVC_UPDATE_META_WIDTH_HEIGHT "UPDATE %s SET %s=%d, %s=%d WHERE media_uuid = '%s';"
-#define MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID_AND_MEDIA_ID "UPDATE %s SET tag_id=%d WHERE media_uuid='%s' and tag_id=%d;"
+#define MB_SVC_UPDATE_MEDIA_TABLE "UPDATE %s SET %s='%q', %s='%q', %s='%q', %s=%d, %s=%d, %s=%d, %s='%q', %s='%q', %s=%d WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_THUMB_PATH "UPDATE %s SET thumbnail_path = '%q' WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID "UPDATE %s SET rating = %d WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_MEDIA_DATE_BY_ID "UPDATE %s SET modified_date = %d WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_FOLDER_ALBUM_STATUS "UPDATE %s SET lock_status = ? WHERE folder_uuid = ?;"
+#define MB_SVC_UPDATE_MEDIA_VALID_BY_UUID "UPDATE %s SET valid = %d WHERE visual_uuid = '%s';"
+#define MB_SVC_UPDATE_FOLDER_VALID_BY_UUID "UPDATE %s SET valid = %d WHERE folder_uuid = '%s';"
+#define MB_SVC_UPDATE_FOLDER_TABLE "UPDATE %s SET %s='%q', %s='%q', %s=%d, %s='%q', %s=%d, %s=%d, %s=%d WHERE folder_uuid = '%s';"
+#define MB_SVC_UPDATE_META_WIDTH_HEIGHT "UPDATE %s SET %s=%d, %s=%d WHERE visual_uuid = '%s';"
+#define MB_SVC_TABLE_UPDATE_TAG_MAP_QUERY_STRING_BY_TAG_ID_AND_MEDIA_ID "UPDATE %s SET tag_id=%d WHERE visual_uuid='%s' and tag_id=%d;"
/* INSERT Query for uuid */
#define MB_SVC_INSERT_FOLDER_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES ('%q', '%q', '%q', %d, '%q', %d, %d, %d, '%q', %d );"
#define MB_SVC_INSERT_IMAGE_META_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s) VALUES ( '%q', %f, %f, '%q', %d, %d, %d, %d );"
-#define MB_SVC_INSERT_MEDIA_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s ) VALUES ( '%q', '%q', '%q', '%q', %d, %d, %d, '%q', '%q', %d );"
+#define MB_SVC_INSERT_MEDIA_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ) VALUES ( '%q', '%q', '%q', '%q', %d, %d, %d, '%q', '%q', %d, %d );"
#define MB_SVC_INSERT_TAG_TABLE "INSERT INTO %s (%s, %s) VALUES ( %d, '%q' );"
#define MB_SVC_INSERT_TAG_MAP_TABLE "INSERT INTO %s (%s, %s, %s) VALUES ( %d, '%q', %d );"
-#define MB_SVC_INSERT_VIDEO_META_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES ( '%q', '%q', '%q','%q', '%q','%q', %d, %d, %f, %f, %d, %d, %d );"
+#define MB_SVC_INSERT_VIDEO_META_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES ( '%q', '%q', '%q','%q', '%q', '%q','%q', %d, %d, %f, %f, %d, %d, %d );"
#define MB_SVC_INSERT_BOOKMARK_TABLE "INSERT INTO %s (%s, %s, %s) VALUES ( '%q', %d,'%q' );"
#define MB_SVC_INSERT_WEB_STREAMING_TABLE "INSERT INTO %s (%s, %s, %s, %s, %s, %s) VALUES ( %d, '%s', '%q', %d, '%q'. '%q' );"
/* DELETE Query for uuid */
-#define MB_SVC_RECORD_DELETE_BY_UUID "DELETE FROM %s WHERE uuid = '%s';"
-#define MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID "DELETE FROM %s WHERE media_uuid = '%s' ;"
+#define MB_SVC_RECORD_FOLDER_DELETE_BY_UUID "DELETE FROM %s WHERE folder_uuid = '%s';"
+#define MB_SVC_RECORD_MEDIA_DELETE_BY_UUID "DELETE FROM %s WHERE visual_uuid = '%s';"
+#define MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID "DELETE FROM %s WHERE visual_uuid = '%s' ;"
#define MB_SVC_DELETE_MEDIA_BY_FOLDER_ID_AND_DISPLAY_NAME "DELETE FROM %s WHERE folder_uuid = '%s' AND display_name = '%q';"
-#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME_MEDIA_UUID "DELETE FROM %s WHERE media_uuid='%s' and tag_id=%d"
-#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_MEDIA_UUID "DELETE FROM %s WHERE media_uuid='%s'"
+#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_TAGNAME_MEDIA_UUID "DELETE FROM %s WHERE visual_uuid='%s' and tag_id=%d"
+#define MB_SVC_TABLE_DELETE_TAG_MAP_BY_MEDIA_UUID "DELETE FROM %s WHERE visual_uuid='%s'"
/**
-* @fn int mb_svc_query_sql_gstring(GString *query_string);
+* @fn int mb_svc_query_sql_gstring(MediaSvcHandle *mb_svc_handle, GString *query_string);
* This function executes the inputted GString sql statement
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] query_string pointer to GString sql statement
* @exception None.
* @remark
*/
int
-mb_svc_query_sql_gstring(GString *query_string);
+mb_svc_query_sql_gstring(MediaSvcHandle *mb_svc_handle, GString *query_string);
/**
-* @fn int mb_svc_query_sql(char *query_str);
+* @fn int mb_svc_query_sql(MediaSvcHandle *mb_svc_handle, char *query_str);
* This function executes inputted sql string
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] query_str pointer to sql string
* @exception None.
* @remark
*/
int
-mb_svc_query_sql(char *query_str);
+mb_svc_query_sql(MediaSvcHandle *mb_svc_handle, char *query_str);
int
-mb_svc_sqlite3_begin_trans(void);
+mb_svc_sqlite3_begin_trans(MediaSvcHandle *mb_svc_handle);
int
-mb_svc_sqlite3_commit_trans(void);
+mb_svc_sqlite3_commit_trans(MediaSvcHandle *mb_svc_handle);
int
-mb_svc_sqlite3_rollback_trans(void);
+mb_svc_sqlite3_rollback_trans(MediaSvcHandle *mb_svc_handle);
void
mb_svc_sql_list_add(GList **list, char **sql);
#define _MEDIA_SVC_DB_H_
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#ifdef __cplusplus
extern "C" {
int _mb_svc_truncate_tbl();
/**
-* @fn int mb_svc_delete_record_bookmark_by_id(int id);
+* @fn int mb_svc_delete_record_bookmark_by_id(MediaSvcHandle *mb_svc_handle, int id);
* This function deletes specified bookmark record by field "_id"
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] id bookmark record id
* @exception None.
* @remark
*
*/
-int mb_svc_delete_record_bookmark_by_id(int id);
+int mb_svc_delete_record_bookmark_by_id(MediaSvcHandle *mb_svc_handle, int id);
/**
-* @fn int int mb_svc_delete_record_folder_by_id(const char *id);
+* @fn int int mb_svc_delete_record_folder_by_id(MediaSvcHandle *mb_svc_handle, const char *id);
* This function deletes specified folder record by id
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] id folder record id
* @exception None.
* @remark
*
*/
-int mb_svc_delete_record_folder_by_id(const char *id);
+int mb_svc_delete_record_folder_by_id(MediaSvcHandle *mb_svc_handle, const char *id);
/**
-* @fn int mb_svc_delete_record_web_streaming_by_id(int id);
+* @fn int mb_svc_delete_record_web_streaming_by_id(MediaSvcHandle *mb_svc_handle, int id);
* This function deletes specified webstreaming record by id
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] id webstreaming record id
* @exception None.
* @remark
*
*/
-int mb_svc_delete_record_web_streaming_by_id(int id);
+int mb_svc_delete_record_web_streaming_by_id(MediaSvcHandle *mb_svc_handle, int id);
/**
-* @fn int mb_svc_delete_record_media_by_id(const char *id);
+* @fn int mb_svc_delete_record_media_by_id(MediaSvcHandle *mb_svc_handle, const char *id);
* This function deletes specified media record by id
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] id media record id
* @exception None.
* @remark
*
*/
-int mb_svc_delete_record_media_by_id(const char *id);
+int mb_svc_delete_record_media_by_id(MediaSvcHandle *mb_svc_handle, const char *id);
/**
-* @fn int mb_svc_delete_record_video_meta_by_id(int id);
+* @fn int mb_svc_delete_record_video_meta_by_id(MediaSvcHandle *mb_svc_handle, int id);
* This function deletes specified video_meta record
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] id video_meta record id
* @exception None.
* @remark
*
*/
-int mb_svc_delete_record_video_meta_by_id(int id);
+int mb_svc_delete_record_video_meta_by_id(MediaSvcHandle *mb_svc_handle, int id);
/**
-* @fn int mb_svc_update_record_folder(mb_svc_folder_record_s *record);
+* @fn int mb_svc_update_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record);
* This function updates folder record
*
* @return This function returns 0 on success, and negative value on failure.
+* @param[in] mb_svc_handle Handle for media service
* @param[in] record pointer to new folder record
* @exception None.
* @remark
*
*/
-int mb_svc_update_record_folder(mb_svc_folder_record_s *record);
+int mb_svc_update_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record);
/**
-* @fn int mb_svc_update_record_media(mb_svc_media_record_s *record);
+* @fn int mb_svc_update_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record);
* This function updates media record
*
* @return This function returns 0 on success, and negative value on failure.
*
*/
-int mb_svc_update_record_media(mb_svc_media_record_s *record);
+int mb_svc_update_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record);
/**
-* @fn int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record);
+* @fn int mb_svc_update_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record);
* This function updates video_meta record
*
* @return This function returns 0 on success, and negative value on failure.
*
*/
-int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record);
+int mb_svc_update_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record);
/**
-* @fn int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record);
+* @fn int mb_svc_update_record_image_meta(MediaSvcHandle *mb_svc_handle, mb_svc_image_meta_record_s *record);
* This function updates image_meta record
*
* @return This function returns 0 on success, and negative value on failure.
*
*/
-int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record);
+int mb_svc_update_record_image_meta(MediaSvcHandle *mb_svc_handle, mb_svc_image_meta_record_s *record);
/**
-* @fn int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record);
+* @fn int mb_svc_insert_record_bookmark(MediaSvcHandle *mb_svc_handle, mb_svc_bookmark_record_s *record);
* This function inserts record into bookmark table
*
* @return This function returns 0 on success, and -1 on failure.
*/
-int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record);
+int mb_svc_insert_record_bookmark(MediaSvcHandle *mb_svc_handle, mb_svc_bookmark_record_s *record);
/**
-* @fn mb_svc_insert_record_folder(mb_svc_folder_record_s *record);
+* @fn mb_svc_insert_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record);
* This function inserts record into folder table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_insert_record_folder(mb_svc_folder_record_s *record);
+int mb_svc_insert_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record);
/**
-* @fn int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record);
+* @fn int mb_svc_insert_record_web_streaming(MediaSvcHandle *mb_svc_handle, mb_svc_web_streaming_record_s *record);
* This function inserts record into webstreaming table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record);
+int mb_svc_insert_record_web_streaming(MediaSvcHandle *mb_svc_handle, mb_svc_web_streaming_record_s *record);
/**
-* @fn int mb_svc_insert_record_media(mb_svc_media_record_s *record);
+* @fn int mb_svc_insert_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record);
* This function inserts record into media table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_insert_record_media(mb_svc_media_record_s *record, minfo_store_type storage_type);
+int mb_svc_insert_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record, minfo_store_type storage_type);
/**
-* @fn int mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
+* @fn int mb_svc_insert_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
* This function insert record into video_meta table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
+int mb_svc_insert_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record, minfo_store_type storage_type);
/**
-* @fn int mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
+* @fn int mb_svc_insert_record_image_meta(MediaSvcHandle *mb_svc_handle, mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
* This function inserts record into image_meta table
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
-int mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
+int mb_svc_insert_record_image_meta(MediaSvcHandle *mb_svc_handle, mb_svc_image_meta_record_s *record, minfo_store_type storage_type);
/**
* @fn int mb_svc_load_record_bookmark(sqlite3_stmt* stmt, mb_svc_bookmark_record_s * record);
int mb_svc_load_record_image_meta(sqlite3_stmt* stmt, mb_svc_image_meta_record_s * record);
/**
-* @fn int mb_svc_insert_record_tag(mb_svc_tag_record_s *record);
+* @fn int mb_svc_insert_record_tag(MediaSvcHandle *mb_svc_handle, mb_svc_tag_record_s *record);
* This function inserts tag record which should be filled up the corresponding value
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_insert_record_tag(mb_svc_tag_record_s *record);
+mb_svc_insert_record_tag(MediaSvcHandle *mb_svc_handle, mb_svc_tag_record_s *record);
/**
-* @fn int mb_svc_insert_record_tag_map(const char *media_id, int tag_id);
+* @fn int mb_svc_insert_record_tag_map(MediaSvcHandle *mb_svc_handle, const char *media_id, int tag_id);
* This function inserts tag_map record which should be filled up the corresponding value
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_insert_record_tag_map(const char *media_id, int tag_id);
+mb_svc_insert_record_tag_map(MediaSvcHandle *mb_svc_handle, const char *media_id, int tag_id);
/**
* @fn int mb_svc_load_record_tag(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
mb_svc_load_record_tagmap(sqlite3_stmt* stmt, mb_svc_tag_record_s * record);
/**
-* @fn int mb_svc_update_thumb_path_by_id(const char *media_id, const char* thumb_path);
+* @fn int mb_svc_update_thumb_path_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* thumb_path);
* This function updates thumb path for media record
*
* @return This function returns 0 on success, and -1 on failure.
*/
-int mb_svc_update_thumb_path_by_id(const char *media_id, const char* thumb_path);
+int mb_svc_update_thumb_path_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char* thumb_path);
/**
-* @fn int mb_svc_delete_record_media(const char *folder_id, char* display_name);
+* @fn int mb_svc_delete_record_media(MediaSvcHandle *mb_svc_handle, const char *folder_id, char* display_name);
* This function deletes media record
*
* @return This function returns 0 on success, and -1 on failure.
int
-mb_svc_delete_record_media(const char *folder_id, char* display_name);
+mb_svc_delete_record_media(MediaSvcHandle *mb_svc_handle, const char *folder_id, char* display_name);
/**
-* @fn int mb_svc_delete_bookmark_meta_by_media_id(const char *media_id , mb_svc_media_type_t file_type);
+* @fn int mb_svc_delete_bookmark_meta_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id , mb_svc_media_type_t file_type);
* This function deletes media related record in other tables
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_delete_bookmark_meta_by_media_id(const char *media_id , minfo_file_type content_type);
+mb_svc_delete_bookmark_meta_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id , minfo_file_type content_type);
/**
-* @fn int mb_svc_update_favorite_by_id(const char *media_id, int favorite);
+* @fn int mb_svc_update_favorite_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite);
* This function updates favorite field in media record
*
* @return This function returns 0 on success, and -1 on failure.
int
-mb_svc_update_favorite_by_id(const char *media_id, int favorite);
+mb_svc_update_favorite_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite);
/**
-* @fn int mb_svc_delete_record_image_meta_by_id(int id);
+* @fn int mb_svc_delete_record_image_meta_by_id(MediaSvcHandle *mb_svc_handle, int id);
* This function gets folder record by path information
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_delete_record_image_meta_by_id(int id);
+mb_svc_delete_record_image_meta_by_id(MediaSvcHandle *mb_svc_handle, int id);
/**
-* @fn int mb_svc_update_date_by_id(const char *media_id, int date);
+* @fn int mb_svc_update_date_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int date);
* This function updates favorite field in media record
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_update_date_by_id(const char *media_id, int date );
+mb_svc_update_date_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int date );
/**
-* @fn int mb_svc_get_web_streaming_record_by_id(int webstreaming_id, mb_svc_web_streaming_record_s *webstreaming_record);
+* @fn int mb_svc_get_web_streaming_record_by_id(MediaSvcHandle *mb_svc_handle, int webstreaming_id, mb_svc_web_streaming_record_s *webstreaming_record);
* This function gets webstreaming record by id
*
* @return This function returns 0 on success, and -1 on failure.
*
*/
int
-mb_svc_get_web_streaming_record_by_id(int webstreaming_id,
+mb_svc_get_web_streaming_record_by_id(MediaSvcHandle *mb_svc_handle, int webstreaming_id,
mb_svc_web_streaming_record_s *webstreaming_record);
int
-mb_svc_set_media_records_as_valid(const minfo_store_type storage_type, int valid);
+mb_svc_set_media_records_as_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid);
int
-mb_svc_update_album_lock_status(const char *folder_id, int lock, minfo_store_type storage_type );
+mb_svc_update_album_lock_status(MediaSvcHandle *mb_svc_handle, const char *folder_id, int lock, minfo_store_type storage_type );
int
mb_svc_load_record_folder_name(sqlite3_stmt* stmt, char * folder_name, int max_length);
int
-mb_svc_update_record_folder_path(char* old_path, char* new_path);
+mb_svc_update_record_folder_path(MediaSvcHandle *mb_svc_handle, char* old_path, char* new_path);
int
-mb_svc_update_folder_modified_date(char* path, int date);
-
-int
-mb_svc_update_width_and_height(const char *media_id, minfo_file_type content_type, int width, int height);
+mb_svc_update_folder_modified_date(MediaSvcHandle *mb_svc_handle, char* path, int date);
int
mb_svc_set_folder_as_valid_sql_add(const char *folder_id, int valid);
int
-mb_svc_set_item_as_valid_sql_add(const char *full_path, int valid);
+mb_svc_set_item_as_valid_sql_add(MediaSvcHandle *mb_svc_handle, const char *full_path, int valid);
int
-mb_svc_set_item_as_valid();
+mb_svc_set_item_as_valid(MediaSvcHandle *mb_svc_handle);
int
mb_svc_insert_record_folder_sql(mb_svc_folder_record_s *record, char **sql);
int
mb_svc_delete_bookmark_meta_by_media_id_sql(const char *media_id, char **sql);
-int
-mb_svc_update_width_and_height_sql(const char *media_id, minfo_file_type content_type,
- int width, int height, char **sql);
#ifdef __cplusplus
}
#define _MEDIA_SVC_STRUCTURES_H_
#include <sqlite3.h>
-#include "minfo-types.h"
+#include "visual-svc-types.h"
#ifdef __cplusplus
* This structure defines the mb_svc_media_record_s.
*/
typedef struct {
- char media_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< UUID */
+ char media_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< UUID */
char path[MB_SVC_FILE_PATH_LEN_MAX+1]; /**< path */
char folder_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< folder UUID */
char display_name[MB_SVC_FILE_NAME_LEN_MAX+1]; /**< media name */
- minfo_file_type content_type; /**< media type, 1:image, 2:video*/
+ minfo_file_type content_type; /**< media type, 1:image, 2:video*/
bool rate; /**< favoriate option */
- int modified_date; /**< modified time */
+ int modified_date; /**< modified time */
char thumbnail_path[MB_SVC_FILE_PATH_LEN_MAX+1]; /**< thumbail path */
char http_url[MB_SVC_DIR_PATH_LEN_MAX +1]; /**< http url */
+ int size; /**< file size */
}mb_svc_media_record_s;
* This structure defines the mb_svc_video_meta_record_s.
*/
typedef struct {
- int _id; /**< video meta id. Prime Key */
- char media_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< media UUID */
- char album[MB_SVC_FILE_NAME_LEN_MAX+1]; /**< album */
- char artist[MB_SVC_ARRAY_LEN_MAX+1]; /**< artist */
+ int _id; /**< video meta id. Prime Key */
+ char media_uuid[MB_SVC_UUID_LEN_MAX+1]; /**< media UUID */
+ char album[MB_SVC_FILE_NAME_LEN_MAX+1]; /**< album */
+ char artist[MB_SVC_ARRAY_LEN_MAX+1]; /**< artist */
char title[MB_SVC_FILE_NAME_LEN_MAX+1]; /**< title */
+ char genre[MB_SVC_FILE_NAME_LEN_MAX+1]; /**< genre */
char description[MB_SVC_ARRAY_LEN_MAX+1]; /**< description */
char youtube_category[MB_SVC_ARRAY_LEN_MAX+1]; /**< youtube_category */
- int last_played_time; /**< last palyed time*/
- int duration; /**< duration */
- double longitude; /**< longitude */
- double latitude; /**< latitude */
+ int last_played_time; /**< last palyed time*/
+ int duration; /**< duration */
+ double longitude; /**< longitude */
+ double latitude; /**< latitude */
int width; /**< width */
int height; /**< height */
int datetaken; /**< datetaken */
#define _MB_SVC_THUMB_H_
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#ifdef __cplusplus
extern "C" {
mb_svc_video_create_thumb(const char *file_fullpath, char* thumb_path_hash, size_t max_thumb_length);
/**
-* @fn int mb_svc_get_video_meta(char* file_full_path, mb_svc_video_meta_record_s *video_record);
+* @fn int mb_svc_get_video_meta(MediaSvcHandle *mb_svc_handle, char* file_full_path, mb_svc_video_meta_record_s *video_record);
* This function gets video_meta record by filefull path
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_video_meta(const char* file_full_path, mb_svc_video_meta_record_s *video_record);
+mb_svc_get_video_meta(MediaSvcHandle *mb_svc_handle, const char* file_full_path, mb_svc_video_meta_record_s *video_record);
/**
-* @fn int mb_svc_get_image_meta(char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
+* @fn int mb_svc_get_image_meta(MediaSvcHandle *mb_svc_handle, char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
* This function gets image_meta record by filefull path
*
* @return This function returns 0 on success, and -1 on failure.
*/
int
-mb_svc_get_image_meta(const char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
+mb_svc_get_image_meta(MediaSvcHandle *mb_svc_handle, const char* file_full_path, mb_svc_image_meta_record_s *image_record, bool *thumb_done);
/**
* @brief Delete thumbnail file of original file.
* @{
*/
-#include "minfo-types.h"
+#include "visual-svc-types.h"
+#include "media-svc-types.h"
#ifndef _MINFO_BOOKMARK_H_
#define _MINFO_BOOKMARK_H_
*/
Mbookmark*
-minfo_mbookmark_new(int id);
+minfo_mbookmark_new(MediaSvcHandle *mb_svc_handle, int id);
/**
* @fn void minfo_mbookmark_destroy(Mbookmark* bookmark);
* @{
*/
-#include "minfo-types.h"
+#include "visual-svc-types.h"
+#include "media-svc-types.h"
#ifndef _MINFO_CLUSTER
#define _MINFO_CLUSTER
*/
Mcluster*
-minfo_mcluster_new(const char *uuid);
+minfo_mcluster_new(MediaSvcHandle *mb_svc_handle, const char *uuid);
/**
* @fn void minfo_mcluster_destroy(Mcluster* cluster);
#ifndef _MINFO_ITEM_H_
#define _MINFO_ITEM_H_
-#include "minfo-types.h"
+#include "visual-svc-types.h"
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#define MINFO_TYPE_MITEM (0x55550)
#define MINFO_MITEM(obj) ((Mitem*)(obj))
*
*
*/
-__attribute__((deprecated))
-Mitem*
-minfo_mitem_new(const char *uuid);
Mitem*
-minfo_media_item_new (const char *uuid, mb_svc_media_record_s *p_md_record);
+minfo_media_item_new (MediaSvcHandle *mb_svc_handle, const char *uuid, mb_svc_media_record_s *p_md_record);
/**
* @{
*/
-#include "minfo-types.h"
+#include "visual-svc-types.h"
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#ifndef _MINFO_META_H_
#define _MINFO_META_H_
#define IS_MINFO_MVIDEO(obj) (MINFO_TYPE_MVIDEO == MINFO_MVIDEO_GET_TYPE(MINFO_MVIDEO(obj)))
Mvideo*
-minfo_mvideo_new(const char *id);
+minfo_mvideo_new(MediaSvcHandle *mb_svc_handle, const char *id);
void
minfo_mvideo_destroy(Mvideo* video);
#define IS_MINFO_MIMAGE(obj) (MINFO_TYPE_MIMAGE == MINFO_MIMAGE_GET_TYPE(MINFO_MIMAGE(obj)))
Mimage*
-minfo_mimage_new(const char *id);
+minfo_mimage_new(MediaSvcHandle *mb_svc_handle, const char *id);
void
minfo_mimage_destroy(Mimage* image);
*/
Mmeta*
-minfo_mmeta_new(const char *media_uuid, mb_svc_media_record_s *p_md_record);
+minfo_mmeta_new(MediaSvcHandle *mb_svc_handle, const char *media_uuid, mb_svc_media_record_s *p_md_record);
/**
* @fn void minfo_mmeta_destroy(Mmeta* item);
#ifndef _MINFO_TAG_H_
#define _MINFO_TAG_H_
-#include "minfo-types.h"
+#include "visual-svc-types.h"
#include "media-svc-structures.h"
+#include "media-svc-types.h"
#define MINFO_TYPE_MTAG (0x55555)
#define MINFO_MTAG(obj) ((Mtag*)(obj))
*/
Mtag*
-minfo_media_tag_new (int id, mb_svc_tag_record_s *p_tag_record);
+minfo_media_tag_new (MediaSvcHandle *mb_svc_handle, int id, mb_svc_tag_record_s *p_tag_record);
/**
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines synchronize apis for phone explorer.
+ *
+ * @file visual-svc-debug.h
+ * @author Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version 1.0
+ * @brief This file defines in-house apis for media service.
+ */
+
+
+ /**
+ * @ingroup MEDIA_SVC
+ * @defgroup VISUAL_SVC_DEBUG in-house media service API
+ * @{
+ */
+
+
+
+#ifndef _VISUAL_SVC_DEBUG_H_
+#define _VISUAL_SVC_DEBUG_H_
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "Visual-SVC"
+
+#ifndef DEBUG_PREFIX
+#define DEBUG_PREFIX "Visual-SVC"
+#endif
+
+//#define MB_SVC_LOG_FILE "/opt/mb-svc.log"
+
+#define MB_DEBUG
+
+#ifdef MB_DEBUG
+
+
+#ifndef LOG_TAG
+
+
+#ifdef MB_SVC_LOG_FILE
+#define pb_svc_debug(fmt, arg...) \
+ { \
+ FILE *fp; \
+ fp = fopen(MB_SVC_LOG_FILE, "a"); \
+ fprintf(fp, "[%s] ", DEBUG_PREFIX); \
+ fprintf(fp, fmt, ##arg); \
+ fclose(fp); \
+ fprintf(stderr, "[%s] ", DEBUG_PREFIX); \
+ fprintf(stderr, fmt, ##arg); \
+ }
+
+#else /*MB_SVC_LOG_FILE*/
+#define mb_svc_debug(fmt, arg...) \
+{ \
+ fprintf(stderr, "[%s] ", DEBUG_PREFIX); \
+ fprintf(stderr, fmt, ##arg); \
+}
+#endif /*MB_SVC_LOG_FILE*/
+
+
+#else /*LOG_TAG*/
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <pthread.h>
+static pid_t gettid(void)
+{
+ return syscall(__NR_gettid);
+}
+
+#define mb_svc_debug(fmt, arg...) LOGD("[%d] [%s : %d] " fmt "\n", gettid(), __FUNCTION__, __LINE__, ##arg)
+
+
+
+#endif /*LOG_TAG*/
+
+#else /*MB_DEBUG*/
+
+#define mb_svc_debug(fmt, arg...)
+
+#endif /*MB_DEBUG*/
+
+#endif /*_VISUAL_SVC_DEBUG_H_*/
+
+/**
+* @}
+*/
+
+
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file defines the error code of media service
+ *
+ * @file media-svc-util.h
+ * @author Hyunjun Ko <zzoon.ko@samsung.com>
+ * @version 1.0
+ * @brief This file defines the error code of media service
+ */
+
+/**
+* @ingroup MEDIA-SVC
+* @defgroup MEDIA_SVC_UTIL error code table
+* @{
+*/
+
+
+#ifndef _MEDIA_SVC_UTIL_H_
+#define _MEDIA_SVC_UTIL_H_
+
+#include <glib.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MB_SVC_PATH_PHONE "/opt/media" /**< File path prefix of files stored in phone */
+#define MB_SVC_PATH_MMC "/opt/storage/sdcard" /**< File path prefix of files stored in mmc card */
+
+
+/**
+* @fn int _mb_svc_get_file_display_name (const char* file_path, char* file_name);
+* This function gets file name by file full path
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] file_path file full path
+* @param[out] file_name file name
+* @exception None.
+* @remark
+*
+*
+*/
+
+bool
+_mb_svc_get_file_display_name (const char* file_path, char* file_name);
+
+
+ /**
+ * @fn int _mb_svc_get_file_parent_path(const char* file_path, char* parent_path);
+ * This function gets file parent path
+ *
+ * @return This function returns 0 on success, and -1 on failure.
+ * @param[in] file_path file full path
+ * @param[out] parent_path file parent path
+ * @exception None.
+ * @remark
+ *
+ *
+ */
+
+bool
+_mb_svc_get_file_parent_path(const char* file_path, char* parent_path);
+
+/**
+* @fn int _mb_svc_get_dir_display_name (const char* dir_path, char* dir_name);
+* This function gets directory name
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] dir_path directory path
+* @param[out] dir_name directory name
+* @exception None.
+* @remark
+*
+*
+*/
+bool
+_mb_svc_get_dir_display_name (const char* dir_path, char* dir_name);
+
+/**
+* @fn int _mb_svc_get_dir_parent_path(const char* dir_path, char* parent_path);
+* This function gets directory parent path
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] dir_path directory path
+* @param[out] parent_path directory parent path
+* @exception None.
+* @remark
+*
+*
+*/
+bool
+_mb_svc_get_dir_parent_path(const char* dir_path, char* parent_path);
+
+/**
+* @fn int _mb_svc_get_file_dir_modified_date(const char* full_path);
+* This function gets file modified date
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] full_path file full path
+* @exception None.
+* @remark
+*
+*
+*/
+
+int
+_mb_svc_get_file_dir_modified_date(const char* full_path);
+
+/**
+* @fn int _mb_svc_get_store_type_by_full(const char* full_path);
+* This function gets file store type
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] full_path file full path
+* @exception None.
+* @remark
+*
+*
+*/
+int
+_mb_svc_get_store_type_by_full(const char* full_path);
+
+/**
+* @fn int _mb_svc_get_rel_path_by_full(const char* full_path, char* path);
+* This function gets file relative path
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] full_path file full path
+* @param[out] path file relative path
+* @exception None.
+* @remark
+*
+*
+*/
+int
+_mb_svc_get_rel_path_by_full(const char* full_path, char* path);
+
+/**
+* @fn int _mb_svc_get_file_ext (const char* file_path, char* file_ext);
+* This function gets file extension
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] file_path file full path
+* @param[out] file_ext pointer to file extention
+* @exception None.
+* @remark
+*
+*
+*/
+bool
+_mb_svc_get_file_ext (const char* file_path, char* file_ext);
+
+/**
+* @fn int _mb_svc_glist_free(GList** glist, bool is_free_element);
+* This function frees glist and maybe free each items in glist
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] glist the glist to be freed
+* @param[in] is_free_element falg to declare if to free items in glist
+* @exception None.
+* @remark
+*
+*
+*/
+
+bool
+_mb_svc_glist_free(GList** glist, bool is_free_element);
+
+/**
+* @fn int _mb_svc_get_file_type(char* file_full_path);
+* This function gets file type
+*
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] file_full_path file full path
+ * @exception None.
+* @remark
+*
+*
+*/
+
+int
+_mb_svc_get_file_type(const char* file_full_path);
+
+bool
+_mb_svc_get_path_by_full(const char* full_path, char* path, int max_length);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /*_MEDIA_SVC_UTIL_H_*/
+
+/**
+* @}
+*/
+
*
*/
-#include "media-svc-debug.h"
+#include "visual-svc-debug.h"
#include "media-img-codec-common.h"
#include "IfegDecodeAGIF.h"
#include <string.h>
#if defined(_PERFORMANCE_CHECK_) && defined(_USE_LOG_FILE_)
-#include "media-info-debug.h"
+#include "media-svc-debug.h"
#include <time.h>
#include <sys/time.h>
#endif
-#include "media-svc-debug.h"
+#include "visual-svc-debug.h"
#include "media-img-codec-common.h"
#include "media-img-codec-parser.h"
*
*/
-#include "media-svc-debug.h"
+#include "visual-svc-debug.h"
#include "media-img-codec.h"
#include <string.h>
* limitations under the License.
*
*/
-#include "media-info-debug.h"
-#include "media-svc-api.h"
-#include "media-svc-thumb.h"
-#include "media-svc-db-util.h"
-#include "media-svc-debug.h"
-#include "media-svc-util.h"
-#include "media-svc-db.h"
-#include "media-info-util.h"
-#include "minfo-types.h"
-#include "media-svc-error.h"
#include <glib.h>
#include <glib-object.h>
#include <drm-service.h>
#include <dirent.h>
#include <sys/types.h>
+#include <string.h>
+#include "media-svc-debug.h"
+#include "media-svc-api.h"
+#include "media-svc-thumb.h"
+#include "media-svc-db-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-util.h"
+#include "media-svc-db.h"
+#include "media-svc-util.h"
+#include "media-svc-types.h"
+#include "visual-svc-error.h"
#ifdef _PERFORMANCE_CHECK_
double g_insertdb = 0;
#endif
static __thread GList *g_insert_sql_list = NULL;
+static __thread GList *g_move_sql_list = NULL;
const char *mb_svc_media_order[5] = {
- "uuid ASC",
+ "visual_uuid ASC",
"display_name COLLATE NOCASE DESC",
"display_name COLLATE NOCASE ASC",
"modified_date DESC",
};
const char *mb_svc_folder_order[5] = {
- "uuid ASC",
+ "folder_uuid ASC",
"folder_name COLLATE NOCASE DESC",
"folder_name COLLATE NOCASE ASC",
"modified_date DESC",
#define MB_SVC_DB_DEFAULT_GET_ALL_RECORDS -1 /* get all records, not limit on start position */
#define MB_SVC_DB_GET_UNTIL_LAST_RECORD -1 /* get all records until last item */
-static int __mb_svc_folder_by_path_iter_start(char *parent_path, mb_svc_iterator_s *mb_svc_iterator);
-static int __mb_svc_get_folder_record_by_path_info(const char *uri, char *display_name, minfo_store_type storage_type, mb_svc_folder_record_s *record);
-static int __mb_svc_get_folder_record_by_full_path(const char *folder_full_path, mb_svc_folder_record_s *folder_record);
-static int __mb_svc_get_media_id_by_fid_name(const char *folder_id, char *display_name, char *media_id);
-static int __mb_svc_get_media_list_by_folder_id(const char *folder_id, GList **p_record_list, int valid);
-static int __mb_svc_delete_media_records_list(GList *p_record_list);
-static int __mb_svc_delete_tag_by_id(const int tag_id);
-static int __mb_svc_update_tag(int tag_id, const char *tag_name);
-static int __mb_svc_update_tagmap(int src_tag_id, int dst_tag_id);
-static int __mb_svc_update_tagmap_by_media_id(const char *media_id, int src_tag_id, int dst_tag_id);
-static int __mb_svc_get_media_cnt_by_tagid(int tag_id);
-
-int mb_svc_insert_items()
+static int __mb_svc_folder_by_path_iter_start(MediaSvcHandle *mb_svc_handle, char *parent_path, mb_svc_iterator_s *mb_svc_iterator);
+static int __mb_svc_get_folder_record_by_path_info(MediaSvcHandle *mb_svc_handle, const char *uri, char *display_name, minfo_store_type storage_type, mb_svc_folder_record_s *record);
+static int __mb_svc_get_folder_record_by_full_path(MediaSvcHandle *mb_svc_handle, const char *folder_full_path, mb_svc_folder_record_s *folder_record);
+static int __mb_svc_get_media_id_by_fid_name(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *display_name, char *media_id);
+static int __mb_svc_get_media_list_by_folder_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, GList **p_record_list, int valid);
+static int __mb_svc_delete_media_records_list(MediaSvcHandle *mb_svc_handle, GList *p_record_list);
+static int __mb_svc_delete_tag_by_id(MediaSvcHandle *mb_svc_handle, const int tag_id);
+static int __mb_svc_update_tag(MediaSvcHandle *mb_svc_handle, int tag_id, const char *tag_name);
+static int __mb_svc_update_tagmap(MediaSvcHandle *mb_svc_handle, int src_tag_id, int dst_tag_id);
+static int __mb_svc_update_tagmap_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int src_tag_id, int dst_tag_id);
+static int __mb_svc_get_media_cnt_by_tagid(MediaSvcHandle *mb_svc_handle, int tag_id);
+
+int mb_svc_insert_items(MediaSvcHandle *mb_svc_handle)
{
mb_svc_debug("");
int i = 0;
for (i = 0; i < length; i++) {
char *sql = (char*)g_list_nth_data(g_insert_sql_list, i);
- mb_svc_query_sql(sql);
+ mb_svc_query_sql(mb_svc_handle, sql);
}
mb_svc_sql_list_release(&g_insert_sql_list);
return 0;
}
+int mb_svc_move_items(MediaSvcHandle *mb_svc_handle)
+{
+ mb_svc_debug("");
+ int i = 0;
+ int length = g_list_length(g_move_sql_list);
+
+ for (i = 0; i < length; i++) {
+ char *sql = (char*)g_list_nth_data(g_move_sql_list, i);
+ mb_svc_query_sql(mb_svc_handle, sql);
+ }
+
+ mb_svc_sql_list_release(&g_move_sql_list);
+
+ return 0;
+}
int
-mb_svc_insert_file_batch(const char *file_full_path, minfo_file_type content_type)
+mb_svc_insert_file_batch(MediaSvcHandle *mb_svc_handle, const char *file_full_path, minfo_file_type content_type)
{
char dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
/* 2. insert or update folder table */
- ret = __mb_svc_get_folder_record_by_full_path(dir_path, &folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, dir_path, &folder_record);
if (ret < 0) {
mb_svc_debug("no any record in %s", dir_path);
store_type = _mb_svc_get_store_type_by_full(file_full_path);
("no record in %s, ready insert the folder record into db\n",
dir_path);
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_record_folder failed (%d)\n", ret);
media_record.modified_date);
bool thumb_done = FALSE;
- ret = mb_svc_get_image_meta(file_full_path, &image_record, &thumb_done);
+ ret = mb_svc_get_image_meta(mb_svc_handle, file_full_path, &image_record, &thumb_done);
if (ret < 0) {
mb_svc_debug("mb_svc_get_image_meta failed\n");
video_record.latitude = 0.0;
video_record.longitude = 0.0;
- ret = mb_svc_get_video_meta(file_full_path, &video_record);
+ ret = mb_svc_get_video_meta(mb_svc_handle, file_full_path, &video_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_video_meta failed\n");
return ret;
}
int
-mb_svc_insert_file(const char *file_full_path, minfo_file_type content_type)
+mb_svc_insert_file(MediaSvcHandle *mb_svc_handle, const char *file_full_path, minfo_file_type content_type)
{
char dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
char dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
/* 2. insert or update folder table */
- ret = __mb_svc_get_folder_record_by_full_path(dir_path, &folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, dir_path, &folder_record);
if (ret < 0) {
mb_svc_debug("no any record in %s", dir_path);
store_type = _mb_svc_get_store_type_by_full(file_full_path);
#endif
bool thumb_done = FALSE;
- ret = mb_svc_get_image_meta(file_full_path, &image_record, &thumb_done);
+ ret = mb_svc_get_image_meta(mb_svc_handle, file_full_path, &image_record, &thumb_done);
#ifdef _PERFORMANCE_CHECK_
end = mediainfo_get_debug_time();
return ret;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
mb_svc_sql_list_release(&insert_sql_list);
video_record.latitude = 0.0;
video_record.longitude = 0.0;
- ret = mb_svc_get_video_meta(file_full_path, &video_record);
+ ret = mb_svc_get_video_meta(mb_svc_handle, file_full_path, &video_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_video_meta failed\n");
mb_svc_sql_list_release(&insert_sql_list);
return ret;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
mb_svc_sql_list_release(&insert_sql_list);
for (i = 0; i < length; i++) {
char *sql = (char *)g_list_nth_data(insert_sql_list, i);
- ret = mb_svc_query_sql(sql);
+ ret = mb_svc_query_sql(mb_svc_handle, sql);
if (ret < 0) {
mb_svc_debug
("mb_svc_query_sql failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&insert_sql_list);
return ret;
}
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&insert_sql_list);
return ret;
}
}
-int mb_svc_delete_file(const char *file_full_path)
+int mb_svc_delete_file(MediaSvcHandle *mb_svc_handle, const char *file_full_path)
{
char dir_full_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
char file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
mb_svc_debug("Delete start : %s", file_full_path);
_mb_svc_get_file_parent_path(file_full_path, dir_full_path);
- ret = __mb_svc_get_folder_record_by_full_path(dir_full_path, &folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, dir_full_path, &folder_record);
if (ret < 0) {
mb_svc_debug(" file directory %s doesn't exist ",
dir_full_path);
_mb_svc_get_file_display_name(file_full_path, file_display_name);
/* if the folder has at least one file */
ret =
- mb_svc_get_media_record_by_full_path(file_full_path, &media_record);
+ mb_svc_get_media_record_by_full_path(mb_svc_handle, file_full_path, &media_record);
if (ret < 0) {
mb_svc_debug
}
/* delete the matched file info in media table */
- ret = mb_svc_delete_record_media_by_id(media_record.media_uuid);
+ ret = mb_svc_delete_record_media_by_id(mb_svc_handle, media_record.media_uuid);
if (ret < 0) {
mb_svc_debug
("mb_svc_delete_record_media fail:folder id is %s,file name is %s ",
media_record.media_uuid, media_record.content_type, media_record.path);
#ifdef DELETE_FOLDER_RECORD_IF_NO_FILE_IN /* the media file is deleted succeed, then verify if the folder has no left files */
- media_record_cnt = mb_svc_get_folder_content_count_by_folder_id(media_record.folder_uuid); /* after delete the media file,get the left media file count in the specified folder */
+ media_record_cnt = mb_svc_get_folder_content_count_by_folder_id(mb_svc_handle, media_record.folder_uuid); /* after delete the media file,get the left media file count in the specified folder */
mb_svc_debug("media_record_cnt after delete the media file is %d\n",
media_record_cnt);
if (media_record_cnt == 0) { /* the folder has no left files, so delete the folder record */
- ret = mb_svc_delete_record_folder_by_id(folder_record.uuid);
+ ret = mb_svc_delete_record_folder_by_id(mb_svc_handle, folder_record.uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_delete_record_older fail:%s\n",
folder_record.uuid);
if (folder_record.modified_date < folder_modified_date) {
mb_svc_debug("directory %s is modified", dir_full_path);
folder_record.modified_date = folder_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
}
/* delete file info in image_meta table & (video_meta table and bookmark table if it's video file) */
ret =
- mb_svc_delete_bookmark_meta_by_media_id(media_record.media_uuid,
+ mb_svc_delete_bookmark_meta_by_media_id(mb_svc_handle, media_record.media_uuid,
media_record.content_type);
if (ret < 0) {
mb_svc_debug
}
int
-mb_svc_rename_file(const char *old_file_full_path,
- const char *new_file_full_path, minfo_file_type content_type,
- char *thumb_path)
+mb_svc_rename_file(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_full_path,
+ const char *new_file_full_path,
+ minfo_file_type content_type,
+ char *thumb_path)
{
mb_svc_debug("");
old_file_display_name);
_mb_svc_get_file_parent_path(old_file_full_path, old_dir_path);
- ret = __mb_svc_get_folder_record_by_full_path(old_dir_path, &folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, old_dir_path, &folder_record);
if (ret < 0) {
mb_svc_debug(" file directory %s doesn't exist ", old_dir_path);
return MB_SVC_ERROR_DIR_NOT_EXSITED;
}
ret =
- mb_svc_get_media_record_by_fid_name(folder_record.uuid,
+ mb_svc_get_media_record_by_fid_name(mb_svc_handle, folder_record.uuid,
old_file_display_name,
&media_record);
if (ret >= 0) {
strncpy(media_record.thumbnail_path, thumb_path,
MB_SVC_FILE_PATH_LEN_MAX + 1);
- mb_svc_update_record_media(&media_record);
+ mb_svc_update_record_media(mb_svc_handle, &media_record);
}
folder_modified_date = _mb_svc_get_file_dir_modified_date(old_dir_path);
if (folder_record.modified_date < folder_modified_date) {
mb_svc_debug("directory %s is modified", old_dir_path);
folder_record.modified_date = folder_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
return 0;
}
int
-mb_svc_move_file(const char *old_file_full_path, const char *new_file_full_path,
- minfo_file_type content_type, char *thumb_path)
+mb_svc_move_file(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_full_path,
+ const char *new_file_full_path,
+ minfo_file_type content_type,
+ char *thumb_path)
{
mb_svc_debug("");
char *media_sql = NULL;
int insert_new_folder = 0;
- _mb_svc_get_file_display_name(old_file_full_path,
- old_file_display_name);
+ _mb_svc_get_file_display_name(old_file_full_path, old_file_display_name);
_mb_svc_get_file_parent_path(old_file_full_path, old_dir_path);
- _mb_svc_get_file_display_name(new_file_full_path,
- new_file_display_name);
+ _mb_svc_get_file_display_name(new_file_full_path, new_file_display_name);
_mb_svc_get_file_parent_path(new_file_full_path, new_dir_path);
- ret = __mb_svc_get_folder_record_by_full_path(new_dir_path, &dst_folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, new_dir_path, &dst_folder_record);
if (ret < 0) {
mb_svc_debug("Directory %s is NOT in DB", new_dir_path);
mb_svc_debug("Now making new dir %s", new_dir_path);
int folder_modified_date = 0;
store_type = _mb_svc_get_store_type_by_full(new_file_full_path);
-
+
if (store_type == MB_SVC_ERROR_INTERNAL) {
mb_svc_debug("Failed to get storage type : %s",
new_file_full_path);
insert_new_folder = 1;
}
- ret = mb_svc_get_media_record_by_full_path(old_file_full_path, &media_record);
+ ret = mb_svc_get_media_record_by_full_path(mb_svc_handle, old_file_full_path, &media_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_record_by_full_path fails : %d", ret);
return ret;
/* verify if the old folder has no files left */
src_clus_cont_cnt =
- mb_svc_get_folder_content_count_by_folder_id(src_cluster_uuid);
+ mb_svc_get_folder_content_count_by_folder_id(mb_svc_handle, src_cluster_uuid);
if (src_clus_cont_cnt == 1) {
} else { /* update modified date */
src_clus_modified_date =
_mb_svc_get_file_dir_modified_date(old_dir_path);
- mb_svc_get_folder_record_by_id(src_cluster_uuid, &src_folder_record);
+ mb_svc_get_folder_record_by_id(mb_svc_handle, src_cluster_uuid, &src_folder_record);
mb_svc_debug("src cluster modified_date is %d\n",
src_clus_modified_date);
if (src_folder_record.modified_date < src_clus_modified_date) {
}
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
for (i = 0; i < length; i++) {
char *sql = (char *)g_list_nth_data(move_sql_list, i);
- ret = mb_svc_query_sql(sql);
+ ret = mb_svc_query_sql(mb_svc_handle, sql);
if (ret < 0) {
mb_svc_debug
("mb_svc_query_sql failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&move_sql_list);
return ret;
}
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
+
+ return ret;
+}
+
+int
+mb_svc_move_file_batch(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_full_path,
+ const char *new_file_full_path,
+ minfo_file_type content_type,
+ char *thumb_path)
+{
+ mb_svc_debug("");
+
+ int ret = 0;
+
+ if (old_file_full_path == NULL || new_file_full_path == NULL
+ || thumb_path == NULL) {
+ mb_svc_debug
+ ("old_file_full_path==NULL || new_file_full_path==NULL || thumb_path == NULL\n");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+ mb_svc_debug("old file_full_path is %s, new file full path is %s\n",
+ old_file_full_path, new_file_full_path);
+
+ char old_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+ char new_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+ char old_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+ char new_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+ mb_svc_folder_record_s src_folder_record = {"",};
+ mb_svc_folder_record_s dst_folder_record = {"",};
+ mb_svc_media_record_s media_record = {"",};
+ int src_clus_cont_cnt = 0;
+ int src_clus_modified_date = 0;
+ int dst_clus_modified_date = 0;
+ char src_cluster_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+ char *update_old_folder_sql = NULL;
+ char *update_new_folder_sql = NULL;
+ char *delete_folder_sql = NULL;
+ char *media_sql = NULL;
+ int insert_new_folder = 0;
+
+ _mb_svc_get_file_display_name(old_file_full_path,
+ old_file_display_name);
+ _mb_svc_get_file_parent_path(old_file_full_path, old_dir_path);
+
+ _mb_svc_get_file_display_name(new_file_full_path,
+ new_file_display_name);
+ _mb_svc_get_file_parent_path(new_file_full_path, new_dir_path);
+
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, new_dir_path, &dst_folder_record);
+ if (ret < 0) {
+ mb_svc_debug("Directory %s is NOT in DB", new_dir_path);
+ mb_svc_debug("Now making new dir %s", new_dir_path);
+
+ int store_type = 0;
+ char new_dir_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+ int folder_modified_date = 0;
+
+ store_type = _mb_svc_get_store_type_by_full(new_file_full_path);
+
+ if (store_type == MB_SVC_ERROR_INTERNAL) {
+ mb_svc_debug("Failed to get storage type : %s",
+ new_file_full_path);
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ _mb_svc_get_dir_display_name(new_dir_path, new_dir_display_name);
+ mb_svc_debug("dir_display_name is %s\n", new_dir_display_name);
+
+ folder_modified_date = _mb_svc_get_file_dir_modified_date(new_dir_path);
+
+ dst_folder_record.modified_date = folder_modified_date;
+ dst_folder_record.storage_type = store_type;
+ strncpy(dst_folder_record.uri, new_dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+ strncpy(dst_folder_record.display_name, new_dir_display_name,
+ MB_SVC_FILE_NAME_LEN_MAX + 1);
+ strncpy(dst_folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+ strncpy(dst_folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
+ dst_folder_record.lock_status = 0;
+
+ insert_new_folder = 1;
+ }
+
+ ret = mb_svc_get_media_record_by_full_path(mb_svc_handle, old_file_full_path, &media_record);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_get_media_record_by_full_path fails : %d", ret);
+ return ret;
+ }
+
+ strncpy(src_cluster_uuid, media_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+ strncpy(media_record.folder_uuid, dst_folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+ strncpy(media_record.path, new_file_full_path, sizeof(media_record.path));
+ strncpy(media_record.display_name, new_file_display_name, sizeof(media_record.display_name));
+ media_record.modified_date = _mb_svc_get_file_dir_modified_date(new_file_full_path);
+
+ _mb_svc_thumb_move(old_file_full_path, new_file_full_path, thumb_path);
+
+ strncpy(media_record.thumbnail_path, thumb_path, sizeof(media_record.thumbnail_path));
+
+ /* verify if the old folder has no files left */
+ src_clus_cont_cnt =
+ mb_svc_get_folder_content_count_by_folder_id(mb_svc_handle, src_cluster_uuid);
+
+ if (src_clus_cont_cnt == 1) {
+
+ ret = mb_svc_delete_record_folder_sql(src_cluster_uuid, &delete_folder_sql);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+ ret);
+ return ret;
+ }
+ mb_svc_sql_list_add(&g_move_sql_list, &delete_folder_sql);
+ } else { /* update modified date */
+ src_clus_modified_date =
+ _mb_svc_get_file_dir_modified_date(old_dir_path);
+ mb_svc_get_folder_record_by_id(mb_svc_handle, src_cluster_uuid, &src_folder_record);
+ mb_svc_debug("src cluster modified_date is %d\n",
+ src_clus_modified_date);
+ if (src_folder_record.modified_date < src_clus_modified_date) {
+ src_folder_record.modified_date = src_clus_modified_date;
+
+ ret = mb_svc_update_record_folder_sql(&src_folder_record, &update_old_folder_sql);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+ ret);
+ return ret;
+ }
+
+ mb_svc_sql_list_add(&g_move_sql_list, &update_old_folder_sql);
+ }
+ }
+
+ if (insert_new_folder == 1) {
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &dst_folder_record);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_insert_record_folder_sql fails : %d", ret);
+ return ret;
+ }
+
+ strncpy(media_record.folder_uuid, dst_folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
+
+ } else {
+ dst_clus_modified_date =
+ _mb_svc_get_file_dir_modified_date(new_dir_path);
+
+ mb_svc_debug("dst cluster modified_date is %d\n",
+ dst_clus_modified_date);
+ if (dst_folder_record.modified_date < dst_clus_modified_date) {
+ dst_folder_record.modified_date = dst_clus_modified_date;
+
+ ret = mb_svc_update_record_folder_sql(&dst_folder_record, &update_new_folder_sql);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_delete_record_folder_sql fail:%d\n",
+ ret);
+ return ret;
+ }
+
+ mb_svc_sql_list_add(&g_move_sql_list, &update_new_folder_sql);
+ }
+ }
+
+ ret = mb_svc_update_record_media_sql(&media_record, &media_sql);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_update_record_media fails : %d", ret);
return ret;
}
+ mb_svc_sql_list_add(&g_move_sql_list, &media_sql);
+
return ret;
}
-int mb_svc_move_file_by_id(const char *src_media_id, const char *dst_cluster_id)
+int mb_svc_move_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id)
{
mb_svc_debug("");
mb_svc_debug("minfo_mv_media#src_media_id: %s", src_media_id);
mb_svc_debug("minfo_mv_media#dst_cluster_id: %s", dst_cluster_id);
- ret = mb_svc_get_media_record_by_id(src_media_id, &media_record);
+ ret = mb_svc_get_media_record_by_id(mb_svc_handle, src_media_id, &media_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
return ret;
strncpy(src_cluster_uuid, media_record.folder_uuid, MB_SVC_UUID_LEN_MAX + 1);
- mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, dst_cluster_id, dst_clus_path,
sizeof(dst_clus_path));
snprintf(dst_file_full_path, MB_SVC_FILE_PATH_LEN_MAX + 1, "%s/%s",
dst_clus_path, media_record.display_name);
//media_record.folder_id = dst_cluster_id;
strncpy(media_record.folder_uuid, dst_cluster_id, MB_SVC_UUID_LEN_MAX + 1);
- mb_svc_update_record_media(&media_record);
+ mb_svc_update_record_media(mb_svc_handle, &media_record);
/* verify if the old folder has no files left */
src_clus_cont_cnt =
- mb_svc_get_folder_content_count_by_folder_id(src_cluster_uuid);
+ mb_svc_get_folder_content_count_by_folder_id(mb_svc_handle, src_cluster_uuid);
if (src_clus_cont_cnt == 0) {
- ret = mb_svc_delete_record_folder_by_id(src_cluster_uuid);
+ ret = mb_svc_delete_record_folder_by_id(mb_svc_handle, src_cluster_uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_delete_record_older fail:%d\n",
src_clus_cont_cnt);
return ret;
}
} else { /* update modified date */
- mb_svc_get_folder_fullpath_by_folder_id(src_cluster_uuid,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, src_cluster_uuid,
src_clus_path,
sizeof(src_clus_path));
src_clus_modified_date =
_mb_svc_get_file_dir_modified_date(src_clus_path);
- mb_svc_get_folder_record_by_id(src_cluster_uuid, &folder_record);
+ mb_svc_get_folder_record_by_id(mb_svc_handle, src_cluster_uuid, &folder_record);
mb_svc_debug("src cluster modified_date is %d\n",
src_clus_modified_date);
if (folder_record.modified_date < src_clus_modified_date) {
mb_svc_debug("src cluster directory %s is modified",
src_clus_path);
folder_record.modified_date = src_clus_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
}
- mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, dst_cluster_id, dst_clus_path,
sizeof(dst_clus_path));
dst_clus_modified_date =
_mb_svc_get_file_dir_modified_date(dst_clus_path);
- mb_svc_get_folder_record_by_id(dst_cluster_id, &folder_record);
+ mb_svc_get_folder_record_by_id(mb_svc_handle, dst_cluster_id, &folder_record);
mb_svc_debug("src cluster modified_date is %d\n",
dst_clus_modified_date);
if (folder_record.modified_date < dst_clus_modified_date) {
mb_svc_debug("src cluster directory %s is modified",
dst_clus_path);
folder_record.modified_date = dst_clus_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
return 0;
}
int
-mb_svc_copy_file(const char *old_file_full_path, const char *new_file_full_path,
- minfo_file_type content_type, char *thumb_path)
+mb_svc_copy_file(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_full_path,
+ const char *new_file_full_path,
+ minfo_file_type content_type,
+ char *thumb_path)
{
char new_file_display_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
char new_dir_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
/* 1.1. get old media record info */
ret =
- mb_svc_get_media_record_by_full_path(old_file_full_path,
+ mb_svc_get_media_record_by_full_path(mb_svc_handle, old_file_full_path,
&media_record);
if (ret < 0) {
folder_modified_date = _mb_svc_get_file_dir_modified_date(new_dir_path);
mb_svc_debug("folder_modified_date is %d\n", folder_modified_date);
- ret = __mb_svc_get_folder_record_by_full_path(new_dir_path, &folder_record);
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, new_dir_path, &folder_record);
if (ret < 0 && ret == MB_SVC_ERROR_DB_INTERNAL) {
("no record in %s, ready insert the folder record into db\n",
new_dir_path);
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug
("insert file info into folder table failed. Trying to get folder record again.\n");
memset(&folder_record, 0x00,
sizeof(mb_svc_folder_record_s));
- ret = __mb_svc_get_folder_record_by_full_path(new_dir_path,
+ ret = __mb_svc_get_folder_record_by_full_path(mb_svc_handle, new_dir_path,
&folder_record);
if (ret < 0) {
mb_svc_debug("__mb_svc_get_folder_record_by_full_path failed again.");
if (folder_record.modified_date < folder_modified_date) {
mb_svc_debug("directory %s is modified", new_dir_path);
folder_record.modified_date = folder_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
}
strncpy(media_record.thumbnail_path, thumb_path,
MB_SVC_FILE_PATH_LEN_MAX + 1);
- ret = mb_svc_insert_record_media(&media_record, store_type);
+ ret = mb_svc_insert_record_media(mb_svc_handle, &media_record, store_type);
if (ret < 0) {
if (is_new_folder == TRUE) {
ret =
- mb_svc_delete_record_folder_by_id(folder_record.uuid);
+ mb_svc_delete_record_folder_by_id(mb_svc_handle, folder_record.uuid);
if (ret < 0) {
mb_svc_debug
("mb_svc_delete_record_older fail:%s\n",
if (content_type == MINFO_ITEM_IMAGE) {
mb_svc_debug("update image record\n");
ret =
- mb_svc_get_image_record_by_media_id(old_media_uuid,
+ mb_svc_get_image_record_by_media_id(mb_svc_handle, old_media_uuid,
&image_record);
if (ret < 0) {
mb_svc_debug("get image record by media id failed\n");
strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
ret =
- mb_svc_insert_record_image_meta(&image_record, store_type);
+ mb_svc_insert_record_image_meta(mb_svc_handle, &image_record, store_type);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_record_image_meta failed\n");
} else if (content_type == MINFO_ITEM_VIDEO) {
mb_svc_debug("update video record\n");
ret =
- mb_svc_get_video_record_by_media_id(old_media_uuid,
+ mb_svc_get_video_record_by_media_id(mb_svc_handle, old_media_uuid,
&video_record);
if (ret < 0) {
mb_svc_debug("get video record by media id failed\n");
strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
ret =
- mb_svc_insert_record_video_meta(&video_record, store_type);
+ mb_svc_insert_record_video_meta(mb_svc_handle, &video_record, store_type);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_record_video_meta failed\n");
int record_cnt = 0;
ret =
- mb_svc_bookmark_iter_start(old_media_uuid,
+ mb_svc_bookmark_iter_start(mb_svc_handle, old_media_uuid,
&mb_svc_bm_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed");
strncpy(bookmark_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = mb_svc_insert_record_bookmark(&bookmark_record);
+ ret = mb_svc_insert_record_bookmark(mb_svc_handle, &bookmark_record);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_record_bookmark failed\n");
return 0;
}
-int mb_svc_copy_file_by_id(const char *src_media_id, const char *dst_cluster_id)
+int mb_svc_copy_file_by_id(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id)
{
int ret = 0;
mb_svc_media_record_s media_record = {"",};
char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
minfo_store_type store_type = MINFO_SYSTEM;
- ret = mb_svc_get_media_record_by_id(src_media_id, &media_record);
+ ret = mb_svc_get_media_record_by_id(mb_svc_handle, src_media_id, &media_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
return ret;
}
- mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, dst_cluster_id, dst_clus_path,
sizeof(dst_clus_path));
snprintf(dst_file_full_path, MB_SVC_FILE_PATH_LEN_MAX + 1, "%s/%s",
dst_clus_path, media_record.display_name);
//media_record.folder_id = dst_cluster_id;
strncpy(media_record.folder_uuid, dst_cluster_id, MB_SVC_UUID_LEN_MAX + 1);
- mb_svc_insert_record_media(&media_record, store_type);
+ mb_svc_insert_record_media(mb_svc_handle, &media_record, store_type);
if (media_record.content_type == MINFO_ITEM_IMAGE) {
mb_svc_debug("update image record\n");
ret =
- mb_svc_get_image_record_by_media_id(src_media_id,
+ mb_svc_get_image_record_by_media_id(mb_svc_handle, src_media_id,
&image_record);
if (ret < 0) {
mb_svc_debug("get image record by media id failed\n");
strncpy(image_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
ret =
- mb_svc_insert_record_image_meta(&image_record, store_type);
+ mb_svc_insert_record_image_meta(mb_svc_handle, &image_record, store_type);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_record_image_meta failed\n");
} else if (media_record.content_type == MINFO_ITEM_VIDEO) {
mb_svc_debug("update video record\n");
ret =
- mb_svc_get_video_record_by_media_id(src_media_id,
+ mb_svc_get_video_record_by_media_id(mb_svc_handle, src_media_id,
&video_record);
if (ret < 0) {
mb_svc_debug("get video record by media id failed\n");
}
strncpy(video_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
- mb_svc_insert_record_video_meta(&video_record, store_type);
+ mb_svc_insert_record_video_meta(mb_svc_handle, &video_record, store_type);
}
- mb_svc_get_folder_fullpath_by_folder_id(dst_cluster_id, dst_clus_path,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, dst_cluster_id, dst_clus_path,
sizeof(dst_clus_path));
dst_clus_modified_date =
_mb_svc_get_file_dir_modified_date(dst_clus_path);
- mb_svc_get_folder_record_by_id(dst_cluster_id, &folder_record);
+ mb_svc_get_folder_record_by_id(mb_svc_handle, dst_cluster_id, &folder_record);
mb_svc_debug("src cluster modified_date is %d\n",
dst_clus_modified_date);
if (folder_record.modified_date < dst_clus_modified_date) {
mb_svc_debug("src cluster directory %s is modified",
dst_clus_path);
folder_record.modified_date = dst_clus_modified_date;
- mb_svc_update_record_folder(&folder_record);
+ mb_svc_update_record_folder(mb_svc_handle, &folder_record);
}
ret =
return 0;
}
-int mb_svc_update_cluster_name(const char *cluster_id, const char *new_name)
+int mb_svc_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char *new_name)
{
int ret = -1;
int len = 0;
mb_svc_debug("minfo_update_cluster_name#cluster_id: %s", cluster_id);
mb_svc_debug("minfo_update_cluster_name#new_name: %s", new_name);
- ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &folder_record);
if (ret < 0) {
mb_svc_debug
("minfo_update_cluster_name: no folder record matched with the folder id\n");
}
/* Update all folder record's path, which are matched by old parent path */
- ret = mb_svc_update_record_folder_path(src_parent_path, dir_full_path);
+ ret = mb_svc_update_record_folder_path(mb_svc_handle, src_parent_path, dir_full_path);
if (ret < 0) {
mb_svc_debug("mb_svc_update_record_folder_path failed\n");
return ret;
/* Update all folder record's modified date, which are changed above */
ret =
- mb_svc_update_folder_modified_date(dir_full_path,
+ mb_svc_update_folder_modified_date(mb_svc_handle, dir_full_path,
folder_record.modified_date);
if (ret < 0) {
mb_svc_debug("mb_svc_update_folder_modified_date failed\n");
return ret;
}
- ret = mb_svc_update_record_folder(&folder_record);
+ ret = mb_svc_update_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug
("minfo_update_cluster_name: update cluster name failed\n");
filter.file_type = MINFO_ITEM_ALL;
char old_media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
- ret = __mb_svc_folder_by_path_iter_start(folder_record.uri, &mb_svc_folder_iterator);
+ ret = __mb_svc_folder_by_path_iter_start(mb_svc_handle, folder_record.uri, &mb_svc_folder_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed");
}
ret =
- mb_svc_media_iter_start_new(matched_folder_record.uuid,
+ mb_svc_media_iter_start_new(mb_svc_handle, matched_folder_record.uuid,
&filter, MINFO_CLUSTER_TYPE_ALL,
1, NULL,
&mb_svc_media_iterator);
"%s", DEFAULT_IMAGE_THUMB);
}
- ret = mb_svc_update_record_media(&media_record);
+ ret = mb_svc_update_record_media(mb_svc_handle, &media_record);
if (ret < 0) {
mb_svc_debug
("Error : mb_svc_update_record_media path : %s",
return 0;
}
+#if 0
EXPORT_API int mb_svc_initialize()
{
int err = -1;
return ret;
}
-
+#endif
/* clock_t */
long mb_svc_get_clock(void)
{
return curtime;
}
-int mb_svc_table_member_count(char *table_name)
+int mb_svc_table_member_count(MediaSvcHandle *mb_svc_handle, char *table_name)
{
char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
int rc = 0;
int count = 0;
int err = -1;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_geo_media_iter_start(const char *folder_id,
- minfo_folder_type store_filter,
- minfo_item_filter *filter,
- mb_svc_iterator_s *mb_svc_iterator,
- double min_longitude,
- double max_longitude,
- double min_latitude, double max_latitude)
+mb_svc_check_exist_by_path(MediaSvcHandle *mb_svc_handle, const char *path, const char *table_name)
+{
+ char *query = NULL;
+ int rc = 0;
+ sqlite3_stmt *stmt = NULL;
+ int count = 0;
+ int err = -1;
+
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
+ if (handle == NULL) {
+ mb_svc_debug("handle is NULL");
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ query = sqlite3_mprintf(MB_SVC_TABLE_COUNT_BY_PATH_QUERY_STRING, table_name, path);
+
+ err = sqlite3_prepare_v2(handle, query, strlen(query), &stmt, NULL);
+
+ if (SQLITE_OK != err) {
+ mb_svc_debug("prepare error [%s]\n", sqlite3_errmsg(handle));
+ mb_svc_debug("query string is %s\n", query);
+ sqlite3_free(query);
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ rc = sqlite3_step(stmt);
+ while (rc == SQLITE_ROW) {
+ count = sqlite3_column_int(stmt, 0);
+ rc = sqlite3_step(stmt);
+ }
+
+ sqlite3_finalize(stmt);
+ sqlite3_free(query);
+ mb_svc_debug("record count of table %s is %d\n", table_name, count);
+
+ if (count > 0) {
+ return MB_SVC_ERROR_NONE;
+ } else {
+ return MB_SVC_ERROR_DB_NO_RECORD;
+ }
+}
+
+int
+mb_svc_geo_media_iter_start(MediaSvcHandle *mb_svc_handle,
+ const char *folder_id,
+ minfo_folder_type store_filter,
+ minfo_item_filter *filter,
+ mb_svc_iterator_s *mb_svc_iterator,
+ double min_longitude,
+ double max_longitude,
+ double min_latitude, double max_latitude)
{
mb_svc_debug("");
char query_where[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
char tmp_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_media_iter_start_new(const char *folder_id, minfo_item_filter *filter,
- minfo_folder_type folder_type, int valid,
- GList *p_folder_id_list,
- mb_svc_iterator_s *mb_svc_iterator)
+mb_svc_media_iter_start_new(MediaSvcHandle *mb_svc_handle,
+ const char *folder_id,
+ minfo_item_filter *filter,
+ minfo_folder_type folder_type,
+ int valid,
+ GList *p_folder_id_list,
+ mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
MB_SVC_TBL_NAME_MEDIA);
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
if (valid) {
strncpy(query_where,
- " f.uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
+ " f.folder_uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
sizeof(query_where));
} else {
strncpy(query_where,
- " f.uuid = m.folder_uuid and m.valid=0 and f.valid=0 ",
+ " f.folder_uuid = m.folder_uuid and m.valid=0 and f.valid=0 ",
sizeof(query_where));
}
if (folder_id != NULL) {
int len =
snprintf(condition_str, sizeof(condition_str),
- " and folder_uuid = '%s' ", folder_id);
+ " and m.folder_uuid = '%s' ", folder_id);
if (len < 0) {
mb_svc_debug("snprintf returns failure ( %d )", len);
condition_str[0] = '\0';
}
int
-mb_svc_media_search_iter_start(minfo_search_field_t search_field,
+mb_svc_media_search_iter_start(MediaSvcHandle *mb_svc_handle,
+ minfo_search_field_t search_field,
const char *search_str,
minfo_folder_type folder_type,
minfo_item_filter filter,
snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
MB_SVC_TBL_NAME_MEDIA);
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
table_name);
strncpy(query_where,
- " f.uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
+ " f.folder_uuid = m.folder_uuid and m.valid=1 and f.valid=1 ",
sizeof(query_where));
if (filter.favorite == MINFO_MEDIA_FAV_ONLY) {
}
int
-mb_svc_get_video_record_by_media_id(const char *media_id,
- mb_svc_video_meta_record_s *
- video_meta_record)
+mb_svc_get_video_record_by_media_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ mb_svc_video_meta_record_s *
+ video_meta_record)
{
int err = -1;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
sqlite3_stmt *p_Stmt_mb = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
* condition: each video_meta record mapped to media_id one by one
*/
int
-mb_svc_get_image_record_by_media_id(const char *media_id,
- mb_svc_image_meta_record_s *
- image_meta_record)
+mb_svc_get_image_record_by_media_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ mb_svc_image_meta_record_s *
+ image_meta_record)
{
int err = -1;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
sqlite3_stmt *stmt = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_folder_fullpath_by_folder_id(const char *folder_id, char *folder_fullpath,
+mb_svc_get_folder_fullpath_by_folder_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *folder_fullpath,
int max_length)
{
int err = -1;
int ret_len = 0;
char *tmp = NULL;
- /* mb_svc_debug ("mb_svc_get_folder_fullpath_by_folder_id--enter\n"); */
-
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_media_fullpath(const char *folder_id, char *media_display_name,
+mb_svc_get_media_fullpath(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *media_display_name,
char *media_fullpath)
{
int err = -1;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
err =
- mb_svc_get_folder_fullpath_by_folder_id(folder_id, folder_fullpath,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, folder_id, folder_fullpath,
sizeof(folder_fullpath));
if (err < 0) {
mb_svc_debug("get folder fullpath error\n");
}
int
-mb_svc_folder_iter_start(minfo_cluster_filter *cluster_filter,
+mb_svc_folder_iter_start(MediaSvcHandle *mb_svc_handle, minfo_cluster_filter *cluster_filter,
mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
mb_svc_debug("mb_svc_folder_iter_start--enter\n");
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return err;
}
-static int __mb_svc_folder_by_path_iter_start(char *parent_path, mb_svc_iterator_s *mb_svc_iterator)
+static int __mb_svc_folder_by_path_iter_start(MediaSvcHandle *mb_svc_handle, char *parent_path, mb_svc_iterator_s *mb_svc_iterator)
{
mb_svc_debug("");
MB_SVC_TBL_NAME_FOLDER);
snprintf(path_like, sizeof(path_like), "%s/%%", parent_path);
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
*
* get folder content count from media table according to specified folder ID
*/
-int mb_svc_get_folder_content_count_by_folder_id(const char *folder_id)
+int mb_svc_get_folder_content_count_by_folder_id(MediaSvcHandle *mb_svc_handle, const char *folder_id)
{
char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
int rc = 0;
int count = 0;
int err = -1;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
* caller need to provide memory space for storing bookmark_record
*/
int
-mb_svc_get_bookmark_record_by_id(int record_id,
- mb_svc_bookmark_record_s *record)
+mb_svc_get_bookmark_record_by_id(MediaSvcHandle *mb_svc_handle,
+ int record_id,
+ mb_svc_bookmark_record_s *record)
{
sqlite3_stmt *stmt = NULL;
int err = -1;
char *table_name = MB_SVC_TBL_NAME_BOOKMARK;
char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
/**
* caller need to provide memory space for storing bookmark_record
*/
-int mb_svc_get_media_tag_by_id(int _id, mb_svc_tag_record_s *mtag_record)
+int mb_svc_get_media_tag_by_id(MediaSvcHandle *mb_svc_handle, int _id, mb_svc_tag_record_s *mtag_record)
{
sqlite3_stmt *stmt = NULL;
int err = -1;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_web_album_cluster_record(int sns_type, const char *name, const char *account_id, const char *album_id, mb_svc_folder_record_s *folder_record)
+mb_svc_get_web_album_cluster_record(MediaSvcHandle *mb_svc_handle,
+ int sns_type,
+ const char *name,
+ const char *account_id,
+ const char *album_id,
+ mb_svc_folder_record_s *folder_record)
{
int err = -1;
sqlite3_stmt *stmt = NULL;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
char *query_string = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_folder_list_by_web_account_id(char *web_account,
- GList **p_record_list)
+mb_svc_get_folder_list_by_web_account_id(MediaSvcHandle *mb_svc_handle,
+ char *web_account,
+ GList **p_record_list)
{
int record_cnt = 0;
mb_svc_folder_record_s *fd_record;
cluster_filter.sort_type = MINFO_CLUSTER_SORT_BY_NONE;
cluster_filter.start_pos = MB_SVC_DB_DEFAULT_GET_ALL_RECORDS;
- err = mb_svc_folder_iter_start(&cluster_filter, &mb_svc_iterator);
+ err = mb_svc_folder_iter_start(mb_svc_handle, &cluster_filter, &mb_svc_iterator);
if (err == MB_SVC_ERROR_DB_NO_RECORD) {
return err;
return 0;
}
-static int __mb_svc_get_folder_record_by_path_info(const char *uri, char *display_name,
- minfo_store_type storage_type, mb_svc_folder_record_s *record)
+static int __mb_svc_get_folder_record_by_path_info(MediaSvcHandle *mb_svc_handle,
+ const char *uri,
+ char *display_name,
+ minfo_store_type storage_type,
+ mb_svc_folder_record_s *record)
{
int err = -1;
char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-static int __mb_svc_get_folder_record_by_full_path(const char *folder_full_path,
- mb_svc_folder_record_s *folder_record)
+static int __mb_svc_get_folder_record_by_full_path(
+ MediaSvcHandle *mb_svc_handle,
+ const char *folder_full_path,
+ mb_svc_folder_record_s *folder_record)
{
minfo_store_type store_type = MINFO_SYSTEM;
int err = -1;
_mb_svc_get_dir_display_name(folder_full_path, display_name);
- err = __mb_svc_get_folder_record_by_path_info(folder_full_path, display_name, store_type, folder_record);
+ err = __mb_svc_get_folder_record_by_path_info(mb_svc_handle, folder_full_path, display_name, store_type, folder_record);
if (err < 0) {
mb_svc_debug
("Error:get folder record via uri and display name failed\n");
}
int
-mb_svc_get_folder_id_by_full_path(const char *folder_full_path, char *folder_id, int max_length)
+mb_svc_get_folder_id_by_full_path(MediaSvcHandle *mb_svc_handle, const char *folder_full_path, char *folder_id, int max_length)
{
minfo_store_type store_type = MINFO_SYSTEM;
int err = -1;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_folder_id_by_web_album_id(const char *web_album_id, char *folder_id)
+mb_svc_get_folder_id_by_web_album_id(MediaSvcHandle *mb_svc_handle, const char *web_album_id, char *folder_id)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-static int __mb_svc_get_media_id_by_fid_name(const char *folder_id, char *display_name, char *media_id)
+static int __mb_svc_get_media_id_by_fid_name(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *display_name, char *media_id)
{
int err = -1;
char *query_string = NULL;
sqlite3_stmt *stmt = NULL;
char *table_name = MB_SVC_TBL_NAME_MEDIA;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_media_record_by_fid_name(const char *folder_id, const char *display_name,
+mb_svc_get_media_record_by_fid_name(MediaSvcHandle *mb_svc_handle, const char *folder_id, const char *display_name,
mb_svc_media_record_s *m_record)
{
int err = -1;
sqlite3_stmt *stmt = NULL;
char *table_name = MB_SVC_TBL_NAME_MEDIA;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-int mb_svc_update_favorite_by_media_id(const char *media_id, int favorite)
+int mb_svc_update_favorite_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite)
{
- int err = mb_svc_update_favorite_by_id(media_id, favorite);
+ int err = mb_svc_update_favorite_by_id(mb_svc_handle, media_id, favorite);
return err;
}
int
-mb_svc_get_media_record_by_id(const char *media_id,
- mb_svc_media_record_s *media_record)
+mb_svc_get_media_record_by_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ mb_svc_media_record_s *media_record)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_MEDIA;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_folder_name_by_id(const char *folder_id, char *folder_name, int max_length)
+mb_svc_get_folder_name_by_id(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *folder_name, int max_length)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_folder_record_by_id(const char *folder_id,
- mb_svc_folder_record_s *folder_record)
+mb_svc_get_folder_record_by_id(MediaSvcHandle *mb_svc_handle,
+ const char *folder_id,
+ mb_svc_folder_record_s *folder_record)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_web_streaming_record_by_id(int webstreaming_id,
- mb_svc_web_streaming_record_s *
- webstreaming_record)
+mb_svc_get_web_streaming_record_by_id(MediaSvcHandle *mb_svc_handle,
+ int webstreaming_id,
+ mb_svc_web_streaming_record_s *
+ webstreaming_record)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_WEB_STREAMING;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
-int mb_svc_webstreaming_iter_start(mb_svc_iterator_s *mb_svc_iterator)
+int mb_svc_webstreaming_iter_start(MediaSvcHandle *mb_svc_handle, mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-static int __mb_svc_get_media_list_by_folder_id(const char *folder_id, GList **p_record_list, int valid)
+static int __mb_svc_get_media_list_by_folder_id(MediaSvcHandle *mb_svc_handle,
+ const char *folder_id,
+ GList **p_record_list,
+ int valid)
{
int record_cnt = 0;
mb_svc_media_record_s *md_record;
filter.file_type = MINFO_ITEM_IMAGE | MINFO_ITEM_VIDEO;
err =
- mb_svc_media_iter_start_new(folder_id, &filter,
+ mb_svc_media_iter_start_new(mb_svc_handle, folder_id, &filter,
MINFO_CLUSTER_TYPE_ALL, valid, NULL,
&mb_svc_iterator);
return 0;
}
-static int __mb_svc_get_invalid_media_list(const minfo_store_type storage_type, GList **p_record_list)
+static int __mb_svc_get_all_media_list(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, GList **p_record_list)
+{
+ int record_cnt = 0;
+ char *sql = NULL;
+ mb_svc_media_record_s *md_record;
+ int err = -1;
+ GList *l_record_list = NULL;
+ mb_svc_iterator_s mb_svc_iterator = { 0 };
+
+ if (p_record_list == NULL) {
+ mb_svc_debug("p_record_list is null \n");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
+ if (handle == NULL) {
+ mb_svc_debug("handle is NULL");
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ sql = sqlite3_mprintf(MB_SVC_SELECT_ALL_MEDIA_LIST_BY_STORAGE, storage_type);
+ err =
+ sqlite3_prepare_v2(handle, sql, strlen(sql), &mb_svc_iterator.stmt, NULL);
+
+ sqlite3_free(sql);
+
+ if (SQLITE_OK != err) {
+ mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ while (1) {
+ md_record =
+ (mb_svc_media_record_s *)
+ malloc(sizeof(mb_svc_media_record_s));
+ if (md_record == NULL) {
+ mb_svc_debug("Error: memory allocation failed\n");
+ mb_svc_iter_finish(&mb_svc_iterator);
+ _mb_svc_glist_free(&l_record_list, true);
+ return MB_SVC_ERROR_OUT_OF_MEMORY;
+ }
+ memset(md_record, 0x00, sizeof(mb_svc_media_record_s));
+
+ err = mb_svc_media_iter_next(&mb_svc_iterator, md_record);
+
+ if (err == MB_SVC_NO_RECORD_ANY_MORE) {
+ if (md_record)
+ free(md_record);
+ md_record = NULL;
+ break;
+ }
+
+ if (err < 0) {
+ mb_svc_debug("mb-svc iterator get next recrod failed");
+ mb_svc_iter_finish(&mb_svc_iterator);
+ if (md_record)
+ free(md_record);
+ md_record = NULL;
+ _mb_svc_glist_free(&l_record_list, true);
+ return err;
+ }
+
+ record_cnt++;
+
+ l_record_list = g_list_append(l_record_list, md_record);
+ }
+
+ mb_svc_iter_finish(&mb_svc_iterator);
+ *p_record_list = l_record_list;
+
+ if (record_cnt == 0)
+ return MB_SVC_ERROR_DB_NO_RECORD;
+ else
+ return 0;
+}
+
+static int __mb_svc_get_invalid_media_list(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, GList **p_record_list)
{
int record_cnt = 0;
char *sql = NULL;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-static int __mb_svc_delete_media_records_list(GList *p_record_list)
+static int __mb_svc_delete_media_records_list(MediaSvcHandle *mb_svc_handle, GList *p_record_list)
{
int ret = -1;
mb_svc_media_record_s *m_data = NULL;
int i = 0;
int length = g_list_length(delete_sql_list);
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
mb_svc_sql_list_release(&delete_sql_list);
for (i = 0; i < length; i++) {
char *sql = (char *)g_list_nth_data(delete_sql_list, i);
- ret = mb_svc_query_sql(sql);
+ ret = mb_svc_query_sql(mb_svc_handle, sql);
if (ret < 0) {
mb_svc_debug
("mb_svc_query_sql failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&delete_sql_list);
return ret;
}
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&delete_sql_list);
return ret;
}
int i = 0;
int length = g_list_length(delete_sql_list);
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
mb_svc_sql_list_release(&delete_sql_list);
for (i = 0; i < length; i++) {
char *sql = (char *)g_list_nth_data(delete_sql_list, i);
- ret = mb_svc_query_sql(sql);
+ ret = mb_svc_query_sql(mb_svc_handle, sql);
if (ret < 0) {
mb_svc_debug
("mb_svc_query_sql failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&delete_sql_list);
return ret;
}
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
mb_svc_sql_list_release(&delete_sql_list);
return ret;
}
return 0;
}
-int mb_svc_delete_folder(const char *folder_id, minfo_store_type storage_type)
+int mb_svc_delete_folder(MediaSvcHandle *mb_svc_handle, const char *folder_id, minfo_store_type storage_type)
{
int ret = 0;
GList *p_record_list = NULL;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = __mb_svc_get_media_list_by_folder_id(folder_id, &p_record_list, TRUE);
+ ret = __mb_svc_get_media_list_by_folder_id(mb_svc_handle, folder_id, &p_record_list, TRUE);
if (ret == MB_SVC_ERROR_DB_NO_RECORD) {
mb_svc_debug("There's no item in the folder %s", folder_id);
return ret;
}
- ret = __mb_svc_delete_media_records_list(p_record_list);
+ ret = __mb_svc_delete_media_records_list(mb_svc_handle, p_record_list);
_mb_svc_glist_free(&p_record_list, true);
if (ret < 0) {
}
DELETE_FOLDER:
- ret = mb_svc_delete_record_folder_by_id(folder_id);
+ ret = mb_svc_delete_record_folder_by_id(mb_svc_handle, folder_id);
if (ret < 0) {
mb_svc_debug
* caller need to provide the local statement--stmt
*/
int
-mb_svc_bookmark_iter_start(const char *media_id, mb_svc_iterator_s *mb_svc_iterator)
+mb_svc_bookmark_iter_start(MediaSvcHandle *mb_svc_handle, const char *media_id, mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_BOOKMARK;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
* caller need to provide the local statement--stmt
*/
int
-mb_svc_tag_iter_start(const char *tag_name, const char *media_id,
- mb_svc_iterator_s *mb_svc_iterator)
+mb_svc_tag_iter_start(MediaSvcHandle *mb_svc_handle,
+ const char *tag_name,
+ const char *media_id,
+ mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
char query_string_with_lock_status[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_tag_iter_with_filter_start(const char *tag_name, minfo_tag_filter filter,
- mb_svc_iterator_s *mb_svc_iterator)
+mb_svc_tag_iter_with_filter_start(MediaSvcHandle *mb_svc_handle,
+ const char *tag_name,
+ minfo_tag_filter filter,
+ mb_svc_iterator_s *mb_svc_iterator)
{
int err = -1;
char query_string_with_lock_status[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-static int __mb_svc_delete_tag_by_id(const int tag_id)
+static int __mb_svc_delete_tag_by_id(MediaSvcHandle *mb_svc_handle, const int tag_id)
{
int err = -1;
char *query_string = NULL;
sqlite3_mprintf(MB_SVC_TABLE_DELETE_TAG_BY_TAGID, table_name,
tag_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_delete_tagmap_by_media_id(const char *media_id)
+int mb_svc_delete_tagmap_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id)
{
int err = -1;
char *query_string = NULL;
sqlite3_mprintf(MB_SVC_TABLE_DELETE_TAG_MAP_BY_MEDIA_UUID, table_name,
media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_delete_record_tag(const char *tag_name, const char *media_id)
+int mb_svc_delete_record_tag(MediaSvcHandle *mb_svc_handle, const char *tag_name, const char *media_id)
{
int err = -1;
int tag_id = 0;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- tag_id = mb_svc_get_tagid_by_tagname(tag_name);
+ tag_id = mb_svc_get_tagid_by_tagname(mb_svc_handle, tag_name);
if (tag_id <= 0) {
mb_svc_debug("There's no tag %s in the table");
table_name, media_id, tag_id);
}
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return MB_SVC_ERROR_DB_INTERNAL;
}
- count = __mb_svc_get_media_cnt_by_tagid(tag_id);
+ count = __mb_svc_get_media_cnt_by_tagid(mb_svc_handle, tag_id);
if (count <= 0) {
- err = __mb_svc_delete_tag_by_id(tag_id);
+ err = __mb_svc_delete_tag_by_id(mb_svc_handle, tag_id);
if (err < 0) {
mb_svc_debug("__mb_svc_delete_tag_by_id : %d", tag_id);
return err;
return 0;
}
-int mb_svc_rename_record_tag(const char *src_tagname, const char *dst_tag_name)
+int mb_svc_rename_record_tag(MediaSvcHandle *mb_svc_handle, const char *src_tagname, const char *dst_tag_name)
{
int err = 0;
- int src_tag_id = mb_svc_get_tagid_by_tagname(src_tagname);
+ int src_tag_id = mb_svc_get_tagid_by_tagname(mb_svc_handle, src_tagname);
if (src_tag_id <= 0) {
mb_svc_debug("there's no tag %s ", src_tagname);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- int dst_tag_id = mb_svc_get_tagid_by_tagname(dst_tag_name);
+ int dst_tag_id = mb_svc_get_tagid_by_tagname(mb_svc_handle, dst_tag_name);
if (dst_tag_id > 0) {
- err = __mb_svc_update_tagmap(src_tag_id, dst_tag_id);
+ err = __mb_svc_update_tagmap(mb_svc_handle, src_tag_id, dst_tag_id);
} else {
- err = __mb_svc_update_tag(src_tag_id, dst_tag_name);
+ err = __mb_svc_update_tag(mb_svc_handle, src_tag_id, dst_tag_name);
}
return err;
}
int
-mb_svc_rename_record_tag_by_id(const char *media_id, const char *src_tagname,
- const char *dst_tag_name)
+mb_svc_rename_record_tag_by_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ const char *src_tagname,
+ const char *dst_tag_name)
{
int err = 0;
mb_svc_tag_record_s tag_record = { 0 };
- int src_tag_id = mb_svc_get_tagid_by_tagname(src_tagname);
+ int src_tag_id = mb_svc_get_tagid_by_tagname(mb_svc_handle, src_tagname);
if (src_tag_id <= 0) {
mb_svc_debug("there's no tag %s ", src_tagname);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- int dst_tag_id = mb_svc_get_tagid_by_tagname(dst_tag_name);
+ int dst_tag_id = mb_svc_get_tagid_by_tagname(mb_svc_handle, dst_tag_name);
if (dst_tag_id > 0) {
- err = __mb_svc_update_tagmap_by_media_id(media_id, src_tag_id, dst_tag_id);
+ err = __mb_svc_update_tagmap_by_media_id(mb_svc_handle, media_id, src_tag_id, dst_tag_id);
} else {
strncpy(tag_record.tag_name, dst_tag_name,
MB_SVC_ARRAY_LEN_MAX + 1);
- err = mb_svc_insert_record_tag(&tag_record);
+ err = mb_svc_insert_record_tag(mb_svc_handle, &tag_record);
if (err < 0) {
mb_svc_debug("mb_svc_insert_record_tag fail\n");
return err;
}
- err = __mb_svc_update_tagmap_by_media_id(media_id, src_tag_id, tag_record._id);
+ err = __mb_svc_update_tagmap_by_media_id(mb_svc_handle, media_id, src_tag_id, tag_record._id);
}
return err;
}
-static int __mb_svc_update_tag(int tag_id, const char *tag_name)
+static int __mb_svc_update_tag(MediaSvcHandle *mb_svc_handle, int tag_id, const char *tag_name)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-static int __mb_svc_update_tagmap(int src_tag_id, int dst_tag_id)
+static int __mb_svc_update_tagmap(MediaSvcHandle *mb_svc_handle, int src_tag_id, int dst_tag_id)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-static int __mb_svc_update_tagmap_by_media_id(const char *media_id, int src_tag_id, int dst_tag_id)
+static int __mb_svc_update_tagmap_by_media_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ int src_tag_id,
+ int dst_tag_id)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_get_tagid_by_tagname(const char *tag_name)
+int mb_svc_get_tagid_by_tagname(MediaSvcHandle *mb_svc_handle, const char *tag_name)
{
mb_svc_debug("");
char *table_name = MB_SVC_TBL_NAME_TAG;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return return_id;
}
-static int __mb_svc_get_media_cnt_by_tagid(int tag_id)
+static int __mb_svc_get_media_cnt_by_tagid(MediaSvcHandle *mb_svc_handle, int tag_id)
{
int rc = 0;
sqlite3_stmt *stmt = NULL;
char *table_name = MB_SVC_TBL_NAME_TAG_MAP;
char *query_string = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return count;
}
-int mb_svc_add_web_streaming_folder(char *folder_id)
+int mb_svc_add_web_streaming_folder(MediaSvcHandle *mb_svc_handle, char *folder_id)
{
mb_svc_folder_record_s folder_record = {"",};
int ret = 0;
strncpy(folder_record.web_account_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
strncpy(folder_record.web_album_id, "", MB_SVC_ARRAY_LEN_MAX + 1);
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug("mb_svc_insert_record_folder failed\n");
return ret;
return 0;
}
-int mb_svc_get_web_streaming_folder_uuid(char *folder_uuid, int max_length)
+int mb_svc_get_web_streaming_folder_uuid(MediaSvcHandle *mb_svc_handle, char *folder_uuid, int max_length)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_FOLDER;
sqlite3_stmt *stmt = NULL;
int folder_id = 0;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-int mb_svc_get_media_id_by_full_path(const char *file_full_path, char *media_id)
+int mb_svc_get_media_id_by_full_path(MediaSvcHandle *mb_svc_handle, const char *file_full_path, char *media_id)
{
int err = 0;
int folder_id = 0;
_mb_svc_get_file_parent_path(file_full_path, dir_full_path);
_mb_svc_get_file_display_name(file_full_path, file_display_name);
- err = mb_svc_get_folder_id_by_full_path(dir_full_path, folder_uuid, sizeof(folder_uuid));
+ err = mb_svc_get_folder_id_by_full_path(mb_svc_handle, dir_full_path, folder_uuid, sizeof(folder_uuid));
if (err < 0) {
mb_svc_debug("mb_svc_get_folder_id_by_full_path fails:%s",
dir_full_path);
}
_mb_svc_get_file_display_name(file_full_path, file_display_name);
- err = __mb_svc_get_media_id_by_fid_name(folder_uuid, file_display_name, media_id);
+ err = __mb_svc_get_media_id_by_fid_name(mb_svc_handle, folder_uuid, file_display_name, media_id);
if (err < 0) {
mb_svc_debug("__mb_svc_get_media_id_by_fid_name fails:%d,%s",
folder_id, file_display_name);
return 0;
}
-int mb_svc_get_media_id_by_http_url(const char *http_url, char *media_id)
+int mb_svc_get_media_id_by_http_url(MediaSvcHandle *mb_svc_handle, const char *http_url, char *media_id)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_MEDIA;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_get_media_record_by_full_path(const char *file_full_path,
- mb_svc_media_record_s *record)
+mb_svc_get_media_record_by_full_path(MediaSvcHandle *mb_svc_handle,
+ const char *file_full_path,
+ mb_svc_media_record_s *record)
{
int err = -1;
char *table_name = MB_SVC_TBL_NAME_MEDIA;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-int mb_svc_delete_invalid_media_records(const minfo_store_type storage_type)
+int mb_svc_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type)
+{
+ mb_svc_debug("storage_type: %d", storage_type);
+
+ sqlite3_stmt *stmt = NULL;
+
+ int err = -1;
+ char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+
+ char *sql = NULL;
+ char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
+ GList *delete_media_list = NULL;
+
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
+ if (handle == NULL) {
+ mb_svc_debug("handle is NULL");
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ err = __mb_svc_get_all_media_list(mb_svc_handle, storage_type, &delete_media_list);
+ if (err == MB_SVC_ERROR_DB_NO_RECORD) {
+ mb_svc_debug("There is no media");
+ return 0;
+ } else if (err < 0) {
+ mb_svc_debug("__mb_svc_get_all_media_list failed : %d", err);
+ mb_svc_debug("Keep going to remove folder..");
+ } else {
+ err = __mb_svc_delete_media_records_list(mb_svc_handle, delete_media_list);
+ if (err < 0) {
+ _mb_svc_glist_free(&delete_media_list, true);
+ mb_svc_debug
+ ("__mb_svc_delete_media_records_list failed : %d", err);
+ return err;
+ }
+ }
+
+ _mb_svc_glist_free(&delete_media_list, true);
+
+ /* Get folder list to remove */
+ memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
+ snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
+ MB_SVC_TBL_NAME_FOLDER);
+
+ sql =
+ sqlite3_mprintf("select folder_uuid from %s where storage_type = %d;",
+ table_name, storage_type);
+ err = sqlite3_prepare_v2(handle, sql, strlen(sql), &stmt, NULL);
+
+ mb_svc_debug("query string is %s\n", sql);
+ sqlite3_free(sql);
+
+ if (SQLITE_OK != err) {
+ mb_svc_debug("prepare error [%s]", sqlite3_errmsg(handle));
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ for (;;) {
+ err = sqlite3_step(stmt);
+ if (err != SQLITE_ROW) {
+ break;
+ }
+
+ strncpy(folder_uuid, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
+
+ err = mb_svc_delete_record_folder_by_id(mb_svc_handle, folder_uuid);
+ if (err < 0) {
+ mb_svc_debug("mb_svc_delete_record_folder_by_id fail:%d\n", err);
+ return err;
+ }
+ }
+
+ err = sqlite3_finalize(stmt);
+ if (SQLITE_OK != err) {
+ mb_svc_debug("failed to clear row\n");
+ return MB_SVC_ERROR_DB_INTERNAL;
+ }
+
+ return 0;
+}
+
+int mb_svc_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type)
{
mb_svc_debug("storage_type: %d", storage_type);
char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
GList *invalid_media_list = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
- err = __mb_svc_get_invalid_media_list(storage_type, &invalid_media_list);
+ err = __mb_svc_get_invalid_media_list(mb_svc_handle, storage_type, &invalid_media_list);
if (err == MB_SVC_ERROR_DB_NO_RECORD) {
mb_svc_debug("There is no invalid media");
return 0;
mb_svc_debug("__mb_svc_get_invalid_media_list failed : %d", err);
mb_svc_debug("Keep going to remove invalid folder..");
} else {
- err = __mb_svc_delete_media_records_list(invalid_media_list);
+ err = __mb_svc_delete_media_records_list(mb_svc_handle, invalid_media_list);
if (err < 0) {
_mb_svc_glist_free(&invalid_media_list, true);
mb_svc_debug
}
}
+ _mb_svc_glist_free(&invalid_media_list, true);
+
/* Get folder list to remove, which is invalid */
memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
MB_SVC_TBL_NAME_FOLDER);
sql =
- sqlite3_mprintf("select uuid from %s where storage_type = %d and valid=0;",
+ sqlite3_mprintf("select folder_uuid from %s where storage_type = %d and valid=0;",
table_name, storage_type);
err = sqlite3_prepare_v2(handle, sql, strlen(sql), &stmt, NULL);
strncpy(folder_uuid, (const char *)sqlite3_column_text(stmt, 0), MB_SVC_UUID_LEN_MAX + 1);
- err = mb_svc_delete_record_folder_by_id(folder_uuid);
+ err = mb_svc_delete_record_folder_by_id(mb_svc_handle, folder_uuid);
if (err < 0) {
mb_svc_debug("mb_svc_delete_record_folder_by_id fail:%d\n", err);
return err;
return 0;
}
-int mb_svc_get_all_item_count(int *cnt)
+int mb_svc_get_all_item_count(
+ MediaSvcHandle *mb_svc_handle,
+ minfo_folder_type folder_type,
+ minfo_file_type file_type,
+ minfo_media_favorite_type fav_type,
+ int *cnt)
{
char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+ char folder_type_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+ char file_type_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+ char fav_type_str[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
+
int rc = 0;
sqlite3_stmt *stmt = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
+ if (folder_type == MINFO_CLUSTER_TYPE_ALL) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "1 and ");
+ } else if (folder_type == MINFO_CLUSTER_TYPE_LOCAL_ALL) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "(f.storage_type=0 or f.storage_type=1) and ");
+ } else if (folder_type == MINFO_CLUSTER_TYPE_LOCAL_PHONE) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "f.storage_type=0 and ");
+ } else if (folder_type == MINFO_CLUSTER_TYPE_LOCAL_MMC) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "f.storage_type=1 and ");
+ } else if (folder_type == MINFO_CLUSTER_TYPE_WEB) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "f.storage_type=2 and ");
+ } else if (folder_type == MINFO_CLUSTER_TYPE_STREAMING) {
+ snprintf(folder_type_str, sizeof(folder_type_str), "%s", "f.storage_type=3 and ");
+ } else {
+ mb_svc_debug("Invalid Folder type: %d", folder_type);
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (file_type == MINFO_ITEM_ALL) {
+ snprintf(file_type_str, sizeof(file_type_str), "%s", " 1 and ");
+ } else if (file_type == MINFO_ITEM_IMAGE) {
+ snprintf(file_type_str, sizeof(file_type_str), "%s", " m.content_type=1 and ");
+ } else if (file_type == MINFO_ITEM_VIDEO) {
+ snprintf(file_type_str, sizeof(file_type_str), "%s", " m.content_type=2 and ");
+ } else {
+ mb_svc_debug("Invalid File type: %d", folder_type);
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (fav_type == MINFO_MEDIA_FAV_ALL) {
+ snprintf(fav_type_str, sizeof(fav_type_str), "%s", " 1");
+ } else if (fav_type == MINFO_MEDIA_FAV_ONLY) {
+ snprintf(fav_type_str, sizeof(fav_type_str), "%s", " m.rating=1");
+ } else if (fav_type == MINFO_MEDIA_UNFAV_ONLY) {
+ snprintf(fav_type_str, sizeof(fav_type_str), "%s", " m.rating=0");
+ } else {
+ mb_svc_debug("Invalid favorite type: %d", folder_type);
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
int len =
snprintf(q_string, sizeof(q_string), MB_SVC_SELECT_ALL_ITEM_COUNT,
- MB_SVC_TBL_NAME_MEDIA);
+ MB_SVC_TBL_NAME_MEDIA, folder_type_str, file_type_str, fav_type_str);
if (len < 0) {
mb_svc_debug("snprintf returns failure ( %d )", len);
q_string[0] = '\0';
q_string[len] = '\0';
}
+ mb_svc_debug("Query : %s", q_string);
+
rc = sqlite3_prepare_v2(handle, q_string, strlen(q_string), &stmt,
NULL);
if (SQLITE_OK != rc) {
return 0;
}
-int mb_svc_get_media_count_by_tagname(const char *tagname, int *count)
+int mb_svc_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char *tagname, int *count)
{
char q_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
int rc = 0;
sqlite3_stmt *stmt = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
* common API
*/
-#include "media-info-util.h"
+#include <sqlite3.h>
#include "media-svc-util.h"
+#include "visual-svc-util.h"
#include "media-svc-db-util.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
-int mb_svc_query_sql_gstring(GString *query_string)
+int mb_svc_query_sql_gstring(MediaSvcHandle *mb_svc_handle, GString *query_string)
{
int err = -1;
char *err_msg;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return err;
}
-int mb_svc_query_sql(char *query_str)
+int mb_svc_query_sql(MediaSvcHandle *mb_svc_handle, char *query_str)
{
int err = -1;
char *err_msg;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return err;
}
-int mb_svc_sqlite3_begin_trans(void)
+int mb_svc_sqlite3_begin_trans(MediaSvcHandle *mb_svc_handle)
{
char *err_msg = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-int mb_svc_sqlite3_commit_trans(void)
+int mb_svc_sqlite3_commit_trans(MediaSvcHandle *mb_svc_handle)
{
char *err_msg = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return 0;
}
-int mb_svc_sqlite3_rollback_trans(void)
+int mb_svc_sqlite3_rollback_trans(MediaSvcHandle *mb_svc_handle)
{
char *err_msg = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
*
*/
-#include "media-info-env.h"
-#include "media-info-util.h"
+#include <string.h>
+#include <util-func.h>
+#include <sys/stat.h>
+#include "media-svc-env.h"
+#include "media-svc-util.h"
#include "media-svc-db.h"
-#include "media-svc-debug.h"
+#include "visual-svc-debug.h"
#include "media-svc-db-util.h"
-#include "media-svc-util.h"
+#include "visual-svc-util.h"
#include "media-svc-api.h"
-#include "media-svc-error.h"
-#include "minfo-types.h"
#include "media-svc-structures.h"
-#include <util-func.h>
-#include <sys/stat.h>
-
+#include "visual-svc-types.h"
+#include "visual-svc-error.h"
/**
* Enumerations for table name.
MB_SVC_MEDIA_MODIFIED_DATE,
MB_SVC_MEDIA_THUMBNAIL_PATH,
MB_SVC_MEDIA_HTTP_URL,
+ MB_SVC_MEDIA_SIZE,
MB_SVC_MEDIA_VALID,
MB_SVC_MEDIA_NUM,
} mb_svc_media_field_e;
MB_SVC_VIDEO_META_ALBUM,
MB_SVC_VIDEO_META_ARTIST,
MB_SVC_VIDEO_META_TITLE,
+ MB_SVC_VIDEO_META_GENRE,
MB_SVC_VIDEO_META_DESCRIPTION,
MB_SVC_VIDEO_META_YOUTUBE_CATEGORY,
MB_SVC_VIDEO_META_BOOKMARK_LAST_PLAYED,
mb_svc_tbl_s mb_svc_tbl[MB_SVC_TABLE_CNT_MAX] = {
{"video_bookmark", {
{"_id", "INTEGER"} , /* PK */
- {"media_uuid", "VARCHAR(256)"} ,
+ {"visual_uuid", "VARCHAR(256)"} ,
{"marked_time", "INT"}
,
{"thumbnail_path", "VARCHAR(256)"}
,
{"visual_folder", {
- {"uuid", "VARCHAR(256)"} , /* PK */
+ {"folder_uuid", "VARCHAR(256)"} , /* PK */
{"path", "VARCHAR(256)"} , /* full path */
{"folder_name", "VARCHAR(256)"}
,
,
{"visual_media", {
- {"uuid", "VARCHAR(256)"}
+ {"visual_uuid", "VARCHAR(256)"}
,
{"path", "VARCHAR(256)"}
,
,
{"http_url", "VARCHAR(256)"}
,
+ {"size", "INT"}
+ ,
{"valid", "INT"}
,
{0}
{"video_meta", {
{"_id", "INTEGER"}
,
- {"media_uuid", "VARCHAR(256)"}
+ {"visual_uuid", "VARCHAR(256)"}
,
{"album", "VARCHAR(256)"}
,
,
{"title", "VARCHAR(256)"}
,
+ {"genre", "VARCHAR(256)"}
+ ,
{"description", "VARCHAR(256)"}
,
{"youtube_category", "VARCHAR(256)"}
{"image_meta", {
{"_id", "INTEGER"}
,
- {"media_uuid", "VARCHAR(256)"}
+ {"visual_uuid", "VARCHAR(256)"}
,
{"longitude", "DOUBLE"}
,
{"visual_tag_map", {
{"_id", "INTEGER"} /* PK */
,
- {"media_uuid", "VARCHAR(256)"}
+ {"visual_uuid", "VARCHAR(256)"}
,
{"tag_id", "INT"}
,
static int __mb_svc_create_tbl(bool external);
static int __mb_svc_drop_tbl(void);
#endif
-static int __mb_svc_delete_record(int id, mb_svc_tbl_name_e tbl_name);
-static int __mb_svc_delete_record_by_uuid(const char *id, mb_svc_tbl_name_e tbl_name);
-static int __mb_svc_db_get_next_id(int table_id);
+static int __mb_svc_delete_record(MediaSvcHandle *mb_svc_handle, int id, mb_svc_tbl_name_e tbl_name);
+static int __mb_svc_delete_record_by_uuid(MediaSvcHandle *mb_svc_handle, const char *id, mb_svc_tbl_name_e tbl_name);
+static int __mb_svc_db_get_next_id(MediaSvcHandle *mb_svc_handle, int table_id);
#if 0
static int __mb_svc_create_tbl(bool external)
snprintf(table_name, MB_SVC_TABLE_NAME_MAX_LEN, "%s",
mb_svc_tbl[field_seq].table_name);
- sql = sqlite3_mprintf(MB_SVC_UPDATE_VALID_BY_UUID,
- table_name,
+ sql = sqlite3_mprintf(MB_SVC_UPDATE_FOLDER_VALID_BY_UUID,
+ table_name,
valid,
folder_id);
return 0;
}
-int mb_svc_set_item_as_valid_sql_add(const char *full_path, int valid)
+int mb_svc_set_item_as_valid_sql_add(MediaSvcHandle *mb_svc_handle, const char *full_path, int valid)
{
mb_svc_debug("full path: %s, valid:%d", full_path, valid);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_media_record_by_full_path(full_path, &media_record);
+ ret = mb_svc_get_media_record_by_full_path(mb_svc_handle, full_path, &media_record);
if (ret < 0) {
mb_svc_debug(" mb_svc_get_media_record_by_full_path fails (%d)", ret);
return ret;
mb_svc_tbl[field_seq].table_name);
char *sql =
- sqlite3_mprintf(MB_SVC_UPDATE_VALID_BY_UUID, table_name, valid,
+ sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_VALID_BY_UUID, table_name, valid,
media_record.media_uuid);
mb_svc_sql_list_add(&g_sql_list, &sql);
return 0;
}
-int mb_svc_set_item_as_valid()
+int mb_svc_set_item_as_valid(MediaSvcHandle *mb_svc_handle)
{
mb_svc_debug("");
int i = 0;
for (i = 0; i < length; i++) {
char *sql = (char*)g_list_nth_data(g_sql_list, i);
- mb_svc_query_sql(sql);
+ mb_svc_query_sql(mb_svc_handle, sql);
}
mb_svc_sql_list_release(&g_sql_list);
return 0;
}
+#if 0
static int mb_svc_busy_handler(void *pData, int count)
{
usleep(50000);
mb_svc_debug("Disconnected successfully\n");
return 0;
}
-
+#endif
mb_svc_tbl_s *mb_svc_search_matched_svc_tbl(mb_svc_tbl_name_e tbl_name)
{
int i;
return NULL;
}
-int _mb_svc_table_exist(char *table_name)
+int _mb_svc_table_exist(MediaSvcHandle *mb_svc_handle, char *table_name)
{
char szQuery[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
int ret = -1;;
char *pszTempName = NULL;
sqlite3_stmt *pstStmt_pb = NULL;
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return ret;
}
-int _mb_svc_truncate_tbl()
+int _mb_svc_truncate_tbl(MediaSvcHandle *mb_svc_handle)
{
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
int i, err;
mb_svc_debug("table_name is null\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- err = _mb_svc_table_exist(table_name);
+ err = _mb_svc_table_exist(mb_svc_handle, table_name);
if (err > 0) {
snprintf(query_string, sizeof(query_string),
MB_SVC_TABLE_DELETE_QUERY_STRING, table_name);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("truncate table failed\n");
mb_svc_debug("query string is %s\n",
return 0;
}
-static int __mb_svc_db_get_next_id(int table_id)
+static int __mb_svc_db_get_next_id(MediaSvcHandle *mb_svc_handle, int table_id)
{
int ret = 0;
sqlite3_stmt *stmt = NULL;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
return ret + 1;
}
-static int __mb_svc_delete_record(int id, mb_svc_tbl_name_e tbl_name)
+static int __mb_svc_delete_record(MediaSvcHandle *mb_svc_handle, int id, mb_svc_tbl_name_e tbl_name)
{
int err = -1;
mb_svc_tbl_s *matched_tbl = NULL;
mb_svc_debug("Query: %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
return 0;
}
-static int __mb_svc_delete_record_by_uuid(const char *id, mb_svc_tbl_name_e tbl_name)
+static int __mb_svc_delete_record_by_uuid(MediaSvcHandle *mb_svc_handle, const char *id, mb_svc_tbl_name_e tbl_name)
{
int err = -1;
mb_svc_tbl_s *matched_tbl = NULL;
if (matched_tbl != NULL) {
snprintf(table_name, sizeof(table_name), "%s",
mb_svc_tbl[tbl_name].table_name);
- snprintf(query_string, sizeof(query_string),
- MB_SVC_RECORD_DELETE_BY_UUID, table_name, id);
+ if (tbl_name == MB_SVC_TABLE_FOLDER) {
+ snprintf(query_string, sizeof(query_string),
+ MB_SVC_RECORD_FOLDER_DELETE_BY_UUID, table_name, id);
+ } else {
+ snprintf(query_string, sizeof(query_string),
+ MB_SVC_RECORD_MEDIA_DELETE_BY_UUID, table_name, id);
+ }
mb_svc_debug("Query: %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
return 0;
}
-int mb_svc_delete_record_bookmark_by_id(int id)
+int mb_svc_delete_record_bookmark_by_id(MediaSvcHandle *mb_svc_handle, int id)
{
- return __mb_svc_delete_record(id, MB_SVC_TABLE_BOOKMARK);
+ return __mb_svc_delete_record(mb_svc_handle, id, MB_SVC_TABLE_BOOKMARK);
}
-int mb_svc_delete_record_folder_by_id(const char *id)
+int mb_svc_delete_record_folder_by_id(MediaSvcHandle *mb_svc_handle, const char *id)
{
- return __mb_svc_delete_record_by_uuid(id, MB_SVC_TABLE_FOLDER);
+ return __mb_svc_delete_record_by_uuid(mb_svc_handle, id, MB_SVC_TABLE_FOLDER);
}
-int mb_svc_delete_record_web_streaming_by_id(int id)
+int mb_svc_delete_record_web_streaming_by_id(MediaSvcHandle *mb_svc_handle, int id)
{
- return __mb_svc_delete_record(id, MB_SVC_TABLE_WEB_STREAMING);
+ return __mb_svc_delete_record(mb_svc_handle, id, MB_SVC_TABLE_WEB_STREAMING);
}
-int mb_svc_delete_record_media_by_id(const char *id)
+int mb_svc_delete_record_media_by_id(MediaSvcHandle *mb_svc_handle, const char *id)
{
- return __mb_svc_delete_record_by_uuid(id, MB_SVC_TABLE_MEDIA);
+ return __mb_svc_delete_record_by_uuid(mb_svc_handle, id, MB_SVC_TABLE_MEDIA);
}
-int mb_svc_delete_record_video_meta_by_id(int id)
+int mb_svc_delete_record_video_meta_by_id(MediaSvcHandle *mb_svc_handle, int id)
{
- return __mb_svc_delete_record(id, MB_SVC_TABLE_VIDEO_META);
+ return __mb_svc_delete_record(mb_svc_handle, id, MB_SVC_TABLE_VIDEO_META);
}
-int mb_svc_delete_record_image_meta_by_id(int id)
+int mb_svc_delete_record_image_meta_by_id(MediaSvcHandle *mb_svc_handle, int id)
{
- return __mb_svc_delete_record(id, MB_SVC_TABLE_IMAGE_META);
+ return __mb_svc_delete_record(mb_svc_handle, id, MB_SVC_TABLE_IMAGE_META);
}
-int mb_svc_insert_record_bookmark(mb_svc_bookmark_record_s *record)
+int mb_svc_insert_record_bookmark(MediaSvcHandle *mb_svc_handle, mb_svc_bookmark_record_s *record)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_insert_record_folder(mb_svc_folder_record_s *record)
+int mb_svc_insert_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_insert_record_web_streaming(mb_svc_web_streaming_record_s *record)
+int mb_svc_insert_record_web_streaming(MediaSvcHandle *mb_svc_handle, mb_svc_web_streaming_record_s *record)
{
mb_svc_debug("");
mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_WEB_STREAMING;
mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
- record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_WEB_STREAMING);
+ record->_id = __mb_svc_db_get_next_id(mb_svc_handle, MB_SVC_TABLE_WEB_STREAMING);
if (record->_id < 0) {
mb_svc_debug("__mb_svc_db_get_next_id failed");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
/**
* insert record into table--media
*/
-int mb_svc_insert_record_media(mb_svc_media_record_s *record,
+int mb_svc_insert_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record,
minfo_store_type storage_type)
{
mb_svc_debug("");
mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
- mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
- field_name,
+ mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].field_name,
mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+ mb_svc_field[MB_SVC_MEDIA_SIZE].field_name,
mb_svc_field[MB_SVC_MEDIA_VALID].field_name,
record->media_uuid, record->path,
record->folder_uuid, record->display_name, record->content_type,
record->rate, record->modified_date,
- record->thumbnail_path, record->http_url, 1);
+ record->thumbnail_path, record->http_url, record->size, 1);
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
mb_svc_field[MB_SVC_MEDIA_CONTENT_TYPE].field_name,
mb_svc_field[MB_SVC_MEDIA_RATING].field_name,
mb_svc_field[MB_SVC_MEDIA_MODIFIED_DATE].field_name,
- mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
- field_name,
+ mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].field_name,
mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
+ mb_svc_field[MB_SVC_MEDIA_SIZE].field_name,
mb_svc_field[MB_SVC_MEDIA_VALID].field_name,
record->media_uuid, record->path,
record->folder_uuid,
record->display_name, record->content_type,
record->rate, record->modified_date,
- record->thumbnail_path, record->http_url, 1);
+ record->thumbnail_path, record->http_url, record->size, 1);
mb_svc_debug("Query : %s", *sql);
}
int
-mb_svc_insert_record_video_meta(mb_svc_video_meta_record_s *record,
+mb_svc_insert_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record,
minfo_store_type storage_type)
{
mb_svc_debug("");
mb_svc_field[MB_SVC_VIDEO_META_ALBUM].field_name,
mb_svc_field[MB_SVC_VIDEO_META_ARTIST].field_name,
mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
+ mb_svc_field[MB_SVC_VIDEO_META_GENRE].field_name,
mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
field_name,
mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].field_name,
mb_svc_field[MB_SVC_VIDEO_META_DATETAKEN].
field_name, /* record->_id, */record->media_uuid,
- record->album, record->artist, record->title,
+ record->album, record->artist, record->title, record->genre,
record->description, record->youtube_category,
record->last_played_time, record->duration,
record->longitude, record->latitude, record->width,
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
mb_svc_field[MB_SVC_VIDEO_META_ALBUM].field_name,
mb_svc_field[MB_SVC_VIDEO_META_ARTIST].field_name,
mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
+ mb_svc_field[MB_SVC_VIDEO_META_GENRE].field_name,
mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
field_name,
mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].field_name,
mb_svc_field[MB_SVC_VIDEO_META_DATETAKEN].
field_name, /* record->_id, */record->media_uuid,
- record->album, record->artist, record->title,
+ record->album, record->artist, record->title, record->genre,
record->description, record->youtube_category,
record->last_played_time, record->duration,
record->longitude, record->latitude, record->width,
}
int
-mb_svc_insert_record_image_meta(mb_svc_image_meta_record_s *record,
+mb_svc_insert_record_image_meta(MediaSvcHandle *mb_svc_handle,
+ mb_svc_image_meta_record_s *record,
minfo_store_type storage_type)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_update_record_folder(mb_svc_folder_record_s *record)
+int mb_svc_update_record_folder(MediaSvcHandle *mb_svc_handle, mb_svc_folder_record_s *record)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_update_record_folder_path(char *old_path, char *new_path)
+int mb_svc_update_record_folder_path(MediaSvcHandle *mb_svc_handle, char *old_path, char *new_path)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_update_folder_modified_date(char *path, int date)
+int mb_svc_update_folder_modified_date(MediaSvcHandle *mb_svc_handle, char *path, int date)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_update_record_media(mb_svc_media_record_s *record)
+int mb_svc_update_record_media(MediaSvcHandle *mb_svc_handle, mb_svc_media_record_s *record)
{
mb_svc_debug("");
mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
field_name, record->thumbnail_path,
mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
- record->http_url, record->media_uuid);
+ record->http_url,
+ mb_svc_field[MB_SVC_MEDIA_SIZE].field_name,
+ record->size,
+ record->media_uuid);
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
mb_svc_field[MB_SVC_MEDIA_THUMBNAIL_PATH].
field_name, record->thumbnail_path,
mb_svc_field[MB_SVC_MEDIA_HTTP_URL].field_name,
- record->http_url, record->media_uuid);
+ record->http_url,
+ mb_svc_field[MB_SVC_MEDIA_SIZE].field_name,
+ record->size,
+ record->media_uuid);
mb_svc_debug("Query : %s", *sql);
return err;
}
-int mb_svc_update_record_video_meta(mb_svc_video_meta_record_s *record)
+int mb_svc_update_record_video_meta(MediaSvcHandle *mb_svc_handle, mb_svc_video_meta_record_s *record)
{
mb_svc_debug("");
record->artist,
mb_svc_field[MB_SVC_VIDEO_META_TITLE].field_name,
record->title,
+ mb_svc_field[MB_SVC_VIDEO_META_GENRE].field_name,
+ record->genre,
mb_svc_field[MB_SVC_VIDEO_META_DESCRIPTION].
field_name, record->description,
mb_svc_field[MB_SVC_VIDEO_META_YOUTUBE_CATEGORY].
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_update_record_image_meta(mb_svc_image_meta_record_s *record)
+int mb_svc_update_record_image_meta(MediaSvcHandle *mb_svc_handle, mb_svc_image_meta_record_s *record)
{
mb_svc_debug("");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
}
int
-mb_svc_update_width_and_height(const char *media_id, minfo_file_type content_type,
- int width, int height)
-{
- mb_svc_debug("");
-
- if (content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL) {
- mb_svc_debug
- ("content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
- return MB_SVC_ERROR_INVALID_PARAMETER;
- }
-
- int err = -1;
- mb_svc_tbl_field_s *mb_svc_field;
- char *query_string = NULL;
- mb_svc_tbl_name_e field_seq;
-
- if (content_type == MINFO_ITEM_IMAGE)
- field_seq = MB_SVC_TABLE_IMAGE_META;
- else if (content_type == MINFO_ITEM_VIDEO)
- field_seq = MB_SVC_TABLE_VIDEO_META;
- else
- return MB_SVC_ERROR_INVALID_PARAMETER;
-
- mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
-
- if (content_type == MINFO_ITEM_IMAGE)
- query_string =
- sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
- mb_svc_tbl[field_seq].table_name,
- mb_svc_field[MB_SVC_IMAGE_META_WIDTH].
- field_name, width,
- mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].
- field_name, height, media_id);
- else if (content_type == MINFO_ITEM_VIDEO)
- query_string =
- sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
- mb_svc_tbl[field_seq].table_name,
- mb_svc_field[MB_SVC_VIDEO_META_WIDTH].
- field_name, width,
- mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].
- field_name, height, media_id);
-
- mb_svc_debug("Query : %s", query_string);
-
- err = mb_svc_query_sql(query_string);
- sqlite3_free(query_string);
-
- if (err < 0) {
- mb_svc_debug("Updating image meta width and height failed\n");
- mb_svc_debug("query string is %s\n", query_string);
- return MB_SVC_ERROR_DB_INTERNAL;
- }
-
- return err;
-}
-
-int
-mb_svc_update_width_and_height_sql(const char *media_id, minfo_file_type content_type,
- int width, int height, char **sql)
-{
- mb_svc_debug("");
-
- if (content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL) {
- mb_svc_debug
- ("content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
- return MB_SVC_ERROR_INVALID_PARAMETER;
- }
-
- int err = 0;
- mb_svc_tbl_field_s *mb_svc_field;
- mb_svc_tbl_name_e field_seq;
-
- if (content_type == MINFO_ITEM_IMAGE)
- field_seq = MB_SVC_TABLE_IMAGE_META;
- else if (content_type == MINFO_ITEM_VIDEO)
- field_seq = MB_SVC_TABLE_VIDEO_META;
- else
- return MB_SVC_ERROR_INVALID_PARAMETER;
-
- mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
-
- if (content_type == MINFO_ITEM_IMAGE)
- *sql =
- sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
- mb_svc_tbl[field_seq].table_name,
- mb_svc_field[MB_SVC_IMAGE_META_WIDTH].
- field_name, width,
- mb_svc_field[MB_SVC_IMAGE_META_HEIGHT].
- field_name, height, media_id);
- else if (content_type == MINFO_ITEM_VIDEO)
- *sql =
- sqlite3_mprintf(MB_SVC_UPDATE_META_WIDTH_HEIGHT,
- mb_svc_tbl[field_seq].table_name,
- mb_svc_field[MB_SVC_VIDEO_META_WIDTH].
- field_name, width,
- mb_svc_field[MB_SVC_VIDEO_META_HEIGHT].
- field_name, height, media_id);
-
- mb_svc_debug("Query : %s", *sql);
-
- return err;
-}
-
-int
mb_svc_load_record_bookmark(sqlite3_stmt *stmt,
mb_svc_bookmark_record_s *record)
{
(const char *)sqlite3_column_text(stmt, MB_SVC_MEDIA_HTTP_URL),
MB_SVC_DIR_PATH_LEN_MAX + 1);
+ record->size = sqlite3_column_int(stmt, MB_SVC_MEDIA_SIZE);
+
return 0;
}
(const char *)sqlite3_column_text(stmt,
MB_SVC_VIDEO_META_TITLE),
MB_SVC_FILE_NAME_LEN_MAX + 1);
+ strncpy(record->genre,
+ (const char *)sqlite3_column_text(stmt,
+ MB_SVC_VIDEO_META_GENRE),
+ MB_SVC_FILE_NAME_LEN_MAX + 1);
strncpy(record->description,
(const char *)sqlite3_column_text(stmt,
MB_SVC_VIDEO_META_DESCRIPTION),
return 0;
}
-int mb_svc_delete_record_media(const char *folder_id, char *display_name)
+int mb_svc_delete_record_media(MediaSvcHandle *mb_svc_handle, const char *folder_id, char *display_name)
{
int err = -1;
char *query_string = NULL;
query_string = sqlite3_mprintf(MB_SVC_DELETE_MEDIA_BY_FOLDER_ID_AND_DISPLAY_NAME,
table_name, folder_id, display_name);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
int mb_svc_delete_record_folder_sql(const char *folder_id, char **sql)
{
- *sql = sqlite3_mprintf(MB_SVC_RECORD_DELETE_BY_UUID,
+ *sql = sqlite3_mprintf(MB_SVC_RECORD_FOLDER_DELETE_BY_UUID,
mb_svc_tbl[MB_SVC_TABLE_FOLDER].table_name,
folder_id);
int mb_svc_delete_record_media_sql(const char *media_id, char **sql)
{
- *sql = sqlite3_mprintf(MB_SVC_RECORD_DELETE_BY_UUID,
+ *sql = sqlite3_mprintf(MB_SVC_RECORD_MEDIA_DELETE_BY_UUID,
mb_svc_tbl[MB_SVC_TABLE_MEDIA].table_name,
media_id);
return 0;
}
-int mb_svc_insert_record_tag(mb_svc_tag_record_s *record)
+int mb_svc_insert_record_tag(MediaSvcHandle *mb_svc_handle, mb_svc_tag_record_s *record)
{
mb_svc_debug("");
mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_TAG;
mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
- record->_id = __mb_svc_db_get_next_id(MB_SVC_TABLE_TAG);
+ record->_id = __mb_svc_db_get_next_id(mb_svc_handle, MB_SVC_TABLE_TAG);
if (record->_id < 0) {
mb_svc_debug("__mb_svc_db_get_next_id failed");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
return err;
}
-int mb_svc_insert_record_tag_map(const char *media_uuid, int tag_id)
+int mb_svc_insert_record_tag_map(MediaSvcHandle *mb_svc_handle, const char *media_uuid, int tag_id)
{
mb_svc_debug("");
mb_svc_tbl_name_e field_seq = MB_SVC_TABLE_TAG_MAP;
mb_svc_field = mb_svc_tbl[field_seq].mb_svc_field;
- int _id = __mb_svc_db_get_next_id(MB_SVC_TABLE_TAG_MAP);
+ int _id = __mb_svc_db_get_next_id(mb_svc_handle, MB_SVC_TABLE_TAG_MAP);
if (_id < 0) {
mb_svc_debug("__mb_svc_db_get_next_id failed");
mb_svc_debug("Query : %s", query_string);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
sqlite3_free(query_string);
if (err < 0) {
}
int
-mb_svc_delete_bookmark_meta_by_media_id(const char *media_id, minfo_file_type content_type)
+mb_svc_delete_bookmark_meta_by_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id, minfo_file_type content_type)
{
int err = -1;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
snprintf(query_string, sizeof(query_string),
MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, table_name,
media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
snprintf(query_string, sizeof(query_string),
MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, tbl_name,
media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
MB_SVC_DELETE_MEDIA_RELATED_INFO_BY_MEDIA_UUID, tbl_name,
media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to delete record\n");
mb_svc_debug("query string is %s\n", query_string);
return 0;
}
-int mb_svc_update_thumb_path_by_id(const char *media_id, const char *thumb_path)
+int mb_svc_update_thumb_path_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, const char *thumb_path)
{
int err = -1;
char *query_string = NULL;
query_string = sqlite3_mprintf(MB_SVC_UPDATE_MEDIA_THUMB_PATH,
table_name, thumb_path, media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to update record favorite\n");
mb_svc_debug("query string is %s\n", query_string);
return 0;
}
-int mb_svc_update_favorite_by_id(const char *media_id, int favorite)
+int mb_svc_update_favorite_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int favorite)
{
int err = -1;
char query_string[MB_SVC_DEFAULT_QUERY_SIZE + 1] = { 0 };
snprintf(query_string, sizeof(query_string),
MB_SVC_UPDATE_MEDIA_FAVORITE_BY_ID, table_name, favorite,
media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to update record favorite\n");
mb_svc_debug("query string is %s\n", query_string);
return 0;
}
-int mb_svc_update_date_by_id(const char *media_id, int date)
+int mb_svc_update_date_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, int date)
{
mb_svc_debug("");
int err = -1;
snprintf(query_string, sizeof(query_string),
MB_SVC_UPDATE_MEDIA_DATE_BY_ID, table_name, date, media_id);
- err = mb_svc_query_sql(query_string);
+ err = mb_svc_query_sql(mb_svc_handle, query_string);
if (err < 0) {
mb_svc_debug("failed to update record date\n");
mb_svc_debug("query string is %s\n", query_string);
}
int
-mb_svc_update_album_lock_status(const char *folder_id, int lock,
+mb_svc_update_album_lock_status(MediaSvcHandle *mb_svc_handle, const char *folder_id, int lock,
minfo_store_type storage_type)
{
int err = 0;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
}
int
-mb_svc_set_media_records_as_valid(const minfo_store_type storage_type,
+mb_svc_set_media_records_as_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type,
int valid)
{
mb_svc_debug("storage_type: %d", storage_type);
char table_name[MB_SVC_TABLE_NAME_MAX_LEN] = { 0, };
memset(table_name, 0x00, MB_SVC_TABLE_NAME_MAX_LEN);
- sqlite3 *handle = _media_info_get_proper_handle();
+ sqlite3 *handle = (sqlite3 *)mb_svc_handle;
if (handle == NULL) {
mb_svc_debug("handle is NULL");
return MB_SVC_ERROR_DB_INTERNAL;
char *sql =
sqlite3_mprintf("update %s set valid = %d where storage_type = %d;",
table_name, valid, storage_type);
- err = mb_svc_query_sql(sql);
+ err = mb_svc_query_sql(mb_svc_handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
mb_svc_debug
}
/* 2. get all of related folder id. */
sql =
- sqlite3_mprintf("select uuid from %s where storage_type = %d;",
+ sqlite3_mprintf("select folder_uuid from %s where storage_type = %d;",
table_name, storage_type);
err = sqlite3_prepare_v2(handle, sql, strlen(sql), &stmt, NULL);
sqlite3_mprintf
("update %s set valid = %d where folder_uuid = '%s';",
table_name, valid, folder_uuid);
- err = mb_svc_query_sql(sql);
+ err = mb_svc_query_sql(mb_svc_handle, sql);
sqlite3_free(sql);
if (err != SQLITE_OK) {
mb_svc_debug
#include <time.h>
#ifdef _PERFORMANCE_CHECK_
-#include "media-info-debug.h"
+#include "media-svc-debug.h"
#endif
#include "media-svc-thumb.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
-#include "media-svc-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
+#include "visual-svc-util.h"
#include "media-img-codec.h"
#include "media-img-codec-parser.h"
+#include "media-svc-hash.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <mm_file.h>
}
int
-mb_svc_get_image_meta(const char *file_full_path,
+mb_svc_get_image_meta(MediaSvcHandle *mb_svc_handle,
+ const char *file_full_path,
mb_svc_image_meta_record_s *image_record,
bool *thumb_done)
{
}
int
-mb_svc_get_video_meta(const char *file_full_path,
- mb_svc_video_meta_record_s *video_record)
+mb_svc_get_video_meta(MediaSvcHandle *mb_svc_handle,
+ const char *file_full_path,
+ mb_svc_video_meta_record_s *video_record)
{
MMHandleType content = (MMHandleType) NULL;
MMHandleType tag = (MMHandleType) NULL;
*/
#include <string.h>
-#include "media-info-debug.h"
-#include "minfo-types.h"
-#include "minfo-api.h"
+#include "media-svc-debug.h"
+#include "visual-svc-types.h"
+#include "visual-svc.h"
+#include "visual-svc-error.h"
#include "media-svc-db.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
+#include "visual-svc-util.h"
#include "media-svc-thumb.h"
-#include "media-svc-debug.h"
+#include "visual-svc-debug.h"
#include "minfo-cluster.h"
#include "minfo-item.h"
#include "minfo-tag.h"
#include "minfo-bookmark.h"
#include "minfo-streaming.h"
#include "media-svc-db-util.h"
-#include "media-svc-error.h"
static __thread int g_trans_valid_cnt = 1;
static __thread int g_cur_trans_valid_cnt = 0;
static __thread int g_trans_insert_cnt = 1;
static __thread int g_cur_trans_insert_cnt = 0;
+static __thread int g_trans_move_cnt = 1;
+static __thread int g_cur_trans_move_cnt = 0;
-int _minfo_svc_clear_database(void)
-{
- return _mb_svc_truncate_tbl();
-}
-
+#if 0
EXPORT_API int minfo_init(void)
{
mb_svc_debug("");
mb_svc_debug("");
return mb_svc_finalize();
}
+#endif
EXPORT_API int
-minfo_get_item_list(const char *cluster_id, const minfo_item_filter filter,
- minfo_item_ite_cb func, void *user_data)
+minfo_get_item_list(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ const minfo_item_filter filter,
+ minfo_item_ite_cb func,
+ void *user_data)
{
int record_cnt = 0;
int ret = -1;
mb_svc_iterator_s mb_svc_iterator = { 0 };
Mitem *mitem = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("Func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
filter.favorite);
ret =
- mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+ mb_svc_media_iter_start_new(mb_svc_handle, cluster_id, &mb_filter,
MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
&mb_svc_iterator);
record_cnt++;
- mitem = minfo_media_item_new(NULL, &md_record);
+ mitem = minfo_media_item_new(mb_svc_handle, NULL, &md_record);
if (filter.with_meta && mitem) {
mitem->meta_info =
- minfo_mmeta_new(mitem->uuid, &md_record);
+ minfo_mmeta_new(mb_svc_handle, mitem->uuid, &md_record);
}
func(mitem, user_data);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_item_list_search(minfo_search_field_t search_field,
+minfo_get_item_list_search(MediaSvcHandle *mb_svc_handle,
+ minfo_search_field_t search_field,
const char *search_str,
minfo_folder_type folder_type,
const minfo_item_filter filter,
int ret = -1;
int record_cnt = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (search_str == NULL) {
mb_svc_debug("search string is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_item_list_search--enter\n");
ret =
- mb_svc_media_search_iter_start(search_field, search_str, folder_type, filter, &mb_svc_iterator);
+ mb_svc_media_search_iter_start(mb_svc_handle, search_field, search_str, folder_type, filter, &mb_svc_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed");
record_cnt++;
- mitem = minfo_media_item_new(NULL, &md_record);
+ mitem = minfo_media_item_new(mb_svc_handle, NULL, &md_record);
if (filter.with_meta && mitem) {
mitem->meta_info =
- minfo_mmeta_new(mitem->uuid, &md_record);
+ minfo_mmeta_new(mb_svc_handle, mitem->uuid, &md_record);
}
func(mitem, user_data);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_all_item_list(const minfo_folder_type cluster_type,
- const minfo_item_filter filter, minfo_item_ite_cb func,
+minfo_get_all_item_list(MediaSvcHandle *mb_svc_handle,
+ const minfo_folder_type cluster_type,
+ const minfo_item_filter filter,
+ minfo_item_ite_cb func,
void *user_data)
{
mb_svc_debug("");
int record_cnt = 0;
GList *p_list = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("Func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
memcpy(&mb_item_filter, &filter, sizeof(minfo_item_filter));
mb_svc_debug("minfo_get_all_item_list--enter\n");
- /* ret = mb_svc_media_iter_start(-1, &mb_item_filter, cluster_type, TRUE, p_list, &mb_svc_iterator); */
+
ret =
- mb_svc_media_iter_start_new(NULL, &mb_item_filter, cluster_type, TRUE,
+ mb_svc_media_iter_start_new(mb_svc_handle, NULL, &mb_item_filter, cluster_type, TRUE,
p_list, &mb_svc_iterator);
if (p_list) {
record_cnt++;
- mitem = minfo_media_item_new(NULL, &md_record);
+ mitem = minfo_media_item_new(mb_svc_handle, NULL, &md_record);
if (mitem != NULL) {
if (filter.with_meta) {
mitem->meta_info =
- minfo_mmeta_new(mitem->uuid, &md_record);
+ minfo_mmeta_new(mb_svc_handle, mitem->uuid, &md_record);
}
func(mitem, user_data);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_all_item_cnt(int *cnt)
+DEPRECATED_API int minfo_get_all_item_cnt(MediaSvcHandle *mb_svc_handle, int *cnt)
{
int ret = -1;
mb_svc_debug("");
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cnt == NULL) {
mb_svc_debug("cnt == NULL \n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_all_item_count(cnt);
+ ret = mb_svc_get_all_item_count(mb_svc_handle, MINFO_CLUSTER_TYPE_ALL, MINFO_ITEM_ALL, MINFO_MEDIA_FAV_ALL, cnt);
if (ret < 0) {
mb_svc_debug("Error: get image full pathfull failed\n");
return ret;
}
mb_svc_debug("record count = %d", *cnt);
- return 0;
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int minfo_get_all_item_count(
+ MediaSvcHandle *mb_svc_handle,
+ minfo_folder_type folder_type,
+ minfo_file_type file_type,
+ minfo_media_favorite_type fav_type,
+ int *cnt)
+{
+ int ret = -1;
+
+ mb_svc_debug("");
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cnt == NULL) {
+ mb_svc_debug("cnt == NULL \n");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mb_svc_get_all_item_count(mb_svc_handle, folder_type, file_type, fav_type, cnt);
+ if (ret < 0) {
+ mb_svc_debug("Error: mb_svc_get_all_item_count failed\n");
+ return ret;
+ }
+
+ mb_svc_debug("record count = %d", *cnt);
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_cluster_cover(const char *cluster_id, const int img_cnt,
- minfo_cover_ite_cb func, void *user_data)
+minfo_get_cluster_cover(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ const int img_cnt,
+ minfo_cover_ite_cb func,
+ void *user_data)
{
int record_cnt = 0;
int ret = -1;
mb_svc_iterator_s mb_svc_iterator = { 0 };
minfo_item_filter mb_filter = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_filter.with_meta = FALSE;
ret =
- mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+ mb_svc_media_iter_start_new(mb_svc_handle, cluster_id, &mb_filter,
MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
&mb_svc_iterator);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_item_cnt(const char *cluster_id, const minfo_item_filter filter,
- int *cnt)
+minfo_get_item_cnt(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ const minfo_item_filter filter,
+ int *cnt)
{
int ret = -1;
int record_cnt = 0;
mb_svc_iterator_s mb_svc_iterator = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
minfo_item_filter mb_filter;
memcpy(&mb_filter, &filter, sizeof(minfo_item_filter));
mb_svc_debug("minfo_get_item_cnt#filter.favorite: %d", filter.favorite);
ret =
- mb_svc_media_iter_start_new(cluster_id, &mb_filter,
+ mb_svc_media_iter_start_new(mb_svc_handle, cluster_id, &mb_filter,
MINFO_CLUSTER_TYPE_ALL, TRUE, NULL,
&mb_svc_iterator);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_cluster_cnt(const minfo_cluster_filter filter, int *cnt)
+minfo_get_cluster_cnt(MediaSvcHandle *mb_svc_handle, const minfo_cluster_filter filter, int *cnt)
{
mb_svc_iterator_s mb_svc_iterator = { 0 };
int ret = -1;
int record_cnt = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
minfo_cluster_filter mb_filter;
memcpy(&mb_filter, &filter, sizeof(minfo_cluster_filter));
mb_svc_debug("minfo_get_cluster_list#filter.end_pos: %d",
filter.end_pos);
- ret = mb_svc_folder_iter_start(&mb_filter, &mb_svc_iterator);
+ ret = mb_svc_folder_iter_start(mb_svc_handle, &mb_filter, &mb_svc_iterator);
if (ret < 0) {
mb_svc_debug("mb_svc_folder_iter_start failed\n");
return MB_SVC_ERROR_DB_INTERNAL;
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_cluster_list(const minfo_cluster_filter filter,
- minfo_cluster_ite_cb func, void *user_data)
+minfo_get_cluster_list(MediaSvcHandle *mb_svc_handle,
+ const minfo_cluster_filter filter,
+ minfo_cluster_ite_cb func,
+ void *user_data)
{
mb_svc_iterator_s mb_svc_iterator = { 0 };
mb_svc_folder_record_s fd_record = {"",};
int record_cnt = 0;
Mcluster *cluster = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_cluster_list#filter.end_pos: %d",
filter.end_pos);
- ret = mb_svc_folder_iter_start(&mb_filter, &mb_svc_iterator);
+ ret = mb_svc_folder_iter_start(mb_svc_handle, &mb_filter, &mb_svc_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed\n");
return MB_SVC_ERROR_DB_INTERNAL;
record_cnt++;
- cluster = minfo_mcluster_new(fd_record.uuid);
+ cluster = minfo_mcluster_new(mb_svc_handle, fd_record.uuid);
func(cluster, user_data);
}
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_web_cluster_by_web_account_id(const char *web_account_id,
+minfo_get_web_cluster_by_web_account_id(MediaSvcHandle *mb_svc_handle,
+ const char *web_account_id,
minfo_cluster_ite_cb func,
void *user_data)
{
char _web_account_id[MB_SVC_ARRAY_LEN_MAX + 1] = { 0 };
int i = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("Func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
_web_account_id[MB_SVC_ARRAY_LEN_MAX] = '\0';
ret =
- mb_svc_get_folder_list_by_web_account_id(_web_account_id,
+ mb_svc_get_folder_list_by_web_account_id(mb_svc_handle, _web_account_id,
&p_web_cluster_list);
if (ret < 0) {
record_cnt = g_list_length(p_web_cluster_list);
for (; i < record_cnt; i++) {
fd_record = g_list_nth_data(p_web_cluster_list, i);
- cluster = minfo_mcluster_new(fd_record->uuid);
+ cluster = minfo_mcluster_new(mb_svc_handle, fd_record->uuid);
func(cluster, user_data);
}
_mb_svc_glist_free(&p_web_cluster_list, TRUE);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_bookmark_list(const char *media_id, minfo_bm_ite_cb func,
- void *user_data)
+minfo_get_bookmark_list(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ minfo_bm_ite_cb func,
+ void *user_data)
{
int record_cnt = 0;
mb_svc_bookmark_record_s bookmark_record = { 0 };
mb_svc_iterator_s mb_svc_iterator = { 0 };
Mbookmark *mbookmark = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_bookmark_list#media_id: %s", media_id);
- ret = mb_svc_bookmark_iter_start(media_id, &mb_svc_iterator);
+ ret = mb_svc_bookmark_iter_start(mb_svc_handle, media_id, &mb_svc_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed");
return MB_SVC_ERROR_DB_INTERNAL;
record_cnt++;
- mbookmark = minfo_mbookmark_new(bookmark_record._id);
+ mbookmark = minfo_mbookmark_new(mb_svc_handle, bookmark_record._id);
func(mbookmark, user_data);
}
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_geo_item_list(const char *cluster_id,
+minfo_get_geo_item_list(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
minfo_folder_type store_filter,
minfo_item_filter filter,
double min_longitude,
mb_svc_iterator_s mb_svc_iterator = { 0 };
Mitem *mitem = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("Func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
ret =
- mb_svc_geo_media_iter_start(cluster_id, store_filter, &filter,
+ mb_svc_geo_media_iter_start(mb_svc_handle, cluster_id, store_filter, &filter,
&mb_svc_iterator, min_longitude,
max_longitude, min_latitude,
max_latitude);
record_cnt++;
- mitem = minfo_media_item_new(md_record.media_uuid, &md_record);
+ mitem = minfo_media_item_new(mb_svc_handle, md_record.media_uuid, &md_record);
if (filter.with_meta && mitem) {
mitem->meta_info =
- minfo_mmeta_new(mitem->uuid, &md_record);
+ minfo_mmeta_new(mb_svc_handle, mitem->uuid, &md_record);
}
func(mitem, user_data);
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_streaming_list(GList **p_list)
+EXPORT_API int minfo_get_streaming_list(MediaSvcHandle *mb_svc_handle, GList **p_list)
{
Mstreaming *mstreaming = NULL;
int record_cnt = 0;
int ret = -1;
mb_svc_iterator_s mb_svc_iterator = { 0 };
- mb_svc_debug("minfo_get_streaming_list--enter");
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (p_list == NULL) {
mb_svc_debug("Error:p_list == NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_webstreaming_iter_start(&mb_svc_iterator);
+ ret = mb_svc_webstreaming_iter_start(mb_svc_handle, &mb_svc_iterator);
if (ret < 0) {
mb_svc_debug("mb-svc iterator start failed");
return MB_SVC_ERROR_DB_INTERNAL;
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_meta_info(const char *media_id, Mmeta **meta)
+EXPORT_API int minfo_get_meta_info(MediaSvcHandle *mb_svc_handle, const char *media_id, Mmeta **meta)
{
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_meta_info#media_id: %s", media_id);
Mmeta *mmeta = NULL;
- mmeta = minfo_mmeta_new(media_id, NULL);
+ mmeta = minfo_mmeta_new(mb_svc_handle, media_id, NULL);
if (mmeta == NULL) {
return MB_SVC_ERROR_INVALID_PARAMETER;
}
*meta = mmeta;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_update_video_meta_info_int(const char *media_id,
- minfo_video_meta_field_t meta_field,
- const int updated_value)
+minfo_update_video_meta_info_int(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ minfo_video_meta_field_t meta_field,
+ const int updated_value)
{
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
int ret = -1;
mb_svc_video_meta_record_s video_meta_record = {0,};
- ret = mb_svc_get_video_record_by_media_id(media_id, &video_meta_record);
+ ret = mb_svc_get_video_record_by_media_id(mb_svc_handle, media_id, &video_meta_record);
if (ret < 0) {
mb_svc_debug
default:
break;
}
- ret = mb_svc_update_record_video_meta(&video_meta_record);
+ ret = mb_svc_update_record_video_meta(mb_svc_handle, &video_meta_record);
if (ret < 0) {
mb_svc_debug
}
EXPORT_API int
-minfo_update_image_meta_info_int(const char *media_id,
+minfo_update_image_meta_info_int(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
minfo_image_meta_field_t meta_field,
const int updated_value,
...)
{
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
int ret = -1;
mb_svc_image_meta_record_s image_meta_record = {0,};
- ret = mb_svc_get_image_record_by_media_id(media_id, &image_meta_record);
+ ret = mb_svc_get_image_record_by_media_id(mb_svc_handle, media_id, &image_meta_record);
if (ret < 0) {
mb_svc_debug
va_end(var_args);
- ret = mb_svc_update_record_image_meta(&image_meta_record);
+ ret = mb_svc_update_record_image_meta(mb_svc_handle, &image_meta_record);
if (ret < 0) {
mb_svc_debug
}
EXPORT_API int
-minfo_add_media_start(int trans_count)
+minfo_add_media_start(MediaSvcHandle *mb_svc_handle, int trans_count)
{
mb_svc_debug("Transaction count : %d", trans_count);
+
+ if (trans_count <= 1) {
+ mb_svc_debug("Trans count should be bigger than 1");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
g_trans_insert_cnt = trans_count;
g_cur_trans_insert_cnt = 0;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_add_media_end()
+minfo_add_media_end(MediaSvcHandle *mb_svc_handle)
{
mb_svc_debug("");
if (g_cur_trans_insert_cnt > 0) {
int ret = -1;
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_insert_items();
+ ret = mb_svc_insert_items(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_insert_items failed...");
return ret;
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
g_cur_trans_insert_cnt = 0;
g_trans_insert_cnt = 1;
g_cur_trans_insert_cnt = 0;
g_trans_insert_cnt = 1;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_add_media_batch(const char *file_url, minfo_file_type content_type)
+EXPORT_API int minfo_add_media_batch(MediaSvcHandle *mb_svc_handle, const char *file_url, minfo_file_type content_type)
{
int err = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL) {
mb_svc_debug("File URL is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("file_full_path is %s\n", file_url);
if (g_cur_trans_insert_cnt < g_trans_insert_cnt) {
- err = mb_svc_insert_file_batch(file_url, content_type);
+ err = mb_svc_insert_file_batch(mb_svc_handle, file_url, content_type);
if (err < 0) {
mb_svc_debug("mb_svc_insert_file_batch failed\n");
g_cur_trans_insert_cnt++;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
if (g_cur_trans_insert_cnt == g_trans_insert_cnt) {
- err = mb_svc_insert_file_batch(file_url, content_type);
+ err = mb_svc_insert_file_batch(mb_svc_handle, file_url, content_type);
if (err < 0) {
mb_svc_debug("mb_svc_insert_file_batch failed\n");
return err;
g_cur_trans_insert_cnt = 0;
- err = mb_svc_sqlite3_begin_trans();
+ err = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (err < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return err;
}
- err = mb_svc_insert_items();
+ err = mb_svc_insert_items(mb_svc_handle);
if (err < 0) {
mb_svc_debug
("mb_svc_insert_items failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return err;
}
- err = mb_svc_sqlite3_commit_trans();
+ err = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (err < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return err;
}
}
return err;
}
-EXPORT_API int minfo_add_media(const char *file_url, minfo_file_type content_type)
+EXPORT_API int minfo_add_media(MediaSvcHandle *mb_svc_handle, const char *file_url, minfo_file_type content_type)
{
int err = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL) {
mb_svc_debug("File URL is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("file_full_path is %s\n", file_url);
- err = mb_svc_insert_file(file_url, content_type);
+ err = mb_svc_insert_file(mb_svc_handle, file_url, content_type);
if (err < 0) {
mb_svc_debug("mb_svc_insert_file failed (%d) ", err);
return err;
}
-EXPORT_API int minfo_delete_media(const char *file_url)
+EXPORT_API int minfo_delete_media(MediaSvcHandle *mb_svc_handle, const char *file_url)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL) {
mb_svc_debug("File URL is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_delete_file(file_url);
+ ret = mb_svc_delete_file(mb_svc_handle, file_url);
if (ret < 0) {
mb_svc_debug
("minfo delete media, delete media file info failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_media_id(const char *media_id)
+EXPORT_API int minfo_delete_media_id(MediaSvcHandle *mb_svc_handle, const char *media_id)
{
int ret = -1;
mb_svc_media_record_s media_record = {"",};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_media_record_by_id(media_id, &media_record);
+ ret = mb_svc_get_media_record_by_id(mb_svc_handle, media_id, &media_record);
if (ret < 0) {
mb_svc_debug("minfo delete media, get media record failed\n");
return ret;
/* handle web image case. */
if (strncmp(media_record.http_url, "", 1) != 0) {
- ret = mb_svc_delete_record_media_by_id(media_record.media_uuid);
+ ret = mb_svc_delete_record_media_by_id(mb_svc_handle, media_record.media_uuid);
if (ret < 0) {
mb_svc_debug
("minfo delete media, delete media record by media_id failed\n");
/* delete file info in image_meta table & (video_meta table and bookmark table if it's video file) */
ret =
- mb_svc_delete_bookmark_meta_by_media_id(media_record.media_uuid,
- media_record.
- content_type);
+ mb_svc_delete_bookmark_meta_by_media_id(mb_svc_handle,
+ media_record.media_uuid,
+ media_record.
+ content_type);
if (ret < 0) {
mb_svc_debug
("mb_svc_delete_record_video_or_image_by_media_id fail:media id is %d\n",
return ret;
}
- return minfo_delete_media(media_record.path);
+ return minfo_delete_media(mb_svc_handle, media_record.path);
}
DEPRECATED_API int
-minfo_add_web_media(const char *cluster_id, const char *http_url, const char *file_name,
- const char *thumb_path)
+minfo_add_web_media(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ const char *http_url,
+ const char *file_name,
+ const char *thumb_path)
{
int ret = -1;
mb_svc_media_record_s media_record = {"",};
mb_svc_folder_record_s folder_record = {"",};
minfo_file_type content_type;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_add_web_media#http_url: %s", http_url);
mb_svc_debug("minfo_add_web_media#file_name: %s", file_name);
- ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &folder_record);
if ((ret < 0) || (folder_record.storage_type != MINFO_WEB)) {
mb_svc_debug
("minfo_add_web_media, get web folder record by id failed\n");
}
ret =
- mb_svc_get_media_record_by_fid_name(cluster_id, file_name,
+ mb_svc_get_media_record_by_fid_name(mb_svc_handle, cluster_id, file_name,
&media_record);
if (ret < 0) {
strncpy(media_record.folder_uuid, cluster_id, MB_SVC_UUID_LEN_MAX + 1);
media_record.content_type = content_type;
media_record.rate = MB_SVC_DEFAULT;
- ret = mb_svc_insert_record_media(&media_record, MINFO_WEB);
+ ret = mb_svc_insert_record_media(mb_svc_handle, &media_record, MINFO_WEB);
if (ret < 0) {
mb_svc_debug
("minfo_add_web_media, insert new media record failed\n");
image_meta_record.latitude = MINFO_DEFAULT_GPS;
ret =
- mb_svc_insert_record_image_meta(&image_meta_record,
+ mb_svc_insert_record_image_meta(mb_svc_handle, &image_meta_record,
MINFO_WEB);
if (ret < 0) {
mb_svc_debug
strncpy(video_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
ret =
- mb_svc_insert_record_video_meta(&video_meta_record,
+ mb_svc_insert_record_video_meta(mb_svc_handle, &video_meta_record,
MINFO_WEB);
if (ret < 0) {
mb_svc_debug
return ret;
}
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_add_web_media_with_type(const char *cluster_id, const char *http_url,
- const char *file_name,
- minfo_file_type content_type,
- const char *thumb_path)
+minfo_add_web_media_with_type(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_id,
+ const char *http_url,
+ const char *file_name,
+ minfo_file_type content_type,
+ const char *thumb_path)
{
int ret = -1;
mb_svc_media_record_s media_record = {"",};
mb_svc_video_meta_record_s video_meta_record = {0,};
mb_svc_folder_record_s folder_record = {"",};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("http_url: %s", http_url);
mb_svc_debug("file_name: %s", file_name);
- ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &folder_record);
if ((ret < 0) || (folder_record.storage_type != MINFO_WEB)) {
mb_svc_debug("get web folder record by id failed\n");
return ret;
}
ret =
- mb_svc_get_media_record_by_fid_name(cluster_id, file_name,
+ mb_svc_get_media_record_by_fid_name(mb_svc_handle, cluster_id, file_name,
&media_record);
if (ret < 0) {
strncpy(media_record.folder_uuid, cluster_id, MB_SVC_UUID_LEN_MAX + 1);
media_record.content_type = content_type;
media_record.rate = MB_SVC_DEFAULT;
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_insert_record_media(&media_record, MINFO_WEB);
+ ret = mb_svc_insert_record_media(mb_svc_handle, &media_record, MINFO_WEB);
if (ret < 0) {
mb_svc_debug
("insert new media record failed..Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
image_meta_record.latitude = MINFO_DEFAULT_GPS;
ret =
- mb_svc_insert_record_image_meta(&image_meta_record,
+ mb_svc_insert_record_image_meta(mb_svc_handle, &image_meta_record,
MINFO_WEB);
if (ret < 0) {
mb_svc_debug
("minfo_add_web_media, insert new image_meta record failed..Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
}
strncpy(video_meta_record.media_uuid, media_record.media_uuid, MB_SVC_UUID_LEN_MAX + 1);
ret =
- mb_svc_insert_record_video_meta(&video_meta_record,
+ mb_svc_insert_record_video_meta(mb_svc_handle, &video_meta_record,
MINFO_WEB);
/* Couldn't extract meta information from an web video, which hasn't downloaded yet */
if (ret < 0) {
mb_svc_debug
("minfo_add_web_media, insert new video_meta record failed..Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
+
+ return MB_SVC_ERROR_NONE;
+ }
+
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int
+minfo_move_media_start(MediaSvcHandle *mb_svc_handle, int trans_count)
+{
+ mb_svc_debug("Transaction count : %d", trans_count);
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (trans_count <= 1) {
+ mb_svc_debug("Trans count should be bigger than 1");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ g_trans_move_cnt = trans_count;
+ g_cur_trans_move_cnt = 0;
+
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int
+minfo_move_media_end(MediaSvcHandle *mb_svc_handle)
+{
+ mb_svc_debug("");
+
+ if (g_cur_trans_move_cnt > 0) {
+ int ret = -1;
+
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+
+ g_cur_trans_move_cnt = 0;
+ g_trans_move_cnt = 1;
+
+ return ret;
+ }
+
+ ret = mb_svc_move_items(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_move_items failed...");
return ret;
}
- return 0;
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug
+ ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+
+ g_cur_trans_move_cnt = 0;
+ g_trans_move_cnt = 1;
+
+ return ret;
+ }
}
- return 0;
+ g_cur_trans_move_cnt = 0;
+ g_trans_move_cnt = 1;
+
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_move_media(const char *old_file_url, const char *new_file_url,
- minfo_file_type content_type)
+minfo_move_media(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_url,
+ const char *new_file_url,
+ minfo_file_type content_type)
{
mb_svc_debug("");
bool is_renamed = false;
bool is_moved = false;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (old_file_url == NULL || new_file_url == NULL) {
mb_svc_debug("old_file_url == NULL || new_file_url == NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
+
_mb_svc_get_file_parent_path(old_file_url, old_dir_full_path);
_mb_svc_get_file_parent_path(new_file_url, new_dir_full_path);
MB_SVC_FILE_PATH_LEN_MAX) == 0)
&& (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
!= 0)) {
- is_renamed = TRUE;
+ is_renamed = true;
} else
if ((strncmp
(old_dir_full_path, new_dir_full_path,
&&
(strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
== 0)) {
- is_moved = TRUE;
- } else
- if ((strncmp
- (old_dir_full_path, new_dir_full_path,
- MB_SVC_FILE_PATH_LEN_MAX) != 0)
- &&
- (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX)
- != 0)) {
- is_moved = TRUE;
+ is_moved = true;
} else {
+ if ((strncmp(old_dir_full_path, new_dir_full_path, MB_SVC_FILE_PATH_LEN_MAX) != 0)
+ && (strncmp(old_file_name, new_file_name, MB_SVC_FILE_NAME_LEN_MAX) != 0)) {
+ is_moved = true;
+ } else {
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (g_trans_move_cnt == 1) {
+ if (is_renamed) {
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+ return ret;
+ }
+
+ ret =
+ mb_svc_rename_file(mb_svc_handle, old_file_url, new_file_url, content_type, thumb_path);
+
+ if (ret < 0) {
+ mb_svc_debug
+ ("file rename failed.. Now start to rollback\n");
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
+
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug
+ ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
+
+ return MB_SVC_ERROR_NONE;
+ }
+
+ if (is_moved) {
+ ret = mb_svc_move_file(mb_svc_handle, old_file_url, new_file_url, content_type, thumb_path);
+ if (ret < 0) {
+ mb_svc_debug
+ ("file move failed.. Now start to rollback\n");
+ return ret;
+ } else {
+ mb_svc_debug("move success");
+ return MB_SVC_ERROR_NONE;
+ }
+ }
+ }
+
+ if (g_trans_move_cnt == 1 && is_renamed) {
+ mb_svc_debug("Move batch job doesn't support renaming file");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- if (is_moved) {
- ret =
- mb_svc_move_file(old_file_url, new_file_url, content_type,
- thumb_path);
+ if (g_cur_trans_move_cnt < g_trans_move_cnt) {
+ ret = mb_svc_move_file_batch(mb_svc_handle, old_file_url, new_file_url, content_type, thumb_path);
if (ret < 0) {
- mb_svc_debug
- ("file move failed.. Now start to rollback\n");
+ mb_svc_debug("mb_svc_move_file_batch failed : %d\n", ret);
return ret;
- } else {
- mb_svc_debug("move success");
- return 0;
}
- }
- ret = mb_svc_sqlite3_begin_trans();
- if (ret < 0) {
- mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
- return ret;
+ g_cur_trans_move_cnt++;
}
- if (is_renamed) {
- ret =
- mb_svc_rename_file(old_file_url, new_file_url, content_type,
- thumb_path);
+ if (g_cur_trans_move_cnt == g_trans_move_cnt) {
+ ret = mb_svc_move_file_batch(mb_svc_handle, old_file_url, new_file_url, content_type, thumb_path);
if (ret < 0) {
- mb_svc_debug
- ("file rename failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_debug("mb_svc_move_file_batch failed : %d\n", ret);
return ret;
}
- }
- ret = mb_svc_sqlite3_commit_trans();
- if (ret < 0) {
- mb_svc_debug
- ("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
- return ret;
+ g_cur_trans_move_cnt = 0;
+
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
+ return ret;
+ }
+
+ ret = mb_svc_move_items(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_move_items failed.. Now start to rollback\n");
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
+
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
+ if (ret < 0) {
+ mb_svc_debug("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
+ return ret;
+ }
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_copy_media(const char *old_file_url, const char *new_file_url,
- minfo_file_type content_type)
+minfo_copy_media(MediaSvcHandle *mb_svc_handle,
+ const char *old_file_url,
+ const char *new_file_url,
+ minfo_file_type content_type)
{
int ret = -1;
char thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (old_file_url == NULL || new_file_url == NULL) {
mb_svc_debug("old_file_url == NULL || new_file_url == NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_copy_file(old_file_url, new_file_url, content_type, thumb_path);
+ ret = mb_svc_copy_file(mb_svc_handle, old_file_url, new_file_url, content_type, thumb_path);
if (ret < 0) {
mb_svc_debug("file copy failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
return ret;
}
-EXPORT_API int minfo_update_media_name(const char *media_id, const char *new_name)
+EXPORT_API int minfo_update_media_name(MediaSvcHandle *mb_svc_handle, const char *media_id, const char *new_name)
{
int ret = -1;
mb_svc_media_record_s media_record = {"",};
char new_file_full_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
char dest_thumb_path[MB_SVC_FILE_PATH_LEN_MAX + 1] = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_media_record_by_id(media_id, &media_record);
+ ret = mb_svc_get_media_record_by_id(mb_svc_handle, media_id, &media_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_record_by_id failed: %s\n",
media_id);
}
ret =
- mb_svc_get_folder_record_by_id(media_record.folder_uuid,
+ mb_svc_get_folder_record_by_id(mb_svc_handle, media_record.folder_uuid,
&folder_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_folder_record_by_id failed: %s\n",
strncat(new_file_full_path, new_name,
MB_SVC_FILE_PATH_LEN_MAX - strlen(new_file_full_path));
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
ret =
- mb_svc_rename_file(old_file_full_path, new_file_full_path,
+ mb_svc_rename_file(mb_svc_handle, old_file_full_path, new_file_full_path,
media_record.content_type, dest_thumb_path);
if (ret < 0) {
mb_svc_debug
("mb_svc_rename_file fails.. Now start to rollback");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_update_media_thumb(const char *media_id, const char *thumb_path)
+minfo_update_media_thumb(MediaSvcHandle *mb_svc_handle, const char *media_id, const char *thumb_path)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_update_media_thumb: %s", thumb_path);
- ret = mb_svc_update_thumb_path_by_id(media_id, thumb_path);
+ ret = mb_svc_update_thumb_path_by_id(mb_svc_handle, media_id, thumb_path);
if (ret < 0) {
mb_svc_debug("mb_svc_update_thumb_by_media_id failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_update_media_favorite(const char *media_id, const int favorite_level)
+minfo_update_media_favorite(MediaSvcHandle *mb_svc_handle, const char *media_id, const int favorite_level)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_update_favorite_by_media_id(media_id, favorite_level);
+ ret = mb_svc_update_favorite_by_media_id(mb_svc_handle, media_id, favorite_level);
if (ret < 0) {
mb_svc_debug
("minfo_update_media_favorite, update media record failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-int minfo_update_media_date(const char *media_id, time_t modified_date)
+int minfo_update_media_date(MediaSvcHandle *mb_svc_handle, const char *media_id, time_t modified_date)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (media_id == NULL) {
mb_svc_debug("media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_update_media_date: %s", media_id);
mb_svc_debug("minfo_update_media_date: %d", modified_date);
- ret = mb_svc_update_date_by_id(media_id, modified_date);
+ ret = mb_svc_update_date_by_id(mb_svc_handle, media_id, modified_date);
if (ret < 0) {
mb_svc_debug("mb_svc_update_date_by_media_id failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_cp_media(const char *src_media_id, const char *dst_cluster_id)
+EXPORT_API int minfo_cp_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (src_media_id == NULL || dst_cluster_id == NULL) {
mb_svc_debug("src_media_id == NULL || dst_cluster_id == NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_copy_file_by_id(src_media_id, dst_cluster_id);
+ ret = mb_svc_copy_file_by_id(mb_svc_handle, src_media_id, dst_cluster_id);
if (ret < 0) {
mb_svc_debug("file copy failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
return ret;
}
-EXPORT_API int minfo_mv_media(const char *src_media_id, const char *dst_cluster_id)
+EXPORT_API int minfo_mv_media(MediaSvcHandle *mb_svc_handle, const char *src_media_id, const char *dst_cluster_id)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (src_media_id == NULL || dst_cluster_id == NULL) {
mb_svc_debug("src_media_id == NULL || dst_cluster_id == NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_move_file_by_id(src_media_id, dst_cluster_id);
+ ret = mb_svc_move_file_by_id(mb_svc_handle, src_media_id, dst_cluster_id);
if (ret < 0) {
mb_svc_debug("file move failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
return ret;
}
-EXPORT_API int minfo_add_cluster(const char *cluster_url, char *id, int max_length) /* only for local folder path */
+EXPORT_API int minfo_add_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_url, char *id, int max_length) /* only for local folder path */
{
int ret = -1;
mb_svc_folder_record_s folder_record = {"",};
int folder_modified_date = 0;
int store_type = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_url == NULL || id == NULL) {
mb_svc_debug("cluster_url == NULL || id == NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
("no record in %s, ready insert the folder record into db\n",
cluster_url);
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug
("insert file info into folder table failed\n");
strncpy(id, folder_record.uuid, max_length);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
DEPRECATED_API int
-minfo_add_web_cluster(int sns_type, const char *name, const char *account_id,
- char *id, int max_length)
+minfo_add_web_cluster(MediaSvcHandle *mb_svc_handle,
+ int sns_type,
+ const char *name,
+ const char *account_id,
+ char *id, int max_length)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (name == NULL || account_id == NULL || id == 0) {
mb_svc_debug("the parameters are invalid!\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
folder_record.modified_date = 0;
/* first, check whether the same web cluster has existed. */
- ret = mb_svc_get_web_album_cluster_record(sns_type, name, account_id, NULL, &folder_record);
+ ret = mb_svc_get_web_album_cluster_record(mb_svc_handle, sns_type, name, account_id, NULL, &folder_record);
if (ret == 0) {
strncpy(id, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug("insert record into folder table failed\n");
return ret;
strncpy(id, folder_record.uuid, max_length);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_add_web_cluster_album_id(int sns_type, const char *name,
- const char *account_id, const char *album_id,
- char *id, int max_length)
+minfo_add_web_cluster_album_id(MediaSvcHandle *mb_svc_handle,
+ int sns_type,
+ const char *name,
+ const char *account_id,
+ const char *album_id,
+ char *id, int max_length)
{
int ret = -1;
mb_svc_folder_record_s folder_record = {"",};
folder_record.modified_date = 0;
/* first, check whether the same web cluster has existed. */
- ret = mb_svc_get_web_album_cluster_record(sns_type, name, account_id, album_id, &folder_record);
+ ret = mb_svc_get_web_album_cluster_record(mb_svc_handle, sns_type, name, account_id, album_id, &folder_record);
if (ret == 0) {
strncpy(id, folder_record.uuid, MB_SVC_UUID_LEN_MAX + 1);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
- ret = mb_svc_insert_record_folder(&folder_record);
+ ret = mb_svc_insert_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug("insert record into folder table failed\n");
return ret;
}
strncpy(id, folder_record.uuid, max_length);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_web_cluster(const char *cluster_id)
+EXPORT_API int minfo_delete_web_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id)
{
/* delete id & all media items */
int ret = -1;
mb_svc_folder_record_s folder_record = {"",};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_delete_web_cluster#cluster_id: %s", cluster_id);
- ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &folder_record);
if (ret < 0) {
mb_svc_debug
("minfo_delete_web_cluster: get folder record by id failed\n");
if (folder_record.storage_type == MINFO_WEB) {
- ret = mb_svc_delete_folder(cluster_id, MINFO_WEB);
+ ret = mb_svc_delete_folder(mb_svc_handle, cluster_id, MINFO_WEB);
if (ret < 0) {
mb_svc_debug
("mb_svc_delete_folder: delete web cluster failed..Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
("minfo_delete_web_cluster: the folder is not web folder\n");
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_web_cluster_web_album_id(const char *web_album_id,
- Mcluster **mcluster)
+minfo_get_web_cluster_web_album_id(MediaSvcHandle *mb_svc_handle,
+ const char *web_album_id,
+ Mcluster **mcluster)
{
int ret = 0;
int folder_id = 0;
Mcluster *cluster = NULL;
char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (web_album_id == NULL || *mcluster != NULL) {
mb_svc_debug("web_album_id == NULL || *mcluster != NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_web_cluster_web_album_id#album_id: %s",
web_album_id);
- ret = mb_svc_get_folder_id_by_web_album_id(web_album_id, folder_uuid);
+ ret = mb_svc_get_folder_id_by_web_album_id(mb_svc_handle, web_album_id, folder_uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_get_folder_id_by_web_album_id fails:%s\n",
web_album_id);
return ret;
}
- cluster = minfo_mcluster_new(folder_uuid);
+ cluster = minfo_mcluster_new(mb_svc_handle, folder_uuid);
if (cluster == NULL) {
mb_svc_debug("minfo_mcluster_new: %d\n", folder_id);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
*mcluster = cluster;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_cluster(const char *cluster_id)
+EXPORT_API int minfo_delete_cluster(MediaSvcHandle *mb_svc_handle, const char *cluster_id)
{
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_delete_cluster#cluster_id: %s", cluster_id);
- return mb_svc_delete_folder(cluster_id, MINFO_SYSTEM);
+ return mb_svc_delete_folder(mb_svc_handle, cluster_id, MINFO_SYSTEM);
}
EXPORT_API int
-minfo_update_cluster_name(const char *cluster_id, const char *new_name)
+minfo_update_cluster_name(MediaSvcHandle *mb_svc_handle, const char *cluster_id, const char *new_name)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL || new_name == NULL) {
mb_svc_debug("cluster_id == NULL || new_name == NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_update_cluster_name(cluster_id, new_name);
+ ret = mb_svc_update_cluster_name(mb_svc_handle, cluster_id, new_name);
if (ret < 0) {
mb_svc_debug
("mb_svc_update_cluster_name failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
}
EXPORT_API int
-minfo_update_cluster_date(const char *cluster_id, time_t modified_date)
+minfo_update_cluster_date(MediaSvcHandle *mb_svc_handle, const char *cluster_id, time_t modified_date)
{
int ret = -1;
mb_svc_folder_record_s folder_record;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_update_cluster_date#modified_date: %d",
modified_date);
- ret = mb_svc_get_folder_record_by_id(cluster_id, &folder_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &folder_record);
if (ret < 0) {
mb_svc_debug
("minfo_update_cluster_date: no folder record matched with the folder id\n");
folder_record.modified_date = modified_date;
- ret = mb_svc_update_record_folder(&folder_record);
+ ret = mb_svc_update_record_folder(mb_svc_handle, &folder_record);
if (ret < 0) {
mb_svc_debug
("minfo_update_cluster_date: update cluster date failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_add_bookmark(const char *media_id, const int position,
+minfo_add_bookmark(MediaSvcHandle *mb_svc_handle, const char *media_id, const int position,
const char *thumb_path)
{
int ret = -1;
mb_svc_bookmark_record_s bookmark_record = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (thumb_path == NULL || media_id == NULL) {
mb_svc_debug("Thumb path or media_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
bookmark_record.marked_time = position;
strncpy(bookmark_record.thumbnail_path, thumb_path,
MB_SVC_FILE_PATH_LEN_MAX + 1);
- ret = mb_svc_insert_record_bookmark(&bookmark_record);
+ ret = mb_svc_insert_record_bookmark(mb_svc_handle, &bookmark_record);
if (ret < 0) {
mb_svc_debug("mb_svc_insert_record_bookmark fail\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_bookmark(const int bookmark_id)
+EXPORT_API int minfo_delete_bookmark(MediaSvcHandle *mb_svc_handle, const int bookmark_id)
{
int ret = -1;
mb_svc_debug("minfo_delete_bookmark#bookmark_id: %d", bookmark_id);
- ret = mb_svc_delete_record_bookmark_by_id(bookmark_id);
+ ret = mb_svc_delete_record_bookmark_by_id(mb_svc_handle, bookmark_id);
if (ret < 0) {
mb_svc_debug
("minfo_delete_bookmark: delete matched bookmark record by id failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_add_streaming(const char *title, const char *url, uint duration,
+minfo_add_streaming(MediaSvcHandle *mb_svc_handle, const char *title, const char *url, uint duration,
const char *thumb_path, int *id)
{
/* "> 0 : SuccessOthers : fail" */
mb_svc_web_streaming_record_s webstreaming_record = { 0 };
char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
mb_svc_debug("minfo_add_streaming#title: %s", title);
mb_svc_debug("minfo_add_streaming#url: %s", url);
mb_svc_debug("minfo_add_streaming#duration: %d", duration);
mb_svc_debug("minfo_add_streaming#thumb_path: %s", thumb_path);
- ret = mb_svc_get_web_streaming_folder_uuid(folder_uuid, sizeof(folder_uuid));
+ ret = mb_svc_get_web_streaming_folder_uuid(mb_svc_handle, folder_uuid, sizeof(folder_uuid));
if (ret < 0) {
mb_svc_debug("not add web streaming foler yet, so insert it.");
- ret = mb_svc_add_web_streaming_folder(folder_uuid);
+ ret = mb_svc_add_web_streaming_folder(mb_svc_handle, folder_uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_add_web_streaming_folder failed : %d", ret);
return ret;
strncpy(webstreaming_record.url, url, MB_SVC_FILE_PATH_LEN_MAX + 1);
strncpy(webstreaming_record.thumb_path, thumb_path,
MB_SVC_FILE_PATH_LEN_MAX + 1);
- ret = mb_svc_insert_record_web_streaming(&webstreaming_record);
+ ret = mb_svc_insert_record_web_streaming(mb_svc_handle, &webstreaming_record);
if (ret < 0) {
return ret;
}
mb_svc_debug("minfo_add_streaming: new webstreaming record id is %d\n",
webstreaming_record._id);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_streaming(int streaming_id)
+EXPORT_API int minfo_delete_streaming(MediaSvcHandle *mb_svc_handle, int streaming_id)
{
int ret = -1;
mb_svc_web_streaming_record_s webstreaming_record = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
mb_svc_debug("minfo_delete_streaming#streaming_id: %d", streaming_id);
ret =
- mb_svc_get_web_streaming_record_by_id(streaming_id,
+ mb_svc_get_web_streaming_record_by_id(mb_svc_handle, streaming_id,
&webstreaming_record);
if (ret < 0) {
mb_svc_debug
return ret;
}
/* delete webstreaming record */
- ret = mb_svc_delete_record_web_streaming_by_id(webstreaming_record._id);
+ ret = mb_svc_delete_record_web_streaming_by_id(mb_svc_handle, webstreaming_record._id);
if (ret < 0) {
mb_svc_debug
("minfo_delete_streaming, delete webstreaming record by _id failed\n");
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_thumb_path(const char *file_url, char *thumb_path,
+minfo_get_thumb_path(MediaSvcHandle *mb_svc_handle, const char *file_url, char *thumb_path,
size_t max_thumb_path)
{
int err = -1;
char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
Mitem *item = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL || thumb_path == NULL || max_thumb_path <= 0) {
mb_svc_debug
("file_url == NULL || thumb_path == NULL || max_thumb_path <= 0 \n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- err = mb_svc_get_media_id_by_full_path(file_url, media_uuid);
+ err = mb_svc_get_media_id_by_full_path(mb_svc_handle, file_url, media_uuid);
if (err < 0) {
mb_svc_debug("There is no ( %s ) file in DB", file_url);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- item = minfo_media_item_new(media_uuid, NULL);
+ item = minfo_media_item_new(mb_svc_handle, media_uuid, NULL);
if (item == NULL) {
mb_svc_debug("minfo_media_item_new fails: %s\n", file_url);
minfo_destroy_mtype_item(item);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_thumb_path_for_video(const char *file_url, char *thumb_path,
+minfo_get_thumb_path_for_video(MediaSvcHandle *mb_svc_handle, const char *file_url, char *thumb_path,
size_t max_thumb_path)
{
int err = -1;
char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
Mitem *item = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL || thumb_path == NULL || max_thumb_path <= 0) {
mb_svc_debug
("file_url == NULL || thumb_path == NULL || max_thumb_path <= 0 \n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- err = mb_svc_get_media_id_by_full_path(file_url, media_uuid);
+ err = mb_svc_get_media_id_by_full_path(mb_svc_handle, file_url, media_uuid);
if (err < 0) {
mb_svc_debug("There is no ( %s ) file in DB", file_url);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- item = minfo_media_item_new(media_uuid, NULL);
+ item = minfo_media_item_new(mb_svc_handle, media_uuid, NULL);
if (item == NULL) {
mb_svc_debug("minfo_media_item_new fails: %s\n", file_url);
}
minfo_destroy_mtype_item(item);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int minfo_destroy_mtype_item(void *item)
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int minfo_check_cluster_exist(MediaSvcHandle *mb_svc_handle, const char *path)
+{
+ mb_svc_debug("");
+ int err = -1;
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (path == NULL) {
+ mb_svc_debug("path is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ err = mb_svc_check_exist_by_path(mb_svc_handle, path, MB_SVC_TBL_NAME_FOLDER);
+ if (err < 0) {
+ mb_svc_debug("mb_svc_check_exist_by_path failed : %d", err);
+ return err;
+ }
+
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int minfo_check_item_exist(MediaSvcHandle *mb_svc_handle, const char *path)
+{
+ mb_svc_debug("");
+ int err = -1;
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (path == NULL) {
+ mb_svc_debug("path is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ err = mb_svc_check_exist_by_path(mb_svc_handle, path, MB_SVC_TBL_NAME_MEDIA);
+ if (err < 0) {
+ mb_svc_debug("mb_svc_check_exist_by_path failed : %d", err);
+ return err;
+ }
+
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_item_by_id(const char *media_id, Mitem **mitem)
+EXPORT_API int minfo_get_item_by_id(MediaSvcHandle *mb_svc_handle, const char *media_id, Mitem **mitem)
{
Mitem *item = NULL;
- item = minfo_media_item_new(media_id, NULL);
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ item = minfo_media_item_new(mb_svc_handle, media_id, NULL);
if (item == NULL) {
mb_svc_debug("minfo_mitem_new: %s\n", media_id);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
*mitem = item;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_item(const char *file_url, Mitem ** mitem)
+EXPORT_API int minfo_get_item(MediaSvcHandle *mb_svc_handle, const char *file_url, Mitem ** mitem)
{
int ret = 0;
Mitem *item = NULL;
char _media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (file_url == NULL) {
mb_svc_debug("file_url == NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
mb_svc_debug("minfo_get_item#file_url: %s", file_url);
- ret = mb_svc_get_media_id_by_full_path(file_url, _media_uuid);
+ ret = mb_svc_get_media_id_by_full_path(mb_svc_handle, file_url, _media_uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_id_by_full_path fails:%s\n",
return ret;
}
- item = minfo_media_item_new(_media_uuid, NULL);
+ item = minfo_media_item_new(mb_svc_handle, _media_uuid, NULL);
if (item == NULL) {
mb_svc_debug("minfo_mitem_new: %s\n", file_url);
}
*mitem = item;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_item_by_http_url(const char *http_url, Mitem ** mitem)
+EXPORT_API int minfo_get_item_by_http_url(MediaSvcHandle *mb_svc_handle, const char *http_url, Mitem ** mitem)
{
int ret = 0;
char media_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
Mitem *item = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (http_url == NULL) {
mb_svc_debug("http_url == NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_get_item_by_http_url#http_url: %s", http_url);
- ret = mb_svc_get_media_id_by_http_url(http_url, media_uuid);
+ ret = mb_svc_get_media_id_by_http_url(mb_svc_handle, http_url, media_uuid);
if (ret < 0) {
mb_svc_debug("mb_svc_get_media_id_by_http_url fails:%s\n",
return ret;
}
- item = minfo_media_item_new(media_uuid, NULL);
+ item = minfo_media_item_new(mb_svc_handle, media_uuid, NULL);
if (item == NULL) {
mb_svc_debug("minfo_mitem_new: %s\n", http_url);
}
*mitem = item;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_cluster(const char *cluster_url, const char *cluster_id,
- Mcluster **mcluster)
+minfo_get_cluster(MediaSvcHandle *mb_svc_handle,
+ const char *cluster_url,
+ const char *cluster_id,
+ Mcluster **mcluster)
{
int ret = 0;
char folder_uuid[MB_SVC_UUID_LEN_MAX + 1] = {0,};
char *_uuid = NULL;
Mcluster *cluster = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (*mcluster != NULL) {
mb_svc_debug("cluster_url == NULL || *mcluster != NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
if (cluster_url != NULL) {
mb_svc_debug("minfo_get_item#file_url: %d", cluster_url);
ret =
- mb_svc_get_folder_id_by_full_path(cluster_url, folder_uuid, sizeof(folder_uuid));
+ mb_svc_get_folder_id_by_full_path(mb_svc_handle, cluster_url, folder_uuid, sizeof(folder_uuid));
if (ret < 0) {
mb_svc_debug
("mb_svc_get_folder_id_by_full_path fails:%s\n",
_uuid = folder_uuid;
}
- cluster = minfo_mcluster_new(_uuid);
+ cluster = minfo_mcluster_new(mb_svc_handle, _uuid);
if (cluster == NULL) {
mb_svc_debug("minfo_mcluster_new: %s\n", folder_uuid);
return MB_SVC_ERROR_INVALID_PARAMETER;
}
*mcluster = cluster;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_get_cluster_id_by_url(const char *url, char *cluster_id, int max_length)
+EXPORT_API int minfo_get_cluster_id_by_url(MediaSvcHandle *mb_svc_handle, const char *url, char *cluster_id, int max_length)
{
- return mb_svc_get_folder_id_by_full_path(url, cluster_id, max_length);
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ return mb_svc_get_folder_id_by_full_path(mb_svc_handle, url, cluster_id, max_length);
}
EXPORT_API int
-minfo_get_cluster_name_by_id(const char *cluster_id, char *cluster_name, int max_length)
+minfo_get_cluster_name_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *cluster_name, int max_length)
{
- return mb_svc_get_folder_name_by_id(cluster_id, cluster_name,
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ return mb_svc_get_folder_name_by_id(mb_svc_handle, cluster_id, cluster_name,
max_length);
}
EXPORT_API int
-minfo_get_cluster_fullpath_by_id(const char *cluster_id, char *folder_path,
+minfo_get_cluster_fullpath_by_id(MediaSvcHandle *mb_svc_handle, const char *cluster_id, char *folder_path,
int max_length)
{
int ret = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
ret =
- mb_svc_get_folder_fullpath_by_folder_id(cluster_id, folder_path,
+ mb_svc_get_folder_fullpath_by_folder_id(mb_svc_handle, cluster_id, folder_path,
max_length);
if (ret < 0) {
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_set_cluster_lock_status(const char *cluster_id, int lock_status)
+minfo_set_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int lock_status)
{
mb_svc_debug("");
int ret = 0;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
ret =
- mb_svc_update_album_lock_status(cluster_id, lock_status,
+ mb_svc_update_album_lock_status(mb_svc_handle, cluster_id, lock_status,
MINFO_PHONE);
return ret;
}
EXPORT_API int
-minfo_get_cluster_lock_status(const char *cluster_id, int *lock_status)
+minfo_get_cluster_lock_status(MediaSvcHandle *mb_svc_handle, const char *cluster_id, int *lock_status)
{
mb_svc_debug("");
int ret = 0;
mb_svc_folder_record_s record;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (cluster_id == NULL) {
mb_svc_debug("cluster_id is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_folder_record_by_id(cluster_id, &record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, cluster_id, &record);
if (ret != 0) {
mb_svc_debug("minfo_get_cluster_lock_status fails");
*lock_status = record.lock_status;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_media_path(minfo_store_type storage_type, char *media_path,
- size_t max_media_path)
+minfo_get_media_path(
+ minfo_store_type storage_type,
+ char *media_path,
+ size_t max_media_path)
{
mb_svc_debug("");
int len = 0;
media_path[max_media_path - 1] = '\0';
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_set_db_valid(const minfo_store_type storage_type, int valid)
+minfo_set_db_valid(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type, int valid)
{
mb_svc_debug("storage:%d", storage_type);
int ret;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
mb_svc_debug("storage type should be phone or mmc");
return MB_SVC_ERROR_INVALID_PARAMETER;
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_set_media_records_as_valid(storage_type, valid);
+ ret = mb_svc_set_media_records_as_valid(mb_svc_handle, storage_type, valid);
if (ret < 0) {
mb_svc_debug
("mb_svc_set_media_records_as_valid failed..Now Start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_set_item_valid_start(int trans_count)
+minfo_set_item_valid_start(MediaSvcHandle *mb_svc_handle, int trans_count)
{
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
mb_svc_debug("Transaction count : %d", trans_count);
g_trans_valid_cnt = trans_count;
g_cur_trans_valid_cnt = 0;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_set_item_valid_end()
+minfo_set_item_valid_end(MediaSvcHandle *mb_svc_handle)
{
mb_svc_debug("");
if (g_cur_trans_valid_cnt > 0) {
int ret = -1;
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_set_item_as_valid();
+ ret = mb_svc_set_item_as_valid(mb_svc_handle);
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
g_cur_trans_valid_cnt = 0;
g_trans_valid_cnt = 1;
g_cur_trans_valid_cnt = 0;
g_trans_valid_cnt = 1;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_set_item_valid(const minfo_store_type storage_type, const char *full_path,
- int valid)
+minfo_set_item_valid(MediaSvcHandle *mb_svc_handle,
+ const minfo_store_type storage_type,
+ const char *full_path,
+ int valid)
{
mb_svc_debug("storage:%d", storage_type);
int ret;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
mb_svc_debug("storage type should be phone or mmc");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
if (g_cur_trans_valid_cnt < g_trans_valid_cnt) {
- ret = mb_svc_set_item_as_valid_sql_add(full_path, valid);
+ ret = mb_svc_set_item_as_valid_sql_add(mb_svc_handle, full_path, valid);
if (ret < 0) {
mb_svc_debug("mb_svc_set_item_as_valid_sql_add failed\n");
return ret;
g_cur_trans_valid_cnt++;
- return 0;
+ return MB_SVC_ERROR_NONE;
}
if (g_cur_trans_valid_cnt == g_trans_valid_cnt) {
- ret = mb_svc_set_item_as_valid_sql_add(full_path, valid);
+ ret = mb_svc_set_item_as_valid_sql_add(mb_svc_handle, full_path, valid);
if (ret < 0) {
mb_svc_debug("mb_svc_set_item_as_valid_sql_add failed\n");
return ret;
g_cur_trans_valid_cnt = 0;
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_set_item_as_valid();
+ ret = mb_svc_set_item_as_valid(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_set_item_as_valid failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_delete_invalid_media_records(const minfo_store_type storage_type)
+minfo_delete_all_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type)
{
mb_svc_debug("storage:%d", storage_type);
int ret;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
mb_svc_debug("storage type should be phone or mmc");
return MB_SVC_ERROR_INVALID_PARAMETER;
start = mediainfo_get_debug_time();
#endif
- ret = mb_svc_delete_invalid_media_records(storage_type);
+ ret = mb_svc_delete_all_media_records(mb_svc_handle, storage_type);
if (ret < 0) {
mb_svc_debug
- ("mb_svc_delete_invalid_media_records failed..Now Start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ ("mb_svc_delete_all_media_records failed..: %d", ret);
return ret;
}
mediainfo_print_debug_time_ex(start, end, __FUNCTION__, "time");
#endif
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_delete_tag(const char *media_id, const char *tag_name)
+EXPORT_API int
+minfo_delete_invalid_media_records(MediaSvcHandle *mb_svc_handle, const minfo_store_type storage_type)
+{
+ mb_svc_debug("storage:%d", storage_type);
+ int ret;
+
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+ if (storage_type != MINFO_PHONE && storage_type != MINFO_MMC) {
+ mb_svc_debug("storage type should be phone or mmc");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
+#ifdef _PERFORMANCE_CHECK_
+ long start = 0L, end = 0L;
+ start = mediainfo_get_debug_time();
+#endif
+
+ ret = mb_svc_delete_invalid_media_records(mb_svc_handle, storage_type);
+ if (ret < 0) {
+ mb_svc_debug
+ ("mb_svc_delete_invalid_media_records failed.: %d", ret);
+ return ret;
+ }
+
+#ifdef _PERFORMANCE_CHECK_
+ end = mediainfo_get_debug_time();
+ mediainfo_print_debug_time_ex(start, end, __FUNCTION__, "time");
+#endif
+
+ return MB_SVC_ERROR_NONE;
+}
+
+EXPORT_API int minfo_delete_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char *tag_name)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
#ifdef _PERFORMANCE_CHECK_
long start = mediainfo_get_debug_time();
#endif
- ret = mb_svc_sqlite3_begin_trans();
+ ret = mb_svc_sqlite3_begin_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug("mb_svc_sqlite3_begin_trans failed\n");
return ret;
}
- ret = mb_svc_delete_record_tag(tag_name, media_id);
+ ret = mb_svc_delete_record_tag(mb_svc_handle, tag_name, media_id);
if (ret < 0) {
mb_svc_debug
("mb_svc_delete_record_tag fail..Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
- ret = mb_svc_sqlite3_commit_trans();
+ ret = mb_svc_sqlite3_commit_trans(mb_svc_handle);
if (ret < 0) {
mb_svc_debug
("mb_svc_sqlite3_commit_trans failed.. Now start to rollback\n");
- mb_svc_sqlite3_rollback_trans();
+ mb_svc_sqlite3_rollback_trans(mb_svc_handle);
return ret;
}
#endif
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_rename_tag(const char *src_tagname, const char *dst_tag_name)
+minfo_rename_tag(MediaSvcHandle *mb_svc_handle, const char *src_tagname, const char *dst_tag_name)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (src_tagname == NULL || dst_tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_rename_tag#src_tagname: %s!", src_tagname);
mb_svc_debug("minfo_rename_tag#dst_tag_name: %s!", dst_tag_name);
- ret = mb_svc_rename_record_tag(src_tagname, dst_tag_name);
+ ret = mb_svc_rename_record_tag(mb_svc_handle, src_tagname, dst_tag_name);
sqlite3_free(src_tag_escape);
sqlite3_free(dst_tag_escape);
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_rename_tag_by_id(const char *media_id, const char *src_tagname,
- const char *dst_tag_name)
+minfo_rename_tag_by_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ const char *src_tagname,
+ const char *dst_tag_name)
{
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (src_tagname == NULL || dst_tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("dst_tag_name: %s!", dst_tag_name);
ret =
- mb_svc_rename_record_tag_by_id(media_id, src_tagname, dst_tag_name);
+ mb_svc_rename_record_tag_by_id(mb_svc_handle, media_id, src_tagname, dst_tag_name);
sqlite3_free(src_tag_escape);
sqlite3_free(dst_tag_escape);
return ret;
}
- return 0;
+ return MB_SVC_ERROR_NONE;
}
-EXPORT_API int minfo_add_tag(const char *media_id, const char *tag_name)
+EXPORT_API int minfo_add_tag(MediaSvcHandle *mb_svc_handle, const char *media_id, const char *tag_name)
{
int ret = -1;
bool tag_exist = FALSE;
mb_svc_tag_record_s tag_record = { 0 };
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("minfo_add_tag#media_id: %s!", media_id);
mb_svc_debug("minfo_add_tag#tag_name: %s!", tag_name);
- if ((tag_record._id = mb_svc_get_tagid_by_tagname(tag_name)) > 0) {
+ if ((tag_record._id = mb_svc_get_tagid_by_tagname(mb_svc_handle, tag_name)) > 0) {
mb_svc_debug("This tagname %s is exist");
tag_exist = TRUE;
}
strncpy(tag_record.tag_name, tag_name, MB_SVC_ARRAY_LEN_MAX + 1);
if (!tag_exist) {
- ret = mb_svc_insert_record_tag(&tag_record);
+ ret = mb_svc_insert_record_tag(mb_svc_handle, &tag_record);
if (ret < 0) {
mb_svc_debug("mb_svc_insert_record_tag fail\n");
return ret;
if (media_id != NULL) {
ret =
- mb_svc_insert_record_tag_map(media_id,
+ mb_svc_insert_record_tag_map(mb_svc_handle, media_id,
tag_record._id);
if (ret < 0) {
mb_svc_debug("mb_svc_insert_record_tag_map fail\n");
double tag = ((double)(end - start) / (double)CLOCKS_PER_SEC);
mb_svc_debug("Insert Tag : %f", tag);
#endif
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_media_list_by_tagname(const char *tag_name, bool with_meta,
- minfo_item_ite_cb func, void *user_data)
+minfo_get_media_list_by_tagname(MediaSvcHandle *mb_svc_handle,
+ const char *tag_name,
+ bool with_meta,
+ minfo_item_ite_cb func,
+ void *user_data)
{
mb_svc_debug("");
int err = 0;
Mitem *mitem = NULL;
char *tag_name_escape_char = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("tag_name:%s", tag_name);
tag_name_escape_char = sqlite3_mprintf("%q", tag_name);
- err = mb_svc_tag_iter_start(tag_name_escape_char, NULL, &mb_svc_iterator);
+ err = mb_svc_tag_iter_start(mb_svc_handle, tag_name_escape_char, NULL, &mb_svc_iterator);
sqlite3_free(tag_name_escape_char);
if (err < 0) {
record_cnt++;
- mitem = minfo_media_item_new(tag_record.media_uuid, NULL);
+ mitem = minfo_media_item_new(mb_svc_handle, tag_record.media_uuid, NULL);
if (with_meta && mitem) {
- mitem->meta_info = minfo_mmeta_new(mitem->uuid, NULL);
+ mitem->meta_info = minfo_mmeta_new(mb_svc_handle, mitem->uuid, NULL);
}
if (mitem) {
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_media_list_by_tagname_with_filter(const char *tag_name,
- minfo_tag_filter filter,
- minfo_item_ite_cb func,
- void *user_data)
+minfo_get_media_list_by_tagname_with_filter(MediaSvcHandle *mb_svc_handle,
+ const char *tag_name,
+ minfo_tag_filter filter,
+ minfo_item_ite_cb func,
+ void *user_data)
{
mb_svc_debug("");
int err = 0;
Mitem *mitem = NULL;
char *tag_name_escape_char = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (tag_name == NULL) {
mb_svc_debug("tag_name is NULL!");
return MB_SVC_ERROR_INVALID_PARAMETER;
mb_svc_debug("tag_name:%s", tag_name);
tag_name_escape_char = sqlite3_mprintf("%q", tag_name);
err =
- mb_svc_tag_iter_with_filter_start(tag_name_escape_char, filter,
+ mb_svc_tag_iter_with_filter_start(mb_svc_handle, tag_name_escape_char, filter,
&mb_svc_iterator);
sqlite3_free(tag_name_escape_char);
record_cnt++;
- mitem = minfo_media_item_new(tag_record.media_uuid, NULL);
+ mitem = minfo_media_item_new(mb_svc_handle, tag_record.media_uuid, NULL);
if (filter.with_meta && mitem) {
- mitem->meta_info = minfo_mmeta_new(mitem->uuid, NULL);
+ mitem->meta_info = minfo_mmeta_new(mb_svc_handle, mitem->uuid, NULL);
}
if (mitem) {
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_media_count_by_tagname(const char *tag_name, int *count)
+minfo_get_media_count_by_tagname(MediaSvcHandle *mb_svc_handle, const char *tag_name, int *count)
{
mb_svc_debug("");
int ret = -1;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (tag_name == NULL || count == NULL) {
mb_svc_debug("tag_name == NULL || count == NULL\n");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- ret = mb_svc_get_media_count_by_tagname(tag_name, count);
+ ret = mb_svc_get_media_count_by_tagname(mb_svc_handle, tag_name, count);
if (ret < 0) {
mb_svc_debug
("Error: mb_svc_get_media_count_by_tagname failed\n");
}
mb_svc_debug("record count = %d", *count);
- return 0;
+ return MB_SVC_ERROR_NONE;
}
EXPORT_API int
-minfo_get_tag_list_by_media_id(const char *media_id, minfo_tag_ite_cb func,
- void *user_data)
+minfo_get_tag_list_by_media_id(MediaSvcHandle *mb_svc_handle,
+ const char *media_id,
+ minfo_tag_ite_cb func,
+ void *user_data)
{
mb_svc_debug("");
int err = 0;
mb_svc_tag_record_s tag_record = { 0 };
Mtag *i_tag = NULL;
+ if (mb_svc_handle == NULL) {
+ mb_svc_debug("media service handle is NULL");
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+ }
+
if (func == NULL) {
mb_svc_debug("Func is NULL");
return MB_SVC_ERROR_INVALID_PARAMETER;
}
- err = mb_svc_tag_iter_start(NULL, media_id, &mb_svc_iterator);
+ err = mb_svc_tag_iter_start(mb_svc_handle, NULL, media_id, &mb_svc_iterator);
if (err < 0) {
mb_svc_debug("mb-svc iterator start failed");
record_cnt++;
- i_tag = minfo_media_tag_new(-1, &tag_record);
+ i_tag = minfo_media_tag_new(mb_svc_handle, -1, &tag_record);
if (i_tag) {
err =
- mb_svc_get_media_count_by_tagname(i_tag->tag_name,
+ mb_svc_get_media_count_by_tagname(mb_svc_handle, i_tag->tag_name,
&(i_tag->count));
if (err < 0) {
mb_svc_debug
if (record_cnt == 0)
return MB_SVC_ERROR_DB_NO_RECORD;
else
- return 0;
-}
-
-EXPORT_API int
-minfo_extract_thumbnail(const char *media_id, minfo_file_type content_type)
-{
- mb_svc_debug("");
-
- if (media_id == NULL || content_type <= MINFO_ITEM_NONE
- || content_type >= MINFO_ITEM_ALL) {
- mb_svc_debug
- ("media_id == NULL || content_type <= MINFO_ITEM_NONE || content_type >= MINFO_ITEM_ALL");
- return MB_SVC_ERROR_INVALID_PARAMETER;
- }
-
- int err = -1;
- mb_svc_media_record_s media_record = {"",};
-
- err = mb_svc_get_media_record_by_id(media_id, &media_record);
- if (err < 0) {
- mb_svc_debug("mb_svc_get_media_record_by_id failed\n");
- return err;
- }
-
- err =
- _mb_svc_thumb_generate_hash_name(media_record.path,
- media_record.thumbnail_path,
- sizeof(media_record.
- thumbnail_path));
-
- if (err < 0) {
- mb_svc_debug("_mb_svc_thumb_generate_hash_name failed\n");
- return err;
- }
-
- if (content_type == MINFO_ITEM_IMAGE) {
-
- mb_svc_image_meta_record_s img_meta_record = {0,};
- err =
- mb_svc_image_create_thumb_new(media_record.path,
- media_record.thumbnail_path,
- sizeof(media_record.
- thumbnail_path),
- &img_meta_record);
- if (err < 0) {
- mb_svc_debug("mb_svc_image_create_thumb_new fails : %d",
- err);
- return err;
- }
-
- err = mb_svc_update_record_media(&media_record);
- if (err < 0) {
- mb_svc_debug("mb_svc_update_record_media fails : %d",
- err);
- return err;
- }
- /* Update width and heigth to image meta table at this time, because of performance */
- err =
- mb_svc_update_width_and_height(media_record.media_uuid,
- MINFO_ITEM_IMAGE,
- img_meta_record.width,
- img_meta_record.height);
- if (err < 0) {
- mb_svc_debug
- ("mb_svc_update_width_and_height fails : %d", err);
- return err;
- }
-
- } else if (content_type == MINFO_ITEM_VIDEO) {
-
- err =
- mb_svc_video_create_thumb(media_record.path,
- media_record.thumbnail_path,
- sizeof(media_record.
- thumbnail_path));
- if (err < 0) {
- mb_svc_debug("mb_svc_video_create_thumb fails : %d",
- err);
- return err;
- }
-
- } else {
- mb_svc_debug("This is not image and not video");
- return MB_SVC_ERROR_INVALID_PARAMETER;
- }
-
- return 0;
+ return MB_SVC_ERROR_NONE;
}
#include "minfo-bookmark.h"
#include "media-svc-api.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
#include <string.h>
static void _minfo_mbookmark_init(Mbookmark *mbookmark);
-int minfo_mbookmark_load(Mbookmark *mbookmark)
+int minfo_mbookmark_load(MediaSvcHandle *mb_svc_handle, Mbookmark *mbookmark)
{
mb_svc_bookmark_record_s bookmark_record = { 0 };
int ret = 0;
int length = 0;
ret =
- mb_svc_get_bookmark_record_by_id(mbookmark->_id, &bookmark_record);
+ mb_svc_get_bookmark_record_by_id(mb_svc_handle, mbookmark->_id, &bookmark_record);
if (ret < 0) {
mb_svc_debug("mb_svc_get_bookmark_record_by_id failed");
return ret;
return 0;
}
-Mbookmark *minfo_mbookmark_new(int id)
+Mbookmark *minfo_mbookmark_new(MediaSvcHandle *mb_svc_handle, int id)
{
Mbookmark *bookmark = NULL;
int ret = 0;
_minfo_mbookmark_init(bookmark);
if (id != -1) {
bookmark->_id = id;
- ret = minfo_mbookmark_load(bookmark);
+ ret = minfo_mbookmark_load(mb_svc_handle, bookmark);
if (ret < 0) {
free(bookmark);
return NULL;
#include "minfo-cluster.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
-#include "media-svc-error.h"
+#include "visual-svc-util.h"
+#include "visual-svc-error.h"
#include <string.h>
static void _minfo_mcluster_init(Mcluster *mcluster);
-int minfo_mcluster_load(Mcluster *mcluster)
+int minfo_mcluster_load(MediaSvcHandle *mb_svc_handle, Mcluster *mcluster)
{
mb_svc_folder_record_s fd_record;
int ret = 0;
int length = 0;
- ret = mb_svc_get_folder_record_by_id(mcluster->uuid, &fd_record);
+ ret = mb_svc_get_folder_record_by_id(mb_svc_handle, mcluster->uuid, &fd_record);
if (ret < 0) {
return ret;
}
MB_SVC_FILE_NAME_LEN_MAX);
mcluster->count =
- mb_svc_get_folder_content_count_by_folder_id(mcluster->uuid);
+ mb_svc_get_folder_content_count_by_folder_id(mb_svc_handle, mcluster->uuid);
mcluster->sns_type = fd_record.sns_type;
length = strlen(fd_record.web_account_id) + 1;
return 0;
}
-Mcluster *minfo_mcluster_new(const char *uuid)
+Mcluster *minfo_mcluster_new(MediaSvcHandle *mb_svc_handle, const char *uuid)
{
Mcluster *mcluster = NULL;
int ret = 0;
mcluster->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
strncpy(mcluster->uuid, uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = minfo_mcluster_load(mcluster);
+ ret = minfo_mcluster_load(mb_svc_handle, mcluster);
if (ret < 0) {
minfo_mcluster_destroy(mcluster);
return NULL;
#include "minfo-item.h"
#include "minfo-meta.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
+#include "visual-svc-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
#include <string.h>
static void _minfo_mitem_init(Mitem *mitem);
-static int minfo_mitem_load(Mitem *mitem, mb_svc_media_record_s * p_md_record)
+static int minfo_mitem_load(MediaSvcHandle *mb_svc_handle, Mitem *mitem, mb_svc_media_record_s * p_md_record)
{
mb_svc_media_record_s md_record = {"",};
int ret = 0;
int length = 0;
if (p_md_record == NULL) {
- ret = mb_svc_get_media_record_by_id(mitem->uuid, &md_record);
+ ret = mb_svc_get_media_record_by_id(mb_svc_handle, mitem->uuid, &md_record);
} else {
md_record = *p_md_record;
}
strncpy(mitem->display_name, md_record.display_name, length);
mitem->rate = md_record.rate;
+ mitem->size = md_record.size;
mitem->_reserved = NULL;
return 0;
}
-Mitem *minfo_mitem_new(const char *uuid)
-{
- return minfo_media_item_new(uuid, NULL);
-}
-
-Mitem *minfo_media_item_new(const char *uuid, mb_svc_media_record_s * p_md_record)
+Mitem *minfo_media_item_new(MediaSvcHandle *mb_svc_handle, const char *uuid, mb_svc_media_record_s * p_md_record)
{
Mitem *mitem = NULL;
int ret = 0;
if (p_md_record) {
mitem->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
strncpy(mitem->uuid, p_md_record->media_uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = minfo_mitem_load(mitem, p_md_record);
+ ret = minfo_mitem_load(mb_svc_handle, mitem, p_md_record);
} else if (uuid != NULL) {
mitem->uuid = (char *)malloc(MB_SVC_UUID_LEN_MAX + 1);
strncpy(mitem->uuid, uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = minfo_mitem_load(mitem, NULL);
+ ret = minfo_mitem_load(mb_svc_handle, mitem, NULL);
if (ret < 0) {
free(mitem);
return NULL;
mitem->cluster_uuid = NULL;
mitem->display_name = NULL;
mitem->rate = 0;
+ mitem->size = 0;
mitem->meta_info = NULL;
mitem->_reserved = NULL;
}
*/
#include "minfo-meta.h"
-#include "minfo-api.h"
+#include "visual-svc.h"
#include "minfo-bookmark.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
+#include "visual-svc-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
#include <string.h>
static void _minfo_mmeta_init(Mmeta *mmeta);
-int minfo_mmeta_load(Mmeta *mmeta, mb_svc_media_record_s *p_md_record)
+int minfo_mmeta_load(MediaSvcHandle *mb_svc_handle, Mmeta *mmeta, mb_svc_media_record_s *p_md_record)
{
int ret = -1;
mb_svc_media_record_s media_record = {"",};
if (p_md_record == NULL) {
ret =
- mb_svc_get_media_record_by_id(mmeta->media_uuid,
+ mb_svc_get_media_record_by_id(mb_svc_handle, mmeta->media_uuid,
&media_record);
if (ret < 0) {
mb_svc_debug
if (media_record.content_type == MINFO_ITEM_IMAGE) {
ret =
- mb_svc_get_image_record_by_media_id(mmeta->media_uuid,
+ mb_svc_get_image_record_by_media_id(mb_svc_handle, mmeta->media_uuid,
&image_meta_record);
if (ret < 0) {
return ret;
mmeta->height = image_meta_record.height;
mmeta->datetaken = image_meta_record.datetaken;
- mmeta->image_info = minfo_mimage_new(NULL);
+ mmeta->image_info = minfo_mimage_new(mb_svc_handle, NULL);
if (mmeta->image_info == NULL) {
return MB_SVC_ERROR_INTERNAL;
}
else if (media_record.content_type == MINFO_ITEM_VIDEO) {
ret =
- mb_svc_get_video_record_by_media_id(mmeta->media_uuid,
+ mb_svc_get_video_record_by_media_id(mb_svc_handle, mmeta->media_uuid,
&video_meta_record);
if (ret < 0) {
return ret;
mmeta->height = video_meta_record.height;
mmeta->datetaken = video_meta_record.datetaken;
- mmeta->video_info = minfo_mvideo_new(mmeta->media_uuid);
+ mmeta->video_info = minfo_mvideo_new(mb_svc_handle, mmeta->media_uuid);
if (mmeta->video_info == NULL) {
return MB_SVC_ERROR_INTERNAL;
mmeta->latitude = 0.0f;
}
-Mmeta *minfo_mmeta_new(const char *media_uuid, mb_svc_media_record_s *p_md_record)
+Mmeta *minfo_mmeta_new(MediaSvcHandle *mb_svc_handle, const char *media_uuid, mb_svc_media_record_s *p_md_record)
{
Mmeta *mmeta = NULL;
int ret = 0;
if (p_md_record) {
strncpy(mmeta->media_uuid, p_md_record->media_uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = minfo_mmeta_load(mmeta, p_md_record);
+ ret = minfo_mmeta_load(mb_svc_handle, mmeta, p_md_record);
} else if (media_uuid != NULL) {
strncpy(mmeta->media_uuid, media_uuid, MB_SVC_UUID_LEN_MAX + 1);
- ret = minfo_mmeta_load(mmeta, NULL);
+ ret = minfo_mmeta_load(mb_svc_handle, mmeta, NULL);
if (ret < 0) {
free(mmeta);
return NULL;
return 0;
}
-int minfo_mvideo_load(const char *media_id, Mvideo *mvideo)
+int minfo_mvideo_load(MediaSvcHandle *mb_svc_handle, const char *media_id, Mvideo *mvideo)
{
mb_svc_video_meta_record_s video_meta_record = { 0 };
int ret = 0;
int length = 0;
- ret = mb_svc_get_video_record_by_media_id(media_id, &video_meta_record);
+ ret = mb_svc_get_video_record_by_media_id(mb_svc_handle, media_id, &video_meta_record);
if (ret < 0) {
return ret;
}
memset(mvideo->title, 0x00, length);
strncpy(mvideo->title, video_meta_record.title, length);
+ length = strlen(video_meta_record.genre) + 1;
+ mvideo->genre = (char *)malloc(length);
+ if (mvideo->genre == NULL) {
+ return MB_SVC_ERROR_OUT_OF_MEMORY;
+ }
+ memset(mvideo->genre, 0x00, length);
+ strncpy(mvideo->genre, video_meta_record.genre, length);
+
mvideo->last_played_pos = video_meta_record.last_played_time;
mvideo->duration = video_meta_record.duration;
length);
GList *tmp_list = NULL;
- minfo_get_bookmark_list(media_id, _minfo_bm_ite_fn, &tmp_list);
+ minfo_get_bookmark_list(mb_svc_handle, media_id, _minfo_bm_ite_fn, &tmp_list);
mvideo->bookmarks = tmp_list;
mvideo->album_name = NULL;
mvideo->artist_name = NULL;
mvideo->title = NULL;
+ mvideo->genre = NULL;
mvideo->last_played_pos = 0;
mvideo->duration = 0;
mvideo->web_category = NULL;
mvideo->_reserved = NULL;
}
-Mvideo *minfo_mvideo_new(const char *id)
+Mvideo *minfo_mvideo_new(MediaSvcHandle *mb_svc_handle, const char *id)
{
Mvideo *mvideo = NULL;
int ret = 0;
if (id == NULL) {
_minfo_mvideo_init(mvideo);
} else {
- ret = minfo_mvideo_load(id, mvideo);
+ ret = minfo_mvideo_load(mb_svc_handle, id, mvideo);
if (ret < 0) {
minfo_mvideo_destroy(mvideo);
return NULL;
if (mvideo->title) {
free(mvideo->title);
}
+ if (mvideo->genre) {
+ free(mvideo->genre);
+ }
if (mvideo->web_category) {
free(mvideo->web_category);
}
free(mvideo);
mvideo = NULL;
}
-
}
/*-------------------------mimage--------------------------*/
static void _minfo_mimage_init(Mimage *mimage);
-int minfo_mimage_load(const char *media_id, Mimage *mimage)
+int minfo_mimage_load(MediaSvcHandle *mb_svc_handle, const char *media_id, Mimage *mimage)
{
mb_svc_image_meta_record_s image_meta_record = { 0 };
int ret = 0;
- ret = mb_svc_get_image_record_by_media_id(media_id, &image_meta_record);
+ ret = mb_svc_get_image_record_by_media_id(mb_svc_handle, media_id, &image_meta_record);
if (ret < 0) {
return ret;
}
return 0;
}
-Mimage *minfo_mimage_new(const char *id)
+Mimage *minfo_mimage_new(MediaSvcHandle *mb_svc_handle, const char *id)
{
Mimage *mimage = NULL;
int ret = 0;
if (id == NULL) {
_minfo_mimage_init(mimage);
} else {
- ret = minfo_mimage_load(id, mimage);
+ ret = minfo_mimage_load(mb_svc_handle, id, mimage);
if (ret < 0) {
free(mimage);
return NULL;
#include "minfo-streaming.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
+#include "visual-svc-util.h"
static void _minfo_mstreaming_init(Mstreaming *mstreaming);
#include "minfo-tag.h"
#include "minfo-meta.h"
#include "media-svc-api.h"
-#include "media-svc-util.h"
-#include "media-svc-debug.h"
-#include "media-svc-error.h"
+#include "visual-svc-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
#include <string.h>
-static bool _minfo_mtag_load(Mtag *mtag, mb_svc_tag_record_s *p_tag_record);
-
-static bool _minfo_mtag_load(Mtag *mtag, mb_svc_tag_record_s *p_tag_record)
+static bool _minfo_mtag_load(MediaSvcHandle *mb_svc_handle, Mtag *mtag, mb_svc_tag_record_s *p_tag_record)
{
mb_svc_tag_record_s mtag_record = { 0 };
int ret = 0;
if (p_tag_record == NULL) {
- ret = mb_svc_get_media_tag_by_id(mtag->_id, &mtag_record);
+ ret = mb_svc_get_media_tag_by_id(mb_svc_handle, mtag->_id, &mtag_record);
} else {
mtag_record = *p_tag_record;
}
return 0;
}
-Mtag *minfo_media_tag_new(int id, mb_svc_tag_record_s * p_tag_record)
+Mtag *minfo_media_tag_new(MediaSvcHandle *mb_svc_handle, int id, mb_svc_tag_record_s * p_tag_record)
{
Mtag *mtag = NULL;
int ret = 0;
if (p_tag_record) {
//mtag->media_id = p_tag_record->media_id;
mtag->_id = p_tag_record->_id;
- ret = _minfo_mtag_load(mtag, p_tag_record);
+ ret = _minfo_mtag_load(mb_svc_handle, mtag, p_tag_record);
} else if (id != -1) {
mtag->_id = id;
- ret = _minfo_mtag_load(mtag, NULL);
+ ret = _minfo_mtag_load(mb_svc_handle, mtag, NULL);
if (ret < 0) {
minfo_media_tag_destroy(mtag);
return NULL;
--- /dev/null
+/*
+ * libmedia-service
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "visual-svc-util.h"
+#include "visual-svc-debug.h"
+#include "visual-svc-error.h"
+#include "media-svc-structures.h"
+#include "media-svc-types.h"
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <drm-service.h>
+#include <string.h>
+#include <aul/aul.h>
+
+bool _mb_svc_get_file_display_name(const char *file_path, char *file_name)
+{
+ char *result = NULL;
+
+ if ((result = strrchr(file_path, '/'))) {
+ strncpy(file_name, (result + 1), MB_SVC_FILE_NAME_LEN_MAX + 1);
+ return TRUE;
+ }
+
+ strncpy(file_name, file_path, MB_SVC_FILE_NAME_LEN_MAX + 1);
+ file_name[MB_SVC_FILE_NAME_LEN_MAX] = '\0';
+
+ return TRUE;
+}
+
+bool _mb_svc_get_file_parent_path(const char *file_path, char *parent_path)
+{
+ char file_name[MB_SVC_FILE_NAME_LEN_MAX + 1] = { 0 };
+
+ _mb_svc_get_file_display_name(file_path, file_name);
+ strncpy(parent_path, file_path, MB_SVC_FILE_PATH_LEN_MAX + 1);
+ parent_path[strlen(file_path) - strlen(file_name) - 1] = '\0';
+
+ if (strlen(parent_path) == 0) {
+ strncpy(parent_path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1);
+ }
+
+ return TRUE;
+}
+
+bool _mb_svc_get_dir_display_name(const char *dir_path, char *dir_name)
+{
+ char path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+ char *result = NULL;
+
+ strncpy(path, dir_path, sizeof(path));
+
+ if ((result = strrchr(path, '/'))) {
+ if (*(result + 1) == '\0') {
+ *result = '\0';
+ }
+ }
+
+ if (strncmp(dir_path, MB_SVC_PATH_MMC, strlen(dir_path)) == 0
+ || strncmp(dir_path, MB_SVC_PATH_PHONE, strlen(dir_path)) == 0) {
+ mb_svc_debug("dir path is empty because path is root");
+ strncpy(dir_name, "", MB_SVC_FILE_NAME_LEN_MAX + 1);
+ return true;
+ }
+
+ if ((result = strrchr(path, '/'))) {
+ strncpy(dir_name, (result + 1), MB_SVC_FILE_NAME_LEN_MAX + 1);
+ return TRUE;
+ }
+
+ strncpy(dir_name, path, MB_SVC_FILE_NAME_LEN_MAX + 1);
+ dir_name[MB_SVC_FILE_NAME_LEN_MAX] = '\0';
+
+ return TRUE;
+}
+
+/*
+** in this funtion, if dir_path equals "/01/02/03", parent path is "/01/02/", not "01/02"
+** if dir_path equals "/01", its parent path is "/"
+*/
+bool _mb_svc_get_dir_parent_path(const char *dir_path, char *parent_path)
+{
+ char dir_name[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+ _mb_svc_get_dir_display_name(dir_path, dir_name);
+ strncpy(parent_path, dir_path, MB_SVC_DIR_PATH_LEN_MAX + 1);
+ parent_path[strlen(parent_path) - strlen(dir_name)] = '\0';
+ mb_svc_debug("parent_path is %s", parent_path);
+ return TRUE;
+}
+
+int _mb_svc_get_file_dir_modified_date(const char *full_path)
+{
+ struct stat statbuf = { 0 };
+ int fd = 0;
+ int err = 0;
+
+ fd = stat(full_path, &statbuf);
+ if (fd == -1) {
+ err = errno;
+ mb_svc_debug("stat(%s) fails. err[%d]", full_path, err);
+ return MB_SVC_ERROR_INTERNAL;
+ }
+
+ return statbuf.st_mtime;
+}
+
+bool
+_mb_svc_get_full_path(const char *path, minfo_store_type storage_type,
+ char *full_path)
+{
+ if (path == NULL || full_path == NULL) {
+ mb_svc_debug("path == NULL || full_path == NULL ");
+ return false;
+ }
+
+ switch (storage_type) {
+ case MINFO_MMC:
+ strncpy(full_path, MB_SVC_PATH_MMC, MB_SVC_FILE_PATH_LEN_MAX + 1);
+ break;
+ case MINFO_PHONE:
+ default:
+ strncpy(full_path, MB_SVC_PATH_PHONE, MB_SVC_FILE_PATH_LEN_MAX + 1);
+ break;
+ }
+ if (strncmp(path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1) != 0) {
+ strcat(full_path, path);
+ }
+
+ return true;
+}
+
+bool _mb_svc_is_valid_path(const char *full_path)
+{
+ char phone_root_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+ char mmc_root_path[MB_SVC_DIR_PATH_LEN_MAX + 1] = { 0 };
+
+ if (strlen(full_path) == 0) {
+ return FALSE;
+ }
+
+ _mb_svc_get_full_path("/", MINFO_PHONE, phone_root_path);
+ _mb_svc_get_full_path("/", MINFO_MMC, mmc_root_path);
+
+ if (strncmp(full_path, phone_root_path, strlen(phone_root_path)) == 0) {
+ /* like "/mnt/ums/.message" isn't valid mesage, shoud filter */
+ if (strlen(full_path) > strlen(phone_root_path) + 1 && full_path[strlen(phone_root_path) + 1] == '.') {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+ }
+
+ if (strncmp(full_path, mmc_root_path, strlen(mmc_root_path)) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int _mb_svc_get_store_type_by_full(const char *full_path)
+{
+ if (full_path != NULL) {
+ if (strncmp
+ (full_path, MB_SVC_PATH_PHONE,
+ strlen(MB_SVC_PATH_PHONE)) == 0) {
+ return MINFO_PHONE;
+ } else
+ if (strncmp
+ (full_path, MB_SVC_PATH_MMC,
+ strlen(MB_SVC_PATH_MMC)) == 0) {
+ return MINFO_MMC;
+ }
+ }
+
+ return MB_SVC_ERROR_INTERNAL;
+}
+
+int _mb_svc_get_rel_path_by_full(const char *full_path, char *path)
+{
+ int root_len = 0;
+ minfo_store_type store_type = 0;
+
+ store_type = _mb_svc_get_store_type_by_full(full_path);
+
+ switch (store_type) {
+ case MINFO_PHONE:
+ root_len = strlen(MB_SVC_PATH_PHONE);
+ break;
+ case MINFO_MMC:
+ root_len = strlen(MB_SVC_PATH_MMC);
+ break;
+ default:
+ return MB_SVC_ERROR_INTERNAL;
+ }
+ if (*(full_path + root_len) != '\0') {
+ strncpy(path, full_path + root_len, MB_SVC_FILE_PATH_LEN_MAX + 1);
+ } else {
+ strncpy(path, "/", MB_SVC_FILE_PATH_LEN_MAX + 1);
+ }
+
+ return 0;
+}
+
+bool _mb_svc_get_file_ext(const char *file_path, char *file_ext)
+{
+ int i = 0;
+
+ for (i = strlen(file_path); i >= 0; i--) {
+ if ((file_path[i] == '.') && (i < MB_SVC_FILE_PATH_LEN_MAX)) {
+ strncpy(file_ext, &file_path[i + 1],
+ MB_SVC_FILE_EXT_LEN_MAX + 1);
+ return TRUE;
+ }
+
+ if (file_path[i] == '/') { /* meet the dir. no ext */
+ return TRUE;
+ }
+ }
+ return TRUE;
+}
+
+bool _mb_svc_glist_free(GList **glist, bool is_free_element)
+{
+ int length = 0;
+ int i = 0;
+ void *p = NULL;
+
+ if (*glist == NULL) {
+ return TRUE;
+ }
+
+ if (is_free_element) {
+ length = g_list_length(*glist);
+ for (i = 0; i < length; i++) {
+ p = g_list_nth_data(*glist, i);
+ free(p);
+ p = NULL;
+ }
+ }
+
+ if (*glist != NULL) {
+ g_list_free(*glist);
+ *glist = NULL;
+ }
+ return TRUE;
+}
+
+int _mb_svc_get_file_type(const char *file_full_path)
+{
+ int ret = 0;
+ char mimetype[255];
+
+ if (file_full_path == NULL)
+ return MB_SVC_ERROR_INVALID_PARAMETER;
+
+ if (drm_svc_is_drm_file(file_full_path) == DRM_TRUE) {
+ DRM_FILE_TYPE drm_type = DRM_FILE_TYPE_NONE;
+ drm_type = drm_svc_get_drm_type(file_full_path);
+ if (drm_type == DRM_FILE_TYPE_NONE) {
+ return MINFO_ITEM_NONE;
+ }
+ else {
+ drm_content_info_t contentInfo = { 0 };
+
+ ret = drm_svc_get_content_info(file_full_path, &contentInfo);
+ if (ret != DRM_RESULT_SUCCESS) {
+ mb_svc_debug("drm_svc_get_content_info() fails. ");
+ return MINFO_ITEM_NONE;
+ }
+
+ strncpy(mimetype, contentInfo.contentType, sizeof(mimetype));
+ }
+ } else {
+ /* get content type and mime type from file. */
+ ret =
+ aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype));
+ if (ret < 0) {
+ mb_svc_debug
+ ("aul_get_mime_from_file fail.. Now trying to get type by extension");
+
+ char ext[MB_SVC_FILE_EXT_LEN_MAX + 1] = { 0 };
+ _mb_svc_get_file_ext(file_full_path, ext);
+
+ if (strcasecmp(ext, "JPG") == 0 ||
+ strcasecmp(ext, "JPEG") == 0 ||
+ strcasecmp(ext, "PNG") == 0 ||
+ strcasecmp(ext, "GIF") == 0 ||
+ strcasecmp(ext, "AGIF") == 0 ||
+ strcasecmp(ext, "XWD") == 0 ||
+ strcasecmp(ext, "BMP") == 0 ||
+ strcasecmp(ext, "TIF") == 0 ||
+ strcasecmp(ext, "TIFF") == 0 ||
+ strcasecmp(ext, "WBMP") == 0) {
+ return MINFO_ITEM_IMAGE;
+ } else if (strcasecmp(ext, "AVI") == 0 ||
+ strcasecmp(ext, "MPEG") == 0 ||
+ strcasecmp(ext, "MP4") == 0 ||
+ strcasecmp(ext, "DCF") == 0 ||
+ strcasecmp(ext, "WMV") == 0 ||
+ strcasecmp(ext, "ASF") == 0 ||
+ strcasecmp(ext, "DIVX") == 0 ||
+ strcasecmp(ext, "3GPP") == 0 ||
+ strcasecmp(ext, "3GP") == 0) {
+ return MINFO_ITEM_VIDEO;
+ } else {
+ return MINFO_ITEM_NONE;
+ }
+ }
+ }
+
+ mb_svc_debug("mime type : %s", mimetype);
+
+ /* categorize from mimetype */
+ if (strstr(mimetype, "image") != NULL) {
+ return MINFO_ITEM_IMAGE;
+ } else if (strstr(mimetype, "video") != NULL) {
+ return MINFO_ITEM_VIDEO;
+ }
+
+ return MINFO_ITEM_NONE;
+}
+
CC =gcc
-LIBS = libmedia-info
+LIBS = libmedia-service
OBJS = audio_svc_test.o
SRCS = audio_svc_test.c
*/
#include <audio-svc.h>
-#include <audio-svc-error.h>
+#include <media-svc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
void insert_into_db(const char * dir_path);
-//void list_items(int count, mp_search_record_t *tracks);
void msg_print(int line, char *msg);
int main()
{
- int ret = AUDIO_SVC_ERROR_NONE;;
+ int ret = AUDIO_SVC_ERROR_NONE;
char * audio_id = NULL;
int size = 0;
int idx=0, j;
AudioHandleType *tracks = NULL;
AudioHandleType *item = NULL;
AudioHandleType *groups = NULL;
+ MediaSvcHandle * db_handle = NULL;
//db open ==================================================
- ret = audio_svc_open();
+ ret = media_svc_connect(&db_handle);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to open music database");
+ msg_print(__LINE__, "error to open music database");
return -1;
}
#if 0
//create table test ==================================================
ret = audio_svc_create_table();
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to create table");
+ msg_print(__LINE__, "error to create table");
return -1;
}
#endif
//insert music files to db ==================================================
ret = audio_svc_delete_all(AUDIO_SVC_STORAGE_PHONE);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to delete all items on phone");
+ msg_print(__LINE__, "error to delete all items on phone");
return -1;
}
//insert_into_db("/opt/media/Sounds/Music");
#endif
//iterate all tracks and get the info of tracks ==================================================
msg_print(__LINE__, "iterate all tracks");
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_ALL, "", "", "", "", &rows);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_ALL, "", "", "", "", &rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to delete all items on phone");
+ msg_print(__LINE__, "error to delete all items on phone");
return -1;
}
ret = audio_svc_list_item_new(&tracks, rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to alloc memory for list item");
+ msg_print(__LINE__, "error to alloc memory for list item");
return -1;
}
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_ALL, //item_type,
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_ALL, //item_type,
NULL, //type_string,
NULL, //type_string2,
NULL, //filter_string,
tracks
);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to get list item");
+ msg_print(__LINE__, "error to get list item");
return -1;
}
{
ret = audio_svc_list_item_get_val(tracks, idx, AUDIO_SVC_LIST_ITEM_AUDIO_ID, &audio_id, &size, -1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+ msg_print(__LINE__, "error audio_svc_list_item_get_val");
return -1;
}
fprintf(stderr, "[audio_id] = %s \n", audio_id);
- ret = audio_svc_get_item_by_audio_id(audio_id, item);
+ ret = audio_svc_get_item_by_audio_id(db_handle, audio_id, item);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to get item by audio_id");
+ msg_print(__LINE__, "error to get item by audio_id");
return -1;
}
AUDIO_SVC_TRACK_DATA_YEAR, &year, &size,
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_item_get_val");
+ msg_print(__LINE__, "error audio_svc_item_get_val");
return -1;
}
fprintf(stderr, "**** ITEM INFO[%d] ****\n", idx);
fprintf(stderr, " **year = %s\n", year);
- ret = audio_svc_get_thumbnail_path_by_path(path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
+ ret = audio_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path, AUDIO_SVC_PATHNAME_SIZE);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_item_get_val");
+ msg_print(__LINE__, "error audio_svc_item_get_val");
return -1;
}
fprintf(stderr, " **thumb_path = %s\n\n", thumb_path);
ret = audio_svc_item_free(item);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_item_free");
+ msg_print(__LINE__, "error audio_svc_item_free");
return -1;
}
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
AUDIO_SVC_TRACK_DATA_ALBUM_RATING, AUDIO_SVC_RATING_5,
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_update_item_metadata");
+ msg_print(__LINE__, "error audio_svc_update_item_metadata");
return -1;
}
#endif
//iterate all albums and its tracks ==================================================
msg_print(__LINE__, "iterate all albums and its tracks");
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_ALBUM, NULL, NULL, NULL, NULL, &rows);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, NULL, NULL, NULL, NULL, &rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_group_item");
+ msg_print(__LINE__, "error audio_svc_count_group_item");
return -1;
}
if(rows < 1) {
ret = audio_svc_group_item_new(&groups, rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_new");
+ msg_print(__LINE__, "error audio_svc_list_item_new");
return -1;
}
- ret = audio_svc_get_group_item( AUDIO_SVC_GROUP_BY_ALBUM, //group_type,
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_ALBUM, //group_type,
NULL, //limit_string1,
NULL, //limit_string2,
NULL, //filter_string,
groups);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_get_group_item");
+ msg_print(__LINE__, "error audio_svc_get_group_item");
return -1;
}
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_group_item_get_val");
+ msg_print(__LINE__, "error audio_svc_group_item_get_val");
return -1;
}
fprintf(stderr, " **album_rating = %d\n\n", album_rating);
//iterate tracks of albums ==================================================
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_BY_ALBUM, main_info, "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_BY_ALBUM, main_info, "", "", "", &count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_list_item");
+ msg_print(__LINE__, "error audio_svc_count_list_item");
return -1;
}
if(count < 1) {
ret = audio_svc_list_item_new(&tracks, count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_new");
+ msg_print(__LINE__, "error audio_svc_list_item_new");
return -1;
}
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_BY_ALBUM, main_info, NULL, NULL, NULL, 0, count, tracks);
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_BY_ALBUM, main_info, NULL, NULL, NULL, 0, count, tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_new");
+ msg_print(__LINE__, "error audio_svc_list_item_new");
ret = audio_svc_group_item_free(groups);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
return -1;
AUDIO_SVC_LIST_ITEM_RATING, &rating,
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+ msg_print(__LINE__, "error audio_svc_list_item_get_val");
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
return -1;
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
ret = audio_svc_group_item_free(groups);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
//iterate all Folder and its tracks ==================================================
msg_print(__LINE__, "iterate all Folder and its tracks");
//AudioHandleType *groups = NULL;
- ret = audio_svc_count_group_item(AUDIO_SVC_GROUP_BY_FOLDER, NULL, NULL, NULL, NULL, &rows);
+ ret = audio_svc_count_group_item(db_handle, AUDIO_SVC_GROUP_BY_FOLDER, NULL, NULL, NULL, NULL, &rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_group_item");
+ msg_print(__LINE__, "error audio_svc_count_group_item");
return -1;
}
if(rows < 1) {
ret = audio_svc_group_item_new(&groups, rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_group_item_new");
+ msg_print(__LINE__, "error audio_svc_group_item_new");
return -1;
}
- ret = audio_svc_get_group_item(AUDIO_SVC_GROUP_BY_FOLDER, //group_type,
+ ret = audio_svc_get_group_item(db_handle, AUDIO_SVC_GROUP_BY_FOLDER, //group_type,
NULL, //limit_string1,
NULL, //limit_string2,
NULL, //filter_string,
rows, //rows,
groups);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_get_group_item of get folder");
+ msg_print(__LINE__, "error audio_svc_get_group_item of get folder");
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
return -1;
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_get_val of get folder");
+ msg_print(__LINE__, "error audio_svc_list_item_get_val of get folder");
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
return -1;
fprintf(stderr, " **rating = %d\n\n", rating);
//iterate tracks of albums ==================================================
- ret = audio_svc_count_list_item(AUDIO_SVC_TRACK_BY_FOLDER, sub_info, "", "", "", &count);
+ ret = audio_svc_count_list_item(db_handle, AUDIO_SVC_TRACK_BY_FOLDER, sub_info, "", "", "", &count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_list_item");
+ msg_print(__LINE__, "error audio_svc_count_list_item");
return -1;
}
if(count < 1) {
return -1;
}
else
- fprintf(stderr, " rows = [%d]\n", count);
+ fprintf(stderr, " rows = [%d]\n\n", count);
ret = audio_svc_list_item_new(&tracks, count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_new");
+ msg_print(__LINE__, "error audio_svc_list_item_new");
return -1;
}
- ret = audio_svc_get_list_item(AUDIO_SVC_TRACK_BY_FOLDER, sub_info, NULL, NULL, NULL, 0, count, tracks);
+ ret = audio_svc_get_list_item(db_handle, AUDIO_SVC_TRACK_BY_FOLDER, sub_info, NULL, NULL, NULL, 0, count, tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_new");
+ msg_print(__LINE__, "error audio_svc_list_item_new");
return -1;
}
AUDIO_SVC_LIST_ITEM_RATING, &rating,
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+ msg_print(__LINE__, "error audio_svc_list_item_get_val");
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
return -1;
}
- fprintf(stderr, " **audio_id = %s\n\n", audio_id);
+ fprintf(stderr, " **audio_id = %s\n", audio_id);
fprintf(stderr, " **thumbnail_path = %s\n", thumbname);
fprintf(stderr, " **title = %s\n", title);
fprintf(stderr, " **artist = %s\n", artist);
ret = audio_svc_list_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
ret = audio_svc_group_item_free(groups);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
AudioHandleType*playlists = NULL;
char plst_name[AUDIO_SVC_PLAYLIST_NAME_SIZE] = {0};
- ret = audio_svc_count_playlist(NULL, NULL, &plst_count);
+ ret = audio_svc_count_playlist(db_handle, NULL, NULL, &plst_count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_playlist");
+ msg_print(__LINE__, "error audio_svc_count_playlist");
return -1;
}
if(plst_count < 1) {
ret = audio_svc_playlist_new(&playlists, plst_count);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_playlist_new");
+ msg_print(__LINE__, "error audio_svc_playlist_new");
return -1;
}
- ret = audio_svc_get_playlist(
+ ret = audio_svc_get_playlist(db_handle,
NULL, //filter_string,
NULL, //filter_string2,
0, //offset,
plst_count, //rows
playlists);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_playlist_new");
+ msg_print(__LINE__, "error audio_svc_playlist_new");
return -1;
}
ret = audio_svc_playlist_free(playlists);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_playlist_new");
+ msg_print(__LINE__, "error audio_svc_playlist_new");
return -1;
}
- ret = audio_svc_count_playlist_item(plst_id, "", "", &rows);
+ ret = audio_svc_count_playlist_item(db_handle, plst_id, "", "", &rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_count_list_item");
+ msg_print(__LINE__, "error audio_svc_count_list_item");
return -1;
}
ret = audio_svc_playlist_item_new(&tracks, rows);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to alloc memory for list item");
+ msg_print(__LINE__, "error to alloc memory for list item");
return -1;
}
- ret = audio_svc_get_playlist_item(
+ ret = audio_svc_get_playlist_item(db_handle,
plst_id,
NULL, //filter_string,
NULL, //filter_string2,
tracks
);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to get list item");
+ msg_print(__LINE__, "error to get list item");
return -1;
}
AUDIO_SVC_PLAYLIST_ITEM_PLAY_ORDER, &play_order,
-1);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_get_val");
+ msg_print(__LINE__, "error audio_svc_list_item_get_val");
return -1;
}
ret = audio_svc_playlist_item_free(tracks);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_list_item_free");
+ msg_print(__LINE__, "error audio_svc_list_item_free");
return -1;
}
- ret = audio_svc_get_playlist_name_by_playlist_id(plst_id, plst_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);
+ ret = audio_svc_get_playlist_name_by_playlist_id(db_handle, plst_id, plst_name, AUDIO_SVC_PLAYLIST_NAME_SIZE);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer audio_svc_get_playlist_name_by_playlist_id");
+ msg_print(__LINE__, "error audio_svc_get_playlist_name_by_playlist_id");
return -1;
}
fprintf(stderr,"playlist id = %d, playlist name = %s\n", plst_id, plst_name);
//db close ==================================================
- ret = audio_svc_close();
+ ret = media_svc_disconnect(db_handle);
if (ret != AUDIO_SVC_ERROR_NONE) {
- msg_print(__LINE__, "errer to close music database");
+ msg_print(__LINE__, "error to close music database");
return -1;
}
fprintf(stderr,"[file path] : %s\n", fpath);
+ #if 0
int ret = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, fpath, AUDIO_SVC_CATEGORY_MUSIC);
if (ret != AUDIO_SVC_ERROR_NONE) {
- fprintf(stderr,"[errer to insert music] : %s\n", fpath);
+ fprintf(stderr,"[error to insert music] : %s\n", fpath);
}
-
+ #endif
audio_id++;
}
}
-/*
-void list_items(int count, mp_search_record_t *tracks)
-{
- int i;
- for (i = 0; i < count; i++)
- {
- fprintf(stderr, "--- [audio_id] : %d ---\n", tracks[i].audio_id);
- fprintf(stderr, "--- [firstname] : %s ---\n", tracks[i].firstname);
- fprintf(stderr, "--- [secondname] : %s ---\n", tracks[i].secondname);
- fprintf(stderr, "--- [thumbnail_path] : %s ---\n\n", tracks[i].thumbnail_path);
- }
-}
-*/
void msg_print(int line, char *msg)
{
#include <glib-object.h>
#include <glib/gstdio.h>
#include <pthread.h>
-
-#include "media-info.h"
-#include "media-info-util.h"
-#include "media-info-debug.h"
+#include <sqlite3.h>
+#include "media-svc.h"
+#include "media-svc-util.h"
+#include "media-svc-debug.h"
#include "audio-svc.h"
-#include "audio-svc-error.h"
-#include "media-svc.h"
+#include "visual-svc.h"
void test_connect_disconn();
int test_query(sqlite3* handle);
if(argc < 2) return -1;
- err = mediainfo_open();
+ MediaSvcHandle *handle = NULL;
+ err = media_svc_connect(&handle);
if(err < 0) {
- mediainfo_dbg("mediainfo_open fails");
+ mediainfo_dbg("media_svc_connect fails");
}
- mediainfo_dbg("mediainfo_open succeeds");
+ mediainfo_dbg("media_svc_connect succeeds");
test_case = atoi(argv[1]);
test_connect_disconn();
break;
case 1:
- audio_svc_create_table();
+ audio_svc_create_table(handle);
break;
case 2:
// Test for tag or media list
- err = minfo_get_media_list_by_tagname("ZZOON", FALSE, _ite_fn, &p_list);
+ err = minfo_get_media_list_by_tagname(handle, "ZZOON", FALSE, _ite_fn, &p_list);
if( err < 0 ) {
printf("minfo_get_media_list_by_tagname fails : %d\n", err );
break;
printf("\n-------------------------------------------\n");
- err = minfo_get_tag_list_by_media_id("2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", _ite_tag_fn, &p_list);
+ err = minfo_get_tag_list_by_media_id(handle, "2ba2cd51-e93f-af54-c1c2-b29a19fd97d0", _ite_tag_fn, &p_list);
if( err < 0 ) {
printf("minfo_get_media_list_by_tagname fails : %d\n", err );
break;
printf("\n-------------------------------------------\n");
- err = minfo_get_tag_list_by_media_id("1bf63a42-0530-3cb8-94a1-564d603d85e8", _ite_tag_fn, &p_list);
+ err = minfo_get_tag_list_by_media_id(handle, "1bf63a42-0530-3cb8-94a1-564d603d85e8", _ite_tag_fn, &p_list);
if( err < 0 ) {
printf("minfo_get_media_list_by_tagname fails : %d\n", err );
break;
cluster_filter.start_pos = 0;
cluster_filter.end_pos = 5;
- err = minfo_get_cluster_list(cluster_filter, _ite_cluster_fn, &p_list);
+ err = minfo_get_cluster_list(handle, cluster_filter, _ite_cluster_fn, &p_list);
if( err < 0 ) {
printf("minfo_get_cluster_list fail : %d\n", err);
break;
pthread_join(p_thread[0], (void **) &status);
- err = minfo_update_media_name(media_id, "New.JPG");
+ err = minfo_update_media_name(handle, media_id, "New.JPG");
if( err < 0)
{
printf("minfo_update_media_name failed\n");
item_filter.file_type = MINFO_ITEM_ALL;
item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
- item_filter.start_pos = 3;
+ item_filter.start_pos = 0;
item_filter.end_pos = 10;
item_filter.with_meta = 0;
item_filter.favorite = MINFO_MEDIA_FAV_ALL;
- const char *_id = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
+ const char *_id = "fae82467-6e74-475c-8414-40f011130c6d";
//get a set of items
- err = minfo_get_item_list(_id, item_filter, _ite_fn, &p_list);
+ err = minfo_get_item_list(handle, _id, item_filter, _ite_fn, &p_list);
if( err < 0)
{
printf("minfo_get_item_list failed\n");
printf("media ID[%d]:%s\n", i, item->uuid );
printf("path[%d]:%s\n", i, item->file_url );
printf("display_name[%d]:%s\n", i, item->display_name );
+ printf("size[%d]:%d\n", i, item->size );
printf("thumb url[%d]:%s(length:%d)\n", i, item->thumb_url, strlen(item->thumb_url) );
}
item_filter.favorite = MINFO_MEDIA_FAV_ALL;
//get a set of items
- err = minfo_get_all_item_list(MINFO_CLUSTER_TYPE_ALL, item_filter, _ite_fn, &p_list);
+ err = minfo_get_all_item_list(handle, MINFO_CLUSTER_TYPE_ALL, item_filter, _ite_fn, &p_list);
if( err < 0)
{
printf("minfo_get_all_item_list failed\n");
printf("media ID[%d]:%s\n", i, item->uuid );
printf("path[%d]:%s\n", i, item->file_url );
printf("display_name[%d]:%s\n", i, item->display_name );
+ printf("size[%d]:%d\n", i, item->size );
printf("thumb url[%d]:%s(length:%d)\n", i, item->thumb_url, strlen(item->thumb_url) );
+
+ if (item->type == MINFO_ITEM_VIDEO) {
+ printf("genre : %s\n", item->meta_info->video_info->genre);
+ }
}
/* delete list to avoid memory leak */
case 7:
printf("Test minfo_delete_media_id\n");
- err = minfo_delete_media_id("12ca468c-994d-f62c-7229-a361c3a6c2a1");
+ err = minfo_delete_media_id(handle, "12ca468c-994d-f62c-7229-a361c3a6c2a1");
if( err < 0)
{
printf("minfo_delete_media_id failed\n");
printf("Test for minfo_get_cluster\n");
Mcluster *cluster = NULL;
- err = minfo_get_cluster(NULL, NULL, &cluster);
+ err = minfo_get_cluster(handle, NULL, NULL, &cluster);
if( err < 0 ) {
printf("minfo_get_cluster_list fail : %d\n", err);
break;
filter.with_meta = 0;
//get a media items' list who are included to the same tag with 'test tag'.
- err = minfo_get_media_list_by_tagname_with_filter("gd", filter, _ite_fn, &p_list);
+ err = minfo_get_media_list_by_tagname_with_filter(handle, "gd", filter, _ite_fn, &p_list);
if (err < 0)
{
printf( "failed to get a media items' list. error code->%d", err);
m_filter.with_meta = 0;
m_filter.favorite = MINFO_MEDIA_FAV_ALL;
- err = minfo_get_cluster_cnt(c_filter, &count);
+ err = minfo_get_cluster_cnt(handle, c_filter, &count);
if (err < 0) {
printf( "failed to get a media items' list. error code->%d", err);
printf( "Clouster count : %d\n", count);
}
- err = minfo_get_item_cnt(cluster_id, m_filter, &count);
+ err = minfo_get_item_cnt(handle, cluster_id, m_filter, &count);
if (err < 0) {
printf( "failed to get a media items' list. error code->%d", err);
struct timeval time2;
gettimeofday(&time1, NULL);
- err = minfo_add_media(path, type);
+ err = minfo_add_media(handle, path, type);
if( err < 0 ) {
printf("minfo_add_media fails ( path : %s, type : %d )\n", path, type );
} else {
printf("Enter media id: ");
scanf("%s", inserted_media_uuid);
- err = minfo_delete_media_id(inserted_media_uuid);
+ err = minfo_delete_media_id(handle, inserted_media_uuid);
if( err < 0 ) {
printf("minfo_delete_media_id fails\n");
} else {
const char *cluster_id = "8ddcdba9-9df4-72b4-4890-8d21d13854ad";
//add a web media to a web album.
- err = minfo_add_web_media_with_type(cluster_id, "http://user/specifying/address", "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
+ err = minfo_add_web_media_with_type(handle, cluster_id, "http://user/specifying/address", "web_media", MINFO_ITEM_IMAGE, "thumbnail name");
if (err < 0)
{
printf( "failed to add to a web album. error code->%d", err);
//int type;
//add a web media to a web album.
- err = minfo_update_cluster_name("8ddcdba9-9df4-72b4-4890-8d21d13854ad", "hey");
+ err = minfo_update_cluster_name(handle, "8ddcdba9-9df4-72b4-4890-8d21d13854ad", "hey");
if (err < 0)
{
printf( "failed to add to a web album. error code->%d", err);
char cluster_id[256] = {0,};
//add a web media to a web album.
- err = minfo_get_cluster_id_by_url("/opt/media/Images and videos/hey", cluster_id, sizeof(cluster_id));
+ err = minfo_get_cluster_id_by_url(handle, "/opt/media/Images and videos/hey", cluster_id, sizeof(cluster_id));
if (err < 0)
{
printf( "failed to minfo_get_cluster_id_by_url. error code->%d", err);
item_filter.favorite = MINFO_MEDIA_FAV_ALL;
p_list = NULL;
//get a set of items
- err = minfo_get_item_list(cluster_id, item_filter, _ite_fn, &p_list);
+ err = minfo_get_item_list(handle, cluster_id, item_filter, _ite_fn, &p_list);
if( err < 0)
{
printf("minfo_get_item_list failed\n");
p_list = NULL;
//get a set of items
- err = minfo_get_item_list_search(search_field, search_str, folder_type, item_filter, _ite_fn, &p_list);
+ err = minfo_get_item_list_search(handle, search_field, search_str, folder_type, item_filter, _ite_fn, &p_list);
if (err < 0) {
printf("minfo_get_item_list_search failed\n");
return err;
int height = 480;
//add a web media to a web album.
- err = minfo_update_image_meta_info_int(media_uuid, MINFO_IMAGE_META_WIDTH, width,
+ err = minfo_update_image_meta_info_int(handle, media_uuid, MINFO_IMAGE_META_WIDTH, width,
MINFO_IMAGE_META_HEIGHT, height, -1);
if (err < 0) {
printf( "minfo_update_image_meta_info_int failed->%d\n", err);
}
//add a web media to a web album.
- err = minfo_get_bookmark_list(media_uuid, _bm_ite_fn, &_list);
+ err = minfo_get_bookmark_list(handle, media_uuid, _bm_ite_fn, &_list);
if (err < 0) {
printf( "minfo_get_bookmark_list failed->%d\n", err);
} else {
}
break;
-
- case 35:
- printf("test minfo_extract_thumbnail \n");
+ case 20:
+ printf("test minfo_get_item\n");
+ Mitem *mitem = NULL;
+ const char *url = "/opt/media/Images and videos/My video clips/Helicopter.mp4";
- if(argv[2] && argv[3]) {
- char media_id[256] = {0,};
- strncpy(media_id, argv[2], sizeof(media_id));
- int type = atoi(argv[3]);
+ err = minfo_get_item(handle, url, &mitem);
- err = minfo_extract_thumbnail(media_id, type );
+ if (err < 0) {
+ printf("minfo_get_item failed");
+ return -1;
+ }
- if(err < 0 ) {
- printf("minfo_extract_thumbnail fails(%d)\n", err );
- return -1;
- }
+ printf("mitem->path : %s\n", mitem->file_url);
+ printf("mitem->display_name : %s\n", mitem->display_name);
+ break;
+ case 21:
+ printf("test minfo_get_all_item_conut\n");
+ int cnt = 0;
+ minfo_folder_type f_type = MINFO_CLUSTER_TYPE_LOCAL_ALL;
+ //minfo_folder_type f_type = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
+ //minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ALL;
+ minfo_media_favorite_type fav_type = MINFO_MEDIA_FAV_ONLY;
+
+ minfo_file_type file_type = MINFO_ITEM_ALL;
+ //minfo_file_type file_type = MINFO_ITEM_IMAGE;
+
+ err = minfo_get_all_item_count(handle, f_type, file_type, fav_type, &cnt);
+
+ if (err < 0) {
+ printf("minfo_get_all_item_conut failed");
+ return -1;
}
- printf("minfo_extract_thumbnail success\n" );
+ printf("count : %d\n", cnt);
break;
case 36:
if(argv[2] && argv[3]) {
int type = atoi(argv[3]);
if( type == 1 ) {
- err = minfo_get_thumb_path(argv[2], thumb_path, 255);
+ err = minfo_get_thumb_path(handle, argv[2], thumb_path, 255);
} else if( type == 2) {
- err = minfo_get_thumb_path_for_video(argv[2], thumb_path, 255);
+ err = minfo_get_thumb_path_for_video(handle, argv[2], thumb_path, 255);
} else {
printf("minfo_get_thumb_path fails( invalid type )\n" );
return -1;
printf("minfo_get_thumb_path : %s\n", thumb_path);
break;
- case 37:
+ case 37:
printf("test minfo_delete_invalid_media_records \n");
- err = minfo_delete_invalid_media_records(1);
+ err = minfo_delete_invalid_media_records(handle, 1);
if(err < 0)
{
if( strcmp(path, "exit") == 0 ) break;
- err = audio_svc_insert_item(AUDIO_SVC_STORAGE_PHONE, path, AUDIO_SVC_CATEGORY_MUSIC);
+ err = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_PHONE, path, AUDIO_SVC_CATEGORY_MUSIC);
if (err != AUDIO_SVC_ERROR_NONE) {
fprintf(stderr,"[errer to insert music] : %s\n", path);
}
if( strcmp(path, "exit") == 0 ) break;
- err = audio_svc_delete_item_by_path(path);
+ err = audio_svc_delete_item_by_path(handle, path);
if (err != AUDIO_SVC_ERROR_NONE) {
fprintf(stderr,"[errer to delete music] : %s\n", path);
}
printf("test audio_svc_get_list_item - AUDIO_SVC_TRACK_BY_SEARCH\n");
int offset = 0, count = 10, i = 0;
const char *str = "Sa";
- AudioHandleType *handle = NULL;
+ AudioHandleType *a_handle = NULL;
- err = audio_svc_search_item_new(&handle, count);
+ err = audio_svc_search_item_new(&a_handle, count);
if (err < 0) {
printf("audio_svc_search_item_new failed:%d\n", err);
return err;
}
- err = audio_svc_list_by_search(handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
+ err = audio_svc_list_by_search(handle, a_handle, AUDIO_SVC_ORDER_BY_TITLE_ASC, offset, count, AUDIO_SVC_SEARCH_TITLE, str, strlen(str), AUDIO_SVC_SEARCH_ALBUM, str, strlen(str), AUDIO_SVC_SEARCH_ARTIST, str, strlen(str), -1);
if (err != AUDIO_SVC_ERROR_NONE) {
mediainfo_dbg("Fail to get items : %d", err);
break;
}
- err = mediainfo_close();
+ err = media_svc_disconnect(handle);
if(err < 0) {
- mediainfo_dbg("mediainfo_close fails");
+ mediainfo_dbg("media_svc_disconnect fails");
}
printf("End of Test\n");
void *do_newjob()
{
int err;
- err = mediainfo_open();
-
+
+ MediaSvcHandle *handle = NULL;
+ err = media_svc_connect(&handle);
if(err < 0) {
- mediainfo_dbg("mediainfo_open fails");
+ mediainfo_dbg("media_svc_connect fails");
}
const char *media_id = "2b0a4efe-c3cb-cb62-fe12-3f4f7aef4ab9";
- err = minfo_update_media_name(media_id, "New1.JPG");
+ err = minfo_update_media_name(handle, media_id, "New1.JPG");
if( err < 0)
{
printf("minfo_update_media_name failed\n");
return NULL;
}
- printf("Calling mediainfo_close in do_newjob \n");
- err = mediainfo_close();
+ printf("Calling media_svc_disconnect in do_newjob \n");
+ err = media_svc_disconnect(handle);
if(err < 0) {
- mediainfo_dbg("mediainfo_close fails");
+ mediainfo_dbg("media_svc_disconnect fails");
return NULL;
}
{
mediainfo_dbg("");
int err = -1;
- sqlite3* my_handle = NULL;
-
- err = mediainfo_connect_db_with_handle(&my_handle);
+ MediaSvcHandle *handle = NULL;
+ err = media_svc_connect(&handle);
if( err < 0 ) {
mediainfo_dbg("Error");
return;
- }
- if(my_handle == NULL) mediainfo_dbg("NULL!!!!!");
+ } else { mediainfo_dbg("success"); }
- test_query(my_handle);
+ if(handle == NULL) mediainfo_dbg("NULL!!!!!");
+ test_query((sqlite3 *)handle);
- err = mediainfo_disconnect_db_with_handle(my_handle);
+ err = media_svc_disconnect(handle);
if( err < 0 ) {
mediainfo_dbg("Error");
return;
if( handle == NULL ) {
mediainfo_dbg( "handle is NULL" );
+ return -1;
}
- snprintf(query_string, sizeof(query_string), "select * from folder where _id = 1");
+ snprintf(query_string, sizeof(query_string), "select * from visual_folder where storage_type = 0");
err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);